This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C129ENCPDT: TM4C129ENCPDT

Part Number: TM4C129ENCPDT
Other Parts Discussed in Thread: EK-TM4C1294XL

Hello,

I'm Trying to implement a flash based bootloader. But I couldn't set the Main stack pointer value to the desired flash address.

Does anyone have an idea on how to perform this?

  • Hi,

     Please reference the flash-based bootloader examples. You can find an example bootloader at C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\boot_serial. This bootloader bootload through UART interface. The bootloader must residesat 0x0. The application can reside at a 1024byte boundary. An application example can be found at C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\boot_demo1. This application starts at 0x4000. In the bootloader configuration file bl_config.h the application starting address and the application vector table are specified for 0x4000 but this value can be changed per your application requirement as long as it is a multiple of 1024 bytes. See below snippet in the bl_config.h file. 

    //*****************************************************************************
    //
    // The starting address of the application. This must be a multiple of 1024
    // bytes (making it aligned to a page boundary). A vector table is expected at
    // this location, and the perceived validity of the vector table (stack located
    // in SRAM, reset vector located in flash) is used as an indication of the
    // validity of the application image.
    //
    // The flash image of the boot loader must not be larger than this value.
    //
    // Depends on: None
    // Exclusive of: None
    // Requires: None
    //
    //*****************************************************************************
    #define APP_START_ADDRESS 0x4000

    //*****************************************************************************
    //
    // The address at which the application locates its exception vector table.
    // This must be a multiple of 1024 bytes (making it aligned to a page
    // boundary). Typically, an application will start with its vector table and
    // this value should be set to APP_START_ADDRESS. This option is provided to
    // cater for applications which run from external memory which may not be
    // accessible by the NVIC (the vector table offset register is only 30 bits
    // long).
    //
    // Depends on: None
    // Exclusive of: None
    // Requires: None
    //
    //*****************************************************************************
    #define VTABLE_START_ADDRESS 0x4000

  • Hey Charles,

    Thank you for the reply.

    I found boot_demo1 from the example. It has the Jump to Bootloader function, which I can work with on my application. One issue I faced during building is 

    ROM_SysTickIntDisable();
    ROM_SysTickDisable();

    These 2 functions can't be accessed from my source file. It shows as an implicit declaration of the function.

    1. Do you know which header file I should include to resolve the error?

    I can see that  (*((void (*)(void))(*(uint32_t *)FlashAddress)))(); is called in order to jump to the specified FlashAddress. But I found that it is to call the SVP handler to the application in the FlashAddress. 

    2. Is it not necessary to change the Program Counter to the address and main stack pointer address also? or will it work only with this?

  • Hey Charles,

    One more update. I got the SysTickIntDisable(), and SysTickDisable(); and my errors are resolved. But I could not perform the jump to the application.

    Do you have any idea about that?

  • Hi,

    One more update. I got the SysTickIntDisable(), and SysTickDisable(); and my errors are resolved.

    Glad you that revolve the compile issue. 

    But I could not perform the jump to the application.

    You would need to program the bootloader to the flash to 0x0 through JTAG. After this is done, the only thing you have in the flash is the bootloader. There is no application yet. The bootloader will not jump to the application since the application is not there yet. The bootloader will still be in the bootload mode waiting for you to provide the application code (e.g. boot_demo1). If you are using the LaunchPad which I will strongly suggest you do to get it working before you move on to your own custom board, you can just use LM flash program to provide the boot_demo1.bin. The application will then be downloaded to the flash through the UART interface. Once the application is downloaded, the next time the device is started, the bootloader will find a valid application at 0x4000 and it will then jump to the application. 

    - See below to use LM flash program to select serial interface for download. You need to provide your own COM port.

    - Next provide the boot_demo1.bin and hit 'Program'.

  • Hi Charles,

    Thanks for the reply.

    But I have already flashed the application's hex file to the specified location, which is 0x10010. And my bootloader lies at 0x00000000.

    I have individually tested the application code and it is working fine. Below are the code portions of the bootloader to jump to the application.

    This is the function for GoToApplication().

    void GoToApplication(uint32_t FlashAddress)
    {
            IntMasterDisable();
    
            // We must make sure we turn off SysTick and its interrupt before entering
            // the boot loader!
            SysTickIntDisable();
            SysTickDisable();
    
            //
            // Disable all processor interrupts.  Instead of disabling them
            // one at a time, a direct write to NVIC is done to disable all
            // peripheral interrupts.
            //
            HWREG(NVIC_DIS0) = 0xffffffff;
            HWREG(NVIC_DIS1) = 0xffffffff;
            HWREG(NVIC_DIS2) = 0xffffffff;
            HWREG(NVIC_DIS3) = 0xffffffff;
    
            //
            // Return control to the application.  This is a call to the SVC handler in the application.
    
            (*((void (*)(void))(*(uint32_t *)FlashAddress)))();
    }

    But Application 1 is not executing.

  • In  my reply I already said the application image must align to 1024bytes. Is your application image starting at 0x10010? This is not aligned to 1k boundary. Why don't you try the stock example first (both the serial bootloader and the boot_demo1) and get to to work before you make any modification. 

  • For your kind information, my application is aligned to 1024 bytes. The application image is starting at 0x10010. but I have provided the length to be 384 KB, so it is aligned to 1024 bytes.

    I'm adding the snapshot below.

    anyway, I'll try with the example in the meantime. 

  • Hi,

      I think you are mistaken on what 1024bytes means. 1024 is a decimal value. Its hex value is 0x400. Your starting address is 0x10010 which is equal to 65552 decimal. If you divide 65552 / 1024 is not a whole number. Your starting address must be 0x10000 instead of 0x10010. 0x10000 is equal to 65536. Dividing 65536 by 1024 is equal to 64. That is what I have been saying all along. Please read the comments in the bl_config.h file. You need to change the  below #define to 0x10000 and also your linker command file to start the application at 0x10000, not 0x10010. 

    // The starting address of the application. This must be a multiple of 1024
    // bytes (making it aligned to a page boundary). A vector table is expected at
    // this location, and the perceived validity of the vector table (stack located
    // in SRAM, reset vector located in flash) is used as an indication of the
    // validity of the application image.
    //
    // The flash image of the boot loader must not be larger than this value.
    //
    // Depends on: None
    // Exclusive of: None
    // Requires: None
    //
    //*****************************************************************************
    #define APP_START_ADDRESS 0x4000

    //*****************************************************************************
    //
    // The address at which the application locates its exception vector table.
    // This must be a multiple of 1024 bytes (making it aligned to a page
    // boundary). Typically, an application will start with its vector table and
    // this value should be set to APP_START_ADDRESS. This option is provided to
    // cater for applications which run from external memory which may not be
    // accessible by the NVIC (the vector table offset register is only 30 bits
    // long).
    //
    // Depends on: None
    // Exclusive of: None
    // Requires: None
    //
    //*****************************************************************************
    #define VTABLE_START_ADDRESS 0x4000

  • Hello Charles,

    Thank you for your support.

    This solved my issue.