RP2040 / Custom board in @maxgerhardt platform-raspberrypi

I am developing a custom board/variant with RP2040, and would like to know what does it take to have it published on the official repository?

Also what’s the Dif between @maxgerhardt repository/platform and the raspberrypi?

I use:
platform = GitHub - maxgerhardt/platform-raspberrypi: Raspberry Pi: development platform for PlatformIO

But I see a lot of examples using:
platform = raspberrypi

Just curious to do this properly.

The difference between standard

https://github.com/platformio/platform-raspberrypi/

and my

https://github.com/maxgerhardt/platform-raspberrypi/

is that I have additional support for the Arduino-Pico core by Earle Philhower, whereas the standard platform only has support for ArduinoCore-mbed.

The Arduino-Pico core has way better support for tons of boards (the ArduinoCore-mbed core only has 2 boards and none of the WiFi / BT ones like the PicoW). It’s also easier to add new custom boards on it, per documentation. Unfortunately, the merge-back into mainline is blocked due to company-political / financial reasons and I don’t expect that to change anytime soon.

I really appreciate your help!

What can I do to add a new board and variant to your platform!

It is clear to me that I should stick to your platform.

And is there a way to donate $ to the cause for writing this for us?

You just follow these instructions and PR them into https://github.com/earlephilhower/arduino-pico.

I will then sync the generated board definitions into the platform.

See e.g. PRs like https://github.com/earlephilhower/arduino-pico/pull/1630.

1 Like

Hello!
Thanks again for the help @maxgerhardt

So I am working on the board script. Have a question about this line:

MakeBoard("rpipico", "Raspberry Pi", "Pico", "0x2e8a", "0x000a", 250, "RASPBERRY_PI_PICO", 2, "boot2_w25q080_2_padded_checksum")

I can guess most of the fields from the func but just to be sure :slight_smile:

# MakeBoard(name, vendor_name, product_name, vid, pid, pwr, boarddefine, flashsizemb, boot2, extra = None):

I understand we should use the standard vid field … If this is a custom board should we apply for a custom pid? Or can we use the generic pid field?

How do I specify the clock speed setting for this board if I want it to be pre-configured or pre-set? I imagine leaving blank means configurable in .ini?

And lastly the boot2 field… Is there someplace I can get more info?

I am cloning mostly values from generic since it works with my board except for a few pins that change from generic.

LAlso can I assume we do the PR to:

Will the changes also get pushed to:

or should we do a separate PR for the platform io repo?

Any help welcomed that can point me to the right direction!

Not sure. At least from the current state, about 40 boards reuse the VendorID assigned to Raspberry Pi (Trading) Limited (0x2E8A). Is that right? Can’t say. There are ways to get free VID + PID assignments though.

The clock speed selection menu is shown in full for all boards, you can’t set it per-board. A standard value is given for PlatformIO with a way to override it.

The Boot2 is the second stage bootloader. You need to chose this file in accordance to the Flash chip you have on your board. There are many pre-available ones, with the most generic one being boot2_generic_03h_4_padded_checksum.S. See here too. If your current flash is not listed but you also don’t want to fallback to a generic code, you can check if it’s in here and add and reference the file as needed in the PR.

Yes.

Not automatically but yes, I’ll take care of that.

1 Like

Again thank you very much.

Three last questions I promise :blush:

  1. If I am using platform IO is there a way to test all the settings locally or on my fork before doing the Pull Request?

I see the two repos (arduino/platformio) are different but don’t seem to make sense to me how to test the platformio one without changing the Arduino repo first. Would very much like to see that my changes work in order to do the PR once.

  1. Can you elaborate a little bit more on how to set the clock speed in platformIO or should we do that directly on code? We have an external 12MHz clock and would like to run the chip at 133 MHz

  2. Is there a way/place to donate something to the project ?

Yes. If you adapted makeboards.py in your local fork correctly and executed it, then it spit out a new say my_custom_rp2040_board.json file. I’ll also assume you have a working-copy of your Arduino-Pico fork (that was recursively cloned with git clone --recursive otherwise you’re missing pico-sdk and tinyusb etc. – or git submodule update --init --recursive) on your harddisk.

Create any new PlatformIO project (e.g. Board “Arduino Uno”, Framework “Arduino”). Create a new boards folder at the same level at the platformio.ini. Put the generated board JSON file in there. You can then use a platformio.ini such as

[env:pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
; filename (without extension) of new board JSON in boards folder
board = my_custom_rp2040_board
framework = arduino
board_build.filesystem_size = 0.5m
; use local copy of forked core
platform_packages =
   framework-arduinopico@symlink://C:/Users/MyUser/Desktop/arduino-pico

All of that would have also been documented in the Arduino-Pico docs and PlatformIO docs.

Hello

I had hard time installing Max"s version of the platform, because I am on Windows and I used at first the Git implementation advised somewhere on a page about setting up VS Code (that’s not your fault), because it has a limited path length and some modules have a longer path… The build installed tons of thing and then failed, and the cause was not obvious at first.

So I finally spotted the error about the path and used Cygwin’s Git. Maybe this can help some people.

And now I could run the blinking led example on a Pi W.

But, I have a question: is it sensible to have to install 9 GB of stuff just to blink a led on a microcontroller ?

Arduino-Pico relies on the headers inside pico-sdk. With the current PlatformIO core, I can only tell PIO to pull the entire arduino-pico repo. That pulls pico-sdk too, recursively. The heavist subcomponent there is tinyusb, which includes the HALs/BSPs for dozens of microcontroller series, making it very heavy. The next tinyusb version already already has that restructured, so the download will be lighter. For now, I see 9 GB as not a lot of space in terms of harddrives and SSDs.