Go Down

Topic: [Help :)] WinAVR and the Lock | Unlock bits? (Read 4432 times) previous topic - next topic

TeamMCS

Hey guys,

I'm trying to setup a serial of AtMega8's but I've run into some trouble.

I've successfully programmed the minimal Arduino bootloader from TodBott . I managed to setup the fuses and everything is working correctly with the exception of programming through UART. I can happily use my STK500 clone through WinAVR (doesn't work through the Arduino IDE for some reason), I've even uploaded a blink hex to make sure it's working correctly - no problems.

...but I can't set the lock & unlock bits per the boards.txt file:

Quote

##############################################################

atmega8noxtal.name=ATmega8-noxtal @8MHz

atmega8noxtal.upload.protocol=stk500
atmega8noxtal.upload.maximum_size=7168
atmega8noxtal.upload.speed=38400

atmega8noxtal.bootloader.low_fuses=0xdf
atmega8noxtal.bootloader.high_fuses=0xc4
atmega8noxtal.bootloader.path=atmega8_noxtal
atmega8noxtal.bootloader.file=ATmegaBOOT.hex
atmega8noxtal.bootloader.unlock_bits=0x3F
atmega8noxtal.bootloader.lock_bits=0x0F

atmega8noxtal.build.mcu=atmega8
atmega8noxtal.build.f_cpu=8000000L
atmega8noxtal.build.core=arduino


I can't see an option for unlock bits and WinAVR wont verify the lock bits.

I've probably overlooked something - What am I missing guys?

mellis

What error do you get?  

The "unlock" bits are just the value that's written to the lock bits before burning the bootloader.  Then the "lock" bits are written after burning the bootloader.

TeamMCS

That's what I presumed also. AVR Studio let's me specify the lock bits but as there are seperate bits to unlock and lock the bootloader I assumed I would need to add these seperately?


It's very strange, I can write compiled programs via the ISP. Even use Serial.write to dump to UART but I cannot upload to the AtMega8.

It could have been an oversight but I did notice that I actually had to connect at a faster rate than I specified on the AtMega8 "Serial.begin(9200)", infact I had to connect at 19200 on the host.

Could that be related or is that just an oversight. I'm wondering whether the MCU is running at a higher clock rate than it should.

TeamMCS

Any other thoughts on this? It's prooving very frustrating. I've done this many times with other AVRs and it worked without messing with lock bits.

mellis


TeamMCS

Hmm, so why wouldn't the MCU respond to programming via UART?

borref

#6
Oct 27, 2009, 09:04 am Last Edit: Oct 27, 2009, 09:08 am by borref Reason: 1
Quote
I've successfully programmed the minimal Arduino bootloader from TodBott. I managed to setup the fuses and everything is working correctly with the exception of programming through UART.

As long as upload through UART is not working, you don't really know if the bootloader is ok or not. Some issues to check:

1. The bootloader must be compiled for the crystal/osscillator used (the F_CPU define). If you only have a precompiled ".hex" file you must use the crystal/osscillator specified for the bootloader.
2. The upload speed will be hardcoded within the bootloader (you need to know what this speed is). Also this will only be ok if you get item "1" right.
3. You need to program the fuses to match your required crystal/osscillator (otherwise "1" and "2" will be wrong).
4. You need to know how to invoke the bootloader (auto-reset or manual-reset).

When the above is ok you should look at the output from an Arduino/avrdude upload session for errors/hints on other issues.

TeamMCS

I am actually simple reusing the guide from Todbotts site.

The AtMega 8 (and bootloader above) is supposed to use the internal 8mhz oscillator. I believe he changed the UART to transfer at 384xxx rather than the slower 19200.

As far as the fuses go, I've litrally copied that from the "boards.txt" file which Toddbott provided.

#4, that's an interesting though. I believe he's set it up for manual programming. I've tried hitting reset prior to uploading (many times) but no joy.

Does anyone know of any vanilla AtMega8 bootloaders which use the internal Oscillator?

Go Up