This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem running copied code into flash

Hi everyone,

So I have a question.

I have a ARM-M4 and for what I can tell this has both ARM and Thumb assembly. Meaning sometimes it interprets a 32 bit instruction as 2 16bit ones, some of the times.

How does that work? How does it know how to go about it?

I ask this because of a project.

I have a bootloader like code. And another application code.
I configured the linker in the application code to start at 0x4000. To avoid developing the communication already, I converted the binary to a C array.

I pasted that array as a const in the bootloader code. The bootloader test code as of now just copies the array into the flash at 0x4000 and changes the vector table address to 0x4000 after that. Once all that's done, it jumps the PC to 0x4000.
The jump is done this way - I created a empty function at 0x4000. This way I just have to call it to start the app code.

The problem seems to be that the first instruction is 32bits. It seems the PC is jumping each 16bits instead of each 32. And after a few jumps it just go crazy to a really big address in the RAM.
I checked the memory and the copy was successful, exactly the same as the app code at 0x4000.