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.

Hercules rewriting bootloader

Other Parts Discussed in Thread: TMS570LS3137

Hi, 

I'm looking at the Hercules SPI bootloader example from: http://processors.wiki.ti.com/index.php/RM4x_Hercules_MCU_Bootloader

I stepped through the code and I am confused how the bootloader is able to reprogram itself.  
It appears that only the flashAPIs are being copied and ran from SRAM.  

Specifically, when I reach the function UpdaterSPI(spiBase_t *node), it is running at around address 0x000015a8 instead of in SRAM ( around 0x08000000).   Thus, when it gets to the "case SPI_COMMAND_SEND_DATA", it will erase the flash starting at address 0x00000000 and destroy program execution with the function "Fapi_BlockErase( 0, 0, FLASH_FIRST_SECTOR_SIZE); "

Could I get some clarification on what I am misunderstanding from the example?

Thank You,

Harvey

  • We received your post and will get back to you soon.

    Regards.

  • Hi Harvey,

    The application start address is defined in bl_config.h. The default value is at 0x20000. The bootloader is not able to update itself.

    You also need to send the application start address and image size to bootloader using SPI protocol. The bootloader will check the address and image size. If the start address is different from the addr defined in bl_config.h, or the image size is bigger than the flash size, the bootloader will report error and terminate the operation.

    Only the Flash API objects and bl_flash.obj are loaded into flash, but execute in SRAM. All other objects are loaded into flash and execute in the flash.

    Regards,

    QJ

  • Thanks QJ,

    Your explanation makes sense. I wonder if I am looking at a different version of the source code?  There appears to be code to for the bootloader to update itself with address 0x0000000 in the UpdaterSPI function in bl_spi.c on line 374.   

    By the way, I noticed on other posts that you are working on a USB mass storage bootloader for the Hercules.  Do you have an update on that project?  I am very interested in using it as a starting point for my project.

    Thank You,

    Harvey

  • Hi Harvey,

    I did a simple USB mass storage bootloader last year. But it is not stable, this means it doesn't recognize the MS everytime when It is plugged. I didn't spend much time to debug the code last year. I will take a look again and post it as a reference.

    Regards,

    QJ

  • Dear QJ

    I am trying to execute the UART bootloader on TMDX570LS04HDK.( SafetyMCU_Bootloader_v1.2.0 )   Did you have a chance to test your code for TMDX570LS0432 or for TMDS version? If so may you share the project?  

    My project loops forever in a while loop that what is flash module to change its state. I am all around this forum seeking any help for it and tried every advice but no result. I can share my project if you want. 

    regards

  • Hi Hakan,

    The project should work. What is your flash API version?

    Regards,

    QJ

  • Hi Qj;

    I use F021 Flash API version 02.00.01. 

    Regards

    rha

  • Dear QJ,

    I wonder if there is any way to update the bootloader, either from the application software or from the bootloader itself?
    I've been working on this subject for a few weeks now, and I found that it might not be possible at all. I'm working with a TMS570LS3137, which has only two rewritable flash banks, and Bank0 always has a lock on since the vector table is there. (Or some other reason that I haven't discovered yet.)

    Is there any chance that you know how to make it possible to update the bootloader area on this controller?

    Regards,
    Balázs Menyhárt
  • In theory, you can update the bootloader from your application. However, your system will be "bricked" if the update fails for some reason. You will need to use JTAG connection to reprogram the system. Why do you want to update the bootloader?

    Thanks and regards,

    Zhaohogn
  • Hi Zhaohogn,

    We would like to have a bootloader in our system that can be updated. The reasons are complicated.

    Our expectation was the same as you said, that the application could update the bootloader. But it doesn't work, because Flash Bank0 is always locked, cannot be erased or written. I cannot figure out why.

    Do you have any idea why?

    Thanks,

    Balázs

  • If a flash bank is blocked, it is caused by your software. You can enable erase/program of a bank by setting up the Flash Module Access Control Register (FMAC).

    Thanks and regards,

    Zhaohong
  • Dear Zhaohong,

    You were right. It is caused by our software. Thank you. This was the most useful thing anybody ever told me on this subject. (Without irony.)
    I figured out that if I do the flash operations from a totally blank software instead of our application software, it works.
    So there is something in the software that makes it impossible to operate on the flash after the point when this thing starts. So the bootloader update must be done before that point, or I need to disable that thing somehow when I'm doing the bootloader update. Now I start to seek the lion in the desert.
    Do you have any idea what it could be?

    Thanks,
    Balázs
  • One option is to disable all the functions in your application and then enable them one by one till the failure occurs.

    Thanks and regards,

    Zhaohong