Hi everyone, I'm using XMC4700 board and want to have some shared variables between normal boot mode and ABM0, ABM1 boot mode, so I can check the flag status to switch boot mode. I tried to store variable in flash and modify it using pointer to flash address but it doesn't work. How can I do this task?
When we shift between boot modes, the device is issued with power on reset (PORST). This means that the variables stored in RAM will be lost on PORST. If you need to store any variable prior to change in boot modes, you could store them in flash.
Can you read the flash contents before switching boot modes to verify if your data is stored. After switching the boot modes, read the same location again to see the contents are there. Let me know your observation.
[EDIT]: Boot modes can also be changed through system resets, which do not involve PORST. Here, we get more boot mode options to choose from - Normal, ASC BSL, BMI, CAN BSL, PSRAM boot, ABM-0, ABM-1 and Fallback ABM, unlike with PORST where we get only - Normal, ASC BSL, BMI, CAN BSL.
Hi @ncbs , yeah I can store data into flash but I cannot modify it during run time when switching boot mode.
I have another idea, maybe I can determine which bootmode to use by checking some GPIO pins, that would be easier.
But I have another problem is the flash loader. How can I store new firmware to flash (through UART or SPI, I can transmit data but I don't know how to store data into flash during runtime). I read some example and see that PSRAM mode maybe suitable. Because when code is running from PSRAM, it can modify flash at runtime right?
My idea is store flash loader program into flash, then copy it into PSRAM when executing bootloader, then bootloader jump into PSRAM boot mode to execute flash loader program to load new firmware into flash at ABM0 or ABM1 region. Then jump into ABM0 or ABM1 boot mode to run new firmware.
The problem is I still cannot copy flash loader program from flash into PSRAM to execute PSRAM boot mode. I success in copying PSRAM header from flash to last 32 bytes of PSRAM, but flash loader code is not. I use loop and pointer to do the job. I can copy from flash to DSRAM but cannot copy from flash to PSRAM.