Hello,
I'm having trouble with getting a program to fit into flash on an MSP430F5438A. The code size is ~50K, and the total flash memory on the MSP430F5438A is 256K. This uC has 4 flash sections (SLAS612C, p. 14). If I force things around, the program will sometimes load "successfully" but Code Composer will never reset the CPU (the program will just load, but will not execute).
My entire code size is a little larger than the first flash section defined in the datasheet (SLAS612C, p. 14)
Here's the error (entire project attached as well):
Program will not fit into available memory. placement with alignment fails for section ".cinit" size 0x34 . Available memory ranges: FLASH size: 0xa380 unused: 0x28 max hole: 0x28 lnk_msp430f5438a.cmd line 124 C/C++ Problem
I understand what the error message means, but if I change any of the FLASH or FLASH2 sections, I create all sorts of strange overlaps, and end up blowing the security fuse. Basically my question is: how do I get a large .code base to allocate all the 256K of memory? I have all optimizations turned on for size in linker options, but I cannot figure out how to specify .code to span all 4 flash sections.
msp430f5438a.cmd
MEMORY
{
.....
//Here is where the flash range is defined FLASH : origin = 0x5C00, length = 0xA380 FLASH2 : origin = 0x10000,length = 0x35C00
INT00 : origin = 0xFF80, length = 0x0002
INT62 : origin = 0xFFFC, length = 0x0002 RESET : origin = 0xFFFE, length = 0x0002}
SECTIONS{ .bss : {} > RAM /* GLOBAL & STATIC VARS */ .data : {} > RAM /* GLOBAL & STATIC VARS */ .sysmem : {} > RAM /* DYNAMIC MEMORY ALLOCATION AREA */ .stack : {} > RAM (HIGH) /* SOFTWARE SYSTEM STACK */ .text : {} >> FLASH | FLASH2 /* CODE */ Error usually here .text:_isr : {} > FLASH2 /* ISR CODE SPACE */ .cinit : {} > FLASH /* INITIALIZATION TABLES */ .const : {} > FLASH | FLASH2 /* CONSTANT DATA */ Error usually here .cio : {} > RAM /* C I/O BUFFER */ .pinit : {} > FLASH /* C++ CONSTRUCTOR TABLES */ .init_array : {} > FLASH /* C++ CONSTRUCTOR TABLES */ .mspabi.exidx : {} > FLASH /* C++ CONSTRUCTOR TABLES */ .mspabi.extab : {} > FLASH /* C++ CONSTRUCTOR TABLES */ .infoA : {} > INFOA /* MSP430 INFO FLASH MEMORY SEGMENTS */ .infoB : {} > INFOB .infoC : {} > INFOC .infoD : {} > INFOD
.......
}
Best regards,
Russell
Hi Dung,
The linker/memory problems have been fixed. But the MSP430F5438A will only program with JTAG now. This problem seems to be an immediate result of these fixes.
I've attached the most recent project which programs with JTAG on an EXP430F5438, but no longer programs with Spy-by-Wire (Error: Unknown Device).
Thank you
Russ
Russell LemburgI've attached the most recent project which programs with JTAG on an EXP430F5438, but no longer programs with Spy-by-Wire (Error: Unknown Device).
Failure to program can be caused by a program running which crashes the processor before the debugger has a chance to attach to the device.
The following code initializes the Unified Clock System:
void initClocks(void){ UCSCTL0 = 0x1F00; //DCO and MODulation registers (see p. 50 of chip datasheet) DCO=31, MOD=0 UCSCTL1 = 0x0040; //DCO table for selecting clock ranges on p. 50 of Chip Datashseet DCORSEL = 4 UCSCTL2 = 0x02DC; //DCO multiplier Divide by 1, multiply by 732 UCSCTL4 = 0x0333; //Clock source is DCO for ACLK, SMCLK, MCLK UCSCTL5 = 0x0550; //Clock divide source (set MCLK to /1, set SMCLK and ACLK to /32) UCSCTL6 = 0x01DC; //Set up maximum capacitance for XT1, LF mode, turn off XT2}
Chester Gillonassuming a standard XT1 32768Hz crystal that means the MCLK is set to 24MHz.
_____________________________________Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.
Chester GillonIt is not commented what frequency crystal is connected to XT1
a) I can't see any code which is selecting P7.0 / P7.1 for the XIN / XOUT module functions, and thus the pins will be I/O.
b) The write to UCSCTL6 sets XT1BYPASS bit.
When the initClocks code was tried in a MSP430F5510 (same UCS and DCO Frequency Ranges as a MSP430F5438A) the resulting MCLK was ~20MHz. The XT1LFOFFG and DCOFFG flags were set (DCO bits were maximum of 31). Presumably the device is using the UCS Fail Safe of souring FLLREFCLK from the REFO.
We're not using an external crystal, because we do not need very high precision. Is this somehow related to the Spy-by-Wire issues we're having? Perhaps it's related to the frequency difference between 2 and 4-wire JTAG? Quite bizarre.
Russell LemburgWe're not using an external crystal, because we do not need very high precision.
Russell LemburgIs this somehow related to the Spy-by-Wire issues we're having?
I am getting the same error for .cinit not being able to fit. NOTE: I am using CCS v5.3.0.00067 (RC1) and targeting MSP430F2618.
"../lnk_msp430f2618.cmd", line 94: error #10099-D: program will not fit into available memory. placement with alignment fails for section ".cinit" size 0x7d . Available memory ranges: FLASH size: 0xcebe unused: 0x0 max hole: 0x0 error #10269: output file "xyz-trunk-codecomposer.out" exceeds code size limit
It looks like the FLASH section is getting filled first. I tried putting all FLASH sections before any FLASH2 sections but got the same result.
I then tried replacing the ">> FLASH | FLASH2" with "> FLASH | FLASH2". The error about .cinit disappeared, but still getting code size limit errors.
error #10269: output file "xyz-trunk-codecomposer.out" exceeds code size limit
So what does the >> symbol do, and why is it only used for the .text section ?? I can't find any documentation that describes it :(
Brendan Simon (eTRIX)
OK, found it here:
http://www.ti.com/lit/pdf/slau131
The >> is used for automatically splitting the section into different areas of a memory region, or across multiple memory regions.
Now off to find out why my code (ported from IAR) doesn't fit .....
Brendan SimonSo what does the >> symbol do, and why is it only used for the .text section ??
See also MSP430 linker reports "error #10099-D: program will not fit into available memory" even when there is space
I had a similar problem, I'm using an MSP430F5419 with 128K of memory. The ">>" didn't seem to work, it should have split the code ".text" but didn't, the two Flash segments are separated by the interrupt vectors, my code is reported to be 42.342K and the lower Flash "FLASH" is 41.856K it gave me an error about ".cinit" possibly since it was linked after the code. Since FLASH2 on my chip is 89.088K I just changed the command to ".text : {} > FLASH". I don't know why the linker reports the wrong section or why the ">>" command didn't split my code. I was using the Large Memory model so I didn't think there would be a problem.
Mark James I was using the Large Memory model so I didn't think there would be a problem.
You can explicitely put some of your functions into FLASH2 by putting the proper pragmas into the source code.
Sure, teh linker could do a multi-pass run and optimize placing with the results from the first failed pass (that's actually what you do when thinking 'the linker should...') but it hasn't been designed this way.