forked from zephyrproject-rtos/gsoc-2022-arduino-core
-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
mjs513
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
Select code repository
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:
17 remaining items