[upload] Error 1 with /dev/rfcomm0

Hello Dude,
I’m a new to PlatformIO, but an experienced user for Arduino. I’d like to upload sketch file to Arduino UNO via bluetooth (HC-05) by using PlatformIO.

I’m able to monitor Arduino with pio device monitor command in PlatformIO CLI as follow:

RPi5@raspberrypi:~/Ard_WS/blink_UNO $ pio device monitor -p /dev/rfcomm0 -b 115200 --echo
--- Terminal on /dev/rfcomm0 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H

16:11:40        Jul 30 2024
..\main_MultiTasking_SonyIR_Fan_6h.cpp
Universal Remote Control (Sony)

When I upload to Arduino, it shows error as follow:

RAM:   [=         ]  12.2% (used 250 bytes from 2048 bytes)
Flash: [=         ]   6.1% (used 1954 bytes from 32256 bytes)
Building .pio/build/uno/firmware.hex
Configuring upload protocol...
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port...
Using manually specified: /dev/rfcomm0
Uploading .pio/build/uno/firmware.hex
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x0d
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x0a
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x31
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x36
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x3a
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x31
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x31
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x3a
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x34
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x30

avrdude done.  Thank you.

*** [upload] Error 1
====================== [FAILED] Took 9.72 seconds ======================

Here is my system setup:

Raspberry Pi 5
RPi5@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Visual Studio Code: 
Version: 1.91.1

PlatformIO:
PlatformIO Core             6.1.15
Python                      3.11.2-final.0
System Type                 linux_aarch64
Platform                    Linux-6.1.73-v8-16k+-aarch64-with-glibc2.36

Am I missing something for uploading process? Any suggestion or advice are welcome.

Best regard,
Aung

The TX/RX pins to Optiboot is not the only thing you need. The UART bootloader Optitboot only runs for a short amount of time after reset. So, if you don’t have a mechanism to also remotely trigger a low pulse on the RESET pin via Bluetooth, it won’t work; The bootloader won’t be entered and so it won’t accept a new firmware via UART.

The USB-to-UART converter on an Uno uses the DTR pin as a GPIO pin for that, capacitively coupled into RST.

(Arduino Uno R3 schematics, see C5)

Another issue would be baud rate. I don’t think the HC-12 changes its output baud rate based on commands from the Bluetooth client. Optiboot on the Uno works on 115200, so you would have to make your sketch work at 115200 baud and permantently save baud = 115200 in the HC-12 as its configuration.

Hello Max,
Thank for suggestion, my problem is solved by adding “upload_speed = 74880” to platformio.ini.

This odd baud rate is gotten from one of the your posts.
baud rate

Thank you.

Aung