Skip to content

Make boot/picobin.h self-contained#2944

Open
anoshyn wants to merge 1 commit into
raspberrypi:developfrom
anoshyn:fix-picobin-self-include
Open

Make boot/picobin.h self-contained#2944
anoshyn wants to merge 1 commit into
raspberrypi:developfrom
anoshyn:fix-picobin-self-include

Conversation

@anoshyn
Copy link
Copy Markdown

@anoshyn anoshyn commented May 16, 2026

Summary

#include "boot/picobin.h" before any other SDK header errors out with:

pico/platform.h:20: #error pico/platform.h should not be included directly; include pico.h instead

boot/picobin.h was pulling in pico/platform.h directly (gated only by NO_PICO_PLATFORM), which works only when something else (typically pico.h) has already set _PICO_H. The diagnostic blamed pico/platform.h, while the actual offender was the non-obvious indirect include via boot/picobin.h — a confusing experience flagged in #2797.

The header only uses one platform.h facility: the _u() literal-suffix macro. The same _u() fallback already existed in the NO_PICO_PLATFORM branch of this header. Promote that fallback to the unconditional definition and drop the pico/platform.h include. Add <stdint.h> next to the existing <stdbool.h> in the C-only block so uint32_t is available standalone.

This keeps boot/picobin.h at the lightweight "common" tier (no new heavy SDK dependency) and makes it includable in any order.

Fixes #2797.

Test plan

  • Repro reproduces on develop: a TU containing only #include "boot/picobin.h" fails to compile, citing the pico/platform.h should not be included directly error.
  • After the change, the same TU compiles.
  • __ASSEMBLER__-mode preprocessing still works (_u(x) falls through to the asm branch).
  • Full SDK build remains clean (cmake --build build) for the default PICO_PLATFORM=rp2040 PICO_BOARD=pico config. Existing internal consumers (pico_cyw43_driver, pico_crt0, pico_bootrom, cyw43_partition_firmware) include picobin.h alongside pico.h/pico/bootrom.h, so they already pull in platform.h transitively and are unaffected.
  • CI to confirm other board / RP2350 / RISC-V configurations.

Including boot/picobin.h before any other SDK header errored out:

  pico/platform.h:20: #error pico/platform.h should not be included
  directly; include pico.h instead

picobin.h was reaching into pico/platform.h directly, which only works
when something else (typically pico.h) has already set _PICO_H. The
diagnostic blamed pico/platform.h while the actual offender was the
non-obvious indirect include via boot/picobin.h.

Drop the dependency on pico/platform.h entirely. The only platform.h
facility picobin.h uses is _u(), which the header already defined as a
fallback for NO_PICO_PLATFORM builds; promote that fallback to the
unconditional definition. Also add <stdint.h> alongside the existing
<stdbool.h> include in the C-only block so uint32_t is available
without leaning on platform.h's transitive includes.

Verified by:
- Repro: a TU that only does `#include "boot/picobin.h"` now compiles.
- Full SDK build remains clean; existing consumers (cyw43_driver,
  pico_crt0, pico_bootrom, cyw43_partition_firmware) include picobin.h
  alongside pico.h/bootrom.h and so already pull in platform.h via
  those, unaffected by this change.

Fixes raspberrypi#2797.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@anoshyn
Copy link
Copy Markdown
Author

anoshyn commented May 16, 2026

@kilograham @lurch when you have a moment, would you mind taking a look? This is a small standalone-include fix for boot/picobin.h flagged in #2797. Verified that the existing internal consumers still build clean. Happy to take a different approach if you'd prefer including pico.h instead. Thanks!

@kilograham kilograham requested a review from will-v-pi May 16, 2026 15:53
@kilograham
Copy link
Copy Markdown
Contributor

please don't tag people in issues

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