For a project (using R7FA2L1AB2DFL), a bootloader which can update our firmware is needed. We have decided to copy this bootloader in RAM, and execute it from there since otherwise code flash memory cannot be programmed. We plan to access this bootloader by setting a certain random KEY in no_init RAM (setting this is triggered by an external command) and then triggering a reset. Upon reset and before jumping into our application, we check for this KEY and whether it is set or not. If it is set, we can copy our bootloader from code flash to RAM, and proceed to flash the memory.
For me, it is still unclear what a good way would be to realize this process. There are a couple of points in particular
Where do I actually copy the bootloader from FLASH to RAM, can I do this best in the FSP system.c file?
How do I take preinitialized variables into account?
How do I manage that the linker takes into account that the bootloader is executed from SRAM (absolute vs relative addresses)
Something like an example of similar functionality would be of great help here, as the general picture of this process is still quite unclear to me.
Thanks in advance.
The FSP flash driver will run from RAM if code flash programming is enabled in the configuration of the driver, for the parts of the flash driver driver that actually do the programming or erasing.
I'm trying to erase one code flash block from my application and I've taken parts of flash_lp_ek_ra2e1_ep example as a starting point, but when the program jumps inside r_flash_lp_cf_erase() (which…
Huh that's very interesting! So for everything to run smoothly, I'd only have to either disable the interrupts or move the NVIC vector table to RAM entirely (along with the ISRs)?
I'm trying to erase one code flash block from my application and I've taken parts of flash_lp_ek_ra2e1_ep example as a starting point, but when the program jumps inside r_flash_lp_cf_erase() (which resides in RAM), the emulator hangs and jumps to some illegal address. I checked the disassembly and all the RAM code seems correct and I can step inside it, but when the code arrives at r_flash_lp_delay_us(), if I step inside it the program jumps to 0xeffffffe address and dies. I've checked the disassembly of this function in RAM and it is correct. Also, I verified that it's not a stack corruption problem. Is there anything to be taken into account when erasing blocks of memory? Comparing my program with the example they seem the same.
Which flash block are you erasing? Where does your code reside in flash?
My code resides between 0x00000000 and 0x00007100 and I'm erasing the 16th block. When I erase the block my program hangs and I have to reset the execution, but the erasure works (block 16 is filled with 0xFF) and my code remains unaltered.I can restart the execution and all works fine but if I try to erase the flash again, I have the same result. I've seen that the flash_lp_ek_ra2e1_ep example has some bytes for the heap and so I added heap to my program, but without success.
It sounds like you are erasing some code in flash that is required for the execution of the code that is doing the flash erasure.
What is the address in the map file of the function r_flash_lp_delay_us()
I cannot see r_flash_lp_delay_us() in the map, only when debugging and there it resides in RAM. How can I tell the compiler or the linker to put r_flash_lp_delay_us() in the map, please?
Besides, as I said, AFTER erasing the block, I can restart my application with the block all to 0xFF and it shows the correct r_flash_lp_delay_us() in RAM again, so I don't think it's erased.
Which version of the FSP are you using?