Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Program code Lock ATMEGA328P using atmel studio & AVRISP MKII

Status
Not open for further replies.

johnny78

Full Member level 4
Joined
Jun 28, 2017
Messages
209
Helped
1
Reputation
2
Reaction score
4
Trophy points
18
Activity points
1,726
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 ?

thanks
Johnny
 

Hi,

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.

Klaus
 

    johnny78

    Points: 2
    Helpful Answer Positive Rating
Hi,

I'm not familiar with Studio.
Maybe it's a good idea to upload a screenshot.
... or your programming sequence,
Screenshot (3).png
... 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.

Klaus
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
 

Hi,

I´m not sure - maybe you need to perform a hardware RESET or a POWER cycling for the lock bits to be accepted.

Klaus
 

This might help -



Key info on bootloader - https://arduino.stackexchange.com/questions/47543/locking-atmega328-from-reading-back-the-hex-file

Regards, Dana.
 

    johnny78

    Points: 2
    Helpful Answer Positive Rating
You want to set LB mode 3 "Further programming and verification of the Flash and EEPROM is disabled"

Your setting of LB mode 2 still allows flash verification,

BLB bits are irrelevant for ptogrammer access, they control flash access by instructions,
 

    johnny78

    Points: 2
    Helpful Answer Positive Rating
You want to set LB mode 3 "Further programming and verification of the Flash and EEPROM is disabled"

Your setting of LB mode 2 still allows flash verification,

BLB bits are irrelevant for ptogrammer access, they control flash access by instructions,

Hi Guys

(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 ?

thanks
 
Last edited:

Hi
the chip can be read & write But like the pic code protect
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.

Klaus
--- Updated ---

added:
But what about the application section or boot section what is the lock
for this sections ?
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.

Klaus
 

    johnny78

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top