View previous topic :: View next topic |
Author |
Message |
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Thu Feb 28, 2008 3:05 pm Post subject: how to programm serial number? |
|
|
Hi,
I need to programm a serial number into the flash. The number must increase after each programming.
Is there a solution? |
|
Back to top |
|
|
lpa
Joined: 12 Dec 2006 Posts: 27 Location: Oreokastro, Greece
|
Posted: Thu Feb 28, 2008 6:41 pm Post subject: |
|
|
how do you program the flash ?
are you using bootloader ? |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Thu Feb 28, 2008 6:56 pm Post subject: |
|
|
No bootloader, I donīt want to programm a new number to the same chip every time it is programmed.
I need to programm serial numbers into a large amount of chips, e.g. the serial number of your mobile. |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Thu Feb 28, 2008 10:30 pm Post subject: |
|
|
May not be quite what you want, but Bascom compiler stores the date/time of compilation in a variable called Version in your code. So if you did a re-compile before each chip program, you would get a different date/time stamp for each chip. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Fri Feb 29, 2008 11:56 am Post subject: |
|
|
Thanks a lot!
Both ways are fine to me, Iīll use them both!
I can read the "ponyprog" serial number using the cpeek command, thats easy. Its also easy to find an unused address in the flash, Iīd use the very last address.
But imagine I change my program-code, it might suddenly use the address of the serial number.
My idea is to place dummy-data at the very end of my Code, thus keeping the space left for my serial number.
Does anyone agree? |
|
Back to top |
|
|
lpa
Joined: 12 Dec 2006 Posts: 27 Location: Oreokastro, Greece
|
Posted: Fri Feb 29, 2008 12:16 pm Post subject: |
|
|
Here is my idea:
1)Set the address of a variable in Bascom at a specific address in code memory, put in this variable your default ID-value. Use command : Code: | DIM var AS [XRAM/SRAM/ERAM]type [AT location/variable] [OVERLAY] AT
The optional AT parameter lets you specify where in memory the variable must be stored. When the memory location already is occupied, the first free memory location will be used. You need to look in the report file to see where the variable is located in memory. |
2)Compile and get the HEX file.
3)Make a pc program to run from windows that changes in the HEX file the specific values at bascom variable's address space with your ID value automatically - something like automatic hexeditor.
4)Program the HEX file to chip flash
Since you define the Bascom variable at a specific address, you can modify the rest of the program without affecting the rest of the procedure |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Fri Feb 29, 2008 12:27 pm Post subject: |
|
|
lpa wrote: | Here is my idea:
1)Set the address of a variable in Bascom at a specific address in code memory, put in this variable your default ID-value. Use command : Code: | DIM var AS [XRAM/SRAM/ERAM]type [AT location/variable] [OVERLAY] AT
The optional AT parameter lets you specify where in memory the variable must be stored. When the memory location already is occupied, the first free memory location will be used. You need to look in the report file to see where the variable is located in memory. |
|
Nice idea to reserve space for Ponyprog, address will not change with an software update. _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Fri Feb 29, 2008 12:35 pm Post subject: |
|
|
As far as I understand, that will preseve space in a RAM, but I need to write the serial-number in the flash-ROM. The serial-number cannot be a variable! |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Fri Feb 29, 2008 12:58 pm Post subject: |
|
|
Arera wrote: | As far as I understand, that will preseve space in a RAM, but I need to write the serial-number in the flash-ROM. The serial-number cannot be a variable! |
Yep your right, time to get some lunch. _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
Luciano
Joined: 29 Nov 2004 Posts: 3149 Location: Italy
|
Posted: Fri Feb 29, 2008 1:39 pm Post subject: |
|
|
Hi,
Write a batch file (or program) that calls the tool HEXinc.
(HEXinc will increment a value in the HEX file).
The same batch file (or program) will then call the Atmel command
line programming software stk500.exe which will flash the AVR chip.
Note that stk500.exe will output the file stk500.log after programming.
(Error report).
* * *
Where to download the tool HEXinc:
http://www.atmel.ru/Disks/AVR%20Technical%20Library/tools/developer/stk500/index.html
(See link Serial Number Programming for Batch Programming).
To get help type: hexinc -h
Where do get stk500.exe:
stk500.exe is installed when you install AVR Studio. (Current version 4.13).
The documentation of the command line software (stk500.exe) is in
the help file of AVR studio. (Open the STK500 help file).
The STK500.exe will work with the Atmel ISP programmer STK500, AVRISP and AVRISP Mk II.
Best regards,
Luciano |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Fri Feb 29, 2008 4:21 pm Post subject: |
|
|
Thanks Luciano for this way to get the serial number into the chip.
But what Iīm still worried about is:
Can I be shure, that if I place the serial number at the end of the flash-ROM, this location is untouched by the programm, until its size reaches there? |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Fri Feb 29, 2008 5:21 pm Post subject: |
|
|
Yes, thatīs what I was looking for!
I donīt know anything about that mysterious bootloader stuff, so just to be shure: The bootloader space is always at the end of the memory, right? |
|
Back to top |
|
|
|