Author Topic: Atmega32u4 bootloaders, HWB pin, USB programming  (Read 18619 times)

0 Members and 1 Guest are viewing this topic.

Offline yeah_indeedTopic starter

  • Contributor
  • Posts: 15
  • Country: nl
Atmega32u4 bootloaders, HWB pin, USB programming
« on: December 10, 2016, 06:08:10 pm »
Hello everyone,

At the moment I am working on a project with the Atmega32u4. Unfortunately I am a bit confused about the programming steps and necessary voltages at certain pins. I am planning to have an ISP connector on the board to which I connect my AVR programmer to flash the hex file. But does that mean I do not need a bootloader? Also, I read that for entering the bootloader it is necessary to pull down the /HWB pin, do I have to connect the /HWB pin always to ground or have a pull up and a button to ground on that pin? Same question about /RESET. Last but not least, the Atmega32u4 supports USB natively and also programming over USB. Again; do I need a bootloader for that and could I flash that via ISP?

This is all a bit new so I hope someone can help me clear up my confusion. Thank you!
 

Offline Skashkash

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
Re: Atmega32u4 bootloaders, HWB pin, USB programming
« Reply #1 on: December 10, 2016, 06:29:51 pm »
Hi,

    The 32u4 ships from the factory with the DFU USB bootloader already programmed into the top pages of flash memory. The fuses are also programmed to run the USB bootloader when the HWB button is grounded at power up or reset.  Be aware that you must have the correct frequency crystal connected to use the USB boot loader.

     You can always use the ISP connector to program the 32u4 with or without the bootloader code on the chip.   But if you erase or otherwise overwrite that atmel bootloader code,  then that ability is gone. You then need to always use ISP to program the chip (unless you re-program a bootloader into the chip via isp).

 Be sure to read up on the function of the fuses in the datasheet.

 Also note, finding a .hex file of the atmel usb bootloader to restore the chip to the way it came from the factory might be difficult (it used to be).
 


   
 
The following users thanked this post: I wanted a rude username

Offline yeah_indeedTopic starter

  • Contributor
  • Posts: 15
  • Country: nl
Re: Atmega32u4 bootloaders, HWB pin, USB programming
« Reply #2 on: December 10, 2016, 06:38:53 pm »
Hi,

    The 32u4 ships from the factory with the DFU USB bootloader already programmed into the top pages of flash memory. The fuses are also programmed to run the USB bootloader when the HWB button is grounded at power up or reset.  Be aware that you must have the correct frequency crystal connected to use the USB boot loader.

     You can always use the ISP connector to program the 32u4 with or without the bootloader code on the chip.   But if you erase or otherwise overwrite that atmel bootloader code,  then that ability is gone. You then need to always use ISP to program the chip (unless you re-program a bootloader into the chip via isp).

 Be sure to read up on the function of the fuses in the datasheet.

 Also note, finding a .hex file of the atmel usb bootloader to restore the chip to the way it came from the factory might be difficult (it used to be).
 

Hello and thank you. So if I pull down or ground /HWB on my board then it's OK, also if I decide to overwrite the bootloader later with ISP?
 

Offline Skashkash

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
Re: Atmega32u4 bootloaders, HWB pin, USB programming
« Reply #3 on: December 10, 2016, 07:20:09 pm »


Hello and thank you. So if I pull down or ground /HWB on my board then it's OK, also if I decide to overwrite the bootloader later with ISP?

If you ground the HWB button with the chip configured from the factory it will always run the USB bootloader on power up / reset. 

  You can change the fuses to disable this default behavior. But unless you are very short on IO pins, it's usually best to leave this pin with just a pull up resistor so you can make use of it later. I tend to try to dual use the pin by connecting a front panel push button to it. This way if the button is held down during power up the bootloader runs, otherwise it's just a regular push button during normal operation.           

If you use ISP to erase the chip you will lose the USB boot loader.  It's up to you and your design if that's an issue. But it can be replaced via ISP if you have a bootloader .hex file from atmel or an alternative bootloader (like lufa).

You tend to want to use ISP during development because it's faster. When you ship the finished product,  the builtin USB bootloader can be darned convenient. 
 

 

Offline yeah_indeedTopic starter

  • Contributor
  • Posts: 15
  • Country: nl
Re: Atmega32u4 bootloaders, HWB pin, USB programming
« Reply #4 on: December 10, 2016, 07:53:19 pm »


Hello and thank you. So if I pull down or ground /HWB on my board then it's OK, also if I decide to overwrite the bootloader later with ISP?

If you ground the HWB button with the chip configured from the factory it will always run the USB bootloader on power up / reset. 

  You can change the fuses to disable this default behavior. But unless you are very short on IO pins, it's usually best to leave this pin with just a pull up resistor so you can make use of it later. I tend to try to dual use the pin by connecting a front panel push button to it. This way if the button is held down during power up the bootloader runs, otherwise it's just a regular push button during normal operation.           

If you use ISP to erase the chip you will lose the USB boot loader.  It's up to you and your design if that's an issue. But it can be replaced via ISP if you have a bootloader .hex file from atmel or an alternative bootloader (like lufa).

You tend to want to use ISP during development because it's faster. When you ship the finished product,  the builtin USB bootloader can be darned convenient. 
 

Thanks again for the nice overview. It's not a problem if I have to continue using ISP, moreover I am completely not short on IO so I'll use a pull up on HWB and connect a grounded push button to it as you mentioned. I see Atmel makes the hex files of the DFU bootloaders available so I can try and work with that if necessary. Thank you for the explanation!
 

Offline stj

  • Super Contributor
  • ***
  • Posts: 2155
  • Country: gb
Re: Atmega32u4 bootloaders, HWB pin, USB programming
« Reply #5 on: December 11, 2016, 01:32:28 am »
Also note, finding a .hex file of the atmel usb bootloader to restore the chip to the way it came from the factory might be difficult (it used to be).
i have that if anybody wants it.
it's on Atmel's site, but took forever to find!
 

Offline yeah_indeedTopic starter

  • Contributor
  • Posts: 15
  • Country: nl
Re: Atmega32u4 bootloaders, HWB pin, USB programming
« Reply #6 on: December 11, 2016, 12:51:53 pm »
Also note, finding a .hex file of the atmel usb bootloader to restore the chip to the way it came from the factory might be difficult (it used to be).
i have that if anybody wants it.
it's on Atmel's site, but took forever to find!

When I searched for it yesterday I found it very easily, where did you search? For reference, it is on the product page of the 32U4 (http://www.atmel.com/devices/atmega32u4.aspx) under the PDF datasheet for the DFU bootloader where it says "Download the USB DFU bootloader hex files here."
 

Offline stj

  • Super Contributor
  • ***
  • Posts: 2155
  • Country: gb
Re: Atmega32u4 bootloaders, HWB pin, USB programming
« Reply #7 on: December 11, 2016, 01:40:51 pm »
i think i looked under applications or something.
 
The following users thanked this post: unixb0y

Offline Skashkash

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
Re: Atmega32u4 bootloaders, HWB pin, USB programming
« Reply #8 on: December 11, 2016, 04:56:13 pm »
The factory restore bootloader .hex files for some of the usb devices used to be very difficult to find. (at least as of a couple of years ago)

 Looks like atmel updated the support pages. That's helpful to know.
 
 

Offline unixb0y

  • Contributor
  • Posts: 10
  • Country: de
Re: Atmega32u4 bootloaders, HWB pin, USB programming
« Reply #9 on: March 04, 2021, 03:53:59 pm »
Sorry for replying to an old thread, but I think it fits in here really well.
So, I am also trying to program a 32U4, but it's 32U4-MU and I think it actually has no bootloader on it. I replaced it on an already existing PCB that is setup in a way that if you press a button and boot the circuit up, the micro goes into programming mode and is instantly visible as such in my operating system.
Since it doesn't behave this way with the new chip, I am pretty sure there is no bootloader on it.
I will need to flash the "ATMega32U4-usbdevice_dfu-1_0_0.hex" right?
 

Offline Skashkash

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
Re: Atmega32u4 bootloaders, HWB pin, USB programming
« Reply #10 on: March 06, 2021, 10:07:57 pm »
Nothing like picking up a five year old thread like it was yesterday.
 
   No idea if Atmel stopped shipping 32u4s with the dfu bootloader installed.

   But you need to confirm a few things on the  board you are putting the new chip onto.

   It's possible the orig board had a custom bootloader installed on it that replaced the factory bootloader.     
   
  Can you confirm the right freq crystal is used?
  Can you confirm the HWB pin is being used to put the chip into bootloader mode?

  If that's the case, and you have access to the ISP pins then yes, you can reflash the chip with the atmel DFU bootloader.
  (and make sure the fuses are correct)   

 


 
 
 
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf