Problem uploading binary to nano328P

I’m having problems uploading my binary. Uploading works on the Arduino IDE I have installed on my laptop running Ubuntu 20.04. I have tried changing the upload speed to 57600, as has been suggested on a previous post, but this hasn’t worked. It seems to be auto-detecting the wrong port for some reason.

When I scan the available ports the following is returned. I select the 4th option
— Available ports:
— 1: /dev/ttyACM0 ‘DW5560 - Dell Wireless 5560 HSPA+ Mobile Broadband Mini-Card Modem’
— 2: /dev/ttyACM1 ‘DW5560 - Dell Wireless 5560 HSPA+ Mobile Broadband Mini-Card Data Modem’
— 3: /dev/ttyACM2 ‘DW5560 - Dell Wireless 5560 HSPA+ Mobile Broadband Mini-Card GPS Port’
— 4: /dev/ttyUSB0 ‘USB2.0-Serial’

Here is the error

    Processing uno (platform: atmelavr; board: uno; framework: arduino)
------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (3.2.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES: 
 - framework-arduino-avr 5.1.0 
 - tool-avrdude 1.60300.200527 (6.3.0) 
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio/build/uno/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  12.6% (used 258 bytes from 2048 bytes)
Flash: [=         ]  12.0% (used 3880 bytes from 32256 bytes)
Configuring upload protocol...
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port...
Auto-detected: /dev/ttyACM0
Uploading .pio/build/uno/firmware.hex
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x20

avrdude done.  Thank you.

*** [upload] Error 1
======================================== [FAILED] Took 2.31 seconds ========================================
The terminal process "platformio 'run', '--target', 'upload'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

My platform.ini file

[env:nanoatmega328]
platform = atmelavr
board = nanoatmega328
framework = arduino
upload_speed = 57600

So it’s detected the wrong upload port for you if you say /dev/ttyUSB0 is right.

See docs and docs.

That is correct. The port Platformio uses does not correspond with USB port scan, which is indicating /dev/ttyUSB0 ‘USB2.0-Serial’ and which I have selected by entering 4 on the command line

If you have multiple serial devices attached to your computer (which seems to be the case if you have /dev/ttyACM0 then try to add

upload_port = /dev/ttyUSB0 
monitor_port = /dev/ttyUSB0 

to the platformio.ini to override the auto-selection, per above.

1 Like