2021-12-08 08:29 AM
Hi,
I'm trying to write a code that can receive a new app via uart. Can erase the unused bank. Writes the new code in that bank, flips the bank boot bit and then performs a reset. I also made a small app on a PC that reads the .hex file generated by my IDE and formats the data into 32 bits Addr + 64 bits data then sends it by UART.
So far my code is working somewhat. I am able to flash the new code on the empty bank (from what I can see in the utility tool) but when triggering a reset the MCU gets stuck somewhere and never makes it back.
I write the new app at the address 0x0804 0000 since a flip of the bank bit should switch it back to 0800 0000. I have the app start address in the .hex file but I don't know what to do with it. Since I'm writing the code in a bank doesn't the MCU already know where the app starts ?
I used an example as a base but it only copies code from the current bank to the other one and then does a reset so there isnt anything in there about an app start address (https://github.com/barafael/g4-dual-bank-example)
PS: I'm using STM32G474 if that makes any difference