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.
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.
Top of my head, I think what I did was changing the starting address of RAM in linker file. The project I was working got shelved later on so I don’t have any recent memory about it.
With this, Mbed will use the startup and linker files for the STM32F401xC models and set the appropriate SRAM size, interrupt vector table, MBED_ROM_START and MBED_ROM_SIZE.