platform-raspberrypi
platform-raspberrypi copied to clipboard
Arduino-Pico (Earlephilhower) support, PicoProbe Debugging
Massive upgrade.
- Add support for building for https://github.com/earlephilhower/arduino-pico
- As in the style of platform-ststm32, boards that can be used with both cores can be switched to the other core using
board_build.core = earlephilhower - Integrates with my already merged builder script at https://github.com/earlephilhower/arduino-pico/blob/master/tools/platformio-build.py
- Added all Arduino-Pico boards (Earle auto-gen'ed them through https://github.com/earlephilhower/arduino-pico/blob/master/tools/makeboards.py)
- Arduino core must use toolchain and tools from https://github.com/earlephilhower/pico-quick-toolchain/releases, which are finally in the registry
- no more
platform_packagesinjectionplatformio.inineeded, all tools (except framework) sourced from registry
- no more
- Replace outdated
platformio/tool-openocd-raspberrypi(1 year old, before picoprobe merge) withearlephilhower/tool-openocd-rp2040-earlephilhower-- works for all frameworks and cores (also the mbed-os core) - Added support for LittleFS filesystem building + uploading through picotool and OpenOCD (picoprobe etc.); Arduino-Pico core supports LittleFS
- Added and tested Picoprobe support for both ArduinoCore-mbed and Arduino-Pico, works great
- Reduced default debugging and OpenOCD upload speed to 1000kHz, the 5000kHz was giving me verification errors
- Add Arduino-Pico examples to CI
- Reprogrammed
upload_protocol = mbedto make more sense, it previously tried to upload the.binfile to the drive instead of the.uf2file - Update SVD file with latest from https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2040/hardware_regs/rp2040.svd

Test at will with
[env]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
framework = arduino
board_build.core = earlephilhower
board_build.filesystem_size = 0.5m
[env:pico]
board = pico
; if using picoprobe SWD upload / debugging
;upload_protocol = picoprobe
;debug_tool = picoprobe
; note: newer PicoProbe firmwares emulate a CMSIS-DAP, so you
; use "cmsis-dap" as upload_protocol and debug_tool.
; for more info see docs https://arduino-pico.readthedocs.io/en/latest/platformio.html
ToDo (all done at the moment of writing):
- create PR for platformio-docs, previous docs at https://arduino-pico.readthedocs.io/en/latest/platformio.html are outdated
- create PR for arduino-pico docs as docs is now outdated
- fix https://github.com/earlephilhower/arduino-pico/issues/612
- upload / make Earle upload
framework-arduinopicopackage (after fix of course)
And please squash upon merge, otherwise you have more than 43 commits from me.
Build failed on maOS.

You are using an old platform version. CLI -> pio platform update https://github.com/maxgerhardt/platform-raspberrypi.git.
Ok, I can now compile but I get some ugly warning and errors.

Can you Cmd+Shift+P -> Rebuild Intellisense and upload the .vscode/c_cpp_properties.json to https://pastebin.com/?
Here the cpp.json
// // !!! WARNING !!! AUTO-GENERATED FILE! // PLEASE DO NOT MODIFY IT AND USE "platformio.ini": // https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags // { "configurations": [ { "name": "PlatformIO", "includePath": [ "/Users/sstaub/Dateien/Development/Raspberry Pico/blinky2/include", "/Users/sstaub/Dateien/Development/Raspberry Pico/blinky2/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/cores/rp2040", "/Users/sstaub/.platformio/packages/framework-arduinopico/cores/rp2040/api/deprecated", "/Users/sstaub/.platformio/packages/framework-arduinopico/cores/rp2040/api/deprecated-avr-comp", "/Users/sstaub/.platformio/packages/framework-arduinopico/tools/libpico", "/Users/sstaub/.platformio/packages/framework-arduinopico/variants/rpipico", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/EEPROM", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/ESP8266SdFat/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/FreeRTOS/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/I2S/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/Keyboard/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/LittleFS/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/Mouse/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/PDM/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/SD/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/SDFS/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/SPI/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/Servo/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/Wire/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/rp2040", "" ], "browse": { "limitSymbolsToIncludedHeaders": true, "path": [ "/Users/sstaub/Dateien/Development/Raspberry Pico/blinky2/include", "/Users/sstaub/Dateien/Development/Raspberry Pico/blinky2/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/cores/rp2040", "/Users/sstaub/.platformio/packages/framework-arduinopico/cores/rp2040/api/deprecated", "/Users/sstaub/.platformio/packages/framework-arduinopico/cores/rp2040/api/deprecated-avr-comp", "/Users/sstaub/.platformio/packages/framework-arduinopico/tools/libpico", "/Users/sstaub/.platformio/packages/framework-arduinopico/variants/rpipico", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/EEPROM", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/ESP8266SdFat/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/FreeRTOS/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/I2S/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/Keyboard/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/LittleFS/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/Mouse/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/PDM/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/SD/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/SDFS/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/SPI/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/Servo/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/Wire/src", "/Users/sstaub/.platformio/packages/framework-arduinopico/libraries/rp2040", "" ] }, "defines": [ "PLATFORMIO=60003", "ARDUINO_RASPBERRY_PI_PICO", "ARDUINO_ARCH_RP2040", "USBD_MAX_POWER_MA=500", "ARDUINO=10810", "ARDUINO_ARCH_RP2040", "F_CPU=133000000L", "BOARD_NAME=\"pico\"", "CFG_TUSB_MCU=OPT_MCU_RP2040", "USB_VID=0x2e8a", "USB_PID=0x000a", "USB_MANUFACTURER=\"Raspberry Pi\"", "USB_PRODUCT=\"Pico\"", "SERIALUSB_PID=0x000a", "" ], "cStandard": "c17", "cppStandard": "c++17", "compilerPath": "/Users/sstaub/.platformio/packages/toolchain-rp2040-earlephilhower/bin/arm-none-eabi-gcc", "compilerArgs": [ "-march=armv6-m", "-mcpu=cortex-m0plus", "-mthumb", "-iprefix/Users/sstaub/.platformio/packages/framework-arduinopico", "@/Users/sstaub/.platformio/packages/framework-arduinopico/lib/platform_inc.txt", "" ] } ], "version": 4 }
Hm looks good. I cannot reproduce this in Windows.
Rebuilding the Intellisense and e.g., Ctrl or Cmd-Clicking on the #include <Arduino.h> line does not get rid of the error? All includes are found here. Restart VSCode maybe?
Intellisense rebuild doesn't help. I have seen the same problem some times ago on the MS Arduino plugin for VSC and also at the Arduino IDE 2.0
Can you, just as a test, add
build_flags = -I/Users/sstaub/.platformio/packages/framework-arduinopico/pico-sdk/src/rp2_common
to the platformio.ini and rebuild Intellisense again? Are all errors gone or does it show more nested errors..
Also that is what I get:

Windows has no problem here.
Only other thing I can test is on Linux since I don't have a Mac.
No changes.
I will look deeper inside tomorrow .
Compilation works because the include folders specified in https://github.com/earlephilhower/arduino-pico/blob/master/lib/platform_inc.txt are included in compilation with https://github.com/earlephilhower/arduino-pico/blob/578d3d2a768bff6b7d978c3eb271381c4a0fdc72/tools/platformio-build.py#L45-L46, but this does not show up in .vscode/c_cpp_properties.json since the builder script does not export it in CPPPATH. The problem is, if I do it there, then it's double in there with -iprefix. If I remove -iprefix, I deviate from the Arduino compilation.
Somehow at least on Windows, VSCode is still smart enough to find the include within framework-arduinopico, on Mac not (?). Weird.
This is reproducable on Linux too. I will push a fix in the builder script for this.
This will be fixed by https://github.com/earlephilhower/arduino-pico/pull/615 (not an issue platform-raspberrypi or this PR).
@sstaub if you want to test it out, please replace the contents of /Users/sstaub/.platformio/packages/framework-arduinopico/tools/platformio-build.py with the new version and rebuild intellisense again.
Edit: This was merged, so the framework-arduinopico update should get pulled by pio platform update https://github.com/maxgerhardt/platform-raspberrypi.git
Tested on Arch Linux, both the uf2 & picoprobe upload work great! Nice work!
I didn't test debugging.
The errors and warnings passed away. Now I have to check uploading. Thanks
@sstaub It seems the Intellisense issue is caused by Microsoft, not PlatformIO's builder script: See https://github.com/platformio/builder-framework-arduino-core-mbed/issues/4. Downgrading the C/C++ by Microsoft extension solved the error. Microsoft's stuff is buggy as hell.
Edit: This bug was fixed by Microsoft, update the C/C++ extension to the latest possible version.
@maxgerhardt I have added automatic Platform.IO publishing of core releases and uploaded the 2.1.1 version (under review). If it works, then the Platform.IO release will happen automatically on a Arduino package release. If not, please let me know what I broke and I'll try and correct it!
https://registry.platformio.org/tools/earlephilhower/framework-arduinopico/versions is visible now (thanks @earlephilhower!), I will work on getting a PR in for https://github.com/earlephilhower/arduino-pico/issues/612 and do more testing (possible Adafruit TinyUSB integration faults, recheck race conditions again), then I can reference the next stable version.
Hi @maxgerhardt ! Many thanks for an awesome PR. Please check my comments in the review. Does something make sense?
I'm waiting for https://github.com/earlephilhower/arduino-pico/pull/633 to be merged, then I'll merge https://github.com/maxgerhardt/platform-raspberrypi/pull/8 which should resolve the first round of review comments.
Edit: Done.
Thanks for the updates. I've just added minor comments. After that we should be ready to merge.
Second round of PR comments are worked in.
Thanks for the fixes. LGTM, one last thing is a proper package with the framework. Should we wait for a stable release with the latest changes to the build script?
Yes, also we're currently investigating some issue with Multicore / thread safety things (https://github.com/earlephilhower/arduino-pico/issues/614) and TinyUSB (https://github.com/earlephilhower/arduino-pico/issues/630, I need to check the latter myself and the fix for the first thing might require a change to the builder script and toolchain package -- I would wait those two out, then reference the next stable framework and possibly toolchain version in the platform.json.
This should hopefully be done within the next 7 days maximum.
The multicore stuff looks to be fixed and I've just published the new toolchain and framework package.
@maxgerhardt are we good to go on this? The core seems solid multicore (at least there are no known bugs :crossed_fingers: ) and the TinyUSB stuff seems to be upstream related and more of a "works, but is/always was awkward" than "is busted."
Only thing you might check, is that if you hardcoded any version numbers of packages. There was a new toolchain built for the multicore fixes and there have been a couple framework updates (latest published today) from when this was initially proposed...
@earlephilhower I'd say when the Mac OS ARM64 toolchains are uploaded (or rather, reuploaded with just a different manifest) as discussed in https://github.com/earlephilhower/arduino-pico/issues/661#issuecomment-1168447394 then a new 2.0.2 should be released so that the PlatformIO fix https://github.com/earlephilhower/arduino-pico/pull/658 is integrated. Then I can reference fixed versions for both toolchain + framework and do a final test, then this would be good to merge.