Arduino-cli upload problem

Hello, I want to use arduino-cli on Ubuntu 22.04 LTS so that I can automate the build and installation process. I selected the Arduino Nano 33 IoT for this project and I have been able to compile but I get a strange error at upload time about file permission. I am on an Intel 64 machine running Ubuntu 22.04 LTS.

Any advice is appreciated.

WD850X2TB:$ arduino-cli compile --clean --fqbn arduino:samd:nano_33_iot test1
Sketch uses 11412 bytes (4%) of program storage space. Maximum is 262144 bytes.
Global variables use 3560 bytes (10%) of dynamic memory, leaving 29208 bytes for local variables. Maximum is 32768 bytes.

Used platform Version Path
arduino:samd  1.8.14  /home/pedro/snap/arduino-cli/55/.arduino15/packages/arduino/hardware/samd/1.8.14
WD850X2TB:$ sudo arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:samd:nano_33_iot test1
Error during Upload: Can't open sketch: reading files: open /home/pedro/github/my_kicad/mini_keyboard/arduino/test1: permission denied

I've moved your topic to the dedicated Arduino command line tools section of the forum.

No experience withe the CLI so can't help.

Please show the results of:

  1. ls -ld
  2. ls -l test1.*

Why are you using sudo for the upload?

Hello,

I am using sudo because /dev/ttyACM0 is owned by root.

Below are the contents of my "blink" folder that gives the same results on upload.

WD850X2TB:$ cd blink/
WD850X2TB:$ ls -ld
drwxrwxr-x 2 pedro pedro 4096 Sep 16 12:57 .
WD850X2TB:$ ls -la
total 12
drwxrwxr-x 2 pedro pedro 4096 Sep 16 12:57 .
drwxrwxr-x 5 pedro pedro 4096 Sep 16 13:08 ..
-rw-rw-r-- 1 pedro pedro  343 Sep 16 12:57 blink.ino

I should mention that I can use the Arduino IDE to upload the program to the Nano. It runs fine that way.

Is your user not a member of the dialout group? It should be.

sudo usermod -a -G dialout $USER 

Log out and back in for the change to take effect. Then you won't need sudo.

As for the rest... I asked for some basic information and didn't get it. So you can find someone else to help. Good luck.

For some reason I don't seem to be able to join dialout. I think this is not my main problem. I frequently use sudo to access serial ports.

WD850X2TB:$ sudo usermod -a -G dialout $USER
WD850X2TB:$ groups
pedro adm cdrom sudo dip plugdev lpadmin lxd sambashare wireshark

You must log out of your Linux user account, then log back in after adding it to a group.

Do that, then try the arduino-cli upload command again, without sudo. Hopefully this time it will work as expected.

OK, I rebooted and now I don't have to use sudo but I still get the libstdc++.so.6 error. I have installed that library with "sudo apt-get install libstdc++6". Some search results say it requires a 32 bit version of the library but I think I installed the 64 bit arduino-cli.

WD850X2TB:$ arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:samd:nano_33_iot cli_test/
/home/pedro/snap/arduino-cli/55/.arduino15/packages/arduino/tools/bossac/1.7.0-arduino3/bossac: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
Failed uploading: uploading error: exit status 127
WD850X2TB:$ arduino-cli version
arduino-cli  Version: 1.0.4 Commit: a0d912da Date: 2024-08-12T13:42:37Z

You might have both the 32-bit (i386) and 64-bit (x86_64) versions installed

$ ls -lGh $(find /usr/lib -name 'libstdc++.so*')
lrwxrwxrwx 1 root   40 May 13  2023 /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.so -> ../../../x86_64-linux-gnu/libstdc++.so.6
lrwxrwxrwx 1 root   19 May 13  2023 /usr/lib/i386-linux-gnu/libstdc++.so.6 -> libstdc++.so.6.0.30
-rw-r--r-- 1 root 2.2M May 13  2023 /usr/lib/i386-linux-gnu/libstdc++.so.6.0.30
lrwxrwxrwx 1 root   19 Jan 23  2024 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 -> libstdc++.so.6.0.30
-rw-r--r-- 1 root 2.2M May 13  2023 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30

But that's probably not the problem. You're running snap/arduino-cli. One of the ideas behind snaps is that their dependencies are isolated and self-contained, so that they don't interfere with each other or the main system. But in this case, each board is installed after the fact and has its own tooling; when you run that within the same isolated environment, some of its dependencies are missing.

The snap does not appear to be official, and is not one of the documented ways to install the CLI. Remove the snap and try one of those instead.

1 Like

OK, I think you helped me enough to compile and run a program using arduino-cli on Ubuntu Linux 22.04.

I did this to install arduino-cli.

 wget https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh
 ./install.sh 
 sudo cp /home/pedro/Downloads/arduino/bin/arduino-cli /usr/local/bin

Then

WD850X2TB:$ arduino-cli compile --fqbn arduino:samd:nano_33_iot blink/
Sketch uses 11452 bytes (4%) of program storage space. Maximum is 262144 bytes.
Global variables use 3560 bytes (10%) of dynamic memory, leaving 29208 bytes for local variables. Maximum is 32768 bytes.

Used platform Version Path
arduino:samd  1.8.14  /home/pedro/.arduino15/packages/arduino/hardware/samd/1.8.14
WD850X2TB:$ arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:samd:nano_33_iot blink/
Atmel SMART device 0x10010005 found
Device       : ATSAMD21G18A
Chip ID      : 10010005
Version      : v2.0 [Arduino:XYZ] Apr 19 2019 14:38:48
Address      : 8192
Pages        : 3968
Page Size    : 64 bytes
Total Size   : 248KB
Planes       : 1
Lock Regions : 16
Locked       : none
Security     : false
Boot Flash   : true
BOD          : true
BOR          : true
Arduino      : FAST_CHIP_ERASE
Arduino      : FAST_MULTI_PAGE_WRITE
Arduino      : CAN_CHECKSUM_MEMORY_BUFFER
Erase flash
done in 0.858 seconds

Write 11452 bytes to flash (179 pages)
[==============================] 100% (179/179 pages)
done in 0.068 seconds

Verify 11452 bytes of flash with checksum.
Verify successful
done in 0.009 seconds
CPU reset.
New upload port: /dev/ttyACM0 (serial)
WD850X2TB:$ 

Thanks for all the help.

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