2
\$\begingroup\$

This is my first time trying to program an Atmega32u4. I made a PCB with the following schematic:

schem

Now I've soldered all the parts onto the PCB, and I've plugged a micro usb cable from my computer into J1.

I assumed that when I pressed down SW1, the bootloader would activate and and the device would register as a serial device on my computer, so that I can program it using avrdude.

However, when I pressed the reset button, I couldn't find which port it's communicating over. I tried the command avrdude -p m32u4 -P USB -c avr109 to intialise it, just in case that port happened to work, but the output was:

avrdude: ser_open(): can't open device "USB": No such file or directory

avrdude done.  Thank you.

So what's the issue here? Is there something wrong with my schematic, or with my software approach? Again, I'm a complete beginner to this, so any information at all is useful.

EDIT: I plugged it into a different USB port on my computer and now lsusb lists: "Bus 001 Device 020: ID 03eb:2ff4 Atmel Corp. atmega32u4 DFU bootloader", however when I try to use dfu-programmer (as has been suggesteed), this happens:

j4cob-antergos :: /sys/class/tty » sudo dfu-programmer atmega32u4 dump --debug 4        5 ↵
     target: atmega32u4
    chip_id: 0x2ff4
  vendor_id: 0x03eb
    command: dump
      quiet: false
      debug: 4
device_type: AVR
------ command specific below ------

0%                            100%  Reading 0x7000 bytes...
[ X  ERROR

EDIT 2: I tried to use avrdude instead again, and this happened:

j4cob-antergos :: ~ » sudo avrdude -p m32u4 -P usb -c flip1                                              1 ↵

avrdude: Warning: Failed to read USB device string 1: Input/output error
avrdude: Warning: Failed to read USB device string 2: Input/output error
avrdude: Warning: Failed to read USB device string 3: Input/output error
avrdude: Warning: USB bDeviceClass = 255 (expected 254)
avrdude: Error: Failed to reset DFU state: Input/output error
avrdude: AVR device initialized and ready to accept instructions

Reading |                                                    | 0% 0.00savrdude: Error: DFU_DNLOAD failed: Input/output error
avrdude: Error: Failed to get DFU status: Input/output error
avrdude: error reading signature data for part "ATmega32U4", rc=-1
avrdude: error reading signature data, rc=-1

avrdude done.  Thank you.

This is looking more hopeful, but at this point it seems like my schematic just doesn't work. Any thoughts?

\$\endgroup\$
1

2 Answers 2

2
\$\begingroup\$

From the datasheet:

enter image description here

Your schematic doesn't have a bypass capacitor on VCC. Adding one might help. To maximize its effectiveness, solder it on as close to a pair of VCC/GND pins on the chip as possible. Looking at your schematic, the best bet would be pins 14 and 15.

\$\endgroup\$
2
  • \$\begingroup\$ I'll give it a go, thanks for looking into that! :) \$\endgroup\$ Commented Feb 28, 2019 at 19:49
  • \$\begingroup\$ This kind of worked, I'm getting a different issue now. \$\endgroup\$ Commented Mar 1, 2019 at 16:51
2
\$\begingroup\$

You first need to program a USB bootloader onto the microcontroller using the ISP interface and a programmer. Only then will it understand how to load programs over USB. AVRs don't ship with a bootloader, they only have hardware support for bootloaders. If you have an ISP programmer (e.g. AVIRSPmkII, AVR Dragon, AVR ICE, etc) and wire a header up to the appropriate pins of the AVR, you could, in principle, burn the bootloader Arduino uses for the Leonardo onto your board.

I stand corrected. Excerpt from here.

The 8bits mega AVR with USB interface devices are factory configured with a USB bootloader located in the on-chip flash boot section of the controller.

\$\endgroup\$
5
  • \$\begingroup\$ Is that true even with the Atmega32u4? I read somewhere that it shipped with some kind of bootloader. \$\endgroup\$ Commented Feb 28, 2019 at 18:40
  • \$\begingroup\$ as far as I know it is true of all 8-bit AVRs, but hey I could be wrong. \$\endgroup\$
    – vicatcu
    Commented Feb 28, 2019 at 18:41
  • \$\begingroup\$ ww1.microchip.com/downloads/en/DeviceDoc/… In the features list on the title page of this datasheet it says "Parts using external XTAL clock are pre-programed with a default USB bootloader". I could be misunderstanding this, though. \$\endgroup\$ Commented Feb 28, 2019 at 18:44
  • \$\begingroup\$ @JacobGarby Updated answer, you're quite right... maybe avrdude doesn't support it out of the box, dunno \$\endgroup\$
    – vicatcu
    Commented Feb 28, 2019 at 18:46
  • \$\begingroup\$ I've updated my question. Does the new information provide any sort of new answer? :) \$\endgroup\$ Commented Feb 28, 2019 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.