Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
alexfreed
PostPosted: Jan 14, 2012 - 11:48 PM
Newbie


Joined: May 24, 2004
Posts: 13


I have a board with ATMEGA32U4 and I have written a program for it using generic HID to talk to a PC. So far so good. The device comes from the factory with a bootloader, so I had no trouble flashing my HEX file with the stock Flip tool. My program works fine, but I expected the boot loader to remain protected. Not so - if I reset with the HWB pin jumpered to the ground no boot loader comes to life.
I have JTAG and it works, but I want to be able to preserve the ability to flash via USB. How am I supposed to load a program to keep the boot loader?
Or how do I merge a boot loader with my program?

Thanks.
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Jan 15, 2012 - 09:51 AM
Moderator


Joined: Jan 23, 2004
Posts: 9832
Location: Trondheim, Norway

If you loaded in your application with FLIP, the bootloader should indeed still work if you ground /HWB and reset. Since you have a JTAG, can you check that the HWBE fuse is still set on your device?

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
alexfreed
PostPosted: Jan 16, 2012 - 01:36 AM
Newbie


Joined: May 24, 2004
Posts: 13


Can't be positive as I have re-programmed it a few times.
I tried loading the DFU boot loader from FUFA. Apparently I did something wrong because the device was recognized by Flip and erase OK but refused to program. The HWB fuse was set but no lock bits were. Maybe that was an issue: the whole chip got erased?

Also I have found the Atmel's binary for the boot loader. Should I try that or the one from LUFA? Or it doesn't matter?

Thanks for the reply.
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Jan 16, 2012 - 06:22 AM
Moderator


Joined: Jan 23, 2004
Posts: 9832
Location: Trondheim, Norway

It shouldn't matter which one you use. Odd that FLIP can see it but not program it - are you trying through the GUI, or via the command line?

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
alexfreed
PostPosted: Jan 16, 2012 - 08:10 AM
Newbie


Joined: May 24, 2004
Posts: 13


I was trying the GUI. Same way as worked before with the stock boot loader code. This time I have flashed the BootloaderDFU.hex from 091223.

I'll try again with 111009. What should the fuses be after I flash the boot loader via JTAG?
 
 View user's profile Send private message  
Reply with quote Back to top
abcminiuser
PostPosted: Jan 16, 2012 - 01:01 PM
Moderator


Joined: Jan 23, 2004
Posts: 9832
Location: Trondheim, Norway

Quote:

What should the fuses be after I flash the boot loader via JTAG?


Enable HWBE, and disable BOOTRST. Make sure that the bootloader size is 4KB (2K words) for the LUFA DFU bootloader or (I believe) twice that size for the Atmel DFU bootloader.

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
alexfreed
PostPosted: Jan 16, 2012 - 11:26 PM
Newbie


Joined: May 24, 2004
Posts: 13


I had better luck this time:
compiled DFU loader from 111009 by changing defines in the makefile:
MCU = atmega32u4
FLASH_SIZE_KB = 32

Flashed the hex file and set the BLB1 fuses to protect the boot section. Reset the board and used Flip to flash my code without any trouble.
Another power cycle and my code runs. Jumper the HWB pin to ground and reset again - boot loader runs!

However if I power cycle (the board is powered from USB) instead of asserting a proper /reset signal, my code is executed regardless of the state of the HWB pin. So I guess this was also an issue with the Atmel's own boot loader: I thought all resets were created equal.

Unfortunately I think I have to use JTAG at least once on every board: the fuses are set to divide clock by 8 from the factory and the boot loader can't change the fuses. Currently my application wants to run at full 16 MHz.

Thanks for your help, Dean. And for LUFA.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits