EmbeddedRelated.com
Forums

How to store user specific data into the flash of the microcontroller

Started by faiyaz October 21, 2008
Hi


We are developing a USB device which is based on AT91SAM7S64 which has a
64K of flash in it. We want to store some specific data like Serial No of
the device etc. into the flash of the microcontroller permanently. But the
issue is we can not write the data into the program code of the
microcontroller as constants, because this data is going to be specific for
every single device and we do not want to change program code for every
single device. Instead we are going to develop an application software on
PC which will send this specific data via USB. So is it possible that we
write a firmware which can fetch the data from this USB packet and store it
into the flash permanently? I mean,can the data remain non-volatile
thereafter?
If yes, then please describe in detail.
If not then pleas tell us what are the other ways to store data permanenly
into the flash?

Faiyaz
"faiyaz" <faiyaz.pw@gmail.com> wrote in message 
news:1cqdnVk3jZHbxmDVnZ2dnUVZ_tCdnZ2d@giganews.com...
> Hi > > > We are developing a USB device which is based on AT91SAM7S64 which has a > 64K of flash in it. We want to store some specific data like Serial No of > the device etc. into the flash of the microcontroller permanently. But the > issue is we can not write the data into the program code of the > microcontroller as constants, because this data is going to be specific > for > every single device and we do not want to change program code for every > single device. Instead we are going to develop an application software on > PC which will send this specific data via USB. So is it possible that we > write a firmware which can fetch the data from this USB packet and store > it > into the flash permanently? I mean,can the data remain non-volatile > thereafter? > If yes, then please describe in detail. > If not then pleas tell us what are the other ways to store data permanenly > into the flash? > > Faiyaz
It's fairly easy to do. First read the data sheet very carefully. Now you know how to write to the on-chip flash. The only trick is that you will need to make sure that your flash writing code is in RAM when it executes. You will also need to make sure that interrupts can't upset things. Michael Kellett www.mkesc.co.uk
On Oct 21, 6:32=A0am, "faiyaz" <faiyaz...@gmail.com> wrote:
> Hi > > We are developing a USB device which is based on AT91SAM7S64 which has a > 64K of flash in it. We want to store some specific data like Serial No of > the device etc. into the flash of the microcontroller permanently. But th=
e
> issue is we can not write the data into the program code of the > microcontroller as constants, because this data is going to be specific f=
or
> every single device and we do not want to change program code for every > single device. Instead we are going to develop an application software on > PC which will send this specific data via USB. So is it possible that we > write a firmware which can fetch the data from this USB packet and store =
it
> into the flash permanently? I mean,can the data remain non-volatile > thereafter? > If yes, then please describe in detail. > If not then pleas tell us what are the other ways to store data permanenl=
y
> into the flash? > > Faiyaz
I don't think it should be any big problem to write data to flash. I don't know AT91SAM7S64 family but looking through its Datasheet it seems this controller supports this option. I have been using ATMEL's AT89C51ED2 for years and I wrote many programs which store important data into the same Flash from which the code program is running, and this is 8-bit 8051 family microcontroller, so I don't see the reason why the AT91SAM7S64 couldn't do it. I suggest the following: 1) You should dedicate some area in Flash and instruct the compiler do not use this area at compile and run time. 2) In the past ATMEL provided ISP Flash functions for AT89C51ED2 Flash programming which can be easily incorporated in user applications - I am sure ATMEL has also such application code regarding AT91SAM7S64. Search in ATMEL web site for examples or ask ATMEL's support. Yossi Srebrnik
On 2008-10-21, faiyaz <faiyaz.pw@gmail.com> wrote:

> We are developing a USB device which is based on AT91SAM7S64 which has a > 64K of flash in it. We want to store some specific data like Serial No of > the device etc. into the flash of the microcontroller permanently. But the > issue is we can not write the data into the program code of the > microcontroller as constants, because this data is going to be specific for > every single device and we do not want to change program code for every > single device. Instead we are going to develop an application software on > PC which will send this specific data via USB. So is it possible that we > write a firmware which can fetch the data from this USB packet and store it > into the flash permanently? I mean,can the data remain non-volatile > thereafter?
Yes.
> If yes, then please describe in detail.
Read the user's manual for the AT91SAM7S64 -- Grant Edwards grante Yow! I'm EMOTIONAL at now because I have visi.com MERCHANDISING CLOUT!!
faiyaz wrote:
> If not then pleas tell us what are the other ways to store data permanenly
1. This is what I use For my ATMega projects, I put the device specific information into the flash by manipulating the HEX file generated by the linker and then programming the device only once. So I only compile once, and then via a batch file which contains one line per serial number I generate the multiple, serial number specific images. eg: I start with: ATMega64_boot_v1.0.hex - this is the compiler output Then after I run the batch file, I get: ATMega64_boot_v1.0_0001.hex ATMega64_boot_v1.0_0002.hex ATMega64_boot_v1.0_0003.hex ATMega64_boot_v1.0_0004.hex ATMega64_boot_v1.0_0005.hex ATMega64_boot_v1.0_0006.hex ... My Batch file uses sed commands to - remove the hex file termination line - append encrypted device specific info (like serial number) to the hex file - calculate image crc and append it into the hex file - re-write the hex file termination line 2. If its ONLY a serial number you are after, then you can consider adding a serial number device (they can be tiny 3 pin devices, eg the Dallas iButton and derivatives) or check your other onboard devices to see if any of them support a unique serial number (eg an external flash). W4tch3r &#4294967295;&#4294967295;?&#4294967295;&#4294967295;
MK wrote:

> It's fairly easy to do. First read the data sheet very carefully. Now you > know how to write to the on-chip flash. The only trick is that you will need > to make sure that your flash writing code is in RAM when it executes. > You will also need to make sure that interrupts can't upset things.
Are you sure that it must be executed in RAM? I didn't found it in the datasheet, but some microcontrollers allow to write other pages than the one where the code is executed in flash. Another idea would be to use SAM-BA. It is possible to write some nice TCL-scripts to automate everything you need for flashing the program and different serial numbers, which could be even generated, managed and displayed by the script. -- Frank Buss, fb@frank-buss.de http://www.frank-buss.de, http://www.it4-systems.de
Dear All,

Yes I have got AT91-ISP setup exe from ATMEL website which contains
SAM-BA.exe,  with this we can write any data into any desired location of
Flash or RAM and we can also read data from any specific location and store
it as a file in our PC.  There are three ways to program the memory of SAM7
-- JTAG interface, USB or COM Port.
I have just tried JTAG interface and works very fine with it.

Thanks all for your priceless suggestions and support.

Faiyaz