Hi Alice,
Thanks for the information about the PMPROT register. It makes sense that the application could not rewrite the protection settings made by the bootloader since there is no system reset, only the jump to application; thus, setting the PMPROT in the bootloader resolved the issue.
I have been investigating the other issues I have described and believe that adding FreeRTOS to the project caused the problem. I was able to reproduce this on my custom board, the K64 freedom board, and the K64 tower board. I have attached three projects that demonstrate the problem for the K64 freedom board on very simple projects and would appreciate your input. The projects were formed in KDS using processor expert for K64 freedom and KSDK 1.3. All run at 20MHz FEI.
- Bootloader project - based off of the example that you provided in SD Card Bootloader :how to using SD card to update existing firmware on CodeWarriror or KDS
- Checks if "TestApp.bin" is present on the SD card. Is so, updates the program. If not, jumps to user application
- Erases the flash from 0x10000 to oxFFFFF
- Reads and flashes the binary information from the file in blocks of 512 bytes
- Removes "TestApp.bin" from the SD card and jumps to user application
- Baremetal test project
- Adds debug console and RGB LED components in processor expert
- Prints "Program Successful" and blinks the blue LED approximately every 1 second in main
- FreeRTOS test project
- Added default FreeRTOS component while only changing the heap settings to coalesc blocks in the second SRAM section
- Adds debug console and RGB LED components in processor expert
- Prints "Program Successful" and blinks the blue LED every 1 second in rtos_main
I load the bootloader on through KDS and then load the applications by naming the generated binaries to "TestApp.bin" and putting them on the SD card. The baremetal project always programs and loads properly; however, the FreeRTOS project goes to default ISR after the jump. I can get it to run properly if I add to the end of the bootloader something to the effect of:
memset((unsigned int *)0x1FFF0400,0,0x10000-0x400);
memset((unsigned int *)0x20000000,0,0x30000);
I had also noticed that if the memset is done in the code, the bootloader will work even if the code is programmed back to the bootloader without the memset. This will last until the board is unpowered, which I assume is when the SRAM is reset.
I am additionally unsure if I need to de-initialize the sdhc or other peripherals and interrupts before the jump. I have tried variously ways of doing so but none resolve this issue.
If you can find anything I may be missing that fits these symptoms or can think of any other tests for me to run, please let me know.
Thanks,
Jared