Dear Keil ARM Experts, I am quite new to the Keil toolchain and I haven't found a good answer or explanation about building relocatable code. Here is my setup: - Keil ARMCC ARMLink with uVision 4.23 - NXP LPC1769 (512KB Flash)
The plan is to have: - a secondary Bootloader in User Flash (sector1 and sector2) as in Application Note AN10866 - some flash space for non-volatile application configuration and Log data (~8 Sectors) - 2 Firmware images ~5-6 Sectors each
The Firmware will be downloaded during Application runtime to the alternate location (if image1 runs it will write to location 2 and vice versa) If the checksum on the flash is fine the bootloder is instructed to boot the newly written Image.
Since at compile time I don't which will be the location I need AFAIK position independant code (PIC). For my understanding I need to have relocatable read-only section (RO) and application constants. The RW section will stay Position dependant, namely RAM and peripheral addresses. Is this true?
In the UVision target configuration Tabs for C/C++, ASM the checkbox "Read-Only" Position Independant is checked. In the Linker tab I checked "Make RO Sections Position Independant" With an R/O base of 0x0001 0000 (the first sector with a size of 32KB) - But to for my understanding this address should not matter. BTW. Since I use the /ropi option, I don't use a scatterfile.
.... Unfortunately this does not link.... - The asembler of the (keil delivered) file startup_LPC17xx.s is warning about absolute relocation of ROPI address w.r.t 'Reset_Handler' may cause a linke failure (A1496W) (and many more of these) - C compiler also warns about static initialization of variable USB_P_EP using address of USB_Endpoint0 may cause a link failure --ropi (1357-D)
- and finally the linker fails with error L6248E startup_lpc17xx.o"in PI region 'ER_RO' cannot have the same address type relocation to Reset_Handler' in PI region 'ER_PO' and many more of L6248E
I have read about these errors at infocenter.arm.com/.../index.jsp but I don't want to rewrite the C-Code of Keil provided files e.g. usbcore.c rt_task.c and so on. How can I build relocatable code using RTX lib, and the USB-Device stack etc. ? can you provide a scatterfile for this?
What also makes me feel insecure is the fact that the C++ compiler can't generate PIC? Do I understand this correctly? Does this mean I have to rewrite my c++ code in C?
www.keil.com/.../armccref_chdcdggg.htm "The use of --apcs=/ropi is not supported when compiling C++. You can compile only the C subset of C++ with /ropi."
Thanks in advance for any help, I am grateful for indication to other sources Thomas