cancel
Showing results for 
Search instead for 
Did you mean: 

Portenta H7 Development with STM32CubeIDE

rtalan
Associate III

I'm looking for some instructions on how to develop firmware for the Portenta H7 using the Portenta Breakout Board with the STM32CubeIDE.

 

Before ST Microelectronics comes back and says they can't help because the H7 is not their product, that is unacceptable. If this is the case, it may be time to look at other vendors (Nvidia). STM can only benefit from helping developers write software for the Portenta H7 using the STM32 suite of development tools.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @rtalan 

What you describe could be caused by the corrupted Arduino bootloader!
I don't know but I see that in the official github repo there are different versions that operate in USB FS or HS. https://github.com/arduino/ArduinoCore-mbed/tree/main/bootloaders/PORTENTA_H7

As the code is not available, could you ask to the Arduino community for help?

RomainR_0-1713865308165.png

I don't have the hardware diagram of the Portenta H7 but I assume that their bootloader firmware configures the internal SMPS then the clock of the STM32H747I to ensure correct boot sequence.

As the product is a dual core CPU (M7+M4) perhaps you have disabled the Cortex-M4 boot in the byte options? Can you check with STM32CubeProgrammer the status of the BCM4 option byte?

For the definition of the thread linker memories of your CubeIDE project, it seems safe to me and will not overwrite your bootloader. From this side it's ok.

Finally, it's good news if you managed to debug your code on the CM7. However, the following line of code is mandatory in the case where the CM4 is also used because it allows you to wait until this second CPU is properly started.

while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) != RESET) && (timeout-- > 0));

I suggest you the application note AN5361 which explains how to program and debug a dual core project on the STM32H7 with STM32CubeIDE:

https://www.st.com/resource/en/application_note/an5361-getting-started-with-projects-based-on-dualcore-stm32h7-microcontrollers-in-stm32cubeide-stmicroelectronics.pdf

Best regards,

Romain,

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

7 REPLIES 7
AScha.3
Chief II

https://www.st.com/en/partner-products-and-services/arduino-portenta-h7.html

 

>Before ST Microelectronics comes back and says they can't help because the H7 is not their product, that is unacceptable. 

You puzzling here something : this is an Arduino board, with some chips from STM, Murata, NXP , etc.

So if you have a problem with the chip from STM or  Murata , you could expect help, to find out, whats wrong.

But for the board you have to ask the producer of the board, Arduino (who ever this is now).

Or search, what others already did with this board and what you can find about , like :

https://community.st.com/t5/stm32cubemx-mcus/is-a-stm32cubemx-file-available-for-arduino-portenta-h7/td-p/74582

 

> If this is the case, it may be time to look at other vendors (Nvidia).

Right, might be better. But i recommend, at first ask Nvidia, what help you get for an Arduino board from them.

 

>instructions on how to develop firmware for the Portenta H7 using the Portenta Breakout Board with the STM32CubeIDE.

Same as with every custom board : you define the pins and what you wanna use from peripherals in CubeMX or STM32CubeIDE , generate code and then write your program - no problem at all.

Instructions , how to start , using the IDE , etc you can find on STM or ask google.

see: https://www.st.com/en/development-tools/stm32cubeide.html#documentation

https://www.st.com/resource/en/user_manual/um2553-stm32cubeide-quick-start-guide-stmicroelectronics.pdf

https://wiki.st.com/stm32mcu/wiki/Category:STM32CubeIDE

 

If you dont want using Arduino with their examples, but STM32CubeIDE and not want to read and learn, how to do, then you could get help also:

https://www.fiverr.com/categories/programming-tech/electronics-engineering/embedded-systems-iot

 

If you feel a post has answered your question, please click "Accept as Solution".
RomainR.
ST Employee

Hello @rtalan 

Although I've never tried it, the STM32H747 on the Portenta H7 board is indeed an STM32 supported by the STM32Cube ecosystem.
For hardware and debug programming:
The Portenta H7 breakout has a standard 20-pin JTAG connector to which you should be able to connect a standalone STLinkV3.
There's also a dip switch for the Boot pin, which you'll need to configure so that the dual-core STM32H7 can boot properly into Flash.
When using STM32CubeIDE, you should pay close attention to the configuration of your Linker file, and avoid writing your code to Flash address 0x0800 0000, otherwise you'll overwrite the Arduino Bootloader. You'll need to start your STM32CubeIDE application at a much higher Flash address.
The same applies to STM32CubeProgrammer if you try to erase the Flash at this address. Here too, you risk losing the Arduino Bootloader. I don't know how easy it is to re-flash this specific bootloader, I guess so.

Finally, the Portenta H7 board has been designed for the Arduino environment, so perhaps you could also have a look at this Arduino forum.
https://forum.arduino.cc/t/portenta-h7-stm32cubeide-please-join-me/1010091

Let us know if you're successful on your end?
Best regards,

Romain

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello @RomainR.

 

Thank you for your advice. My bad for not being a little (lot!) more specific. I am very intimate with the STMCube family of developer tools. I have been battling loading a simple blink program from the STMCubeIDE to the H7 via the JTAG connectors on the Portenta Breakout board. I have indeed crushed the H7 bootloader several times but I am successful in re-flashing it (portentah7_bootloader_mbed_fs.bin) at address 0x08000000 via the STM32CubeProgrammer and the requisite hardware (ST-Link, JTAG 2.54 mm to 1.27 mm pitch adapter). Though it seems to have lost the DFU pieces as my PC won't even recognize it and assign a COM port. This is the first thing I must fix. Any help there would be greatly appreciated. Note that because of this issue flashing the bootloader from the Arduino IDE is not an option (there is no COM port). It is my understanding that when the H7 is connected to the breakout boards JTAG connectors the ST Link does not need the COM connection to flash the bootloader or code. 

 

I have made adjustments to the linker file to accommodate the flash address for the size of the Portenta H7 bootloader (portentah7_bootloader_mbed_fs.bin).

 

I have resorted to using the STM32CubeProgrammer to flash the CM7 and CM4 .elf and or .bin file at addresses 0x08040000 and 0x08100000 respectively (everything compiles just fine, as expected). STM32CubeProgrammer reports success every time for flashing the bootloader and the CM7 and CM4 code. But the H7 does not run the blink program. Ironically, the STM32CubeIDE reports problems when trying to run the blink program in either Debug or Release.

 

At first I thought maybe the breakout board was somehow interfering. But when I disconnect the H7 from the breakout board, STM32CubeProgrammer complains about not being able to find the STM32 target. So clearly it is seeing the H7.

 

I have exhausted all help from the Arduino community. My project does not lend itself to development solely from the Arduino IDE. It has several hardware agnostic projects as well as two MCU projects (the H7 and ESP32) and the STM32CubeIDE lends itself well to developing ALL of this software under a single development tree.

As I mentioned at the start I am very familiar with the STMCube ecosystem of developer tools though by no means an expert. The intention of my post was simply to get ST Microelectronics to stand up and say "Okay, this is what you need to do." I believe STM can only benefit from helping Portenta H7 developers as its heart is the STM32H747XI. And Arduino can also benefit from helping their developers whom are working outside of the Arduino IDE.

 

Thanks again for your advice! Any help in fixing the COM problem even just getting Blink to work would be appreciated.

Hello @rtalan 

First thank you for sharing all your tests in detail.

<t seems to have lost the DFU pieces as my PC won't even recognize it and assign a COM port. This is the first thing I must fix. Any help there would be greatly appreciated.>

Maybe you've already seen this tutorial, but I don't know why the COM port enumeration will be lost after flashing the bootloader (if this is the official Arduino) ? 
https://docs.arduino.cc/tutorials/portenta-h7/updating-the-bootloader/

 

<STM32CubeProgrammer reports success every time for flashing the bootloader and the CM7 and CM4 code. But the H7 does not run the blink program. Ironically, the STM32CubeIDE reports problems when trying to run the blink program in either Debug or Release.>

If you want to use the STM32CubeIDE environment, CubeMX... you will have to adjust your linker file in STM32CubeIDE to be able to debug without the Arduino bootloader.
What happens when STM32CubeIDE reports a problem? Can you share the error messages?
If your blink code never runs, isn't it the bootloader could starts first?

Can you view the program counter and stack pointer registers to check which address they are stuck at?
You should be able to do this using STM32CubeProgrammer and the MCU Core menu.
Also check that the byte options do not have a specific configuration of the STM32H747 on the board that could have changed.

I wish you good luck.
Best regards,
Romain,

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello @RomainR. ,

Thank you for your quick reply.

I have seen the Arduino bootloader tutorial and it actually worked once. But eventually the H7 lost its COM port so the Arduino IDE is no longer an option.

When you say:

 

If you want to use the STM32CubeIDE environment, CubeMX... you will have to adjust your linker file in STM32CubeIDE to be able to debug without the Arduino bootloader.


  • What specific linker file adjustments are you speaking of? My linker file is attached.

 

Before I saw your reply here, I actually got the CM7 to run in debug mode (and I don't know how, I'm constantly changing settings). It hit the built in breakpoint at MPU_Config(). I stepped the code forward an it appears to have entered an infinite loop here:

while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) != RESET) && (timeout-- > 0));

which I believe it is waiting for the M4 core to start up. Unfortunately, I have not been able to achieve this again.

  • Where is it in CubeIDE or CubeMX that I tell it to boot both cores?

In CubeMX->Project Manager->Project->Dual Core Boot Mode is set to "Both CPUs booting at once" and is not changeable to anything else.

I no longer get errors when trying to run from CubeIDE in debugger mode (and I don't know why!) but it appears the program just exits (maybe a problem with the GDB server?).

Again, I really appreciate your help. I will continue trying different things and reading documentation and see if I can get it to run in debugger mode again.

First here is my linker memory layout:

 

 

 

MEMORY
{
  RAM_D1 (xrw)   : ORIGIN = 0x24000000, LENGTH =  512K
  FLASH   (rx)   : ORIGIN = 0x08040000, LENGTH = 2048K - 128K /* Memory starts at 0x08040000 after reserving 128K for the bootloader/system */
  DTCMRAM (xrw)  : ORIGIN = 0x20000000, LENGTH = 128K
  RAM_D2 (xrw)   : ORIGIN = 0x30000000, LENGTH = 288K
  RAM_D3 (xrw)   : ORIGIN = 0x38000000, LENGTH = 64K
  ITCMRAM (xrw)  : ORIGIN = 0x00000000, LENGTH = 64K
}

 

 

 

The attempted run from CubeIDE and CubeProgrammer data immediately after run attempt are attached as well as my linker file.

The stack from the Debugger tab

 

 

 

<terminated>Blink2_CM7 [STM32 C/C++ Application]	
	<terminated, exit value: 0>arm-none-eabi-gdb (13.2.90.20230627)	
	<terminated, exit value: 0>ST-LINK (ST-LINK GDB server)	

 

 

 

Hi @rtalan 

What you describe could be caused by the corrupted Arduino bootloader!
I don't know but I see that in the official github repo there are different versions that operate in USB FS or HS. https://github.com/arduino/ArduinoCore-mbed/tree/main/bootloaders/PORTENTA_H7

As the code is not available, could you ask to the Arduino community for help?

RomainR_0-1713865308165.png

I don't have the hardware diagram of the Portenta H7 but I assume that their bootloader firmware configures the internal SMPS then the clock of the STM32H747I to ensure correct boot sequence.

As the product is a dual core CPU (M7+M4) perhaps you have disabled the Cortex-M4 boot in the byte options? Can you check with STM32CubeProgrammer the status of the BCM4 option byte?

For the definition of the thread linker memories of your CubeIDE project, it seems safe to me and will not overwrite your bootloader. From this side it's ok.

Finally, it's good news if you managed to debug your code on the CM7. However, the following line of code is mandatory in the case where the CM4 is also used because it allows you to wait until this second CPU is properly started.

while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) != RESET) && (timeout-- > 0));

I suggest you the application note AN5361 which explains how to program and debug a dual core project on the STM32H7 with STM32CubeIDE:

https://www.st.com/resource/en/application_note/an5361-getting-started-with-projects-based-on-dualcore-stm32h7-microcontrollers-in-stm32cubeide-stmicroelectronics.pdf

Best regards,

Romain,

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

@RomainR. 

I cannot thank you enough for your time!

I grabbed the latest bootloader from GitHub and now my H7 is visible on a COM port! I used the Arduino IDE to write a multiple colored led blink sketch and it worked great. I then wrote that sketch and flashed it via the CubeIDE and it works great!

 

This is the good bootloader:

portentah7_bootloader_mbed_hs_v2.bin

It has an .elf equivalent but the CubeProgrammer couldn't flash it.

Admittedly, I am not as well versed with the Cube set of tools as I thought I was. So I have a lot of reading and test programs to write.

 

Again, I really appreciate your time

Rtalan.