1

I am interested in locking my sketch of arduino of atmega328 to make it undownloadable.

Is there some way to enable lock bits by compiling the sketch into Hex and then uploading it with avrdude ?

Thank you

George Alto
  • 11
  • 1
  • 2
  • 1
    Somebody deleted an answer with a link to http://embeddedtechi.blogspot.in/2016/06/setting-lockbits-in-atmel.html. It's not the best page, but deleting answers with useful information *never* makes sense. "If you're not going to rewrite the documentation in an answer, we shouldn't have the information at all!" is a nonsense policy. – Glenn Maynard Feb 16 '17 at 03:33

2 Answers2

0

After you upload and test your Sketch using the Arduino IDE you should be able to lock out access to the code with the following Avrdude command.

avrdude -c usbtiny -p m328p -U lock:w:0x00:m -u

You might need to change the -c or -p options.

Jeff
  • 1,364
  • 1
  • 8
  • 17
0

You need to read over the docs on locking the chip. You can lock it where it takes a high voltage programmer to un-brick it. You can lock the boot loader, jump straight into code and other things. Beware, seems like 99% of my problems have been learning what they meant in the docs...:>>

Also most IDE's, Atmel has a recommend procedure for doing what you are attempting. They specify which bit to lock when, usually after upload the code:)

  • Providing a link to the documentation you are referring to would be helpful to everyone that comes across this question and answer. – TW80000 Aug 18 '16 at 03:25
  • "Read the docs" isn't a helpful answer, especially when it's followed by saying "most people find them confusing", and "by the way there are procedures" is least helpful of all... – Glenn Maynard Feb 16 '17 at 03:31
  • I agree with Glenn, the link is a good reference. EEPRPOM memory is preserved during Chip Erase if the EESAVE Fuse is programmed. I use this to maintain access to diagnostic data. – Jack Wilborn Feb 17 '17 at 07:44