AnsweredAssumed Answered

STM32F103 Bootloader Branching Troubles

Question asked by BennVenn on Mar 25, 2015
Latest reply on Mar 25, 2015 by BennVenn
I've read just about all the existing posts regarding jumping from one code section to another and still I cannot jump without triggering a hard fault.

I'm adhering to advice given such as always jump to an address with least significant bit set, disabling interrupts, setting SP etc..

So my main code supports firmware update (32K file) via USB-MSC. All the complicated routines have been completed, checksums, writing the data to flash (0x08010000) and I've stepped through the debugger and can confirm the data is where it should be.

I've written code (with no dependencies on addresses - it should work in RAM or Flash at any location) I copy the code to either RAM or Flash, again confirmed it is there (exact word by word replica as seen in the memory windows) but when I jump (BX R0) to the fixed address I always end up triggering a hard fault.

I can 'BX R0' to the original code in the flash (approx 0x0800409D) and it executes without a problem. I just cant jump to 0x08018000 (or 0x08010001) to execute the erase and flash-write code.

I'll post my code here if there is nothing obvious that I'm missing. I am assuming 0x08018001 is not in-valid for somereason? Do I need to lock the flash before executing from it?

I've also noticed other branches in my code will branch to an even address without issue (Keil assembled code) So I'm not sure how strict the requirement to branch to an odd address is in the STM32F103...

Any insight would be appreciated