Command line build and flash MicroPython Portenta H7

Hello OpenMV Community,

I am currently working with the Portenta H7 and would like to flash a microPython program to it, without the IDE in an environment without gui/graphics capabilities.

Are there any references or documentation on the command line build/flash process for micropython onto the Portenta H7? (insight on to the both core flashing would be ideal!)

Any guidance or insight/direction would be much appreciated :mrgreen:

Thank you for supporting the Portenta H7!

Yes, you can do so using the DFU command.

I’d recommend just copying the DFU command that appears in the IDE. Otherwise, you can read the IDE source code for the command.

Thank you for the quick reply @kwagyeman

Is it possible to point me to the line in github that utilizes the command? A quick search through github yielded no results for dfu keyword.

Thank you, there is very limited discussion online about the portenta and micropython :^)

I thought I had made a video about micro-python using openMV, but it was just me chatting about it: Portenta OpenMV MicroPython - YouTube, I never actually made the micro-python video because at the time I was using an OpenMV version that had not been officially released.

Now I believe it works great on the PortentaH7. What was your issue @on3 ? I just dragged the main.py micro-python code to the open folder and things magically worked. No command line DFU was needed.

Um, try flashing a DFU file in the IDE and the IDE will print some debug text during the programming that you can grab. The command is built up via appending multiple things together so it only exists in the final form when being used by the IDE.

Like, the command that’s being done will appear in the terminal that pops up.

./dfu-util -a 0 -d 2341:035b --dfuse-address=0x08040000:leave -D build/bin/firmware.bin

You should use the dfu-util that comes with Arduino IDE.

Thank you for the replies everyone. Does the command encompass the two core?

Both my machines are MX linux 19 (Debian Buster) and so I ran into some issues with the build of openmv-ide.

The initial issue was with dependencies libx11 and ia32-lib. I unfortunately dont have the error and not able to reproduce it at the moment. I will have to try inside a ubuntu virtualbox. :slight_smile:

Does the command encompass the two core?

What do you mean?

Does the command flash both the M7 Cortex and M4 Cortex on the Portenta?

Wait what are you trying to do again :neutral_face: ?

@iabdalkader Thank you again for the quick responses.

I would like to run two micro python firmware applications in parallel on both cores of the Portenta. A common use case would be to utilize one core for network (bluetooth) related functionalities and the other for peripheral controls (ie a motor/camera/sensor).

Below are examples of Portenta H7 dual core, but I would like to flash both cores with MicroPython. I am sure this would be much simpler utilizing the IDE, so I apologize but this might be useful references for future readers. :mrgreen:


Running two Arduino sketches in parallel on two cores:

Arduino Sketch on one core and Micropython on the other:

Portenta H7 simultaneously runs high level code along with real time tasks. The design includes two processors that can run tasks in parallel. For example, is possible to execute Arduino compiled code along with MicroPython one, and have both cores to communicate with one another. The Portenta functionality is two-fold, it can either be running like any other embedded microcontroller board, or as the main processor of an embedded computer. Use the Portenta Carrier board to transform your H7 into an eNUC computer and expose all of the H7 physical interfaces. Portenta can easily run processes created with TensorFlow™ Lite, you could have one of the cores computing a computer vision algorithm on the fly, while the other could be making low level operationis like controlling a motor, or acting as a user interface.

I see, the M4 core is not used right now in our firmware, but we may support it in the future… You can probably run vanilla/upstream micropython along with Arduino firmware, I’m not sure you should ask in the Arduino forums.

Understood. Thank you

:mrgreen: