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.

TM4C123GH6PM: Fail safe bootloader for TM4C123GH6PM, Two location for loading main app

Part Number: TM4C123GH6PM

I want to copy code using bootloader fail safe, means if somehow UART communication stops while loading code using bootloader i can be able to upload code again after reset of controller.I want to copy code firstly in some different location of Flash than after my code upload successfully i will write it to the location where my existing code is running.so that no risk of losing code.In my existing scenario if communication during boot loading process stops, my controller stops working and i am not able to enter in boot mode.I this case i need to erase whole flash and than need to upload bootloader after that only i am able to proceed further. Please help or refer some helpful piece of code/example.I am using boot_serial example as bootloader.

I am entering to boot loader mode using UART Command in application.

  • Following function used to jump to bootloader in main app

    its something like this if "#" is recieved in UART interrupt it will jump to bootloader mode.

    if(dfc =='#')
    {
    JumpToBootLoader();
    }

    void JumpToBootLoader(void)
    {
    //
    // 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;


    //
    // Return control to the boot loader. This is a call to the SVC
    // handler in the boot loader.
    //
    (*((void (*)(void))(*(uint32_t *)0x2c)))();
    }

    I exactly want is to jump to bootloader on command basis , now bootloader should copy code to some other location(e.g. 0xABCD) than my application resides , if communication fails during bootloading , my code should start running main app on power reset , if bootloader successfully load code to location 0xABCD , then i will start writing code to main application location i.e. 0x00002800. 

    Hope i am able to make understand you my problem,

    Please Help.

  • Hi,

      Wouldn't you want to consider the below two options in the bl_config.h file? Hope this post will also help. https://e2e.ti.com/support/microcontrollers/other/f/908/p/537681/2000471?tisearch=e2e-quicksearch&keymatch=binpack%20TI-RTOS#2000471

    //*****************************************************************************
    //
    // Enables runtime and download CRC32 checking of the main firmware image.
    // If this is defined, the boot loader will scan the main firmware image for
    // an image information header (stored immediately above the vector table and
    // marked by the words 0xFF01FF02 and 0xFF03FF04). If the header is found and
    // the CRC32 value it contains matches that calculated for the image, the
    // firmware is run. If the CRC32 does not match or the image information
    // is not found, the boot loader retains control and waits for a new download.
    // To aid debugging, if this option is used without ENFORCE_CRC being set, the
    // image will also be booted if the header is present but the length field is
    // set to 0xFFFFFFFF, typically indicating that the firmware file has not been
    // run through the post-processing tool which inserts the length and CRC values.
    //
    // Note that firmware images intended for use with CRC checking must have been
    // built with an 8 word image header appended to the top of the vector table
    // and the binary must have been processed by a tool such as tools/binpack.exe
    // to ensure that the required length (3rd word) and CRC32 (4th word) fields
    // are populated in the header.
    //
    // Depends on: ENFORCE_CRC
    // Exclusive of: None
    // Requires: None
    //
    //*****************************************************************************
    //#define CHECK_CRC

    //*****************************************************************************
    //
    // This definition may be used alongside CHECK_CRC to remove the debug behavior
    // which will allow an image with an uninitialized header to be run. With
    // ENFORCE_CRC defined firmware images will only be booted if they contain a
    // valid image information header and if the embedded CRC32 in that header
    // matches the calculated value.
    //
    // Depends on: None
    // Exclusive of: None
    // Requires: CHECK_CRC
    //
    //*****************************************************************************
    //#define ENFORCE_CRC

  • Thank you charles,

    First of all thank you very much for fast response.

    The process of enabling runtime CRC Checking is good option to solve my purpose but i need to understand the whole process implementation,

    If some document describe it step wise, or some reference describe it step wise  will be greatful.

    Also clear the process and want to know about tools/binpack.exe.

  • Hi,

      Please reference the TivaWare Host Tools user's guide under <TivaWare_Installation>/docs/SW-TM4C-TOOLS-UG-2.1.4.178.pdf about the usage of binpack.exe. Below is what is described in the user's guide.