2

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?

Jacob Garby
  • 714
  • 9
  • 18
  • This link http://ww1.microchip.com/downloads/en/devicedoc/doc7618.pdf says that the chip has a factory boot loader and how to use it. People also seem to like https://dfu-programmer.github.io/ . – crj11 Feb 28 '19 at 18:46

2 Answers2

2

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.

vicatcu
  • 22,499
  • 13
  • 79
  • 155
  • Is that true even with the Atmega32u4? I read somewhere that it shipped with some kind of bootloader. – Jacob Garby Feb 28 '19 at 18:40
  • as far as I know it is true of all 8-bit AVRs, but hey I could be wrong. – vicatcu Feb 28 '19 at 18:41
  • http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7766-8-bit-AVR-ATmega16U4-32U4_Datasheet.pdf 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. – Jacob Garby Feb 28 '19 at 18:44
  • @JacobGarby Updated answer, you're quite right... maybe avrdude doesn't support it out of the box, dunno – vicatcu Feb 28 '19 at 18:46
  • I've updated my question. Does the new information provide any sort of new answer? :) – Jacob Garby Feb 28 '19 at 18:58
2

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.

crj11
  • 5,480
  • 1
  • 13
  • 32
  • I'll give it a go, thanks for looking into that! :) – Jacob Garby Feb 28 '19 at 19:49
  • This _kind of_ worked, I'm getting a [different issue](https://electronics.stackexchange.com/questions/425079/issue-with-programming-atmega32u4-lfuse-memory-not-accessible-using-flip?noredirect=1#comment1056688_425079) now. – Jacob Garby Mar 01 '19 at 16:51