My program for a Freescale MC9S08DZ128 (HCS08 family) got too big, and I was getting the message:
Link Error : L1102: Out of allocation space in segment ROM2 at address 0xFE13
so I tried to switch to the banked memory model.
My options before I switched were:
-Cs08 -Fd -Ms -OnB=b -TD2LD2LLD2
and my options afterwards are:
-Cs08 -Fd -Mb -MMU -OnB=b -TD2LD2LLD2
I also changed my library from ansifs.lib to ansibfm.lib
But after doing this (and recompiling everything), I still get the same linker error as I did before, implying it is still out of memory. Any idea why it is not making use of the banked memory in my device? It has 128K of Flash memory.
I am using version 6.3 of Code Warrior (Classic IDE, Basic Edition, code & data limited to 128K).
Here is the .prm file showing the banked segments (PPAGE_)
/* This is a linker parameter file for the mc9s08dz128 */
NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */
SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
Z_RAM = READ_WRITE 0x0080 TO 0x00FF;
RAM = READ_WRITE 0x0100 TO 0x17FF;
RAM1 = READ_WRITE 0x1900 TO 0x217F;
/* unbanked FLASH ROM */
ROM = READ_ONLY 0x4000 TO 0x7FFF;
/*ROM1 = READ_ONLY 0x2180 TO 0x3BFF;*/
ROM1 = READ_ONLY 0x2200 TO 0x3BFF; /* changed due to code gen error at 0x2180 when code size >= 0x6000 */
ROM2 = READ_ONLY 0xC000 TO 0xFF7F;
EEPROM = READ_ONLY 0x3C00 TO 0x3FFF;
/* INTVECTS = READ_ONLY 0xFF80 TO 0xFFFF; Reserved for Interrupt Vectors */
/* banked FLASH ROM */
PPAGE_0 = READ_ONLY 0x008000 TO 0x00A17F; /* PAGE partially contained in ROM segment */
PPAGE_0_1 = READ_ONLY 0x00BC00 TO 0x00BFFF;
PPAGE_2 = READ_ONLY 0x028000 TO 0x02BFFF;
PPAGE_4 = READ_ONLY 0x048000 TO 0x04BFFF;
PPAGE_5 = READ_ONLY 0x058000 TO 0x05BFFF;
PPAGE_6 = READ_ONLY 0x068000 TO 0x06BFFF;
PPAGE_7 = READ_ONLY 0x078000 TO 0x07BFFF;
/* PPAGE_1 = READ_ONLY 0x018000 TO 0x01BFFF; PAGE already contained in segment at 0x4000-0x7FFF */
/* PPAGE_3 = READ_ONLY 0x038000 TO 0x03BFFF; PAGE already contained in segment at 0xC000-0xFFFF */
END
PLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */
DEFAULT_RAM, /* non-zero page variables */
INTO RAM,RAM1;
_PRESTART, /* startup code */
STARTUP, /* startup data structures */
ROM_VAR, /* constant variables */
STRINGS, /* string literals */
VIRTUAL_TABLE_SEGMENT, /* C++ virtual table segment */
NON_BANKED, /* runtime routines which must not be banked */
DEFAULT_ROM,
COPY /* copy down information: how to initialize variables */
INTO ROM,ROM1,ROM2; /* ,ROM1,ROM2: To use "ROM1,ROM2" as well, pass the option -OnB=b to the compiler */
PAGED_ROM /* routines which can be banked */
INTO PPAGE_0,PPAGE_0_1,PPAGE_2,PPAGE_4,PPAGE_5,PPAGE_6,PPAGE_7,ROM1,ROM2;
_DATA_ZEROPAGE, /* zero page variables */
MY_ZEROPAGE INTO Z_RAM;
END
STACKSIZE 0x200
VECTOR 0 _Startup /* Reset vector: this is the default entry point for an application. */
and the beginning of the .map file showing the banked object file (.o) under the FILE SECTION:
*********************************************************************************************
STARTUP SECTION
---------------------------------------------------------------------------------------------
*********************************************************************************************
SECTION-ALLOCATION SECTION
Section Name Size Type From To Segment
---------------------------------------------------------------------------------------------
.data 70 R/W 0x100 0x145 RAM
.init 138 R 0x4000 0x4089 ROM
.startData 18 R 0x408A 0x409B ROM
.rodata 2596 R 0x409C 0x4ABF ROM
.rodata1 1697 R 0x4AC0 0x5160 ROM
.text 11910 R 0x5161 0x7FE6 ROM
***************************************************************************************
******
TARGET SECTION
---------------------------------------------------------------------------------------------
Processor : Freescale HC08
Memory Model: BANKED
File Format : ELF (no debug info)
Linker : SmartLinker V-5.0.37 Build 9279, Oct 7 2009
*********************************************************************************************
FILE SECTION
---------------------------------------------------------------------------------------------
main.c.o Model: BANKED, Lang: ANSI-C
Analog.c.o Model: BANKED, Lang: ANSI-C
Character_Library_for_Dot_Matrix_LCD.c.oModel: BANKED, Lang: ANSI-C
MC9S08DZ128.C.o Model: BANKED, Lang: ANSI-C
Start08.c.o Model: BANKED, Lang: ANSI-C
Menu.c.o Model: BANKED, Lang: ANSI-C
IIC.c.o Model: BANKED, Lang: ANSI-C
eeprom.c.o Model: BANKED, Lang: ANSI-C
LCD-NHD-C12865AR.c.o Model: BANKED, Lang: ANSI-C
LCD.c.o Model: BANKED, Lang: ANSI-C
time.c.o Model: BANKED, Lang: ANSI-C
functions.c.o Model: BANKED, Lang: ANSI-C
input_data.c.o Model: BANKED, Lang: ANSI-C
recording.c.o Model: BANKED, Lang: ANSI-C
CTYPE.C.o (ansibfm.lib) Model: BANKED, Lang: ANSI-C
MATH08F.C.o (ansibfm.lib) Model: BANKED, Lang: ANSI-C
PRINTF.C.o (ansibfm.lib) Model: BANKED, Lang: ANSI-C
RTSHC08.C.o (ansibfm.lib) Model: BANKED, Lang: ANSI-C
STDLIB.C.o (ansibfm.lib) Model: BANKED, Lang: ANSI-C
STRING.C.o (ansibfm.lib) Model: BANKED, Lang: ANSI-C
*********************************************************************************************
STARTUP SECTION
---------------------------------------------------------------------------------------------
*********************************************************************************************
SECTION-ALLOCATION SECTION
Section Name Size Type From To Segment
---------------------------------------------------------------------------------------------
.data 71 R/W 0x100 0x146 RAM
.init 139 R 0x4000 0x408A ROM
.startData 18 R 0x408B 0x409C ROM
.rodata 2596 R 0x409D 0x4AC0 ROM
.rodata1 1697 R 0x4AC1 0x5161 ROM
NON_BANKED 3008 R 0x5162 0x5D21 ROM
.text 8215 R 0x5D22 0x7D38 ROM