Society of Robots - Robot Forum
General Misc => Misc => Topic started by: Trumpkin on October 10, 2009, 11:58:03 AM
-
When going through Admin's bootloader tutorial, when I use the bootloader the first time it works just fine, but when I try to upload another program it just says this forever "COM 1 at 9600 Baud: " with the spinning /.
My guess is that somehow uploading a program to my microcontroller wipes the bootloader off of it. Any Ideas why this would happen and what I can do to fix it?
-
hmmm, and you power off the mcu before trying to use the bootloader again?
And nope, its impossible to overwrite the bootloader unless your program does jump to memory commands (impossible to do by accident)
-
Maybe I didn't write the bootloader correctly? I just flashed it normally with AVRDUDE.
-
edit: I said something stupid, again . . . :-X
-
Found out it looks like Pomprocker had the same problem over at AVR Freaks http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=62534&highlight= (http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=62534&highlight=) (scroll down about two thirds of the page) I think I should be able to figure it out from there.
-
Still only works once, here is the command I'm using with AVRDUDE:
avrdude -c ponyser -p m32 -P /dev/ttyS0 -e -U lock:w:0x3f:m -U flash:w:BOOTLOAD.hex -U lock:w:0x0f:m -U lfuse:w:0xff:m -U hfuse:w:0x9e:m
I'm using an Atmega32 with a 16mhz external crystal.
-
This is just a top of my head theory as I'm not very familiar with AVRDUDE commands, but . . . I see what looks like two lockbit fuse settings:
lock:w:0x3f:m
lock:w:0x0f:m
Are you perhaps locking future programming? Why not use 0xff to turn off all lock bits? Shouldn't there just be one lockbit setting?
ps - apologies about my previous post, I wasn't thinking at the time . . .
-
From what I've read I thought "lock:w:0x3f:m" would unlock the bootloader section of the flash memory and then "lock:w:0x0f:m" would re-lock it.
Why not use 0xff to turn off all lock bits?
Wouldn't that just set everything to 1 (which is default).
EDIT:
Looking a bit more closely I see that 0x3f will only program the two unused bits, 7 and 6.
-
Ok, makes sense on why you are using it twice.
Is there any reason you need to lock memory? What did you intend to lock (LPM, SPM, app section, boot section, etc)?
According to AVR Studio, 0xff is the setting for unlocking everything. 0xCF is what I use to lock the boot section entirely.
-
Just a quick follow up post. I did get this working a while ago, it turned out I just needed to power the ft232rl and ATmega32 from different power sources. I powered the ft232rl from USB to keep the software happy (so it doesn't say that there isn't a COM1 port) while I reset the ATmega32 by disconnecting and then reconnecting the battery. It now works more than one time as long as I reset the ATmega32 before I program. I guess this might have been a lot easier if I had mentioned that I was using a usb to uart bridge.
-
haha yea I had that bootloader problem when I was developing the original Axon. Took me 2 additional prototypes to get it to work right during power resets.