Hello,
I want to place a default username, password and some configuration data in the internal Flash of the MCF52233.
My question is:
Is there a file that I can place these default values in and tell codewarrior the address in flash to place them? Or is there some other simple way of doing this?
I can already write to and read from the flash. I just need a way of placing my default values in the flash.
Thanks
Renee
Hi Renee
See chapter 9 of http://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF
Regards
Mark
www.uTasker.com
- OS, TCP/IP stack, USB, device drivers and simulator for M521X, M521XX, M5221X, M5222X, M5223X, M5225X. One package does them all - "Embedding it better..."
Mark,
Thank you for the information.
What I was really looking for was a way (perhaps in the linker file?) to place default values into the flash at location "N" when the part was programmed. We already have a lot of our code finished.
Our current idea:
Since flash is erased before we program, I use memcpy to move a block of flash from location "N" that I am going to save our config data in, test the first byte to see if it is 0xff. If it is 0xff I then write our default config data back to flash and set that byte to 0x00. This should only occur once - the first time the unit is powered on. If it is 0x00 we do nothing.
A side note:
When we program our FPGAs we can go into the programmer and tell it to place default configuration data in file1.mem at memory location X (where X is past the config data for the FPGA of course). This works really well. We just thought that either the linker (which we don't understand the syntax at this point) or another file might hold the key to performing the same function in Codewarrior.
I would really be interested in how others get their default data into their products as they ship.
We are not placing MAC addresses in our product yet because it is configured serially and the Ethernet management port isn't utilized, but in the future I will be using the management port and will need to load a MAC address - which of course is unique for each product.
Thank you
Renee
Hi Renee
You can add values via linker by doing the following (only new lines are shown and example is for 8 bytes - eg. MAC address):
MEMORY
{
...
... flashtest (RX) : ORIGIN = 0x00002000, LENGTH = 0x8
...
}
SECTIONS
{
....
.flashtest :
{
mac_address.c (.text)
. = ALIGN(0x10);
} > flashtest
....
}
In mac_address.c you have a const defining the MAC address value. This will then be positioned at address 0x2000.
However this is not very practical since it means recompiling to change the MAC address.
Typically the MAC address is one-time programmable. As you suggest, when the location of the MAC address is 0xff 0xff 0xff 0xff 0xff 0xff 0ff 0xff it is not programmed and the card can default to a fixed MAC address in case you still want to communicate with it via Ethernet.
Then the value can be programmed over UART, HTTP, TCP application etc., after which it is fixed and can not be changed again. A PC can manage the programming and coordinate the distribution of MAC addresses from the purchased block.
Another method used is to simply compile the project to generate a binary or SREC image. Then use a PC utility to parse the file and add an additional SREC line (or binary values) at the appropriate address corresponding to the value of MAC address. Again this program can also be responsible for distributing the MAC addresses from the purchased block.
Regards
Mark
Hello,
Where does the linker search for the file "mac_address.c" mentioned in Mark's post? I tried modifying the lcf file as mentioned in his post and Codewarrior says it cannot find the file "mac_address.c".
I am using Codewarrior 10.1.
Renee
Go to the project settings, Tab Tool Settings > ColdFire Linker > Input and add the path where your file is to the Library Search Paths.
More detail:
https://community.freescale.com/thread/105586
If you're programming a MAC into each part in production you'll want to do it a bit differently I would think - leave an address in flash blank (0xFF) and then either use BDM/JTAG on the production line to set the value, or a once-only command that writes to the CFM (easier if you put the MAC in a blank *page* of flash).
Another method, not so easy, is to buy a MAC-on-a-chip EERPOM. That way it's not your problem, you just read it over SPI/I2C and every part is unique. It does add a component though.
(I shouldn't of named the file "mac_address.c". It isn't a mac address I am storing.)
I am using CW 10.2.
My lcf file and design was working fine. However I would like to be able to initialize a location in flash to a particular value.
I am using the MCF52233 and want to initialize location 0x3F010 to 0xff just for starters so I can understand how to do it.
Here is what I did:
I modified the working lcf file in the following fashion:
from
MEMORY {
vectorrom (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
cfmprotrom (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000020
code (RX) : ORIGIN = 0x00000500, LENGTH = 0x0003FB00
vectorram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400
userram (RWX) : ORIGIN = 0x20000400, LENGTH = 0x00007C00
}
to
MEMORY {
vectorrom (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
cfmprotrom (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000020
code (RX) : ORIGIN = 0x00000500, LENGTH = 0x0003F000
flashtest (RX) : ORIGIN = 0x0003F010, LENGTH = 0x00000001
vectorram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400
userram (RWX) : ORIGIN = 0x20000400, LENGTH = 0x00007C00
}
Then I added the following
From:
.bss :
{
___BSS_START = .;
__START_SBSS = .;
*(.sbss)
. = ALIGN (0x4);
*(SCOMMON)
__END_SBSS = .;
__START_BSS = .;
*(.bss)
. = ALIGN (0x4);
*(COMMON)
__END_BSS = .;
___BSS_END = .;
. = ALIGN(0x4);
} >> userram
.custom :
{
___HEAP_START = .;
___heap_addr = ___HEAP_START;
___HEAP_END = ___HEAP_START + ___heap_size;
___SP_END = ___HEAP_END;
___SP_INIT = ___SP_END + ___stack_size;
. = ALIGN (0x4);
} >> userram
TO:
.bss :
{
___BSS_START = .;
__START_SBSS = .;
*(.sbss)
. = ALIGN (0x4);
*(SCOMMON)
__END_SBSS = .;
__START_BSS = .;
*(.bss)
. = ALIGN (0x4);
*(COMMON)
__END_BSS = .;
___BSS_END = .;
. = ALIGN(0x4);
} >> userram
.flashtest :
{
mac_address.c(.text)
. = ALIGN(0x10);
} >flashtest
.custom :
{
___HEAP_START = .;
___heap_addr = ___HEAP_START;
___HEAP_END = ___HEAP_START + ___heap_size;
___SP_END = ___HEAP_END;
___SP_INIT = ___SP_END + ___stack_size;
. = ALIGN (0x4);
} >> userram
Then I created a "c" file named mac_address.c and within that file I have the following line:
const uint8 bob = 0xff;
Then I went to project-properties-settings-coldfire linker- Input and added to the"library search paths" the path to the mac_address.c file.
However, Codewarrior still says it cannot file mac_address.c