Skip to main content
Giu S
Associate II
August 31, 2017
Question

STM32F0 cortex jump to application

  • August 31, 2017
  • 8 replies
  • 2458 views
Posted on August 31, 2017 at 16:29

Hello to all, I need to write the bootloader for a cortex M0. Could someone explain to me what I have to do. What are the code that I have to write and how I have to modify the linker and the sturtup .s file? In the forum I find many different solution, but at the moment no one works. I read that in the M0 processor is not possible to relocate the vector table, but I don't understand what I have to do. Thank you very much in advanced.

    This topic has been closed for replies.

    8 replies

    After Forever
    Senior III
    August 31, 2017
    Posted on August 31, 2017 at 16:49

    Indeed, custom bootloader related questions seem to be the most popular ones here. There are several very informative posts written by

    Turvey.Clive.002

    ‌ and others describing the technique and demonstrating the code. If you want something more official then there are example projects provided by ST too.

    1. Install STM32CubeMX, install the latest F0 library

    2. Find where is located your repository directory by opening the 'Help -> Updater settings...' menu item

    3. You will find two projects inside your repository in 'STM32Cube_FW_F0_V1.8.0/Projects/STM32091C_EVAL/Applications/IAP'

    One of those projects is the example bootloader, and the other one is the example application. Examine their source code to understand how it works.

    Giu S
    Giu SAuthor
    Associate II
    August 31, 2017
    Posted on August 31, 2017 at 17:11

    Ok, thank you very much. I found it! I have a question now. I have to do a CAN bootloader so if I understand good I have to write the code of the CAN bootloader in this 'if':

    if

    (

    BSP_PB_GetState

    (

    BUTTON_TAMPER

    ) ==

    GPIO_PIN_RESET

    )

    {

    /*

    Initialise

    Flash */

    FLASH_If_Init();

    /* Execute the IAP driver in order to reprogram the Flash */

    IAP_Init();

    /* Display main menu */

    Main_Menu ();

    }

    ............

    and I have to write my application in the while(1) after the else. It's correct?

    If this is correct I don't understand how my application code is stored after the APPLICATION_ADDRESS.

    Could someone explain this to me?

    Thank you very much!

    Tesla DeLorean
    Guru
    August 31, 2017
    Posted on August 31, 2017 at 18:11

    >>I don't understand how my application code is stored after the APPLICATION_ADDRESS.

    You configure your tool chain's linker to build the code at that address, either via the GUI, or scatter file, or linker script.

    Your loader needs to store the downloaded image there.

    The Cortex-M0 will need you to build a new vector table in RAM, typically by copying the one built by the linker to the base of RAM at 0x20000000, and then use the STM32 specific mapping register to map/shadow RAM at zero.

    The CM0+ does provide the SCB->VTOR Vector Table mapping register, and this can be used instead.

    Get an understanding of the CPU have chosen, read the docs so you have some grasp of how it functions with respect to your existing knowledge of micro-controllers.

    Then understand the features/functions of your chosen STM32 part (not specified) by reviewing the Data Sheet and Reference Manual with respect to the knowledge gained above.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..