Society of Robots - Robot Forum

General Misc => Misc => Topic started by: Trumpkin on October 10, 2009, 11:58:03 AM

Title: Bootloader problem
Post 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?
Title: Re: Bootloader problem
Post by: Admin on October 10, 2009, 12:12:42 PM
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)
Title: Re: Bootloader problem
Post by: Trumpkin on October 10, 2009, 12:15:58 PM
Maybe I didn't write the bootloader correctly? I just flashed it normally with AVRDUDE.
Title: Re: Bootloader problem
Post by: Admin on October 11, 2009, 09:38:22 AM
edit: I said something stupid, again . . . :-X
Title: Re: Bootloader problem
Post by: Trumpkin on October 11, 2009, 12:43:20 PM
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.
Title: Re: Bootloader problem
Post by: Trumpkin on October 15, 2009, 07:05:53 PM
Still only works once, here is the command I'm using with AVRDUDE:
Code: [Select]
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.
Title: Re: Bootloader problem
Post by: Admin on October 15, 2009, 07:52:23 PM
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 . . .
Title: Re: Bootloader problem
Post by: Trumpkin on October 16, 2009, 02:32:18 PM
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.
Quote
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.
Title: Re: Bootloader problem
Post by: Admin on October 16, 2009, 02:47:19 PM
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.
Title: Re: Bootloader problem
Post by: Trumpkin on December 28, 2009, 08:38:31 PM
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.
Title: Re: Bootloader problem
Post by: Admin on January 05, 2010, 12:41:43 AM
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.