Batch Programming - ( Random ) Device Number

Go To Last Post
2 posts / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am about to do a production run of some ATMEGA168 based boards. I need to store a unique number in each of the boards and was wondering what the best way to do this is? I would prefer the number be stored in Flash.

So far I was thinking about using a simple script to generate a .h file that can be included and then make can be called again.

I'll get the ball rolling with my limited bash skilz.

i=`awk '{print $1 }' countfile.txt` #read in starting number from file
for ((i;i<=1000;i+=1)); do
        echo "\#define SERIAL "$i > number.h
        make program
        if [failure]; then 
               #beep and paint red failure message on screen
               #print green message on screen
               echo $i> countfile.txt   #update countfile.txt
        pause(); #or whatever asks to press any key to continue

The boards will be programmed using ISP and not Parallel programming (at least for the first production run).

I am happy to use either AVRDude or an Atmel program. I will most likely be using a ATAVRISP programmer to program the boards.

Look foward to some ideas


  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not sure on the specifics of the hex format, but it's just text, so I imagine you could append a value directly into the .hex file so you wouldn't have to recompile.

For instance if you were to initialize a variable with some peculiar value, it would probably be easy to find it in the hex (I THINK inited variables are at the end of the .hex file), and then have a program go through and change it before each programing cycle. That way you don't have to recompile. As long as you don't alter the value in your code, you're fine. Plus then you don't have to fiddle with the 'read from program memory' stuff yourself.