I am trying to write a simple bootloader that runs from bank 1 and can receive code over the serial port. I have based this on the code example as provided on the ST web site (STR9 In-Application Programming using UART an2475) however I finding it vary difficult to get this running using the Keil tools (ref thread 10804). Now I'm having problems with writing to the flash, I have set the flash writing functions to be loaded into RAM so there shouldn't be any issues with accessing the 2 flash banks. But after I call the FMI_EraseSector function the flash doesn't appear to be erased (using the Memory window to check) but the wait function returns no error and when I try to read a half word from the flash I have just written to the code jumps to the abort function.
Code snippet
FlashDestination_u32 = 0x80000;
FMI_WriteProtectionCmd(FMI_B0S0, DISABLE); FMI_EraseSector(FMI_B0S0); WaitResult_u8 = FMI_WaitForLastOperation(FMI_BANK_0);
if(WaitResult_u8 == FMI_NO_TIME_OUT_ERROR) { FMI_WriteHalfWord(FlashDestination_u32, *(u16*)RamLocation_u32); WaitResult_u8 = FMI_WaitForLastOperation(FMI_BANK_0);
if (*((u16*)FlashDestination_u32) != *((u16*)RamLocation_u32)) { } }
Does anyone have any suggestions what I'm doing wrong? Better still does any one have a working version of the ST example for the Keil tools?
www.danlhenry.com/.../keil_code.png