Porting MbedOS on STM32H735IGKx DISCO-H735 STM32H735G-DK

Hello,
I am trying to port MbedOS v6.15.1 STM32H735G-DK,
I have followed this guide to port it,
I have generated PinNames.h and PeripheralPins.c automatically using XML file from CubeMX using the following command:

python STM32_gen_PeripheralPins.py -m "STM32H735IGKx.xml

Then I have changed the Px_x in PinNames to the following :

#define LED1 PC_3
#define LED2 PC_2
#define LED3 PF_7
#ifdef MBED_CONF_TARGET_STDIO_UART_TX
CONSOLE_TX = MBED_CONF_TARGET_STDIO_UART_TX,
#else
CONSOLE_TX = PD_8,
#endif
#ifdef MBED_CONF_TARGET_STDIO_UART_RX
CONSOLE_RX = MBED_CONF_TARGET_STDIO_UART_RX,
#else
CONSOLE_RX = PD_9,
#endif

I have inherited the board from MCU_STM32H735xG and added a macro for "HSE_VALUE=25000000"

the full code is on this public GitHub repo
The important file that I think is wrong and making the below errors is system_clock.c, I have compared the DIV (PPLx) from MbedTLS since it is already ported in the board, so the following lines are changed:

#if HSE_VALUE==25000000
RCC_OscInitStruct.PLL.PLLM = 5; // 2 MHz
RCC_OscInitStruct.PLL.PLLN = 104; // 550 MHz
#else
#error Unsupported externall clock value, check HSE_VALUE define
#endif
RCC_OscInitStruct.PLL.PLLP = 1;
RCC_OscInitStruct.PLL.PLLQ = 4;
RCC_OscInitStruct.PLL.PLLR = 2;
RCC_OscInitStruct.PLL.PLLFRACN = 0;
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;

Result: It compiles correctly, it loads the bin file but not completely, and put the board in a deadlock( If the board SMPS/LDO firmware PWR configuration does not match its hardware configuration, a deadlock occurs. After the reset, the ST-LINK cannot connect to the target anymore.) , so I had to do a Mass reset to work with it again, the error is as follow:

0001125:CRITICAL:main:STLink error (9): Get IDCODE error
Traceback (most recent call last):
File “/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/main.py”, line 402, in run
self._COMMANDSself._args.cmd
File “/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/main.py”, line 572, in do_flash
with session:
File “/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/core/session.py”, line 339, in enter
self.open()
File “/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/core/session.py”, line 457, in open
self._board.init()
File “/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/board/board.py”, line 85, in init
self.target.init()
File “/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/core/soc_target.py”, line 117, in init
seq.invoke()
File “/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/utility/sequencer.py”, line 213, in invoke
resultSequence.invoke()
File “/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/utility/sequencer.py”, line 208, in invoke
resultSequence = call()
File “/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/coresight/dap.py”, line 376, in _connect
connector.connect(self._protocol)
File “/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/coresight/dap.py”, line 163, in connect
self._connect_probe(protocol)
File “/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/coresight/dap.py”, line 183, in _connect_probe
self._probe.connect(protocol)
File “/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/probe/stlink_probe.py”, line 136, in connect
self._link.enter_debug(STLink.Protocol.SWD)
File “/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/probe/stlink/stlink.py”, line 267, in enter_debug
self._check_status(response)
File “/Library/Application Support/Mbed Studio/mbed-studio-tools/python/lib/python3.7/site-packages/pyocd/probe/stlink/stlink.py”, line 305, in _check_status
raise exceptions.ProbeError(error_message)
pyocd.core.exceptions.ProbeError: STLink error (9): Get IDCODE error

Hi

I will try to check your code, but 2 comments to start :slight_smile:

Just for information about STM32_gen_PeripheralPins.py script use.
As STM32H735G-DK is an official ST board, it is part of STM32 database (which is not perfect, be careful…)

$ python targets/TARGET_STM/tools/STM32_gen_PeripheralPins.py -b | grep H735
H76_Discovery_STM32H735G-DK_STM32H735IGK_Board_AllConfig.ioc

$ python targets/TARGET_STM/tools/STM32_gen_PeripheralPins.py -t H76_Discovery_STM32H735G-DK

=> you should then get the same file as you had!

I have inherited the board from MCU_STM32H735xG

This is the good start.
Having a look on

and in board user manual, you need to update the system_power_supply:
“overrides”: {
“system_power_supply”: “PWR_DIRECT_SMPS_SUPPLY”
}

Now if you have issues to recover your board, good thing should be to use STM32 Cube Programmer tool, and maybe use the “Power Down” mode to connect and reset the board.

Jerome

I have tried to reproduce the steps from this guide to port it, however, the structure seems to be unrecognized by MbedOS, I have also tried to reproduce the old steps using the old guide of MbedOS 5 and I got the same result ( DISCO-H735G is not supported MCU).
I remember having changes in MbedOS last time, so even if I copy the files that were used in the old Repo and post, the result throws another error(it is not “MCU not supported”)

After reading those guides I tried to add the new files for the board directly in MbedOS,
Result: no deadlock, no error at all during building or during downloading but no LEDs are working
Expected behavior: User LEDs (LD1-3) are turned ON

I have tried to debug it using STM32Cube IDE, but it stops at HardFault error, and when I force it to resume and after it finish and the GDB closes connection, the LD1 is toggling and in a different frequency from time to time,

I have created a new Git repo which has two branches for the first case where I ported it as a custom board but I get unsupported MCU, and the second branch presents the importing of the board files directly in MbedOS

In the First case:
I wanted to make sure the TARGET folder is included so I added it to the global CMakeLists.txt, so I added the following, even though I have respected the structure from the porting guide

set(DISCO_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mbed-os CACHE INTERNAL “”)
add_subdirectory(${DISCO_PATH})

In the second case:
1- I have moved TARGET_DISCO_H735G under /mbed-os/targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H735xG
2- added the content of custom_target.json into mbed-os/targets/targets.json

“DISCO_H735G”: {
“inherits”: [
“MCU_STM32H735xG”
],
“macros_add”: [
“HSE_VALUE=25000000”
],
“default_toolchain”: “IAR”,
“overrides”: {
“system_power_supply”: “PWR_DIRECT_SMPS_SUPPLY”,
“clock_source”: “USE_PLL_HSE_XTAL|USE_PLL_HSI”
},
“detect_code”: [
“0875”
],
“device_name”: “STM32H735IGTx”,
“extra_labels_add”: [
“STM32H735IGKx”,
“STM32H735G-DK”,
“STM32H735IGK”
]

I think that I am missing a clock or another configuration in system_clock.c

Hi
I could find one DISCO-H735G, and then support it.
See DISCO_H735G support · ARMmbed/mbed-os@df32243 · GitHub

Regards,
Jerome

Thank you for your support,

Best regards,
Hamdi