Using CCS Version 5.2.1.00018 and MSP430 compiler v4.1.2 I have sometimes seen the linker report "error #10099-D: program will not fit into available memory" even when there is space.
The steps to reproduce are:
a) Create new empty CCS project for MSP430F5438, using eabi (ELF) output format.
b) Add esparanoia.c to the project, from the Embedded System Paranoia source code in http://www.leshatton.org/wp-content/uploads/2012/01/esp_19.zip
c) Add pre_init.c to the project containing:
#include <msp430.h>#if !defined(__TI_EABI__)
extern int __cinit__; /* define by TI linker == -1 if .cinit isn't loaded */
extern char __bss__; /* defined by the TI linker to be the start of .bss */
extern char __end__; /* defined by the TI linker to be the end of .bss */
#endifint _system_pre_init(void)
{
WDTCTL = WDTPW+WDTHOLD;#if !defined(__TI_EABI__)
/* if .cinit is not loaded, the loader has already initialized .bss */
if (&__cinit__ != (int *)-1) {
char *cp;/* otherwise, we initialize all .bss to 0 before .cinit is processed */
for (cp = &__bss__; cp <= &__end__; ) {
*cp++ = 0;
}
}
#endifreturn (1);
}
d) Configure the project settings for the program:
- Set the level of printf support required to full
- Add the predefined symbols NOSIGNAL and NOSETJUMP
- Set the stack size to 1024
- Set the heap size to 1024
- Disable all ULP checks (to reduce warnings)
- Set the data memory model to restricted (to prevent linker warnings of the form #17003-D: relocation from function "atoi" to symbol "_ctypes_" overflowed; the 17-bit relocated address 0x1f4a7 is too large to encode in the 16-bit field)
e) The resulting program is configured to test double precision floating point, and compiles / links / runs. The linker map is esparanoia_double.map
The following size is reported when load in the debugger:
MSP430: Program loaded. Code Size - Text: 99790 bytes Data: 0 bytes.
f) Add the pre-defined symbol SINGLE to the project settings, to change the program to test single precision floating point. Linking now fails with error #10099-D:
The linker map from the failed link is esparanoia_single_fail.map**** Build of configuration Debug for project esparanoia_test ****
C:\ti\ccsv5\utils\bin\gmake -k all
'Building file: ../esparanoia.c'
'Invoking: MSP430 Compiler'
"C:/ti/ccsv5/tools/compiler/msp430_4.1.2/bin/cl430" -vmspx --abi=eabi --data_model=restricted -g --include_path="C:/ti/ccsv5/ccs_base/msp430/include" --include_path="C:/ti/ccsv5/tools/compiler/msp430_4.1.2/include" --define=__MSP430F5438__ --define=SINGLE --define=NOSIGNAL --define=NOSETJUMP --diag_warning=225 --display_error_number --diag_wrap=off --silicon_errata=CPU15 --silicon_errata=CPU18 --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU23 --silicon_errata=CPU40 --printf_support=full --preproc_with_compile --preproc_dependency="esparanoia.pp" "../esparanoia.c"
"../esparanoia.c", line 276: warning #552-D: variable "E3" was set but never used
'Finished building: ../esparanoia.c'
' '
'Building file: ../pre_init.c'
'Invoking: MSP430 Compiler'
"C:/ti/ccsv5/tools/compiler/msp430_4.1.2/bin/cl430" -vmspx --abi=eabi --data_model=restricted -g --include_path="C:/ti/ccsv5/ccs_base/msp430/include" --include_path="C:/ti/ccsv5/tools/compiler/msp430_4.1.2/include" --define=__MSP430F5438__ --define=SINGLE --define=NOSIGNAL --define=NOSETJUMP --diag_warning=225 --display_error_number --diag_wrap=off --silicon_errata=CPU15 --silicon_errata=CPU18 --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU23 --silicon_errata=CPU40 --printf_support=full --preproc_with_compile --preproc_dependency="pre_init.pp" "../pre_init.c"
'Finished building: ../pre_init.c'
' '
'Building target: esparanoia_test.out'
'Invoking: MSP430 Linker'
"C:/ti/ccsv5/tools/compiler/msp430_4.1.2/bin/cl430" -vmspx --abi=eabi --data_model=restricted -g --define=__MSP430F5438__ --define=SINGLE --define=NOSIGNAL --define=NOSETJUMP --diag_warning=225 --display_error_number --diag_wrap=off --silicon_errata=CPU15 --silicon_errata=CPU18 --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU23 --silicon_errata=CPU40 --printf_support=full -z --stack_size=1024 -m"esparanoia_test.map" --heap_size=1024 --use_hw_mpy=F5 -i"C:/ti/ccsv5/ccs_base/msp430/include" -i"C:/ti/ccsv5/tools/compiler/msp430_4.1.2/lib" -i"C:/ti/ccsv5/tools/compiler/msp430_4.1.2/include" --reread_libs --warn_sections --display_error_number --diag_wrap=off --rom_model -o "esparanoia_test.out" "./pre_init.obj" "./esparanoia.obj" -l"libc.a" "../lnk_msp430f5438.cmd"
<Linking>
"../lnk_msp430f5438.cmd", line 172: warning #10374-D: Interrupt vector "RTC" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 173: warning #10374-D: Interrupt vector "PORT2" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 174: warning #10374-D: Interrupt vector "USCI_B3" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 175: warning #10374-D: Interrupt vector "USCI_A3" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 176: warning #10374-D: Interrupt vector "USCI_B1" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 177: warning #10374-D: Interrupt vector "USCI_A1" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 178: warning #10374-D: Interrupt vector "PORT1" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 179: warning #10374-D: Interrupt vector "TIMER1_A1" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 180: warning #10374-D: Interrupt vector "TIMER1_A0" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 181: warning #10374-D: Interrupt vector "DMA" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 182: warning #10374-D: Interrupt vector "USCI_B2" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 183: warning #10374-D: Interrupt vector "USCI_A2" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 184: warning #10374-D: Interrupt vector "TIMER0_A1" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 185: warning #10374-D: Interrupt vector "TIMER0_A0" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 186: warning #10374-D: Interrupt vector "ADC12" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 187: warning #10374-D: Interrupt vector "USCI_B0" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 188: warning #10374-D: Interrupt vector "USCI_A0" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 189: warning #10374-D: Interrupt vector "WDT" does not have an interrupt handler routine.
>> Compilation failure
"../lnk_msp430f5438.cmd", line 190: warning #10374-D: Interrupt vector "TIMER0_B1" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 191: warning #10374-D: Interrupt vector "TIMER0_B0" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 192: warning #10374-D: Interrupt vector "UNMI" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 193: warning #10374-D: Interrupt vector "SYSNMI" does not have an interrupt handler routine.
"../lnk_msp430f5438.cmd", line 112: error #10099-D: program will not fit into available memory. placement with alignment fails for section ".cinit" size 0x140 . Available memory ranges:
FLASH size: 0xa380 unused: 0x0 max hole: 0x0
error #10010: errors encountered during linking; "esparanoia_test.out" not built
gmake: *** [esparanoia_test.out] Error 1
gmake: Target `all' not remade because of errors.
**** Build Finished ****
g) In the lnk_msp430f5438.cmd file change from the CCS default of:
.text : {}>> FLASH | FLASH2 /* CODE */
To:
The program now links and runs..text : {}>> FLASH2 | FLASH /* CODE */
When loaded in the debugger the size is:
The linker command file is esparanoia_single_works.mapMSP430: Program loaded. Code Size - Text: 78632 bytes Data: 0 bytes.
Therefore, there appears to a linker limitation / bug where under some circumstances tries to place too much .text into FLASH, rather than FLASH2, which then causes other sections which can only fit in FLASH to fail to be allocated.
The attached esparanoia.zip contains the linker map files mentioned above, and is the state of the CCS project in the linker fail step f). It doesn't contain the esparanoia.c source file since I am not the author - to build the project you need to get the source file from the esp_19.zip file mentioned above.