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

Position inpdeped code for bootloader.

Hello,

I'm creating a custom OTA firmware update on cc2640 chip from TI. (Cortex M3)
For this reason two memory regions are reserved for firmware images.
The problem is, the code works only if it is stored in one of the regions. (According to the Linker File)
If the code is stored in the second region, it does not start at all.

In IAR Compiler the -ropi (the same as PIE/PIC in GCC) works correctly.

The Linker Script is the following:



The Startup function was already updated to copy the .rodata correctly as following:

The bootloader calles the entry (ResetISR(void)) function of the valid firmware at startup.

All libraries are linked with -fPIC option.

target_link_libraries(${TARGETFILE}} ${LIB_LIST} "-fPIC")

I have used listet options:

Compiler flags :  -O2 -fdata-sections -ffunction-sections -fno-strict-aliasing -nostartfiles -fno-exceptions -mcpu=cortex-m3 -mthumb -g0 -Wall "
Linker flags: -Wl,-Map=${CMAKE_PROJECT_NAME}.map -Wl,--gc-sections  -nostartfiles -mthumb -lc -lm -lgcc -lnosys -u __vector_table"
 Effekt -> Firmware works only at first address (0x1000). Other positions does not works.


Compiler flags :  -O2 -fdata-sections -ffunction-sections -fno-strict-aliasing -nostartfiles -fno-exceptions -mcpu=cortex-m3 -mthumb -g0 -Wall -fPIE "
Linker flags: -Wl,-Map=${CMAKE_PROJECT_NAME}.map -Wl,--gc-sections  -nostartfiles -mthumb -lc -lm -lgcc -lnosys -u __vector_table"
 Effekt -> Firmware does not starts

Compiler flags :  -O2 -fdata-sections -ffunction-sections -fno-strict-aliasing -nostartfiles -fno-exceptions -mcpu=cortex-m3 -mthumb -g0 -Wall -fPIE"
Linker flags: -Wl,-Map=${CMAKE_PROJECT_NAME}.map -Wl,--gc-sections  -nostartfiles -mthumb -lc -lm -lgcc -lnosys -u __vector_table -pie "
 Effekt -> Firmware does not starts. The linker flag -pie causes the binarys to be 3 Times grater as whitout this option.


I have alredy read the "Multiple Application Code with Bootloader" question. Unfortunately, the provided solution does not work for me:

Compiler flags :  -O2 -fdata-sections -ffunction-sections -fno-strict-aliasing -nostartfiles -fno-exceptions -mcpu=cortex-m3 -mthumb -g0 -Wall -fPIC "
Linker flags: -Wl,-Map=${CMAKE_PROJECT_NAME}.map -Wl,--gc-sections  -nostartfiles -mthumb -lc -lm -lgcc -lnosys -u __vector_table -msingle-pic-base -mpic-register=r9"
Effekt -> Firmware does not starts.


Coud someone provide some assistance to correct the mistake?

0