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.

TIVA doensot reboot properly after upgrading it through API : ROM_UpdateUART ()

Other Parts Discussed in Thread: LMFLASHPROGRAMMER, UNIFLASH

Hi,

After calling the API : ROM_UpdateUART(), The TIVA goes into UART boot mode.

When it is upgraded by sflash utility to upgrade the TIVA over uart, . the application is loaded half and then it stops working, may be it is going into faultisr() routine.

But then when I hard-reset the tiva, the upgraded firmware works fine.

Any suggestions as to why did this happen like this?

Thanks,

Sanchit Mehra

 

  • Hello Sanchit,

    Are you using LMFlashProgrammer and empty device to upload the Boot Code through UART?

    Regards

    Amit

  • Hello Amit,

    The Device is not empty and I am using the SFlash utility, which is I guess the same utility as LM Flash programmer.

    Actually, with that I am upgrading the Application code and not the boot code.

    On the UART0 of TIVA, firstly the communication is done, for getting the TIVA into UART boot mode by disabling all interrupts and calling the UpdateUART() API.

    When my application was smaller in size, the application was loaded and run fine.

    but now, as my application size increases, the application gets loaded But it doesnot loads properly and hangs in middle, I guess , must be in FaultISR routine.

    Thanks,

    Sanchit Mehra

  • When my application was smaller in size, the application was loaded and run fine.

    but now, as my application size increases, the application gets loaded But it doesnot loads properly and hangs in middle, I guess , must be in FaultISR routine.

    How about telemetry ? (Adding some debug output, e.g. via another UART interface).

    Another common problem are incomplete peripheral configurations, making implicit assumptions about register contents. That often fails when this registers are not cleared, lika after an POR.

    Or, as the application grew bigger, you may run into stack overflows, another common runtime issue.

  • Hello Sanchit,

    As f.m. aptly mentioned, did you check the Stack Size, since the application was working fine when it was smaller in size and not when the size increased.

    You can connect the debugger and see what state the NVIC_FAULTSTAT and FAULTADDR registers indicate.

    Regards

    Amit

  • Hi Amit,

    The Application gets stuck only first time it was loaded via UART bootloader , 

    Once given a POR, it loades perfectly fine and works.

    Had it been a stack issue, it should get stuck everytime .

    Am i right ?

    Thanks,

    Sanchit Mehra

  • Hello Sanchit

    1. What is the sflash command line arguments being parsed?

    2. If you do the same step by using LMFlashProgrammer then does it still get stuck?

    Regards

    Amit

  • Hello Amit,

    The Sflash command which I use to update my application over UART is :

    sflash -c /dev/ttymxc1 -b 115200 -d -l [application -filename]

    After giving this, TIVA which is already in UART bootmode, starts receiving the packet , but after finish sending the firmware, sflash issues the reboot command.

    At this point, TIVA doesnot come up properly, its very slow also, and gets hang up somewhere , ( may be the point where I initialise the HTTP Service.)

    I could not get , why it is happening so, the only difference is that now my firmware size is big, whereas when it was small enough, i didnt face issues like this .

    i will test this with LM FLASH programmer also and let you know, but I hope this is one and the same thing.

    Thanks,

    Sanchit Mehra

     

  • Hello Sanchit,

    There are couple of things.

    The -l option is for the boot loader binary and not the application binary

    Also you must try using -p and -r to download the application and run the same from the offset in flash,

    Regards

    Amit

  • Hi Amit,

    May I know how and where can I find and get the application's Program Address ( -p) and Execution Address (-r)

    so that I may put the respective addresses with the options .

    Thanks,

    Sanchit Mehra

  • Hello Sanchit,

    The Run Address is specified by the linker command file which tells where the image has to be located w.r.t. Reset vectors

    Regards

    Amit

  • Hello Amit,

    Thanks for the reply.

    I also want to make my application upgrade as fail-safe.

    So, if in between, Power-failure is there , while the upgrade is in process .

    Then on resuming the power, will the bootloader again be ready for the Upgrade process vis UART ?

    I read the document, which says that the bootloader will enter into the update mode if it finds 

    "The application is assumed to be valid if the first location is a valid stack pointer (that is, it resides in SRAM, and has a value of0x2xxx.xxxx), and the second location is a valid reset handler address (that is, it resides in flash,and has a value of 0x000x.xxxx, where the value is odd). If either of these tests fail, then theapplication is assumed to be invalid and an update is forced."

    here my query arises that , if the last byte of application is not written , due to power failure, ( means application update is not success , in any way ) , then also, will the above highlighted condition will become true, and application update will be forced ?

    Awaiting your suggestions.

    Thanks,

    Sanchit Mehra

  • Hello Sanchit,

    Please note that it is the first two words that dictate the validity of the program. Hence the ROM boot Loader is not aware of the size of your program. So it would execute the faulty program. To prevent such a case, it would be advisable to use a Flash based boot loader where CRC can be computed by the Flash Boot Loader and checked against a known value which is programmed in the end.

    Regards

    Amit

  • Hi Amit,

    Thanks for the reply.

    Could you please suggest some examples, that

    1) how can we modify the bootloader

    2) how can be make UART mode bootloader as a default ?

     

    Thanks,

    Sanchit Mehra

     

  • Hello Sanchit,

    Not the ROM Based boot loader. The only changes that can be done are for a Flash based boot loader. In the flash based boot loader you can have a single interface (removing all other interfaces). Please note that binpack.exe would be reqiore to take the image and append CRC before sending the image to the device over UART.

    Regards

    Amit

  • Hello Amit, 

    Just One clarification over the flash based bootloader, to make the tiva upgrade fail-safe.

    Will it be required to update the flash bootloader everytime, on each upgrade, to make it fault tolerant/ fail-safe ?

    Or flash bootloader only needs to be upgraded only one time, and then it always remain in flash, and makes the device fail-safe for any future application upgrades ?

    Thanks,

    Sanchit

  • Hello Sanchit,

    This is something for the application requirement to decide. If you may need to change the boot loader in terms of feature then a flash boot loader would be required to be updated. In most cases the flash boot loader can be updated only once. It is the application that needs an update.

    Regards
    Amit
  • Amit Ashara said:
    To prevent such a case, it would be advisable to use a Flash based boot loader where CRC can be computed by the Flash Boot Loader and checked against a known value which is programmed in the end.

    There is another method, fairly frequently used. That is to program those two words only after the rest of the flash has been programmed.

    This really should be the default behaviour of the download program although I don't know if it is. It has been the behaviour of serial downloaders I've used in the past.

    Robert

  • Hello Robert

    That is what is done by the boot loaders in TivaWare and ROM.

    Regards
    Amit
  • Good to know, and I agree a CRC is superior at ensuring the integrity and a cryptographic hash is even better.

    Robert
  • Thanks Amit. Thanks Robert.

    Can you please guide me as to how can I build the flash bootloader. I have the code for flash bootloader given by TI.

    And how can I flash the bootloader along with the application using CCS or LM Flash ?

    Thanks,

    Sanchit Mehra

  • Hello Sanchit,

    You can start with the example flash bootloader in TivaWare.

    The process of flashing the bootloader can either be via JTAG or Serial Interface. CCS shall only perform JTAG. Uniflash and LMFlash can perform either JTAG, UART or USB. Uniflash has a larger set of emulator for JTAG as compared to LMFlash.

    Regards
    Amit
  • Thanks Amit,
    And at what address should I flash the flash bootloader ? is it 0x2000.0000 ?

    Sanchit
  • Hello Sanchit

    The flash boot loader must be at 0x0 as that is the location from where the execution is done when the CPU is reset.

    Regards
    Amit
  • Hi Amit,

    If the flash boot loader address  must be at 0x00, in the flash , then where should the application resides in the flash ?

    Where the flash bootloader must be configured to load the application from 0x? address ?

    Thanks,

    Sanchit Mehra

  • Hello Sanchit,

    Did you read the boot loader user guide and internal memory section of the data sheet as I believe you are asking questions that should be primed with an answer in the two documents

    Regards
    Amit