hello Guys
im trying to lock the code in the ATMEGA328P & i have tried almost all the lock bit settings in atmel studio7
Further programming disabled
lpm & spm prohibited in application section
lpm & spm prohibited in boot section
after i set this lock bits what should happen ?
i have tried to read the chip after setting the lock bits & its read
in PIC MCU's the read is set of 0's so no program can be re write
what im testing here is simple but its not locking the code
im reading it again & programming it on another chip & it works
how to protect my code ?
I'm not familiar with Studio.
Maybe it's a good idea to upload a screenshot.
... or your programming sequence,
... or the programers output text
When you program the code, then usually the fuses are not automatically programmed.(depending on software and setup)
Maybe you need to do additional "fuse programming".
Another option: If I'm not mistaken then the fuses may be programmed by software. So include this in your code.
I'm not familiar with Studio.
Maybe it's a good idea to upload a screenshot.
... or your programming sequence, ... or the programers output text
When you program the code, then usually the fuses are not automatically programmed.(depending on software and setup)
Maybe you need to do additional "fuse programming".
Another option: If I'm not mistaken then the fuses may be programmed by software. So include this in your code.
in Atmel studio > device programming > i program lock bits seperately
the 3 lock bits are prgrammed when i read the lock bits
But when i try to read the memory it reads also
It would be something like this: avrdude -c usbtiny -p m328p -U lock:w:0xFC:m You could do that via the SPI interface using a USBtinyISP or similar programmer. Be warned that after doing this you can only ever change the chip again by using a high-voltage programmer like the AVR Dragon. So if...
(Further programming And virification Disabled
PROG_VER_DISABLED)
its ok now with this option
& the chip can be read & write But like the PIC Mcu code protect
the read code is useless.
But what about the application section or boot section what is the lock
for this sections ?
I guess you are using the SPI like programming interface.
The master (programming device) generates the clock SCK sends out DATA via MOSI and recieves data via MISO.
(Let´s ignore CS for now)
as soon as the clock is running there is bidirectional communication.
With every clock cycle the receiver´s shift register will receive a bit.
* it may be true HIGH
* it may be true LOW
* or it may be random HIGH or LOW when the data line is tristated. But if tristated the reciever will never know. It just sees the HIGHs and LOWs.
It´s impossible to recieve "no data". It will always recieve data.
For the SPI hardware it is impossible to know whether the received data is valid or not.
So for the AVR programming device it is not possible to decide whtether the received data is valid or nonsense.
Since the hardware can not know this, it´s the job of the protocol.
With AVR programming this is done by using the AVR device ID.
With the Atmega328P this is 0x1E950F.
So the programmer asks for the device ID and the MCU has to respond with 0x1E950F for the programmer to know that the AVR ... and also the correct AVR is connected.
This is not for the programming interface.
It´s for the firmware.
This is important for bootloaders for example.
* You may the bootloader to erase/read/write the application section, while you prohibit the same for the bootloader section.