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 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.
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.