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.
I have used Application Report SPNA241 (Aug 2019) - CAN Bus Bootloader for Hercules Microcontrollers - successfully to flash an application binary to my LaunchXL2-TMS57012, but I have not been able to make my application successfully write to location 0x00010000 to trigger a new update. I used the bootloader's linker cmd file as a reference to load the flashAPI library into RAM, but attempting to write to 0x00010000 results in the nERROR LED flashing and the board resetting continuously. I'm sure I'm missing something minor, but up until now I have not had to mess around with linker files or pulling in assembler files.
Is there an *application* code example demonstrating writing to the magic word location? I may have missed it in the TI git repo for the Hercules bootloaders, but I don't think so.
By the way, I wound up writing the PC side application in Python since I don't have a National Instruments adapter and the Python CAN library simplified things for me. Everything works great except triggering a new update within my application. The application itself runs fine after the first load via the bootloader.
Thanks!
- Tom
Hi Tom,
My understanding is that the application has been programmed to flash successfully. But your application wants to write new magic word to 0x10000, so the bootloader can update the application again.
What is the value of the ESM status register for ESM group 3?
BTW, You can pull one GPIO (example uses GIOA.7) low to force the bootloader to update the application.
I suggest another way to store the magic word:
1. Use the last flash sector if it is not used by your application code
2. use bank7 as EEPROM to store the magic word.
I think I tried using the FEE library, but realized I could only write to Bank 7, not 0x10000. I'll try changing the APP_STATUS_ADDRESS location to the beginning of Bank 7 in the bootloader, and using FEE in my application. We need to store some persistent state anyway, and I'd planned to use FEE for that.
RE: using a GIO pin to initiate update - the board will be in a remote, unattended location. I considered using a latch to set an unused pin low prior to resetting the MCU, but that started adding parts and more failure modes. Still keeping it as an option.
Thank you for the prompt response.
- Tom
Thanks Tom.
When the magic numbers are written by the bootloader, their ECC values are also programmed to ECC space. If you want to toggle one bit of the magic number from "1" to "0", the corresponding ECC value is programmed automatically at the same time, but if the previous ECC value is "0", the ECC will not be changed. This means you have wrong ECC value for the new magic number. This is why I don't suggest to write magic numbers without erase them.
My initial naive change in bl_config.h:
#define APP_STATUS_ADDRESS 0xF0200000 //0x00010000
results in the bootloader hanging in Fapi_UpdateStatusProgram() in bl_flash.c:
uint32_t Fapi_UpdateStatusProgram(uint32_t Flash_Start_Address, uint32_t Data_Start_Address, uint32_t Size_In_Bytes) { register uint32_t src = Data_Start_Address; register uint32_t dst = Flash_Start_Address; unsigned int bytes; if (Size_In_Bytes < 16) bytes = Size_In_Bytes; else bytes = 16; Fapi_issueProgrammingCommand((uint32_t *)dst, (uint8_t *)src, (uint32_t) bytes, 0, 0, Fapi_AutoEccGeneration); while( Fapi_checkFsmForReady() == Fapi_Status_FsmBusy ); while(FAPI_GET_FSM_STATUS != Fapi_Status_Success); // <-- hangs here return (0); }
I may be missing a required change to bl_link.cmd or some other file to allow access to Bank 7, but I haven't needed to modify a linker file before.
- Tom
Quick update - I am able to write the magic word to the first four bytes of Bank 7 (EEPROM) in the bootloader. However, I still cannot write to that location in my application using either TI_Fee_WriteAsync() or TI_Fee_WriteSync() or using the F021 "native" API.
Went back to looking at the TI FEE example, and that doesn't seem to be working properly now either. I made some changes to the linker file to make the binary loadable with the bootloader, which may be causing issues.
I may have to come back to this in a couple of weeks since I may not be able to access the hardware for a while.
- Tom
Hello Tom,
The EEPROM works in different way from the main flash. If magic words is different magic words defined in bootloader, the magic words will be written to different locations in EEPROM. Reading is to read the block number rather than the physical flash address.