NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » Bootloader being overwritten

July 07, 2010
by blinky
blinky's Avatar

Hello I bought the NK kit and find the whole learning experience great.

I've now bought a AVRISP Mk2 and have tried loading the 168 bootloader HEX onto a totally blank chip that I bought off the net.

Ive got a breadboard setup to connect everything, and after 6hours of frustration realised that i had mosi and sck wires wrong way round and finally connected the isp to the chip - great.

Read through the datasheet and forums and finally found (what I think are ) the correct settings. Fuses. BOOTSZ=boot flash size=1024 starting at address=$1C00... BOOTRTS=checked... SPIEN=checked... WDTON=checked... Brownout detection disabled... SUT_CKSEL=Ext crystal osc 8.0mhz - PWRDWN/RESET:16K CK/14...

LockBits. LB=No memory lock... BLB0=no lock in applications... BLB1=LPM & SPM prohibited in Boot Section...

I plugged it into the NK breadboard and tested it by loading the clock app hex into it - it worked fine ( NOW THE WORLD!)

Then I tried loading a different app into it and it stopped working?

It doesn't seem to protect the bootloader even though I put the lockbits on protecting it(BLB1=LPM & SPM prohibited in Boot Section).. So I have to reload the bootloader each time, before I load my program on? Anyone else had this problem - or pointers to what I'm doing wrong would be great

Thanks Andy

July 07, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Blinky,

Your descriptions of what should be happening seem right. Can you post what you are actually setting the individual bits to, just to make sure they match up with the description of what should be happening.

Did you try loading a program that you know fits in the space allotted to the program space (initialload perhaps). Since the bootloader is at the end of the flash address space, it should not be clobber itself with a small enough program even if it is unprotected by the lock bits.

Just to make sure, did you double check that the switch is in programming mode when you attempt to load the program the second time.

Let us know if you find the issue.


July 08, 2010
by blinky
blinky's Avatar

Hi Humberto I've managed to load the 168 and 328 bootloader hex into the repective chips - all the settings I described were exactly the same as described above. I can now load nerdkit projects up over and over no problem.

The only change I made to the process of flashing the respective bootloaders (168 & 328) onto the chips was to load the bootloader hex file from a local machine - not a network drive machine-and this seems to have sorted it !!

Wierdly - the first chip I used was corrupted (don't now why) so when I reattached it to the ISP to try and flash it again, the settings on the 'Fuses' and 'LockBit' tabs would change randomly each time I toggled between the two tabs.

Anyway - the problem seems sorted - I wish I could say it was something definate as this seems a bit of a woolly explination for a fix.

But thanks for your response


Post a Reply

Please log in to post a reply.

Did you know that reading a double floating point variable with scanf requires "%lf" for "long float"? Learn more...