6 years ago.

MBED BOOTLOADER PROBLEM FOR STM32F401RE NUCLEO

Hello All,

I am a long time user of mbed. With the intruduction of FlashIAP library and mbed_start_application() method i will try to wirte a bootloader.

Requests: Bootloader will be placed on Sector 0 (0x08000000) of F401; Default application will be placed on Sector 6 (0x0804000) of F401; New application (updated firmware) will be placed on Sector 7 of F401;

Methodolgy is...

Run f401...start bootlader...check eeprom...if any update available write to sector 7 (since default is in sector 6)..jumpt to sector 7 program....if any command received from usart reset board and start bootloader..... write new firmware to sector 6.....jumpt to sector 6...

My problem is i can not jump to sector 6 or sector 7 with below code (it is simplified) (I2C, uart, etc initialized for communication in bootloader code). I am preparing and compiling my code with online compiler;

#include "mbed.h"

// UART and I2C satrted..
// bla bla

// NEW FIRMWARE CANNOT FOUND. START FROM OLD FIRMWARE LOCATION
            if (eeprom_read(CURRENT_FIRMWARE_LOCATION_ADDRESS) != 0x07) {
mbed_start_application(STM32F401_FLASH_SECTOR_6); // 0x08040000

} else if (eeprom_read(CURRENT_FIRMWARE_LOCATION_ADDRESS) == 0x07) {

                mbed_start_application(STM32F401_FLASH_SECTOR_7); // 0x08060000

            }


The next try is:

if (eeprom_read(CURRENT_FIRMWARE_LOCATION_ADDRESS) != 0x07) {

SysTick->CTRL = 0;
    SysTick->LOAD = 0;
    SysTick->VAL = 0;
    
    __disable_irq();
    
    
                //SYSCFG->MEMRMP = 0x01;
                
                SysMemBootJump = (void (*)(void)) (*((uint32_t *)(0x08040000 + 4)));
            
            __set_MSP(*(uint32_t*) 0x08040000);
            SysMemBootJump();

} else if (eeprom_read(CURRENT_FIRMWARE_LOCATION_ADDRESS) == 0x07) {
SysTick->CTRL = 0;
    SysTick->LOAD = 0;
    SysTick->VAL = 0;
    
    __disable_irq();
    
    
                //SYSCFG->MEMRMP = 0x01;
                
                SysMemBootJump = (void (*)(void)) (*((uint32_t *)(0x08060000 + 4)));
            
            __set_MSP(*(uint32_t*) 0x08060000);
            SysMemBootJump();

                //mbed_start_application(STM32F401_FLASH_SECTOR_7);

            }

Any help appreciated...

Regards...

KM

Be the first to answer this question.