SIGSEGV porting Nucleo-F334R8 to Mbed OS 6

Hi all,

Recently I bought a NUCLEO-F334R8 board.
This board was officially supported by Mbed OS 5, but the support was dropped in Mbed OS 6.
I want to use this board with the new Mbed OS 6 API, so I tried to port it as a custom target.

I did the following steps:

  1. add an entry in custom_target.json which simply inherits MCU_STM32F334x8.
    2.copy system_clock.c, PinNames.h, PeripheralPins.c, PeripheralNames.h from the latest 5.15 branch, place them into the TARGET_NUCLEO_F334R8 folder.
    3.modify PinNames.h to comply with the Mbed OS 6 conventions.
    4.make the SystemInit function in system_stm32f3xx.c __weak, since it’s redefined in system_clock.c of NUCLEO_F334R8 target.
    5.change MBED_RAM_SIZE to 0x3000(12KB) in mbed-os\targets\TARGET_STM\TARGET_STM32F3\TARGET_STM32F334x8.

After applying these changes I was able to compile a simple blinky app with Mbed OS 6, but the app crashes before entering main function.

I set a breakpoint in SystemInit function and step through the function, then the Segment Fault occurs at the exit of SystemInit.

I had successfully ported many F1, F4, H7, L0, G0 boards to Mbed OS 6, this is the first time to encounter such problem.

The same blinky app runs without a problem when compiled with Mbed OS 5.

Any suggestions?
Thanks.

I examined the generated .map file, and found ARM_LIB_STACK was placed at 0x20003000, which is beyond the 12KB SRAM size. It seems changing MBED_RAM_SIZE in cmsis_nvic.h has no effect.

Adding a mbed_ram_size entry in the custom_targets.json fixed the problem.

The complete custom target definition is:

"NUCLEO_F334R8": {
    "inherits": ["MCU_STM32F334x8"],
    "device_name": "STM32F334R8Tx",
    "mbed_ram_size": "0x3000"
}

I haven’t found where the default value 0x4000 comes from, but it’s a bug and should be fixed.

I was just curious, so I did a quick search through my mbedOS folder and it threw up a bunch of cmsis_nvic.h files in the target folders. I see inside there is this (note this is an example from a random cmsis_nvic.h file found within folder TARGET_STM32L496xG):

#if !defined(MBED_RAM_SIZE)
#define MBED_RAM_SIZE  0x40000  // 64 KB
#endif

Hi

Thx for reporting this issue!

I agree this is not easy to find it…
This comes from “ARM pack manager”

This json file has been populated from Keil packs information (Arm Keil | Devices)

I have proposed a path there:

Jerome

You could also have a look on:

This is very helpful. Thank you.