0

In Code Composer, you can define new symbols in the linker command file simply:

_Addr_start = 0x5C00;
_AppLength  = 0x4C000;

before the memory map and section assignment. This is done in the bootloader example from TI.

You can then refer to the address (as integers) in your c-code as this

extern uint32_t _Addr_start; // note that uint32_t is fake. 
extern uint32_t _AppLength;  // there is no uint32_t object allocated

printf("start = %X len= %X\r\n", (uint32_t)&_Addr_start, (uint32_t)&_AppLength);

The problem is that if you use the 'small' memory model, the latter symbol (at 0x45C00) gives linker warning, because it tries to cast it to a 16-bit pointer.

"C:/lakata/hardware-platform/CommonSW/otap.c", line 78: warning #17003-D: 
relocation from function "OtapGetExternal_CRC_Calc" to symbol "_AppLength"
overflowed; the 18-bit relocated address 0x3f7fc is too large to encode in
the 16-bit field (type = 'R_MSP_REL16' (161), file = "./otap.obj", offset =
0x00000002, section = ".text:OtapGetExternal_CRC_Calc")

I tried using explicit far pointers, but code composer doesn't understand the keyword far. I tried to make the dummy symbol a function pointer, to trick the compiler into thinking that dereferencing it would.... The pointer points to code space, and the code space model is "large" while the data space model is "small".

Mark Lakata
  • 18,024
  • 5
  • 88
  • 112

1 Answers1

0

I figured it out before I finished entering the question!

Instead of declaring the symbol as

extern uint32_t _AppLength; // pretend it is a dummy data

declare it as

void _AppLength(void); // pretend it is a dummy function

Then the pointer conversion works properly, because &_AppLength is assumed to be far now. (When it declared as an integer, &_AppLength is assumed to be near and the linker fails.)

Mark Lakata
  • 18,024
  • 5
  • 88
  • 112