arduino / ArduinoCore-mbed

330 stars 192 forks source link

Can't program via Arduino IDE the Pi Pico in linux #573

Open Parsec86 opened 1 year ago

Parsec86 commented 1 year ago

Trying to build & upload the blinky example in Ubuntu 20.04.5 LTS, kernel 5.4.0-113-generic x64. Only partial success.

I connected the Raspberry PI Pico board keeping pressed the Bootload button. I do not have automount feature enabled. Here are the outputs of "sudo lsblk -o NAME,TYPE,FSTYPE,LABEL,UUID,MOUNTPOINT,SIZE,VENDOR,MODEL,SERIAL" and "lsusb" commands:

lsblk: sdd disk 128M RPI RP2 E0C912952D5 └─sdd1 part vfat RPI-RP2 000B-33DC 128M

lsusb: Bus 002 Device 114: ID 2e8a:00c0

I started Arduino IDE 1.8.13 (I previously installed the "Arduino Mbed OS RP2040 Boards" and selected the Raspberry PI Pico as target board), opened the blinky example, pressed the upload button. Compilation was fine but the upload stage failed:

... /home/lubu64/.arduino15/packages/arduino/tools/rp2040tools/1.0.6/rp2040load -v -D /tmp/arduino_build_932857/Blink.ino.elf rp2040load 1.0.6 - compiled with go1.16.2 ..................... An error occurred while uploading the sketch

So I mounted the Pico board in /media/RPI-RP2 and copied in it the binary (Blink.ino.uf2) found in temp directory /tmp/arduino_build_932857 (from IDE log).

The board rebooted automatically and the led started to blink. It worked, but so the Integrated Development Environment is not so integrated...

After that, I restarted the Arduino IDE. The serial port "/dev/ttyACM0 (Raspberry PI Pico)" showed up in Tools menu and menu entry Tools->Get Board Info worked as expected so I tried again to upload the sketch. No success, same error as before.

I tried (almost) any combination of settings, starting the board with/without the bootload button pressed, mounting or not the Pico in /media/RPI-RP2 as root or as myself, adding/removing the "upload_port=/media/RPI-RP2" (or "upload_port=/dev/ttyACM0") row in Arduino IDE preferences.txt, as suggested in Upload port required, restarting IDE countless times, etc. No success. The IDE produces a working binary but it seems impossible to upload it to the board inside the IDE.

Any suggestions welcome!

facchinm commented 1 year ago

Hi @Parsec86 , you are probably missing the udev rules https://github.com/arduino/ArduinoCore-mbed/blob/master/post_install.sh that should install automatically with the core. We don't use the drag and drop for uploading but the raw usb interface via picotool , so all the automount stuff should not be a problem. Try running the script as root, detach and reattach the board and you should be up and running.

gpb01 commented 1 month ago

Hi @facchinm, there is a small problem that, in my case, concerns Arduino GIGA, but is still related to the "post_install.sh" script.

This script is also called on macOS, but ... on macOS ... there is NO "udev" ... it would be the case to modify the script to check the environment in which it is executed to behave accordingly. ;-)

TIA, Guglielmo