Was looking for some direction from FSL developers...I am using MC9S08QE64, with a bootloader developed by a collegue for the MC9S08QE32. 64k component has ROM memory pages, while 32k uses direct addresing only. The 32k used a bootloader to for an SD card, borrowed from AN2295, AN3927. My questions revolve around how to set the Flash address min and max, used by EraseFlash() in ParseS19.c. These are set in Bootloader_S08.h. Also, the PRM file, defines RAM/ROM consistent with the memory map for 64k component.
When the bootload code runs, it opens the S19, the goes into wonderland when calling EraseFlash() in ParseS19.c...I suspect my issues lie with how I am defining the memory map in the PRM and address boundaries in Bootloader_S08.h.
Also, I'd like advice on my PRM files, are they correct for the QE64 with 5k of flash protected for the bootloader?
I paste a bunch of code snippits here...thanks in advance to the experts, I am new to this MCU...davo321
bootloader PRM file:
NAMES
END
SECTIONS
Z_RAM = READ_WRITE 0x0080 TO 0x009F;
RAM = READ_WRITE 0x00A0 TO 0x107F; /* unbanked FLASH ROM */
ROM = READ_ONLY 0x2080 TO 0x7FFF; /* following line generated by PE for 64k MCU */
ROM1 = READ_ONLY 0xC000 TO 0xEBFF;
HBOOTLOADER = READ_ONLY 0xEC00 TO 0xFFAD;
HBOOTLOADER_RAM = READ_WRITE 0x00A0 TO 0x107F; /* banked FLASH ROM */
PPAGE_0 = READ_ONLY 0x008000 TO 0x00A07F; /* PAGE partially contained in ROM segment */ PPAGE_2 = READ_ONLY 0x028000 TO 0x02BFFF;
MY_STACK = READ_WRITE 0x0F80 TO 0x107F;
/* INT_VECTS = READ_ONLY 0xFFC0 TO 0xFFFF; Reserved for Interrupts */
END
PLACEMENT DEFAULT_RAM, /* non-zero page variables */
INTO HBOOTLOADER_RAM;
_PRESTART, /* start up code */
STARTUP, /* start up data structures */
ROM_VAR, /* constant variables */
STRINGS, /* string literals */
NON_BANKED, /* non banked */
COPY /* */
INTO HBOOTLOADER;
DEFAULT_ROM, /* */
PAGED_ROM /* routines which can be banked */
INTO PPAGE_0,PPAGE_2,ROM1;
_DATA_ZEROPAGE, /* zero page variables */
MY_ZEROPAGE INTO Z_RAM;
END
INIT _EntryPoint /* The entry point of the application. This function is generated into the CPU module. */ STACKSIZE 0x0100 /* Size of the system stack. Value can be changed on the "Build options" tab */
bits from Bootloader_S08.h:
// 64k MCU
#define MIN_RAM1_ADDRESS 0x0080
#define MAX_RAM1_ADDRESS 0x107F
#define MIN_FLASH2_ADDRESS 0x028000 //FLASH2 = PAGE 2
#define MAX_FLASH2_ADDRESS 0x02BFFF
#define MIN_FLASH1_ADDRESS 0x2080
#define MAX_FLASH1_ADDRESS 0xFFFF //0xFFFF // NOTE: EraseFlash() assumes this address, only works with S08s with 64K memory space
#define FLASH_PROTECTED_ADDRESS 0xEC00
#define USER_ENTRY_ADDRESS 0xEBBD
#define FLASH_PAGE_SIZE 512 // Redirected Interrupt Vector Table
#define InterruptVectorsNum 29 // Number of interrupt vectors to relocate
#define VectorAddressTableAddress (FLASH_PROTECTED_ADDRESS - 3*(InterruptVectorsNum + 1))
#define BootVectorTableAddress 0xFFC4 // Lowest interrupt vector address to relocate
Bootloader PE project sets the CPU beans:
Reset vector to 0xFFFE
IRQ table to 0xFFC0
Flash Protect 5k: 0xEC00-0xFFFF
The end of the bootloader code has the jump to USER_ENTRY_ADDRESS, and is functioing OK
application code PRM file:
NAMES
END
SECTIONS
Z_RAM = READ_WRITE 0x0080 TO 0x009F;
RAM = READ_WRITE 0x00A0 TO 0x107F; /* unbanked FLASH ROM */
ROM = READ_ONLY 0x2080 TO 0x7FFF; /* following line (commented out) was generated by PE for 64k MCU */
ROM1 = READ_ONLY 0xC000 TO 0xEBFF;
HBOOTLOADER = READ_ONLY 0xEC00 TO 0xFFAD;
HBOOTLOADER_RAM = READ_WRITE 0x00A0 TO 0x107F; /* banked FLASH ROM */
PPAGE_0 = READ_ONLY 0x008000 TO 0x00A07F; /* PAGE partially contained in ROM segment */ PPAGE_2 = READ_ONLY 0x028000 TO 0x02BFFF;
MY_STACK = READ_WRITE 0x0F80 TO 0x107F;
/* INT_VECTS = READ_ONLY 0xFFC0 TO 0xFFFF; Reserved for Interrupts */
END
PLACEMENT DEFAULT_RAM, /* non-zero page variables */
INTO RAM;
_PRESTART, /* start up code */
STARTUP, /* start up data structures */
ROM_VAR, /* constant variables */
STRINGS, /* string literals */
NON_BANKED, /* non banked */
COPY /* */
INTO ROM;
DEFAULT_ROM, /* */
PAGED_ROM /* routines which can be banked */
INTO PPAGE_0,PPAGE_2,ROM1;
_DATA_ZEROPAGE, /* zero page variables */
MY_ZEROPAGE INTO Z_RAM;
END
INIT _EntryPoint /* The entry point of the application. This function is generated into the CPU module. */ STACKSIZE 0x0100 /* Size of the system stack. Value can be changed on the "Build options" tab */
Application PE project sets the CPU beans:
Reset vector to 0xEBFE
IRQ table to 0xEBC0
Flash Protect 5k: 0xEC00-0xFFFF
The application Project.c file has the identifier as entry point as USER_ENTRY_ADDRESS
as it turns out..the bootloader code is fine...the issue was with the application entry point...the address was stored as 3 bytes, while the structure to generate the JumpVect UsrEntry@ USER_ENTRY_ADDRESS used the JMP instruction, which expects a 2 byte address...since QE128 series has paged memory, it has a 3 byte address..so application jumped to a bad location when it started. Now just need to make the table for IRQ vector redirection.