Open
Description
For the fun of it, I thought I would try to add the Camera support that was added to the GIGA to the Portenta H7.
I now have it building and the camera makes it through the begin call, but the camera soon errors out:
In case anyone wishes to play along:
Here are my overlay and config file.
I also needed to edit the fixups.c to allow the Portenta to work.
Changed the line that had GIGA and added portenta:
#if (defined(CONFIG_BOARD_ARDUINO_GIGA_R1) || defined(CONFIG_BOARD_ARDUINO_PORTENTA_H7)) && defined(CONFIG_VIDEO)
The error code shown in monitor window:
[00:00:14.808,000] <wrn> video_stm32_dcmi: HAL_DCMI_ErrorCallback(41)
Note: I edited the file to add the error code, which is error DMA overrun I believe.
Now back to playing
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
KurtE commentedon Feb 25, 2025
Quick update:
Looking at where this message is generated: [00:00:14.808,000] video_stm32_dcmi: HAL_DCMI_ErrorCallback(41)
It is in the zephyr/drivers/video/vides_stm32_dcmi.c
Which is called from: the modules\hal\stm32\stm32cure\stm32h7xx\drivers\src\stm32h7xx_hal_dma.c
from the function:
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
which was called by the (same directory) stm32h7xx_hal_dcmi.c
from: void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi)
Where it sets the error callback to the HAL_DCMI_ErrorCallback.
So my read of this is, that in this case we receive that one message, and the DMA stream is stopped, we probably
need to call something to restart it?
Something like: HAL_DCMI_Start_DMA ?
@pillo79 and/or @facchinm - Does this make sense?
KurtE commentedon Mar 3, 2025
For the fun (or pain) of it, I thought it might be interesting to try adapting to a different camera that zephyr supports, such as the
OV2640 and OV5640. So today I (actually both of us) have tried to setup for the OV5640. I have a couple of them that the two of us
a while ago, were experimenting with, in adapting and extending the camera library to work on the Teensy 4.x boards.
So far it is not working yet. Some of the issues we have run into include:
a) Reset/power down pins - The name of the power down pin is different: powerdown-gpios versus pwdn-gpios
Also the Adafruit OV5640 and maybe others, the camera is powered down when the pin has a high signal, not low.
b) the port { area - looks like they use remote-endpoint-label instead of remote-endpoint and they have different
data associated with them.
c) the current OV5640 object does not currently support the size 320x240 size of image.
Actually, only support (1280x720) and 640x480). The camera reference shows that they support several other resolutions as well,
like 2592x1944, 1920x1080, 1280x960. And can support several others by setting up windows within...
So far I have not gotten past the camera initializing, but will try some more tomorrow. Will also try the OV2640 as well.
mjs513 commentedon Mar 3, 2025
Theres a lot more that @KurtE didn't mentioned that we noticed. As mentioned for the OV5640 camera failed to start until we releasized about reset and powerdown pin states via a LA trace that Kurte did.
Once started noticed a error messages on Serial1:
Digging a bit deeper noticed in driver that we are currently using in the core it is starting the stream with IO as mipi vs dvp? Think we are using DVP for the GC2145. The above errors are coming from video_stm32_dcmi.c
Though I am not seeing an error for unable to power up MIPI. The latest driver for the OV5640 actually provides support for both: https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/video/ov5640.c
@KurtE mention about available resolutions. There is an open issue on zephyr about that: video: ov5640 support for vga , qvga and qqvga not there zephyrproject-rtos/zephyr#86519, that @KurtE found yesterday. Kurt mentioned that we played with this camera on the Teensy 4 so I modified the ov5640_reg low_res_params to support the lower resoutions but hard to test.
While @KurtE was testing the OV2640 I tried the OV7670 and again managed to get camera started but received the same DCMI errors:
KurtE commentedon Mar 3, 2025
Thanks @mjs513 for filling in a lot of the gaps, Will try 2640 next as it looks like there may be more complete information in the driver.
One thing that I keep wondering about, is once more of Arduino integration with zephyr is completed. How do you expect it
will work. That is the MBED version I believe supported 4 cameras. It was reasonably easy to switch between them.
With this current version on Zephyr, there may be Several more cameras. How can different sketches choose which one to use?
Will the Overlay(s) allow multiple cameras to be included. How then to choose?
The chosen{zephyr,camera = &dcmi; Sort of maybe allows you choose to use the hardware camera subsystem, but currently
not necessarily which actual camera, the DCMI should be configured for.
I am assuming that once the real basics of the camera are working, that a lot more of the functionality of the MBED camera library will be added.
But now back to trying some of the basics.
KurtE commentedon Mar 3, 2025
Quick update: currently the OV2640 shows more promise than the OV5640.
Note: I changed all of the 5640 to 2640 in overlay and config file. Also noted that it has a different I2C address of 0x30, so
changed that in two places.
Build first failed as POWERDOWN pin is not defined in their yaml file... so commented out that line.
Images are not good yet, Sort of like I am seeing from GC2145.
Note: the ceiling in my office does not look like that ;)
The images of the GC2145 are similar. I am not getting the same error on the OV2640...
And runs for long time. I do get the: could not get buffer a few times, but...
mjs513 commentedon Mar 4, 2025
@KurtE
I hacked up the existing ov5640.c file to take the initialization arrays and a couple of things from the 5640.c that looks like will be in release 4.1 as a quick and dirty test and did get a totally out of synch image and lot of errors on serial1 about dma buffers.
So don;t think I am going to do anything else on the 5640 until I see if the incoporarte the driver changes. Otherwise I will rewriting it completely
KurtE commentedon Mar 4, 2025
Quick update: OV2640.
I added debug code to the ov2640.c to printk all of the registers that are set by the code. Plus when I know them their name.
Code extracted/modified from our Teensy code. Note: the processing image still looks like the one I posted yesterday:
As a comparison, here is the debug output I just ran on a Teensy Micromod using OV2640 and displayed on an ILI9341 display:
Note: in this output, the code shows each of them as they are set, and then later prints a summary of the current setting for
each of the registers we touched:
Image of setup:
mjs513 commentedon Mar 5, 2025
Did manage to get an image out of the ov7670
Still dies after a while with the errors you see with DCMI failed callback.
to get it working to this point
after reading this:
zephyrproject-rtos/zephyr#84229
however doesn't look like that change made it into 4.1-rc2
mjs513 commentedon Mar 5, 2025
Just as a quick update I switched to using portenta mid-carrier with the ov7670 and image quality improved drastically but still hit the error message when it stops noted in previous posts:
Do have to hit reset a couple of times to get more that a single image to display. Then I will get may 10-12 then it errors out.
Did verify that you have to update to {OV7670_COM10, 0x03}, /* COM10 */ otherwise will get no images.
KurtE commentedon Mar 5, 2025
Will have to try it in the morning. Looks a lot better
mjs513 commentedon Mar 8, 2025
See this issue as well: #81
iabdalkader commentedon Mar 8, 2025
I've sent a fix for the pixel format array: zephyrproject-rtos/zephyr#86810
Only the GC2145 has been tested and known to work well enough with the Giga. The rest of the sensors all have issues, bad regs, bad config, buggy drivers etc... I don't know the state of the H7 support and whether it can use the cameras or not.
Note if the colors look wrong, try passing
True
in the last argument:cam.begin(DISPLAY_W, DISPLAY_H, CAMERA_RGB565, true)
mjs513 commentedon Mar 8, 2025
@iabdalkader
I have been having issues with the GC2145 on the GIGA and H7 but going to try and sort it out. Basically on Giga looks like its running if I watch the Serial1 spew and on the H7 will see 1 frame in the visualizer. In both cases get this message and then it halts:
Again using the H7:
The 5640 looks like the driver has major issues with reg settings etc. Did try and hack it to use settings from other sources including openmv. DId get that messed up image in Portenta H7: Trying to add the Camera/GC2145 support #78 (comment) then said forget since it looks like they redid the driver in a later release.
On the other hand had alot better luck with the OV7670 by making one change in the driver:
also set clock to 12Mhz and using FIFO_FULL then will run for a couple of minutes but will eventually get the:
2 remaining items
iabdalkader commentedon Mar 9, 2025
This is not an error, it just means you're not reading the frames fast enough so the video buffers FIFO is full. The streaming will not stop as the video driver always holds one video buffer. You could try increasing
CONFIG_VIDEO_BUFFER_POOL_NUM_MAX
to 4.This is an error, most likely DCMI FIFO overrun. It's possible to recover from this by just restarting the DMA stream, but the Zephyr driver doesn't do that. Try lowering the clock to 10MHz, if it works better we can make this the default.
You can't print anything because the frame is sent over serial, so you'll corrupt the frame if you do and break the sync. This serial frame visualizer has always been unreliable, so you may have to stop/start it a few times, and make sure the board runs first.
Also, have you tried this branchDoesn't build.arduino_core_merge_4.1.0-rc2
? It should have the latest fixes.I just tested this with and I had no problems with streaming. The colors are wrong, but I already fixed that upstream.
KurtE commentedon Mar 9, 2025
Thanks @iabdalkader
Will try more of this again. I am also trying to output the image to a TFT display over SPI, which is maybe slower than output over USB... Which is showing similar issues.
The Arduino_core_merge... build issue, - A few days ago on the other machine I was able to build some of the variants.
But there was/is an issue where you could not compile sketches due to devicetree stuff with embeded comments.
I believe @facchinm has a fix on his fork/branch:
facchinm/zephyr@b7940c6
Which I am going to try on my other machine that I installed the merge...
Personally wish there were easier ways to switch between cameras... Than having to edit the overlay and the config file, rebuild zephyr...
On the different cameras, has someone gone through and tried to fix the configurations and maybe add in the missing pieces? For example the OV7670 camera, I don't believe they have anything in it to support the OV7675 camera that Arduino sells. I definitely notice differences of trying it versus some of the older OV7670 cameras I purchased from Amazon or elsewhere.
Will try again on GIGA, but need to grab another USB to serial adapter, as GIGA is always now in debug mode...
Thanks again
mjs513 commentedon Mar 9, 2025
Thanks @iabdalkader for getting back so fast.
SOrry it took so long in getting back to you but wanted to try with a few changes based on your feedback.
Yep - I remember that you mentioned that to facchinm in your original PR. Didn;t mean to say that was an error sorry.
@KurtE discussed that in the first post so we are on own on that one.
Yep thats why I mentioned it since I thought it was kind of funny. And yeah have to start and stop it several times to get to work. Glad you confirmed it.
If I wait for continuous spew (even with vido buffers = 4)
This is at 10 mhz by the way
PS. First if I was going to do anything serious with the camera I would be using OpenMV!!!!
Second is there an alternate way to view the images with openmv ide or the arducam windows app?
mjs513 commentedon Mar 9, 2025
well made a couple of minor changes and the visualizer seems to be working better.
In the sketch change loop to
and in the processing sketch in setup
kind of a handshake
iabdalkader commentedon Mar 9, 2025
It could be a serial issue on Windows, maybe it's buffering the data, as it works fine on Linux. Could you try the mbed core? If you get similar results then it's definitely a Windows issue.
I don't know anything about arducam app, but OpenMV uses a debugging protocol over serial, and the IDE is more fault-tolerant, but it will never work with this. There's a websockets viewer in mbed core. The sketch will need to be update to support work with it though (see CameraCaptureWebSerial example).
mjs513 commentedon Mar 10, 2025
@iabdalkader - @KurtE
Sorry I didn't get back to you all yesterday - kind of ran out of steam
As for the GC2145 on the GIGA and the Visualizer sketch I never had much luck with it working with mbed on the GIGA thats why I just loaded up OpenMv on it and it worked like a charm.
With that said I hack up the camera api to add:
wanted to see if I could send a BMP to the arducam windows app (supports jpeg and bmp images) and it kind of worked but not well. So reverted back to the H7 and used a modified sketch that @KurtE generated
and seems I am able to get past the
HAL_DCMI_ErrorCallback
warning message with H7 and the OV7670. And using the visualizer (and processing 4.3):now when I get that warning I will see in the visualizer

but if I open and close the image window I recover back to what I showed in the original image.
However with that said I am now getting an error message:
that I am not sure how to handle.
As for restarting DMA I did notice in video_stm32_dcmi.c a command they use when they start stream:
not sure we can use that to restart DMA?
KurtE commentedon Mar 10, 2025
I think I tried to recover by using things like:
But I believe it gave me a lot of errors. And/or they were not in the export table... forgot what I ran into.
Will try more later. Now I trying to figure out how to force a pin into Analog mode.
mjs513 commentedon Mar 11, 2025
Got energetic and ran the GC2145 on the H7 and guess what its working as well as the ov7670, same behavior as described in my last post. No issues with Visualizer.
iabdalkader commentedon Mar 11, 2025
When I was testing the camera to display, I had to restart the DMA stream in the Zephyr driver (
drivers/video/video_stm32_dcmi.c
), not in the sketch/library. More specially invideo_stm32_dcmi_dequeue
when an overrun is detected. I didn't not commit that change as it seemed pointless to keep restarting it if it can't keep up, so I ended up reducing the frequency to 10MHz. It might be useful to send this fix upstream at some point, for occasional frame drops, but the issue seems to be in IRQ priorities, SDRAM speed or maybe CPU clock, as the H7 can normally maintain way more bandwidth than this (as you've already noticed, by comparing this to the OpenMV firmware for example).I see above that it seems to be working fine. Note the colors issue has been fixed upstream.
mjs513 commentedon Mar 11, 2025
I did try to reduce the clock to 10mhz and it helped with the dropped frames but still eventually stopped just before seeing
<err> video_stm32_dcmi: Failed to dequeue a DCMI buffer.
Now on the Giga I did manage to visualizer working by adding an extra myPort.write(1) in setup. Now seeing corrupt images at 10mhz and fifo_1_4
mjs513 commentedon Jun 7, 2025
@facchinm - @pillo79 - @KurtE
After playings with the graphics library for the last week or so decided to retry the camer and started receiving the following errors:
As time permits going to see whats going on.
mjs513 commentedon Jun 8, 2025
ok did some debugging and looks like the api changed a bit. Did modify camera.cpp and had to add
to llext_exports.c which seems a bit suspicious. Aftet I made the changes was ble to get it to load but does appear to be working.
there is the modified camera.cpp if anyone wants to give it a try and double check my changes
camera.zip
mjs513 commentedon Jun 8, 2025
Issue seems to be use of the GC2145 with the giga display shield - going to make separate issues and pr for tracking
EDIT: see #135