Arm Mbed OS support forum

How to port code to a different MCU of the same family? like from STM32F401RE to STM32F401RC?

Hi,

I am trying to port an app built around STM32F401RE/NUCLEO_F401RE to its sibling STM32F401RC, to save a bit money on each MCU. I thought this is going to be straightforward but so far it doesn’t go well.

On the same board, a blinky built with STM32CubeIDE seems to work just fine.

int main(void)
{
  HAL_Init();
  SystemClock_Config();
  MX_GPIO_Init();
  MX_USART6_UART_Init();
  while (1)
  {
	HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
	HAL_Delay(1000);
  }
}

But blinky built with Mbed somehow doesn’t work.

int main() {
    //Watchdog &watchdog = Watchdog::get_instance();
    //watchdog.start(30000);
    //printf("system started\r\n");

    DigitalOut led(PA_5);

    while (1)
    {
        //printf("System running\r\n");
        led = !led;
        ThisThread::sleep_for(1000);
        //watchdog.kick();
    }
}

Since the only difference between STM32F401RE and F401RC is the size of flash, I assume as long as code can fit into F401RC, it should run fine.

What am I missing here?

Thanks in advance.

The problem is STM32F401RC has only 64KB RAM while F401RE has 96KB. Once this is changed is linker script accordingly, the blinky seems to work just fine.

https://os.mbed.com/docs/mbed-os/v5.15/reference/memory.html

1 Like

Hi @zhiyong ,

I am facing exactly the same issue but cannot make it work.

What is it that you changed?

Did you create a custom target?

Thanks,
Lluis