Other Parts Discussed in Thread: CONTROLSUITE
Tool/software: TI C/C++ Compiler
Hi,
I wonder how the length of the code generated by the linker, i.e. the length of all sections that go to flash, can be "compiled" (i.e. computed by the linker) into the code generated. I tried several approaches:
Approach #1:
Linker Command File:
MEMORY {
...
FLASHE00 : origin = 0x088000,
length = FIRMHEAD_SECTSIZE /* firmware header */
FLASHE2J : origin = 0x088000 + FIRMHEAD_SECTSIZE,
length = 0x030000 - FIRMHEAD_SECTSIZE /* firmware */
}
SECTIONS
{
/* firmware sections in on-chip flash sectors */
.firmware_header: LOAD_SIZE(_firmhead_size), fill = 0xffff
{
_firmware_start = .;
firmware_header(.firmware_header)
}
> FLASHE00 PAGE = 0, ALIGN(4)
/* group all other flash sections */
.firmware GROUP LOAD_SIZE(_firmware_size) {
codestart : //PAGE = 0, ALIGN(4)
.text : //PAGE = 0, ALIGN(4)
ramfuncs : // LOAD = FLASHE2J,
RUN = RAMLS0 | RAMLS1 | RAMLS2 |RAMLS3,
LOAD_START(_RamfuncsLoadStart),
LOAD_SIZE(_RamfuncsLoadSize),
LOAD_END(_RamfuncsLoadEnd),
RUN_START(_RamfuncsRunStart),
RUN_SIZE(_RamfuncsRunSize),
RUN_END(_RamfuncsRunEnd)
//PAGE = 0, ALIGN(4)
/* initalized sections go in flash */
.cinit : //PAGE = 0, ALIGN(4)
.pinit : //PAGE = 0, ALIGN(4)
.econst : //PAGE = 0, ALIGN(4)
.switch : //PAGE = 0, ALIGN(4)
/* end of firmware sections in on-chip flash */
.firmware_end : {
_firmware_end = .;
}
} > FLASHE2J PAGE = 0, ALIGN(4),
}
C-file:
/* place firmware_header in section .firmware_header */
#pragma DATA_SECTION ( firmware_header , ".firmware_header")
/* symbols defined by the linker command file */
extern uint32_t firmware_start, firmware_size;
extern uint32_t firmware_end;
struct firmware_header firmware_header = {
(uint32_t)&firmware_size + FIRMHEAD_SECTSIZE,
...
};
This compiles and links successfully (with the right length compiled in), but a warning
warning #10082-D: placement ignored
for "ramfuncs": object is placed as part of "GROUP_1"
is generated and the ramfuncs RUN section is placed to flash (wrong!).
Approach #2:
Without a GROUP in the command file, I tried to put a section .firmware_end at the end of all (see above), and to use the difference of the symbols as length.
This causes a compile error
//(uint32_t)(&firmware_end - &firmware_start), // error #28: expression must have a constant value
and it is not sure that .firmware_end is really placed at the end, since (SPRU513L):
8.5.5 The SECTIONS Directive
(Note that the memory placement order is not simply the sequence in which
sections occur in the SECTIONS directive.)
Other trials give other errors:
//((uint32_t)&firmware_size + FIRMHEAD_SECTSIZE) * 2, // error #28: expression must have a constant value
//(uint32_t)(&firmware_size + &firmhead_size), // error #31: expression must have integral type
Any hint
- How to get the length (sum of the lengths of several sections) compiled in?
- How to control the order of the sections (.firmhead as first, .firmware_end as last)? (HIGH is not the solution.)
Thanks,
Frank