AnsweredAssumed Answered

Custom Bootloader

Question asked by navarro.benjamin.001 on Mar 23, 2012
Latest reply on Sep 30, 2016 by Clive One
Hi everybody!

I'm trying to make a bootloader that fetch a program from an SD card. I finally manage to parse the HEX file correctly and write the content in the flash memory but when I try to jump to the program, a Hard Fault is generated and I don't know wh
y.

There's my Flash related code :


FLASH_Unlock();
 
...
 
        FLASH_ErasePage(ApplicationAddress + (n-1) * PAGE_SIZE);
        FLASH_PageWrite(ApplicationAddress + (n-1) * PAGE_SIZE, page32);
 
...
 
uint32_t startAddress = *(__IO uint32_t*)(ApplicationAddress + 4);
pFunction Start = (pFunction)startAddress;
__set_MSP(*(__IO uint32_t*)ApplicationAddress);
Start();

Where 'n'
is the page number to be written, page32 a pointer to the page content in RAM and 'FLASH_PageWrite()' a custom function to write an entire page by successive calls to 'FLASH_ProgramWord()'

ApplicationAddress = 0x800F000 (My bootloader uses pages up to 0x800A800)


Thanks

Outcomes