[SOLVED] Arduino not flashing with linux

Hi, I have two arduinos. One arduino Uno and one arduino Mega the Uno is short of genuine (it gets recognized as such at least and the other one is a clone) (https://grobotronics.com/compatible-mega2560-pro-ch340.html). I have a very slow PC so I have to use Linux or I will have a miserable day. Both flash fine on windows. The Uno still flashes normally on Linux but the other one doesn’t (with all the cables that I have tried). What can I do here is the error code I get.

` *  Executing task: platformio run --target upload 

Processing megaatmega2560 (platform: atmelavr; board: megaatmega2560; framework: arduino)
----------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: (link dedicated to post the post)
PLATFORM: Atmel AVR (5.0.0) > Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)
HARDWARE: ATMEGA2560 16MHz, 8KB RAM, 248KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES: 
 - framework-arduino-avr @ 5.2.0 
 - tool-avrdude @ 1.60300.200527 (6.3.0) 
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 8 compatible libraries
Scanning dependencies...
Dependency Graph
|-- Wire @ 1.0
|-- Keypad @ 3.1.1
|-- LiquidCrystal_I2C @ 1.1.4
|-- DFRobotDFPlayerMini @ 1.0.6
Building in release mode
Checking size .pio/build/megaatmega2560/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [====      ]  35.2% (used 2881 bytes from 8192 bytes)
Flash: [=         ]   7.4% (used 18802 bytes from 253952 bytes)
Configuring upload protocol...
AVAILABLE: wiring
CURRENT: upload_protocol = wiring
Looking for upload port...
Auto-detected: /dev/ttyS0
Uploading .pio/build/megaatmega2560/firmware.hex
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude done.  Thank you.

*** [upload] Error 1`

/dev/ttyS0 normally is the device for the first UART serial port on x86 and x86_64 architectures. As I do not believe that you connected your device with something like that :wink:
grafik
to your PC, I suppose that you look for the real device that is created when the device is plugged in and add this device name as upload_port to your platformio.ini

  1. Plug out the Arduino.
  2. Open a new terminal.
  3. Execute sudo dmesg -w
  4. Enter your sudo password as needed, press enter twice
  5. Plug in the Arduino.

What new logs appeared?

This is the output that I get after the second enter press and after I plug in the arduino

[ 222.435682] usb 4-1: new full-speed USB device number 3 using uhci_hcd
[ 222.625345] usb 4-1: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.64
[ 222.625354] usb 4-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 222.625358] usb 4-1: Product: USB Serial
[ 222.628425] ch341 4-1:1.0: ch341-uart converter detected
[ 222.635293] usb 4-1: ch341-uart converter now attached to ttyUSB0
[ 223.218015] input: BRLTTY 6.4 Linux Screen Driver Keyboard as /devices/virtual/input/input46
[ 223.225384] usb 4-1: usbfs: interface 0 claimed by ch341 while ‘brltty’ sets config #1
[ 223.227811] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[ 223.227840] ch341 4-1:1.0: device disconnected

I should also say that i am a huge noob with linux. I am only using it out of nececity.
So the log dump is pretty alien to me…

The BRLTTY program is stealing your serial port. It’s a known trouble maker.

systemctl stop brltty-udev.service
sudo systemctl mask brltty-udev.service
systemctl stop brltty.service
systemctl disable brltty.service

https://www.reddit.com/r/pop_os/comments/uf54bi/how_to_remove_or_disable_brltty/

Do that and it should keep your /dev/ttyUSB0 alive, which is the serial port that should then be auto-detected. (After replugging the device)

Yep that did it thank you so much!

1 Like