Problem trying to link large amount of constant data!

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem trying to link large amount of constant data!

3,217 Views
EmbeddedCoder
Contributor III
Hi All,
 
I am trying to find an elegant solution to my problem. I am using the HCS12 256DP with the Metrowerks CodeWarrior IDE.
 
I am using this device (amongst other functions) to load program code into another device via the SPI Device. I have got the SPI Boot loader working on a small piece of code, but my problems occur now I want to load larger code (i.e. larger than 16K)
 
The maximum code size I will have to load is 64K (and it will probably be near that mark eventually!). I have imported the code into an assembler file using some tools that seem to work quite reliably, which gives me a file of the structure:
 
XDEF CodeStartPoint    ; Allows my C Code to access this ASM area
 
BootCodeData: SECTION  ; Defines this stuff in its own relocatable section
 
CodeStartPoint:             ; The actual start of the Data
 
dc 010h, 001h 100h, 200h, 020h
... and so on . ...
 
To the linker this looks like one HUGE constant array of a size bigger than the Page windows (16K in size), and I am having headaches getting the code into the device!!!
 
I can get a final executable by removing the SEGMENT definitions for PAGE_32 to PAGE_37 and replacing with BOOT_CODE_SEG = READ_ONLY 0x328000 TO 0x37BFFF;
 
Then, in the PLACEMENT section, I add BootCodeData INTO BOOT_CODE_SEG;
 
I think this is a bit of a cheat and causes the linker to "forget" about the 16K windowing for this address range (possibly causing it to think I have an external memory device?) - especially as when I try to load this using the Debugger, I get the error, no memory at 0x338000
 
How can I get the linker to place my constant data across the different paged memory windows in one continuous block?
 
Other than this, the only other solution I can see is to cut up my data into 16K chunks and add each chunk into its own Page - very laborious!!
 
Please Help!!
 
Labels (1)
Tags (1)
0 Kudos
2 Replies

563 Views
CrasyCat
Specialist III

Hello

The Linker does not allow to allocate an object across segment boundary. And segments should reflect real available memory blocks.

Defining a big segment as follows BOOT_CODE_SEG = READ_ONLY 0x328000 TO 0x37BFFF; does not help either, as the linker will try to allocate data at address 0x330000 for instance. And there is no memory there...

With HCS12 the only solution is to split your data into smaller 16K blocks.

CrasyCat

0 Kudos

563 Views
EmbeddedCoder
Contributor III

Hi CrasyCat,

Many thanks for the very swift response!

I was hoping that wasn't going to be the answer - but I guess I'd better get on with splitting up my data!

Many Thanks,

Mike

0 Kudos