Why would the address of reset vector differ when two firmwares are linked with the same linker script?

StackOverflow https://stackoverflow.com/questions/14584631

Question

I have a Cortex-M3 chip and on it I am running a bootloader that uses eCos. The bootloader, after checking for firmware updates etc, jumps to another location (BASE_ADDRESS_OF_APP + 0x19) on the ROM where the actual application resides (also compiled with eCos).

Now instead of running the normal firmware, I want to run my CppUTests compiled for the Cortex-M3 target. So I am able to compile and link my tests for the target platform, using the ecos glibc, but not the actual operating system. But when I load it on to my board using JTAG, it doesn't run.

After some investigation using arm-eabi-objdump, I found out that the reset vector of the CppUTest firmare is at an offset of 0x490 as opposed to an offset of 0x18 for the normal firmware. My suspicion is that this is the reason why the tests are never executed. Is this correct?

How is it possible that the two firmwares have different starting addresses when I am linking them with the same linker script?

How can I make sure that the starting point of the test program is the same as the starting point of the application?

No correct solution

OTHER TIPS

It depends on how your linker script is written, if your entry point address is not set to a static location in the linker script, then there could be the chance that other data/code is put in the object file before your entry point, effectively moving the location of your entry point and indeed causing problems.

I typically solve this by creating a new section with only 1 symbol in it, and a jump/branch instruction as follows:

.section entryPointSection
b myCodeEntryPoint

Then in your linker script put the entryPointSection at the hard coded address that your bootloader will jump to.

The myCodeEntryPoint label can be the name of a C function (or assembly label if necessary) that is in the normal .text section and can be linked anywhere within reach of the jmp. It will become your entry point, but you don't really care where it is because the linker should find it and link it properly.

Consider posting your linker script if you have further questions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top