platform-raspberrypi icon indicating copy to clipboard operation
platform-raspberrypi copied to clipboard

Add support for alternative Arduino core earlephilhower/arduino-pico

Open maxgerhardt opened this issue 4 years ago • 20 comments

Per https://community.platformio.org/t/request-to-add-platformio-support-for-earle-philhowers-arduino-pico-raspberry-pi-pico-sdk/22285.

As simliar to e.g. STM32 and AVR with board_build.core = .., it should be supported to switch to a different Arduino core implementation, the most popular of which is https://github.com/earlephilhower/arduino-pico.

Needs a PlatformIO builder script, a new framwork package and the necessary platform scripts changes here.

maxgerhardt avatar Jul 02 '21 11:07 maxgerhardt

With the new release (1.9.5) it should possible to integrate in PIO

sstaub avatar Sep 20 '21 13:09 sstaub

While https://github.com/earlephilhower/arduino-pico/pull/250 has been merged I am blocked by https://github.com/earlephilhower/pico-quick-toolchain/issues/4, https://github.com/earlephilhower/pico-quick-toolchain/issues/5 and open debugging issues described in https://github.com/earlephilhower/arduino-pico/issues/66#issuecomment-894785078 before I'm able to sensibly merge https://github.com/maxgerhardt/platform-raspberrypi back. A WIP version is available at https://github.com/maxgerhardt/pio-pico-core-earlephilhower-test.

maxgerhardt avatar Sep 20 '21 13:09 maxgerhardt

Any news about?

sstaub avatar Oct 26 '21 12:10 sstaub

Hi Max, the WIP version of this code - are we able to add this address as a platform using the Advanced Installation in Platform IO? Or are there other instructions I need to do to be able to use arduino-pico in PIO? Thanks, Tom

Tomwhiting1987 avatar Oct 27 '21 13:10 Tomwhiting1987

@sstaub Other than the Pico openocd repo finally merging Picoprobe support into the main branch for unification, not much.

@Tomwhiting1987 You don't need to go through the GUI to install it, you have to reference the new platform in the platformio.ini of the project. Even if you did install through the "Advanced Installation", it wouldn't be picked up if the special platform = .. instruction wasn't there. Best to use the platformio.ini from the reference project or the more minimal one shown in the documentation I wrote: https://arduino-pico.readthedocs.io/en/latest/platformio.html

maxgerhardt avatar Oct 27 '21 13:10 maxgerhardt

@sstaub Other than the Pico openocd repo finally merging Picoprobe support into the main branch for unification, not much.

@Tomwhiting1987 You don't need to go through the GUI to install it, you have to reference the new platform in the platformio.ini of the project. Even if you did install through the "Advanced Installation", it wouldn't be picked up if the special platform = .. instruction wasn't there. Best to use the platformio.ini from the reference project or the more minimal one shown in the documentation I wrote: https://arduino-pico.readthedocs.io/en/latest/platformio.html

Thanks very much for this @maxgerhardt , much appreciated - seems to be working well now, it's very impressive! Regarding debugging, is there a way to use pico-debug with the earlephilhower/arduino-pico core in platformio? And if so, how do you do this?

Tomwhiting1987 avatar Nov 04 '21 11:11 Tomwhiting1987

@Tomwhiting1987 as of now I even have problems with an extern debug probe, picoprobe, as described in https://github.com/earlephilhower/arduino-pico/issues/66#issuecomment-894785078. There seems to be some (?) issue with the placement of functions in flash compared to RAM. I think I achieved my partially-working debugging by hacking the linker script to place all crucial things in RAM instead of Flash except the bootloader and vector table of course) I've not yet touched the picodebug path of uploading or debugging.

maxgerhardt avatar Nov 04 '21 11:11 maxgerhardt

Ok no problem, thanks for the update @maxgerhardt. Is it likely that when this core is fully supported as a platform in platformio, we will be able to use the PIO debug in the GUI?

Tomwhiting1987 avatar Nov 04 '21 11:11 Tomwhiting1987

I would only merge it when it's feature-complete with all debugging working, so yes.

maxgerhardt avatar Nov 04 '21 11:11 maxgerhardt

Why wait for debugging feature? I don't think that all users need it really.

sstaub avatar Nov 09 '21 15:11 sstaub

What's the status of getting this included as an official Platformio framework?

Thanks to @maxgerhardt, I've been using it in Platformio for the past several days and it's working great! (I don't need the hardware debugging features.)

I've used both the official, mbed-based framework for the RP2040 and this one by Earle Philhower, and I much prefer this one. For MicroBlocks, the generated code is smaller and uses much less RAM. Some things, like pin IO, also appear to be faster. I like the fact that this framework supports LittleFS, although I haven't used that yet, and I'm seeing that Adafruit and others have created libraries around this framework. Finally, I found it easier to dig into the low level code for things like gpio and i2c in the Philhower framework. (I may have missed something, but I couldn't actually find the source code for the lowest levels in the mbed-based framework.)

In short, I'd love to see this framework supported officially by Platformio.

I've worked a bit with Ivan and the Platformio team in the past, so if it is helpful I can add my voice to those requesting that it be supported officially in whatever way makes sense.

jhmaloney avatar Jan 24 '22 14:01 jhmaloney

We're currently in the process of adding all board JSON files that the Arduino-Pico core supports in https://github.com/earlephilhower/arduino-pico/pull/426, and I've also pinged Earle again on the publishing of the toolchain packages, which are needed.

If I see that getting debugging to work is really too much of a hassle right now, I'll push for a publication without (good / complete) debug support. Gotta prepare for a storm of 'why not working??' issues then though.

maxgerhardt avatar Jan 24 '22 14:01 maxgerhardt

Fantastic! Let me know if you need help to convince Ivan to include this in Platformio. I know he was resistant in early days to having two Arduino frameworks for the RP2040, but over the past nine months the strengths and stability of this framework have become clear so I'm hoping he will reconsider.

jhmaloney avatar Jan 24 '22 15:01 jhmaloney

I've prepared an alternative fork with support for earlephilhower/arduino-pico : relevant branch is episource/platform-raspberrypi#my-platform-pico.

Main differences to maxgerhardt's approach:

  • board definitions and framework build script are not replicated (but read directly from the framework's tools directory)
  • builtin PRs #29, #30, #31 for working CMSIS-DAP/SWD transport
  • does not use toolchain-pico, but reuses build tools of mbed core (toolchain-gccarmnoneeabi, tool-openocd-raspberrypi)
  • automatically disables library Adafruit TinyUSB Library if USE_TINYUSB is not defined (no need to use ldf_mode=chain+ or doing this explicitly)
  • core names pico, rp2040 and earlephilhower are synonyms
  • no littlefs support though
  • Compiling with -DUSE_TINYUSB currently also fails (due to not using toolchain-pico)
    • the Adafruit TinyUSB library duplicates definitions from libpico.a
    • somehow these duplicates are resolved when using toolchain-pico...

episource avatar Mar 13 '22 22:03 episource

Are there any news about.

sstaub avatar May 12 '22 15:05 sstaub

I'm excited to report that debugging finally works, I've updated the integration and created a PR (https://github.com/platformio/platform-raspberrypi/pull/36). We're close to getting full, good support and docs.

maxgerhardt avatar Jun 09 '22 20:06 maxgerhardt

That's great news!

jhmaloney avatar Jun 09 '22 20:06 jhmaloney

any news on this? i would really like to use the 2nd core

MNS26 avatar Dec 22 '22 20:12 MNS26

Look at the open PRs, it's already there and can be used.

maxgerhardt avatar Dec 22 '22 20:12 maxgerhardt

any news on this? i would really like to use the 2nd core


[env:BOARD_RP2040_PICO_ALT]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
;platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git
board = pico
board_build.core = earlephilhower
board_build.filesystem_size = 0.5m

savejeff avatar Dec 22 '22 20:12 savejeff