earlephilhower / arduino-pico

Raspberry Pi Pico Arduino core, for all RP2040 and RP2350 boards
GNU Lesser General Public License v2.1
1.99k stars 412 forks source link

Arduino MBED RP2040 udev rules are insufficient for SparkFun RP2350 board #2438

Closed znmeb closed 2 weeks ago

znmeb commented 2 weeks ago

I'm testing a SparkFun Pro Micro RP2350 board on Fedora Linux 40. The install sequence is as follows:

  1. Install Arduino CLI.
  2. Install the old Arduino MBED RP2040 core: arduino-cli core install arduino:mbed_rp2040. This says
    You might need to configure permissions for uploading.
    To do so, run the following command from the terminal:
    sudo "/var/home/znmeb/.arduino15/packages/arduino/hardware/mbed_rp2040/4.1.5/post_install.sh"
  1. Do the post-install. This creates the udev rule file
    ❯ more /etc/udev/rules.d/60-arduino-mbed.rules

    # Arduino Mbed bootloader mode udev rules

    SUBSYSTEMS=="usb", ATTRS{idVendor}=="2e8a", MODE:="0666"
    SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", MODE:="0666"
    SUBSYSTEMS=="usb", ATTRS{idVendor}=="1fc9", MODE:="0666"
    SUBSYSTEMS=="usb", ATTRS{idVendor}=="0525", MODE:="0666"
  1. Put the board in BOOTSEL mode and run the PSRAMTest test sketch:
    ❯ source ./sparkfun_promicrorp2350.fqbn
    FQBN: rp2040:rp2040:sparkfun_promicrorp2350
    ❯ ./PSRAMTest.sh 2>&1 | tee PSRAMTest.log
    Compiling
    Sketch uses 57908 bytes (0%) of program storage space. Maximum is 16769024 bytes.
    Global variables use 141924 bytes (27%) of dynamic memory, leaving 382364 bytes for local variables. Maximum is 524288 bytes.

    Used platform Version Path
    rp2040:rp2040 4.0.1   /var/home/znmeb/.arduino15/packages/rp2040/hardware/rp2040/4.0.1

    USB and TTY status before upload
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 001 Device 003: ID 0408:a061 Quanta Computer, Inc. HD User Facing
    Bus 001 Device 005: ID 8087:0026 Intel Corp. AX201 Bluetooth
    Bus 001 Device 015: ID 05e3:0610 Genesys Logic, Inc. Hub
    Bus 001 Device 024: ID 2e8a:000f Raspberry Pi RP2350 Boot
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 002 Device 002: ID 05e3:0626 Genesys Logic, Inc. Hub

    ls: cannot access '/dev/ttyACM0': No such file or directory

    Capturing begin time for 'journalctl' filtering
    Sleeping 15 seconds for devices to settle
    Uploading
    Resetting /dev/ttyACM0
    Converting to uf2, output size: 130048, start address: 0x2000
    Scanning for RP2040 devices
    Flashing /run/media/znmeb/RP2350 (RP2350)
    Wrote 130048 bytes to /run/media/znmeb/RP2350/NEW.UF2
    Flashing /media/znmeb/RP2350 (RP2350)
    Wrote 130048 bytes to /media/znmeb/RP2350/NEW.UF2
    Flashing /var/run/media/znmeb/RP2350 (RP2350)
    Wrote 130048 bytes to /var/run/media/znmeb/RP2350/NEW.UF2
    New upload port: /dev/ttyACM0 (serial)

    Sleeping 15 seconds for devices to settle
    Capturing end time for 'journalctl' filtering

    USB and TTY status after upload
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 001 Device 003: ID 0408:a061 Quanta Computer, Inc. HD User Facing
    Bus 001 Device 005: ID 8087:0026 Intel Corp. AX201 Bluetooth
    Bus 001 Device 015: ID 05e3:0610 Genesys Logic, Inc. Hub
    Bus 001 Device 025: ID 1b4f:0026 SparkFun ProMicro RP2350
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 002 Device 002: ID 05e3:0626 Genesys Logic, Inc. Hub

    crw-rw----. 1 root dialout 166, 0 Sep  9 17:45 /dev/ttyACM0 <-- owner and dialout group can use port, "world" can not!!!

    Monitoring
    Port monitor error: command 'open' failed: Permission denied

What has happened is that the upload process and restart changed the vendor:product of the board from 2e8a:000f to 1b4f:0026. There's no udev rule for that in the Arduino MBED rules, and arduino-cli monitor needs /dev/ttyACM0 to be world-writable, which causes the "Permission denied". Adding the rule

SUBSYSTEMS=="usb", ATTRS{idVendor}=="1b4f", MODE:="0666"

fixes it.

Is it possible for Arduino-Pico to include an option to install udev rules so I can do away with the MBED RP2040 install entirely? At this point I'm only using it to get the udev rules.

earlephilhower commented 2 weeks ago

I'm sorry, but it's not possible for the core to install or edit system files (you need root privileges which aren't and shouldn't be available to the running Arduino IDE.)

You can manually add the appropriate VID/PID to your config file (via sudo) and do a sudo udevadm control --reload to have udev reload your changes (or a full reboot, of course) like you said, of course, and this is the only way under Linux...