Debugging OpenMV4 firmware

Discussion related to "under the hood" OpenMV topics.
xvbv
Posts: 9
Joined: Wed Nov 27, 2019 10:16 am

Debugging OpenMV4 firmware

Postby xvbv » Wed Nov 27, 2019 10:40 am

Hi community,

We are using OpenMV4 (with chip STM32H743VI) and are currently trying to debug (step, breakpoints, etc...) the firmware. We have tried all the approaches mentioned in this forum or else where online, without success so far.
Anyone has an official status on this? Is it possible? On Windows? On Linux (Ubuntu)?

Thanks in advance :D
xvbv
User avatar
iabdalkader
Posts: 1026
Joined: Sun May 24, 2015 3:53 pm

Re: Debugging OpenMV4 firmware

Postby iabdalkader » Wed Nov 27, 2019 10:56 am

Yes it's possible, but you have to use the official ST tools because the opensource alternatives don't fully support the H7 yet.
xvbv
Posts: 9
Joined: Wed Nov 27, 2019 10:16 am

Re: Debugging OpenMV4 firmware

Postby xvbv » Thu Nov 28, 2019 1:09 pm

hey iabdalkader,

Thanks for your prompt reply! I guess you're talking about the STM32CubeIDE. We have installed it and are able to debug the STM32H743 board, from a STM32 ("empty") project. Now, do you have any tips on how to import the OpenMV project into STM32Cube's project? It actually could be a very nice feature to have some project files in the OpenMV repository. Thus providing a fast way to get started with firmware development...
Another question: do you know if it's possible to both debug the firmware code and launch the micro-python code from OpenMV IDE ?

On a side track, we've been debugging the .elf, generated by the Makefile in OpenMV, into an empty project in STM32CubeIDE. We can step through the code for a dozen of functions but then the debugging crashes. Same when RUNning the code. Have you seen similar behaviors?

Thanks in advance !
User avatar
kwagyeman
Posts: 3503
Joined: Sun May 24, 2015 2:10 pm

Re: Debugging OpenMV4 firmware

Postby kwagyeman » Thu Nov 28, 2019 1:36 pm

Because MicroPython didn't make their code base compatible with STM32Cube our firmware is not compatible with STM32Cube.
Nyamekye,
xvbv
Posts: 9
Joined: Wed Nov 27, 2019 10:16 am

Re: Debugging OpenMV4 firmware

Postby xvbv » Fri Nov 29, 2019 5:18 am

hey Nyamekye,

I don't mean to debug the micro-python from STM32Cube. Just wondering if OpenMV (USB connection) can run at the same time as debugging (the firmware-only) from STM32Cube (SWD connection) ?
Or do you mean that simply debugging the firmware is not possible in STM32Cube? (iabdalkader just mentionned that it was possible...).
The most important for us is to be able to debug, then we can simulate any command coming from the micro-python layer.

Anyways, what we see so far is that when running the code from Cube IDE, it throws this error after just 1-2 seconds : libusb: error [udev_hotplug_event] ignoring udev action bind. Our bet is that there is a power conflict on the OpenMV4 board. Can you comment on that ?
Or this error: failed to insert all hardware breakpoints you may have requested too many hardware breakpoints. Even though there is no breakpoints... Are there any "pre-programmed" breakpoints in the .elf file generated by OPenMV4.
Note that these two errors only happen when debugging the .elf from OpenMV. When compiling another project (of similar size) in STM32Cube, the debugging works perfectly fine!

Btw, these tests have been conducted with a ST-LINK/V2-ISOL and also a ST-LINK/V3. And OpenMV latest tag built with simple: "make all".

We are considering to go down the path of importing the OpenMV project into STM32Cube (to facilitate (firmware only) development (debugging, pin configuration, etc...), what are your thoughts on that ?
Thanks !
User avatar
kwagyeman
Posts: 3503
Joined: Sun May 24, 2015 2:10 pm

Re: Debugging OpenMV4 firmware

Postby kwagyeman » Sat Nov 30, 2019 3:28 pm

Hi, um, so, I get that you are struggling through this... but, MicroPython has no hooks in it to integrate into STM32Cube. This is actually a pain for us too... but, me and Ibrahim mainly just debug the old school way using printf() and seeing that output in OpenMV IDE. You can use OpenMV IDE to load the firmware too.

If you want to use SWD debugging I guess you can too. I've never done it before however. That said, at my day job, I use a Segger debugger for projects with gdb. This works on STM32 chips.

Anyway, I don't think you can easily use the current firmware setup with a nice single step debugger. Ibrahim may know more however.
Nyamekye,
xvbv
Posts: 9
Joined: Wed Nov 27, 2019 10:16 am

Re: Debugging OpenMV4 firmware

Postby xvbv » Tue Dec 03, 2019 4:11 am

We managed to make it work !
Key take-aways :
- Use STM32Cube IDE, create empty STM32 project, use the .elf output from OpenMV in the debugger
- Use external 5V (Vin)
- Don't connect USB plug
- Use the python file on internal flash
- Set a few breakpoints in main before the call to "exec_boot_script("/main.py", false, true);" (apparently when running too big chunks of code, the debugger crashes)

Return to “Technical Discussion”

Who is online

Users browsing this forum: MSN [Bot] and 6 guests