Part Number:RM48L952
Support Path: /Product/Help with Device Selection/
Hello,
My Hercules application needs to erase and write some sections of flash memory. I started with the code from the Hercules bootloader project that contains bl_flash.c, Fapi_UserDefinedFunctions.c, and also uses the F021 API. I also modified the linker.cmd file to locate the FAPI and bl_flash code in RAM. In general, the code appears to be working, I can write to onchip flash location 0x18000 (bank2).
1. To get bl_flash.c to work I had to modify bl_flash.c in several places to change the "bytes" variable to an int. This is because the code performs a "while (bytes > 0)" check, and the byte value goes negative if the initial number of bytes not a multiple of 4. Note that it should be valid to write, say, 7 bytes to flash.
Example:
register int bytes = No_Of_Bytes; //was uint32, loop never exited if initial number of bytes not a multiple of 4 !
while(bytes > 0)
{
if(*dst1++ != *src1++)
error = 1;
bytes -= 0x4;
}
2. When my program runs I can see that the flash is written Ok. (memory window displays correct values at location 0x180000.) But If I restart the debugger and reload my program, the entire flash is erased and so my previous "data" values the program wrote to flash are lost. How to tell the debugger to launch but not erase certain areas of the flash?
3. I am running FreeRTOS, and calling Fapi_BlockProgram() from a FreeRTOS task. Do you recommend I call the FAPI functions from within a critical section? Otherwise FreeRTOS may preempt these flash program/erase calls. Does the FAPI support preemption, assuming no other tasks are using the FAPI?
Thank you,
Keith