Can't program Mega or Atmega4808 in Linux, but Uno works

It's been a couple years since I've used the arduino IDE, I'm having trouble getting things to program in Linux. Windows works fine with everything.

I have an Uno, a Mega2560, and even a ATMEGA4808 I program with an Atmel ICE programmer. They all work fine in Windows, but I can only get the Uno to work in Linux. The Uno shows up a port, and I can get board info. The Mega doesn't see a port, and obviously without that, you can't get info. I'm not able to use the Atmel ICE to program either. When I started this process, the Uno wouldn't program either, but it magically started working on its own.

The one I'm dealing with right now is the Atmel ICE programmer. I get the following error:

avrdude: Version 7.1-arduino.1
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is /home/poduck/.arduino15/packages/MegaCoreX/hardware/megaavr/1.1.2/avrdude.conf
         User configuration file is /home/poduck/.avrduderc
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : atmelice_updi
avrdude usbhid_open() warning: USB device with VID: 0x03eb and PID: 0x2141 not found
avrdude usbdev_open() error: cannot open device: Permission denied
avrdude jtag3_open_common() error: no device found matching VID 0x03eb and PID list: 0x2141
avrdude main() error: unable to open programmer atmelice_updi on port usb

avrdude done.  Thank you.

Failed programming: uploading error: exit status 1

When I check lsusb, it shows the debugger "Bus 003 Device 003: ID 03eb:2141 Atmel Corp. ICE debugger", which shows the correct VID and PID.

With the Mega, I show no serial port for it at all. I see ttys0, which is always there, so I assume that's going to be the serial port on my computer, and selecting it does nothing. It just times out.

I was originally thinking that the Mega might be bad, or need a new bootloader, but when I checked it in Windows, everything worked fine. The same with the Atmel ICE programmer.

I have added my user to the dialout and tty groups, and I have rebooted. I'm not sure what else to check at this point.

Hi @poduck.

I'm going to ask you to run the dmesg command from the command line and post the output.


:exclamation: This procedure is not intended to solve the problem. The purpose is to gather more information.


  1. Open a terminal.
  2. Disconnect the USB cable of the Mega board from your computer.
  3. Connect the Mega board to your computer with a USB cable.
  4. Type this command:
    sudo dmesg | tail --lines=20
    
  5. Press the Enter key
  6. If prompted for it, enter your Linux account password and press the Enter key.
  7. Click and drag the mouse to select all the output in the terminal window.
  8. Press the Ctrl+Shift+C keyboard shortcut.
    This will copy the selected text to the clipboard.
  9. Open a forum reply here by clicking the "Reply" button.
  10. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the output is correctly formatted.
    Code block icon on toolbar
  11. Press the Ctrl+V keyboard shortcut.
    This will paste the output into the code block.
  12. Move the cursor outside of the code block markup before you add any additional text to your reply.
  13. Click the "Reply" button to post the output.

Please let me know if you have any questions or problems while following those instructions.

In order for the Arduino development software to upload to the Arduino board, your Linux user account must have write permission for that device.

Standard user accounts don't have this permission by default. This "Permission denied" error can occur when you attempt an upload without the necessary permissions. So it is necessary to configure your system to allow the upload. This is done by creating a special file.

I don't own an ATMEL ICE so I can't verify this, but I would guess this udev rule would do the trick:

While I am investigating that link, here is the dmesg output:

[   21.748567] ata9: limiting SATA link speed to 1.5 Gbps
[   22.832991] ata9: SATA link down (SStatus 0 SControl 310)
[   23.070164] ata9: limiting SATA link speed to 1.5 Gbps
[   23.473397] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
[   23.475960] Bridge firewalling registered
[   23.785037] ata9: SATA link down (SStatus 0 SControl 310)
[   25.534034] ata9: limiting SATA link speed to 1.5 Gbps
[   26.269056] ata9: SATA link down (SStatus 0 SControl 310)
[   28.172730] ata9: limiting SATA link speed to 1.5 Gbps
[   28.901158] ata9: SATA link down (SStatus 0 SControl 310)
[   29.098385] ata9: limiting SATA link speed to 1.5 Gbps
[   29.809124] ata9: SATA link down (SStatus 0 SControl 310)
[   30.269243] hfsplus: Filesystem is marked locked, mounting read-only.
[   30.602562] rfkill: input handler disabled
[   32.268509] ata9: limiting SATA link speed to 1.5 Gbps
[   32.993181] ata9: SATA link down (SStatus 0 SControl 310)
[   33.042113] ata9: limiting SATA link speed to 1.5 Gbps
[   33.769308] ata9: SATA link down (SStatus 0 SControl 310)
[  318.578532] CE: hpet increased min_delta_ns to 20115 nsec
[  645.037839] logitech-hidpp-device 0003:046D:1028.0008: HID++ 1.0 device connected.

Okay, that worked for the Atmel ICE. I can now program the 4808. Still can't see the serial port for the Mega though, and I don't see anything in that dmesg stuff to suggest it's being seen there.

Yay! I'm glad at least some of your troubles are now resolved.

I concur. I was interested in learning whether the operating system was recognizing the device even at the lowest level and it seems that it is not.

Make sure the USB cable is completely plugged into both the Arduino board and the PC.

If that doesn't help, you may have a damaged/defective or charge-only USB cable. Try a different cable.

Either of the above can result in the power connections being made (and thus LEDs lit on the board), but no data connections (and thus no port for the board).

Does the Mega show up in lsusb?

I would run a slightly modified version of dmesg.

  1. Disconnect the board.
  2. Run dmesg -w; the command will not close.
  3. Connect the board and observe the changes.
  4. <CTRL>C to close dmesg.

Further you can do a case insensitive grep on the output of the standard dmesg and check for BRLTTY.

Try "dmesg |grep usb", scroll up if needed.

Okay, I figured it out. When I did sudo dmesg -w;, and plugged it in, I got:

[55919.727361] usb 1-1: new full-speed USB device number 3 using uhci_hcd
[55919.907478] usb 1-1: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.64
[55919.907490] usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[55919.907494] usb 1-1: Product: USB Serial
[55919.909554] ch341 1-1:1.0: ch341-uart converter detected
[55919.916636] usb 1-1: ch341-uart converter now attached to ttyUSB0
[55920.537495] input: BRLTTY 6.4 Linux Screen Driver Keyboard as /devices/virtual/input/input51
[55920.544464] usb 1-1: usbfs: interface 0 claimed by ch341 while 'brltty' sets config #1
[55920.546783] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[55920.546823] ch341 1-1:1.0: device disconnected

It showed that it assigned it to ttyUSB0, but then disconnected it, because brltty conflicts with it. Looking that up, it's some service for brail devices. Since I don't use a brail device, I stopped the brltty service with sudo systemctl mask brltty.service && sudo systemctl stop brltty.service, and now it shows up and works. Because I have no need for brail services, I then disabled it with sudo systemctl disable brltty.service

Stupid blind people messing up my stuff. :wink:

Anyway, thanks for helping me get there.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.