Release 2.1.1 supports memory bank switching for 68HC12.
To load correctly your program, your upload program must know the
special mapping that the linker and gdb use.
Basically, everything between 0..0x00ffff must/can be loaded as is (not
Everything >= 0x10000 is banked and is decomposed in 16K area that must
be put in the correct page. The page number is given by the formula:
(addr - 0x1000000) / 16K
(ie, addr 0x1000000 corresponds to page0, 0x1004000 to page1, 0x1008000 to
The - 0x1000000 is annoying but it is necesary for the current
implementation of the linker so that it links correctly.
To link in several areas, you must define several regions, like:
page0 (rwx) : ORIGIN = 0x0, LENGTH = 256
text (rx) : ORIGIN = 0x0C000, LENGTH = 0x10000 - 0x0C000
bank0 (rx) : ORIGIN = 0x1000000, LENGTH = 16K
bank1 (rx) : ORIGIN = 0x1004000, LENGTH = 16K
data : ORIGIN = 0x001040, LENGTH = 0x08000 - 0x01040
And you must manage to put what you want in either text or bankN.
/* Put startup code at beginning so that _start keeps same address.
/* Startup code. */
KEEP (*(.install0)) /* Section should setup the stack
KEEP (*(.install1)) /* Place holder for applications. */
KEEP (*(.install2)) /* Optional installation of data
sections in RAM. */
KEEP (*(.install3)) /* Place holder for applications. */
KEEP (*(.install4)) /* Section that calls the main. */
} > text
And put the banked code using:
} > bank0
Now, be careful that the current linker does not yet check for function
that cross a page boundary (Release 2.1.1 at least; it will be fixed
in future releases). So, I would recommend to define as many banks
as you need in MEMORY and give them the fixed size 16K.
You can put several files in the same bank as long as it fits.