Hi
It is true that a lot of people stumble on the FLASH initialisation when making their first "Boot-loader" type project. Leaving the initialisation locations unprogrammed (0xff) results in no CPU access rights and so an immediate exception.
The uTasker project has set ups for CW and GNU (Codesourcery) and they work like this.
1 CodeWarrior.
In the linker map we have defined these locations like this
flashconfig (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000018 then we place the contents of an assembler file (called flash_config.s) to this area.
.flashconfig :
{
flash_config.s (.text)
} > flashconfig
flash_config.s contains table where initialisation values can be specifically set. In the general case - when no special protection is required - the contents are left at zero.
FLASH_CONFIG:_FLASH_CONFIG:.long 0x00000000 .long 0x00000000.long 0x00000000.long 0x00000000.long 0x00000000.long 0x00000000.end
The only thing which is also needed is for the start location to be referenced somewhere in the code (dummy reference) so that the linker optimiser doesn't optimise it away..
2. GNU (CodeSourcery)
Here we replace the crt1.s file from the libray (linker flag = -nostartfiles) with our own startup file.
This contains all assembler required in the project [152 bytes]. Then we have simply filled out the rest so that also the FLASH initialisation 'table' can be set as desired (again default all zero).
gnu_startup.s
/* 0x98..fill out with zeros - add general purpose assember in this space if required */ .rept 256-38 .long 0x00000000 /* fill unused area */ .endr/* 0x400..0x418 is used to configure FLASH controller on initialisation */ .rept 265-257 .long 0x00000000 /* flash initialisation range - zero is general case with no protection */ .endr
Note that the project also include a boot loader where the first 2k FLASH sector contains code allowing decryption and FLASH programming (enables complete SW uploads via Ethernet -
http://www.utasker.com/docs/uTasker/BM-Booloader_for_M5223X.PDF )
Regards
Mark Butcher
www.uTasker.com