K70 bootloader struggle...

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

K70 bootloader struggle...

416 Views
ikalogic
Contributor I

Hi!

I have been working on my first K70 bootloader.

I based my work on the AN4370.

The part where code is written to flash seems to be working perfectly. I can see my ram programmed with the correct data.

My struggle of all time is when it comes to jump from bootloader to user application.

No matter what i do, i always end up into weird flash locations and eventually into default ISR.

I don't know from where to start to debug this, because i've already tracked the code down to the part where the SP and PC are written, and everything should be just fine. but it's not.

Here is a concrete example. My user application is located at 0xA0000. To get it down to the simplest level possible, i force the SP and PC at startup; i stop the debugger before it writer the SCB_VTOR, and i manually force the values of SP and PC, which can be copied from 0xA0000 and 0xA0004. In my case, those values are: 1FFF8148 and 000A11BD.

So, when i load those values, the program does go to 0xA11BD as expected, but when i execute the very next instruction, it sends the pc to some weird place (something like 0X3FFFFFFAB....). Then, natualy, the next instruction though an exception. (that is cateched by "unhandled_isr").

Any hint? i am out of ideas of things to try to get a clue of what may be going wrong....

Thanks a lot,

Labels (1)
0 Kudos
1 Reply

287 Views
ikalogic
Contributor I

Okay, i have found the problem and solved it.

I may be the only one of earth who had that very specific problem, but just in case we're two, here is it: My generated S19 file had the bytes order inverted in each 4bytes word.

Once i reordered the bytes, it worked just fine...!

stupid right? yet it ate a couple dozen hours.of my time...

0 Kudos