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.

Is there any default bootloader for TM4C129NCPDT MCU Tiva CSeries , that gets automatically /implicitly flashed when we program the application ?

Hi , 

Does the bootloader automatically gets compiled when compiling application and gets flashed implicitly when we flash the .bin application file ?

Or Do we need to separately compile the bootloader for tiva C Series and then we have to flash the bootloader separately at 0x00 location ?

If so is the case, then May I know , at what address do we need  to flash the application program ?

My whole objective is to make the upgrade of Tiva fail-safe ! for that I would need a secondary bootloader to verify the correctness of the binary in the flash.

Thanks,

Sanchit Mehra

  • Is not a factory boot-loader included w/in MCU's ROM?
  • Hello Sanchit,

    There is a default ROM boot loader which is called when Flash is empty or by using BOOTCFG register. This does not have any major check other than checksum. If you need to develop a mechanism to check for correctness of the binary, then there are 2 things that you need to perform

    1. Implement a CRC to detect error in the boot loader before it gets flashed
    2. Have a mechanism by which the boot loader can inform the host application of an error and ask for a retransmission.

    Regards
    Amit
  • Hi Amit,

    well, I am stuck in a problem, that while upgrading the tiva, if power supply to it is compromised, then the flash of tiva would not get updated with the binary. Hence, it would not boot , since there is no correct binary now!

    So, to handle this scenario, I would divide the flash into two parts . first part for flashing the new binary and second part for keeping the correct backup binary.

    So, what my flash bootloader would do, is to check whether the binary has been flashed properly or not ? If it is not flashed, then it would jump the control to the backup binary , that is kept at other part of the flash.

    Calculating CRC while flashing , I think , is implemented in the TI's sflash utility and ROM bootloader.

    What I need is a mechanism to detect whether the flashed binary has been flashed properly or erroneously? Error could have come up due to power cut during upgrade process in that case, there would not be correct binary present in the flash for bootloader to jump to.

    Thanks,
    Sanchit Mehra
  • Do not (properly) battery-backed "Uninterruptable Power Supplies" (effectively) guard against such compromise?
  • Hello Sanchit,

    When updating the application image, the location for SP and PC are updated in the end. This provides the first level of error detection. If a power failure occurs, then the device remains in boot loader mode as the SP and PC of the application image is not programmed yet and hence a faulty code execution may not commence.

    The second level is provided by use of CRC by means of the defines (CHECK_CRC and ENFORCE_CRC), in which case the boot loader will perform a CRC check. What you require is an application on the Host PC that will insert the CRC into the application image payload at the predesignated position. You can do that using a simple C program.

    Regards
    Amit
  • Hi Amit,

    As you said that

    "When updating the application image, the location for SP and PC are updated in the end. This provides the first level of error detection. If a power failure occurs, then the device remains in boot loader mode as the SP and PC of the application image is not programmed yet and hence a faulty code execution may not commence."

    that if application not fully programmed , then the device remains in the boot loader mode itself. since SP and PC are not programmed!

    Then when I replicated the scenario of incomplete update of application image, and when I again tried to download the application over uart (using sflash), it says that "Failed to send Download Command".

    Why sflash is returning this error, if the tiva is in bootloader mode. It must act upon the download command of sflash utility.

    Best Regards,

    Sanchit Mehra

  • Hello Sanchit

    Did you check the locations 0x0 and 0x4 of the flash? Does it contain the boot loader or the application?

    Regards
    Amit
  • Hello Amit,

    "What you require is an application on the Host PC that will insert the CRC into the application image payload at the predesignated position. "

    The TivaWare "binpack", utility provided in the tools sub-directory is well suited to this...

    Regards,

    Dave

  • Hi Amit,

    Well at the 0x00 location , I am flashing the bootloader and on location 0x1000 , I am flashing the application.
    and
    bl_config.h contains :
    #define APP_START_ADDRESS 0x00001000
    #define VTABLE_START_ADDRESS 0x00001000


    After flashing , how can we check the whether at the location 0x0 and 0x4 , there is bootloader or application ?

    Thanks,
    Sanchit Mehra
  • Hello Sanchit

    Lets keep the discussion to one thread.

    Regards
    Amit
  • Hi Amit,

    you explained: "When updating the application image, the location for SP and PC are updated in the end."
    Theese locations are 0x00000000 and 0x00000004, right ?

    I check the following:
    1) updater() - function in bl_main.c from from the folder TivaWare_C_Series-2.1.3.156\boot_loader  as well as
    2) UpdateFlash(FILE *hFile, FILE *hBootFile, uint32_t ui32Address) - funktion the in sflash.c from TivaWare_C_Series-2.1.3.156\tools\sflash

    But I cant find any construction which would handle such a feature.

    Did I oversee or missunderstood something?

    Best regards

    Karsten

  • Hello Karsten,

    That is done by the ROM boot loader. In case of flash boot loader for which the files you have mentioned, the location 0x0 and 0x4 are for the SP and PC of the flash boot-loader itself and not the application image.
  • Hi Amit,

    thx for the quick reply.

    If we use the flash bootloader, because we would like to use SSI2 instead of SSI0 and we

    have to toggle an external watchdog, is this an item which has be changed ?

    If we use a flash bootloader, is the following correct ?

    1) the rom bootloader starts, and sees a valid stackpointer an a valid resetvector from the

    flash-loader, which is located at 0x00000000.

    2) the flash loader is startet directly after the ROM bootloader. How does the flash bootloader

    check for a valid application ?

    3) if the flash loader is forced to download a new application, I worry about the power fail

    problem. What happens if we have power down during flashing a new application ?

    4) if we have a new, unprogrammed device, can we program the flash bootloader with the

    ROM bootloader, afterwards make a restart and flash then the application with the flash

    bootloader ?

    5) How can the flash bootloader protected against unwanted overwriting, especially with the

    scenario of point 4 ?

    There is a lot of documentation about bootloader stuff about its very confusing and a couple

    of items are discribed very detailed.

    I´m loooking forward receiving your comments.

    Best regards

    Karsten

    Am 9 Dec 2016 um 10:36 hat Amit Ashara geschrieben:

    >

    >  

    >

    >

    >

    > A Message from the TI E2ETM Community

    >

    >

    >

    > Texas Instruments

    >

    >  

    > Amit Ashara replied to Is there any default bootloader for TM4C129NCPDT MCU Tiva CSeries , that gets

    > automatically /implicitly flashed when we program the application ?.

    > Hello Karsten,

    >

    > That is done by the ROM boot loader. In case of flash boot loader for which the files you have

    > mentioned, the location 0x0 and 0x4 are for the SP and PC of the flash boot-loader itself and not the

    > application image.

    >

    >  

    >

    >  

    >

    > You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

    > Flag this post as spam/abuse.

    >

    >

    >

    >

    >

  • Hello Karsten,

    Karsten Klein said:

    1) the rom bootloader starts, and sees a valid stackpointer an a valid resetvector from the

    flash-loader, which is located at 0x00000000.

    Yes that is correct

    Karsten Klein said:

    2) the flash loader is startet directly after the ROM bootloader. How does the flash bootloader

    check for a valid application ?

    Flash loader also does the same check as ROM boot loader. Additionaly CRC checks can be done in Flash boot loader over the application image.

    Karsten Klein said:

    3) if the flash loader is forced to download a new application, I worry about the power fail

    problem. What happens if we have power down during flashing a new application ?

    You can always check the CRC or a checksum to make a decision of remaining in Flash bootloader or executing the "corrupted" application.

    Karsten Klein said:

    4) if we have a new, unprogrammed device, can we program the flash bootloader with the

    ROM bootloader, afterwards make a restart and flash then the application with the flash

    bootloader ?

    Absolutely. Please check the SPMA074 Application note. It does the same.

    Karsten Klein said:

    5) How can the flash bootloader protected against unwanted overwriting, especially with the

    scenario of point 4 ?

    Unwanted overwriting of itself or the application image?

  • Hi Amit,

    thanks again for the quick reply.

    2) the flash loader is started directly after the ROM bootloader. How does the flash bootloader
    check for a valid application ?

    Flash loader also does the same check as ROM boot loader. Additionally CRC checks can be done in Flash boot loader over the application image.
    - The vector table of the flashloader is located at 0x0000000
    - The flashloader is then started from 0x00000004
    - Wherefrom does the flashloader know the location  of the vectortable from the application?
       Is this fixed, depending on the size of the flashloader, like directly after the flashloader?
       flashloader: 0x00000000 ...... 0x00001FFF (8kB)
       application: 0x00002000 ....... 0x0000nnnn (?kB)
       Does the bootloader know its accurate flash size ?

    Where does the bootloader know the location of the application´s CRC from ?
    In our project we have a CRC16 - checksum which is calculated with the IAR EWB, and is located at the end of the binary:
                checksum           const    0x000058c4     0x2  Place holder ielftool_checksum
    I think this kind of CRC can not be used for that.
    We have to use the binpack-tool to combine our binary with the firmware image information header ? Right ?

    5) How can the flash bootloader be protected against unwanted overwriting, especially with the scenario of point 4 ?

        Unwanted overwriting of itself or the application image?

    Unwanted overwriting of itself!


    Best regards
    Karsten

  • Hello Karsten

    You have correctly summed up both the questions.
  • Hi Amit,

    and what about item 5):

    5) How can the flash bootloader be protected against unwanted overwriting of itself?

    From other contollers I know that there are flash-regions which can be protected ==> Read Only.
    Or there is a special region which can be used for bootloader and is Read-Only as well.

    How can this be handled with the TIVA, especialy with the possebility

    - to load the flashloder by use of the romloader and
    - to load the application by use of the flashloader ?

    Best regards

    Karsten

  • Hello Karsten,

    You can set the program/erase disable for the boot loader section in the boot loader. Once this is done a subsequent power cycle of the board would make the bootloader as ROXO (read only execute only). To do so, you need to use the FMPPE and FMPRE registers in the internal memory and set the permissions based on the sectors being used by the boot loader.
  • Hi Amit,

    thank you very much for your informations and clarifications.

    Unless you dont hear anything contrary, I have got it made.

    Best regards

    Karsten