Skip to content

Conversation

hpcraink
Copy link

In pidosdk.py:19 the check for header
isfile(join(FRAMEWORK_DIR, "src", "boards", "include", "boards", header)):
fails, as pico-sdk names boards using the dot.

Otherwise (and without warning) the pico.h header is chosen, leading to false assumptions (e.g. about PICO_DEFAULT_LED_PIN)

In pidosdk.py:19 the check for header
  isfile(join(FRAMEWORK_DIR, "src", "boards", "include", "boards", header)):
fails, as pico-sdk names boards using the dot.

Otherwise (and without warning) the pico.h header is chosen,
leading to false assumptions (e.g. about PICO_DEFAULT_LED_PIN)
@maxgerhardt
Copy link
Owner

maxgerhardt commented Aug 24, 2025

Mhm, sadly that's not the right approach -- the variant in the board definition file is mainly used to select the Arduino core variant:

https://github.com/earlephilhower/arduino-pico/blob/a2d499850288a3d97da1f6c8428f931a22783b08/tools/platformio-build.py#L369

Changing the variant to e.g. waveshare_rp2040_lcd_0.96 would break Arduino builds since there it's called [variants/waveshare_rp2350_lcd_0_96](https://github.com/earlephilhower/arduino-pico/tree/master/variants/waveshare_rp2350_lcd_0_96.

All these board JSON files are automatically generated by makeboards.py in Arduino-Pico

https://github.com/earlephilhower/arduino-pico/blob/master/tools/makeboards.py

It would be great if we could adapt that script to have a map / dictionary of the boards to its specific board headers (https://github.com/maxgerhardt/pico-sdk/tree/master/src/boards/include/boards), so we can keep using it to generate all board files. It can store the "picosdk" variant then in a sub-field or object, like

  "build": {
     "picosdk_variant": "...."
   }

or

   "build": {
      "picosdk": {
         "variant": "...",
         "some_other_setting": "..."
     }
   }

@maxgerhardt
Copy link
Owner

maxgerhardt commented Aug 24, 2025

Actually, we might even get away with not storing that information in the board file at all but have that mapping be done by the builder script builder/frameworks/picosdk.py. We already have a provision for that

header = "%s.h" % board.get("build.variant")
# try to find the board header in the common directory
if isfile(join(FRAMEWORK_DIR, "src", "boards", "include", "boards", header)):
rp2_board_header = board.get("build.picosdk.board_header", header)
else:
rp2_board_header = board.get("build.picosdk.board_header", "pico.h")

@hpcraink
Copy link
Author

Ah I see, thank you for the information. OK, more work to be done ,-)

Actually, we might even get away with not storing that information in the board file at all but have that mapping be done by the builder script builder/frameworks/picosdk.py. We already have a provision for that

header = "%s.h" % board.get("build.variant")
# try to find the board header in the common directory
if isfile(join(FRAMEWORK_DIR, "src", "boards", "include", "boards", header)):
rp2_board_header = board.get("build.picosdk.board_header", header)
else:
rp2_board_header = board.get("build.picosdk.board_header", "pico.h")

Well, see my comment in the commit: it's line 20 in picosdk.py that "fails", or at least doesn't find the file under the supplied (Arduino) name.
We could amend this line with some "heuristic" to check for "digit_2digits.h" and replace with "digit.2digits.h" and check for isfile() again. This would cover the 0_96 and 1_28 case... Would be hacky though.
I agree, it would be best to add "build.pico_sdk_variant" or "build.pico_sdk.variant" to makeboards.py in
https://github.com/earlephilhower/arduino-pico/blob/master/tools/makeboards.py
I can come up with a patch against arduino-pico, but adding another pico_sdk_variant=none parameter in MakeBoard & BuildHeader & MakeBoardJSON seems not very likely to be accepted.

What do You think?

@maxgerhardt
Copy link
Owner

maxgerhardt commented Aug 25, 2025

I've done some work with a script and manual labor to map the current boards to the Pico SDK headers in 0f900eb.

So, that mapping is saved in the picosdk.py builder script.

I can come up with a patch against arduino-pico, but adding another pico_sdk_variant=none parameter in MakeBoard & BuildHeader & MakeBoardJSON seems not very likely to be accepted.

The Arduino core itself doens't use the picosdk header, so only MakeBoard needs to accept an additional default None parameter which it then passes on into MakeBoardJSON. Then of course, the currently mapped board header files would have to be mapped into

https://github.com/earlephilhower/arduino-pico/blob/e6c96e3e8bd7f94b7e8a651ff501d93d85b5b592/tools/makeboards.py#L511-L732

This is also assuming that PicoSDK doesn't change its header name files often, breaking them. But I think that would be an accepted change into Arduino-Pico.

This is also the right place to update the "URL" metadata as you've done for the Waveshare boards.

As for now, this lists works fine here as a temporary quick solution. All WaveShare boards and more are mapped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants