Solved: Mikroprog help

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

hello guys

i have purchased an mikroprog AVR for locking the code as a friend suggested as it is a good solution & a professional standalone programmer

but since i got it i had alot of problems with it & after 2 days Chat with MikroE support team my issues solved But Finally they said

tht no way to protect the code unless i disable the reset or it means no further programming is possible

if tht is the answer so why in AVR FLASH there is 10 lock modes ?

 

So any suggestions ?

 

thx

Last Edited: Thu. Feb 8, 2018 - 10:12 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The lock bits will provide protection for the code, and setting reset disable will prevent any further programming via isp.  But if the chip is removable from the pcb, then hv programming can erase the chip and reset all lockbits.   There are also places that will recover the code from the chip for a price no matter what you do to protect it, so there is no absolute code protection!!!

 

I have produced 100k+ production systems and we only set lock bits for protection.  Lock it and don't worry about it.    YMMV!

 

Jim

 

 

 

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

USD 60 seems like a lot of money for an almost empty box.

And maybe you cant rip out the cable, but you'll break it because of repetitive bending...

 

But apart from that.

Is it supported by avrdude or atmel studio?

 

Apart from that.

Your programmer comes with software and I see a bunch of options to set those lock bits.

Explanation of the lock bits for your AVR (Which one is it?) is in the datasheet.

Some of those fuse bits are for disabling further programming or for protecting the chip against reading.

After that a full erase of the chip you can write and read again from it.

 

Some potential "dangerous" bits:

On some AVR's you can also disable the reset pin but this is not really rrecommended.

You can only recover from that with a high voltage parallel programmer. (There is "arduino" code for that on the 'net).

If you set the fuse bits for an extarnal oscillator / clock  but there is none it does nothing untill an external crystal / clock is added.

mikroprog_for_avr_inside.jpg

https://www.mikroe.com/mikroprog...

 

 

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

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

If someone REALLY wants your code, they can send the AVR...Or ANY micorcontroller to various 'extraction' centers, pay a fee and they will etch off the top of the chip and painstakingly extract the flash programming for you.

 

Moral of the story is that nothing in this world is safe.  Lock bits only keep honest people, and amatuers, honest.

 

Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

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

I heared of a story once where the code was protected by dischagring a 60V capacitor into one of the pins needed for programming.

Worked for quite some time untill after a die update it destroyed too much of the chip and that method could not be used anymore for that project.

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

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

 it looks really Bad 

 

& no it isnt supported by AVRDUDE & i think arduino as ISP programmer is supported 

& i have asked before about the lock bits for AVRs in AVRDUDE

if anyone familiar with using AVRDUDE to lock the code it will be nice if he guide me to do this

i just want simply if anyone connects an ISP programmer to the board it cant be read.

im not talking about the professional ways to extract the code

 

so you think there is no real protection method for AVR's ? or any MCU ?

 

thx for your suggestions & thx esoecially to PAULVDH to remind me i have paid $115 to get this programmer 

& yes i see its nothing BUT nice box BUT even reading & writing to it was a disaster they have problems reading the code

& rewrite it to the chip i have lost 2 days chatting with mikroe technical support to solve an issues which its their fault as i guess

 

THX Guys

  

Last Edited: Thu. Feb 1, 2018 - 06:52 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paulvdh wrote:
I heared of a story once where the code was protected by dischagring a 60V capacitor into one of the pins needed for programming.
Presumably as a result of the discussion in this thread Brian started this more general thread about CPU protection:

 

http://www.avrfreaks.net/forum/c...

 

Follow the link I gave there and read about "power glitch"

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

johnny22 wrote:
or any MCU ?
AVR32 UC3C and UC3L have FlashVaultTM.

PIC32 has a code protect bit.

armv8-M adds TrustZone.

PIC24 and dsPIC have CodeGuardTM.

 

Atmel AVR 32-bit Architecture Manual

http://ww1.microchip.com/downloads/en/DeviceDoc/doc32000.pdf

(page 3, bottom)

via http://www.microchip.com/wwwproducts/en/at32uc3c2512c

PIC32 Flash Programming Specification

http://ww1.microchip.com/downloads/en/devicedoc/60001145u.pdf

https://developer.arm.com/technologies/trustzone

Microchip

CodeGuardTM Security: ...

http://www.microchip.com/stellent/groups/dspic_sg/documents/devicedoc/en027547.pdf

 

Edit: Link target, CodeGuardTM

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Mon. Feb 5, 2018 - 08:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

We can help you better if you start by telling us which AVR you are using.

Different AVR's have different fuse settings and the meaning of the fuses somtimes also change.

They are always in the datasheet, but because the meaning of a fuse can change, depending on other fuses its ... confusing :)

There is a "fuse calculator" on the website from engbedded:

http://www.engbedded.com/fusecalc

For programming the fuse bytes you can copy them from engbedded and put them as an argument to avrdude:

-U lfuse:w:0xe1:m -U hfuse:w:0x99:m 

Some people prefer a GUI for progamming the AVR, but I prefer a command line utility, which can easily be embedded in a makefile.

Almost any IDE can be configured to make specific targets in a makefile, so (after right configuration) I can Compile a Progam & Program an AVR with just a single key on my keyboard.

According to the screenshot from the software from the MicroProg site you can program the fuses with it, and once the proper fuses are set you cannot read the AVR (untill all flash is erased).

But you have to search for the right fuse settings in the datasheet of your particular AVR or use a fuse calculator such as Engbedded.

 

The way of selecting the fuse fuse bits for your programmer is very similar to the Engbedded calculator.

But I can not see a button to write the selected fuse bytes to the programmer.

Maybe it is in one of the menu's?

You can safely experiment by changing the fuses for the "BOD" (Brown out detector). You should be able to write them to your AVR and then read them back (also after a power cycle).mikroprog_for_avr_inside.jpg

 

If you're really stuck it's unlikely we can help much with your programmer.

Probably not many people use it.

 

For the "hobby" / DIY way I reccomend a programmer which is supported by AVRdude such as "USBasp" or "USBtinyISP" from Ebay / Aliexpress or an "arduino" board with a program for programming other AVR's.

For a "professional" way I want to recommend a programmer which is supported by Micromel or Atchip.

https://www.microchipdirect.com/...

 

The Atatmel-ICE has a lot of advantages other programmers do not have such as PDI / (JTAG?) en debugging capabilities from within Atmel Studio, but that's windows software and I run Linux (and are happy with it).

 

@clawson: Yep, I saw Brian's fork.

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

Last Edited: Thu. Feb 1, 2018 - 01:47 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

unfortunately in my country its hard to get this king of tools so an Indian Friend suggested this nice box for me as a professional standalone programmer & he bought it & send it to my friend in Lebanon 

which he send it back to me.

Anyway thx to my Friend which bought it for me from mikroe & paid its price & send it to Lebanon before he gets his money yet   

 

i have two projects on Arduino Mega & UNO which i want to protect the code from being read by any ISP programmer.

i have tried AVRdudess which its a GUI of AVRDUDE but it give me errors when writing to the board

& yes its so confusing the lock bits I used to program pics which its easy & clear One fuse CP Code protect & that's all 

I think the Arduino as ISP programmer is supported by AVRDUDE right ? 

 

if you can help me use AVRDUDE with Arduino UNO programmed as ISP programmer it will be great & very appriciated

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

There is something odd here. The screenshot above clearly shows options for setting lock bits and yet the official answer in the support forum is to disable the reset pin.

"This forum helps those that help themselves."

"If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

 

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

that is the issue 

the options for lock bits its nothing i guess

i was chatting with mikroelektronika support team since 2 days & he said

(To prevent reading and programming of the data on a avr micro controller you need to set certen fuse bits to disable the programming interface. In most cases this is done with this lock bits. However after doing so you will not be able to reprogram the mciro controller.)

 

so is tht right ? no way to reprogram the chip?

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

No, it is not correct.

If you set the lock bits, and later want to change your code, then all you need to do is erase the chip which clears the lock bits. (and the old code obviously.)

"This forum helps those that help themselves."

"If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

 

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

So you think the guy from MIKROELEKTRONIKA doesnt know about the AVR Flash program really ?

Or its me who didnt understand clearly what he means?

 

the exact answer was this:

(To prevent reading and programming of the data on a avr micro controller you need to set certen fuse bits to disable the programming interface. In most cases this is done with this lock bits. However after doing so you will not be able to reprogram the mciro controller.)

 

i will tell you what modes i have in AVR FLASH

 

MODE1:

no memory lock features enabled.

 

MODE2:

Further programming of the Flash & EEPROM is disabled in parallel & Serial Programming mode.

The fuse bits are locked in both serial & parallel programming mode.

 

MODE3:

Further programming & verification of the Flash & EEPROM is disabled in parallel & Serial Programming mode.

The fuse bits are locked in both serial & parallel programming mode.

 

Last Edited: Sat. Feb 3, 2018 - 09:32 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

johnny22 wrote:
So you think the guy from MIKROELEKTRONIKA doesnt know about the AVR Flash program really ?

That would be one possibility, yes. The most likely, in my opinion.

 

Another possibility is that there was some failure and misunderstanding in the communication.

 

A third possibility is that Mikroelektronika has limited what their programming software and/or hardware is able to do.

 


 

As for the AVR as such this is clear (as documented in the data sheet): Lock bits disable certain memory program operations. It does not disable the ability to do a chip erase. A chip erase will (among other things) reset the lock bits to their defaults.

 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

its clear this way so now i can take the risk & try to lock the ATmega328p & re erase it 

 

So modes 2 & 3 are the same i guess

 

here is the conversation about the lock bits

 

(now plz just guide me about the lock code bits & thts all you will get rid of me

To prevent reading and programming of the data on a avr micro controller you need to set certen fuse bits to disable the programming interface. In most cases this is done with this lock bits. However after doing so you will not be able to reprogram the mciro controller.

 

no i dont want to disable the programming

or its ok but can i erase the chip ?

i had i read there is a solution to prevent reading of the chip BUT it can be erased & reprogrammed again

 

Unfortunately that is the only way to lock it.

 

 

Last Edited: Sat. Feb 3, 2018 - 09:39 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

johnny22 wrote:
i have two projects on Arduino Mega & UNO
We know the Arduino UNO has an ATmega328P.

 

There are two Arduino Mega boards, one has an ATmega1280 and the other an ATmega2560.  Which chip does your Arduino Mega have?

johnny22 wrote:
So you think the guy from MIKROELEKTRONIKA doesnt know about the AVR Flash program really ?
I think he gave you bad information. ( I could not write what I actually think because they would censor my post) 

johnny22 wrote:
i will tell you what modes i have in AVR FLASH
The datasheets will provide us that information once we have all the correct chip part numbers to look up.

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

"Make XMEGA Great Again!"  - Greg Muth

Last Edited: Sat. Feb 3, 2018 - 09:41 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

im sorry but the datasheet doesnt cover the programmer im talking about & that is my issue

i have bought it because i didnt find a clear slolution of setting lock bits in the datasheet 

Last Edited: Sat. Feb 3, 2018 - 09:55 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But the datasheet tells you what lock bits exist, and defines what they do - that has nothing to do with the programmer.

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

There are two Arduino Mega boards, one has an ATmega1280 and the other an ATmega2560.  Which chip does your Arduino Mega have?

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

"Make XMEGA Great Again!"  - Greg Muth

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

johnny22 wrote:
im sorry but the datasheet doesnt cover the programmer im talking about

Yes, we understand that.

 

If Mikroelektronika's programming hardware and software does not expose all the possibilities the AVR has then you need to talk to Mikroelektronika about that.

 

There are relatively few Mikroelektronika users here. Not all of us hold them in the highest of esteems. This thread changes nothing in this respect as far as I am concerned.

 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

I would say that Mode 3 is the one to use for the Arduino UNO and its ATmega328P.

 

 

 

 

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

"Make XMEGA Great Again!"  - Greg Muth

Last Edited: Sat. Feb 3, 2018 - 10:36 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i use ATmega2560 

 

do you think trying to use lock bits of Mikroelektronika will distroy my ship or i can erase it again?

i will test it on Arduino Uno

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

JohanEkdahl wrote:
There are relatively few Mikroelektronika users here.
What Johan said is true, we cannot answer for something we have never used.

 

I can say this, the programming interface has an Erase button, this should erase the chip and will also erase the lock bits to "1".  Read paragraph 31.1 above.

 

EDIT: Mode 3 is also good for the Arduino Mega and its ATmega2560

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

"Make XMEGA Great Again!"  - Greg Muth

Last Edited: Sat. Feb 3, 2018 - 10:54 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

johnny22 wrote:
lock bits of Mikroelektronika

The lock bits are not Mikroelektronika's - they are part of the AVR hardware.

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

JohanEkdahl wrote:
Not all of us hold them in the highest of esteems. This thread changes nothing in this respect as far as I am concerned.
I'm not sure any "blame" would be Microelecronica's in this case. OP seems to be struggling with English and understanding datasheets and basic lockbit concepts.

johnny22 wrote:
do you think trying to use lock bits of Mikroelektronika will distroy my ship or i can erase it again?
If you set the lockbits, you can not read or write to the flash anymore. Nothing wil be destroyed. If you want to re-use the chip you have to do a full flash erase. This will also erase the lock bits. After this you can re-program your AVR and then set the lockbits after that if you wish.

 

awneil wrote:
The lock bits are not Mikroelektronika's - they are part of the AVR hardware.
And in the datasheet of your ATmega2560 it is described how they work.

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com

Last Edited: Sat. Feb 3, 2018 - 11:35 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

johnny22 wrote:
a friend suggested as it is a good solution

So have you asked your "friend" for advice/help on this?

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

so what they mean by further programming is disabled if i can erase the chip?

 

Last Edited: Sun. Feb 4, 2018 - 08:31 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

johnny22 wrote:

so what they mean by further programming is disabled if i can erase the chip?

 

 

I suspect that was is happening here is a language problem.

 

With the lock bits set it is true that you cannot program the chip anymore (or read it). To program the chip again you have to do a chip erase which makes the chip look like a new chip.

"This forum helps those that help themselves."

"If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

 

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

They mean that you can't incrementally program it; you can't change (parts of) what's already programmed.

 

You have to erase it before you can do any more programming operations.

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

Brian Fairchild wrote:
I suspect that was is happening here is a language problem.

Yes;  hence the suggestion that johnny22 should discuss with his "friend" - face-to-face communication is so much easier.

 

Maybe johnny22 also has local colleagues / mentors / teachers who could help ... ?

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

OK, I was curious enough to install the program and see what's what.

 

If you press 'options' on the main screen then you get this. It's quite clear from this window that you can program the fuses and lock bits as you want to.

 

So this is all down to a language/semantics issue.

 

"This forum helps those that help themselves."

"If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

 

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

ok thx 

i didnt have time to try this 

i will do it & let you know

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

لthx GUys

 

it works & i can lock &  erase the chip & reprogram it 

 

thx for your Help