MCF52235 flash configuration field initialised with assembly code

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

MCF52235 flash configuration field initialised with assembly code

1,573 Views
pnordby
Contributor I
When attempting to make a bootloader, I discovered that none of the examples I've compared our code to seems to take care of the CFM configuration field as described in Table 17-1 in rev 4 of the MCF52235 reference manual.

According to the manual (if I understand it correctly), flash address 0x400 to 0x417 should contain CFM configuration. __start (or whatever the initial assembly is called) should not occupy this memory space.

This seems to apply for examples from Codewarrior, Interniche and Codesourcery. An SVN repository or similar for improved example code could help others getting more quickly started.
Labels (1)
0 Kudos
1 Reply

274 Views
mjbcswitzerland
Specialist V
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



0 Kudos