Go Down

Topic: Protect Sketch from being Read (Read 1 time) previous topic - next topic

Piton

Ok i have looked around, and found that the sketch on the ATMEGA can be downloaded ( machine language not compile ) and can be put in another arduino.
I should avoid that. Can someone help me in a step to step explaination?
I'v undestood that only if i have an ISP i can set the fuse of the Atmega to avoid reading from external sources.
Are there any link i can read some info about this process? The software not the hardware.
Actually i'm using ATMEGA1280.

Hope someone can help me, but thanks anyway if you read trough here.

shelleycat

#1
May 06, 2012, 08:20 pm Last Edit: May 06, 2012, 08:31 pm by shelleycat Reason: 1
You need to read the ATMEL spec for the processor to see what fuses you need to change.

You will need an ISP, and there are plenty of posts on the forum about the various sorts of ISPs.  I use a arduino board clone that has links on it to allow ISP processing, I got it off ebay for less then £20.  You can also use some arduinos if you cut a track.

Once you have the ISP, the next step to find information is just to press shift when you download a sketch (this is not using the ISP, its just to find out where avrdude).  This shows the processes going on, and the one you will be interested in is avrdude.  The output will show on your system where avrdude is.

Then you need to run avrdude with no options, and read the documentation on that.  One of the things avrdude will do is write to the fuses. On my system the command to write a sketch with an ISP was:
$/home/roger/arduino-0022/hardware/tools/avrdude -C/home/roger/arduino-0022/hardware/tools/avrdude.conf -v -v -v -v -patmega168 -cstk500v1 -P/dev/ttyUSB0 -b19200 -D -Uflash:w:/tmp/build5814928292371967035.tmp/Blink.cpp.hex:i

The command to write a fuse will be similar but with the -U something like  -Ulofuse:w:AA

I would recommend that you buy a few processors, because I bet you will lock up a few.

tim7

After uploading yor sketch, you need an ISP programmer to set the lock bits.  Something like the following will lock the chip from further programming.  Beware, this will block writing as well as reading.

Code: [Select]
ide\tools\avr\bin\avrdude -C ide\tools\avr\etc\avrdude.conf -p atmega328 -P com1 -b 19200 -c stk500v1 -v -u -U lock:w:0x00:m

robtillaart


from the AVRDUDE manual - http://nongnu.askapache.com/avrdude/avrdude-doc-5.5.pdf - page 21

Writing lock bits is supported, but is restricted to
the boot lock bits (BLBxx). These are restrictions imposed by the underlying SPM
instruction that is used to program the device from inside the boot loader. Note that
programming the boot lock bits can result in a "shoot-into-your-foot" scenario as the
only way to unprogram these bits is a chip erase, which will also erase the boot loader
code.


don't know for sure if this applies to all processors but as I read it I think you can revitalize locked up 328's. [still buy some extra]

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

GoForSmoke

A high voltage programmer can clear the MCU.

I'm wondering if the bootloader sets any fuses limiting writing to flash when a sketch has been uploaded?

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Go Up