Skip to main content
Visitor II
April 21, 2024
Solved

Portenta H7 Development with STM32CubeIDE

  • April 21, 2024
  • 2 replies
  • 6818 views

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.

    This topic has been closed for replies.
    Best answer by RomainR.

    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,

    2 replies

    Super User
    April 21, 2024

    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

     

    ST Employee
    April 21, 2024

    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

     

    rtalanAuthor
    Visitor II
    April 21, 2024

    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.

    ST Employee
    April 22, 2024

    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,