maxgerhardt / platform-raspberrypi

Raspberry Pi: development platform for PlatformIO
Apache License 2.0
94 stars 46 forks source link

Problem about auto detection of port #5

Open asukiaaa opened 2 years ago

asukiaaa commented 2 years ago

You introduced auto detection on an issue thread https://github.com/platformio/platform-raspberrypi/issues/2

It works if /media/${USER}/RPI-RP2 presence with the following setting.

[env:pico]
platform = git@github.com:maxgerhardt/platform-raspberrypi.git#develop
; platform = raspberrypi
board = pico
framework = arduino
upload_protocol = mbed
upload_port = /media/asuki/RPI-RP2

However, does not work if /dev/ttyACM0 is mounted.

Thank you.

fiechr commented 2 years ago

I have a similar problem

I'm using Manjaro Linux (Arch based).

Either I don't set a upload protocol/port, then the upload protocol "knocks" on the /dev/ttyACM0 port and the pico restarts and the virtual disk shows up and is mounted (by the OS) at /run/media/username/RPI-RP2*, but the picotool seems to not get that and times out, although the path exists and is readable/writable by the user, while picotool is still running.

If I manually copy the firmware file with a simple cp .pio/build/pico/firmware.uf2 /run/media/username/RPI-RP2/ after the failed upload process, the file gets copied, Pico restarts and all is fine.

Or I set the upload_protocol = mbed together with upload_port = /run/media/username/RPI-RP2. Then the Pico doesn't restart automatically anymore (no port knocking) and I need to manually unplug and re-plug it, holding the boot select button (which is even more cumbersome).

Unfortunately, I can only get one of those behaviors, but not both.

What I'm looking for, is a process that first knocks on the port, waits until the Pico restarts, the fs is (auto-)mounted and then starts the upload/copy part.

*/media/username/RPI-RP2 works too, it's just a symlink to /run/media/username/RPI-RP2.

This is my current platformio.ini:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:pico]
;platform = raspberrypi
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
framework = arduino
board_build.core = earlephilhower
;upload_protocol = mbed
;upload_port = /run/media/username/RPI-RP2
monitor_speed = 115200
lib_deps = https://github.com/bolderflight/sbus

platform_packages =
    framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git
    ;toolchain-pico@https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.3.1-a/x86_64-linux-gnu.arm-none-eabi-7855b0c.210706.tar.gz
    toolchain-pico@https://github.com/earlephilhower/pico-quick-toolchain/releases/download/1.3.3-a/x86_64-linux-gnu.arm-none-eabi-ed6d983.220212.tar.gz