cancel
Showing results for 
Search instead for 
Did you mean: 

Portenta H7: use Arduino bootloader, from command line - for you

tjaekel
Senior III

I use Portenta H7 MCU module. I use it with a STM32CubeIDE project (not Arduino).
I do not like the Arduino IDE - LOL, I am missing several features, esp. not possible to use a HW debugger and to step through my code, no support for HW breakpoints etc. Never mind: I have a full STM32 HAL and STM32CubeIDE based project. I can use external ST-LINK (with Breakout Board).

Portenta H7 comes with an Arduino bootloader flashed: you can flash a new user BIN file (FW) via tool "dfu-util.exe".

I want to keep it, because it is convenient and no need for my users to have a ST-LINK dongle. They can update the FW any time themselves (via USB-C, needed anyway for power and UART command line).

But: I want to use also remote connections, e.g. VNC to the computer where the Portenta H7 is connected (in a lab). I cannot press the reset button quickly twice (I am remote). But I want to activate the Arduino bootloader in MCU flash so that I can update the FW (my new BIN file).

It works!

I have an UART shell command interpreter with command "bootld", implemented this way:

ECMD_DEC_Status CMD_bootld(TCMD_DEC_Results *res, EResultOut out)
{
	(void)out;
	(void)res;

	RTC->BKP0R = 0x0000DF59;
	RTC->BKP7R = 0x00000001;
	NVIC_SystemReset();

	return CMD_DEC_OK;
}

So, it uses the "trick" to write "magic" values into RTC BKP registers. When I fire a reset (here via SW as NVIC_SystemReset();) - the Arduino bootloader sees the magic value and stays in DFU mode (not jumping to my FW entry point as any regular (single) reset button would do). Now I can flash a new FW via "dft-util.exe".

Just:
It takes approx. 10 seconds until I see the fading flashing green LED (as indication that Arduino bootloader is active and in DFU mode). No idea why 10 sec.: a double reset press is way faster (but I cannot do remotely).

If you want to try my project - or you want to use STM32CubeIDE to develop for Portenta H7 (as I do), here is the project:

https://github.com/tjaekel/PortentaH7_WAcouSense 

It is a pretty "heavy" project, mainly with these features:

  • it provides an USB VCP port to have an UART Shell Command line
  • with a Breakout Board (or Vision Shield) it provides PDM MICs, streamed via ETH and VBAN to a host PC,
    also with a web page in MCU (control MCU from Web Browser instead or in parallel with UART VCP COM)
  • with Breakout Board: an I2C based 9-DOF sensor connected (e.g. for gestures)
  • a "Pico-C" C-code interpreter: write C-code on MCU without any compiler, use SD Card to store "Pico-C" C-code scripts and execute these from UART command line

If you do not want to install the entire project and compile:

  • you can grab the BIN file in GitHub bin folder
  • plus the "dfu-util.exe"
  • and flash Portenta H7 via Windows CMD line (see Readme in bin folder)

BTW: via Pico-C you can write C-code scripts for any I2C device connected (there is an example for the IMU sensor, in folder doc). Also SPI is available on the command line: connect SPI devices and write "PIco-C" code (no need for any compiler or to flash FW again).

1 ACCEPTED SOLUTION

Accepted Solutions
tjaekel
Senior III

You can flash just the BIN file and enjoy the UART command line, web browser access, PDM MIC via network...

The Portenta H7 purchased should come with the Arduino flash loader - so, you can just flash the BIN file, without to install and compile the entire project.

View solution in original post

1 REPLY 1
tjaekel
Senior III

You can flash just the BIN file and enjoy the UART command line, web browser access, PDM MIC via network...

The Portenta H7 purchased should come with the Arduino flash loader - so, you can just flash the BIN file, without to install and compile the entire project.