Skip to content

nxplpc: own Arduino/device assets and lib ingestion - #512

Merged
zackees merged 2 commits into
mainfrom
codex/nxplpc-arduino-stub
Jun 8, 2026
Merged

nxplpc: own Arduino/device assets and lib ingestion#512
zackees merged 2 commits into
mainfrom
codex/nxplpc-arduino-stub

Conversation

@zackees

@zackeeszackees commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

  • add fbuild-owned minimal Arduino, Serial, SPI, wiring, and LPC804/LPC845 device-header assets for nxplpc
  • install CMSIS and emit those include roots/defines through normal build_info generation
  • consume lib_extra_dirs / pio ci --lib for nxplpc so FastLED can be built as an external library instead of copying headers into an example
  • keep Windows canonicalized --lib paths usable by stripping extended path prefixes before compiler include flags
  • fix the clippy-only regression from the PR branch after rebasing on current main

Companion FastLED PR: FastLED/FastLED#2989.

Validation

  • soldr cargo clippy -p fbuild-build --all-targets -- -D warnings
  • soldr cargo test -p fbuild-build nxplpc -- --nocapture
  • soldr cargo test -p fbuild-build extra_library -- --nocapture
  • soldr cargo test -p fbuild-config lib_extra_dirs -- --nocapture
  • soldr cargo test -p fbuild-cli build_pio_env_joins_libs_with_platform_separator -- --nocapture
  • soldr cargo build -p fbuild-cli -p fbuild-daemon
  • target\x86_64-pc-windows-msvc\debug\fbuild.exe build tests\platform\lpc804 --quick -v --no-timestamp
  • target\x86_64-pc-windows-msvc\debug\fbuild.exe build tests\platform\lpc845 --quick -v --no-timestamp

Summary by CodeRabbit

  • New Features

    • Added Arduino API compatibility layer for NXP LPC8xx targets, enabling Serial, SPI, GPIO, and timing operations.
    • Added support for LPC804 and LPC845 device headers with CMSIS integration.
    • Added support for extra library directories via PlatformIO configuration.
  • Documentation

    • Updated asset documentation with new Arduino stub and device header entries.

@coderabbitai

coderabbitaiBot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8045e3f2-ce94-4acd-902a-3366b0608ac4

📥 Commits

Reviewing files that changed from the base of the PR and between 894c566 and 08948a7.

📒 Files selected for processing (22)
  • crates/fbuild-build/src/nxplpc/assets/README.md
  • crates/fbuild-build/src/nxplpc/assets/arduino_stub/Arduino.h
  • crates/fbuild-build/src/nxplpc/assets/arduino_stub/HardwareSerial.cpp
  • crates/fbuild-build/src/nxplpc/assets/arduino_stub/HardwareSerial.h
  • crates/fbuild-build/src/nxplpc/assets/arduino_stub/SPI.cpp
  • crates/fbuild-build/src/nxplpc/assets/arduino_stub/SPI.h
  • crates/fbuild-build/src/nxplpc/assets/arduino_stub/wiring_digital.c
  • crates/fbuild-build/src/nxplpc/assets/arduino_stub/wiring_time.c
  • crates/fbuild-build/src/nxplpc/assets/device_headers/LPC804.h
  • crates/fbuild-build/src/nxplpc/assets/device_headers/LPC845.h
  • crates/fbuild-build/src/nxplpc/assets/device_headers/fsl_device_registers.h
  • crates/fbuild-build/src/nxplpc/assets/device_headers/system_LPC804.h
  • crates/fbuild-build/src/nxplpc/assets/device_headers/system_LPC845.h
  • crates/fbuild-build/src/nxplpc/assets/main.cpp
  • crates/fbuild-build/src/nxplpc/mod.rs
  • crates/fbuild-build/src/nxplpc/orchestrator.rs
  • crates/fbuild-build/src/pipeline/library.rs
  • crates/fbuild-build/src/pipeline/mod.rs
  • crates/fbuild-cli/src/cli/compile_many.rs
  • crates/fbuild-config/src/ini_parser/mod.rs
  • crates/fbuild-config/src/ini_parser/tests.rs
  • crates/fbuild-config/src/ini_parser/values.rs

📝 Walkthrough

Walkthrough

This PR adds a complete Arduino API surface and build infrastructure for NXP LPC8xx targets. It introduces stub implementations of Arduino headers (GPIO, serial, SPI, timing), CMSIS device headers for LPC804/LPC845, and support for discovering and compiling extra libraries during the build. Assets are materialized by the orchestrator and integrated into the compilation pipeline.

Changes

LPC8xx Arduino Stub & Device Headers

Layer / File(s)Summary
Arduino API type contracts
crates/fbuild-build/src/nxplpc/assets/arduino_stub/Arduino.h
Defines Arduino-compatible type contracts, macros (HIGH, LOW, pin modes), typedefs (byte, pin_size_t, PinMode, PinStatus), and function prototypes for GPIO, serial, SPI, and timing operations.
HardwareSerial serial implementation
crates/fbuild-build/src/nxplpc/assets/arduino_stub/HardwareSerial.h, HardwareSerial.cpp, crates/fbuild-build/src/nxplpc/assets/main.cpp
HardwareSerial class with stub methods for begin/end, read/write, and print/println; global Serial instance; updated main.cpp entry points from C linkage to C++ linkage per preprocessor comments.
SPI bus implementation
crates/fbuild-build/src/nxplpc/assets/arduino_stub/SPI.h, SPI.cpp
SPIClass with stub methods for begin/end, byte and buffer transfer, and clock/bit-order/mode configuration; SPI mode and clock divider macros; global SPI instance.
Wiring digital and timing functions
crates/fbuild-build/src/nxplpc/assets/arduino_stub/wiring_digital.c, wiring_time.c
GPIO operations (pinMode, digitalWrite, digitalRead); SysTick-based timing with millis/micros/delay/delayMicroseconds; SystemCoreClock weak symbol and SystemCoreClockUpdate; CPU-specific LPC804/LPC845 header selection.
CMSIS device headers
crates/fbuild-build/src/nxplpc/assets/device_headers/LPC804.h, LPC845.h, system_LPC804.h, system_LPC845.h, fsl_device_registers.h
Minimal CMSIS-compliant device headers defining interrupt enumerations, CPU capability macros (__CM0PLUS_REV, __NVIC_PRIO_BITS, etc.), system clock defaults, and compile-time CPU selection via fsl_device_registers.h.
Asset definitions and documentation
crates/fbuild-build/src/nxplpc/mod.rs, crates/fbuild-build/src/nxplpc/assets/README.md
Declares ARDUINO_STUB_ASSETS and DEVICE_HEADER_ASSETS as embedded content maps; extends dependency installation to include CMSIS framework; documents new asset directories.

Extra Library Discovery & Compilation

Layer / File(s)Summary
Library directory configuration
crates/fbuild-config/src/ini_parser/mod.rs, values.rs, tests.rs
Adds get_lib_extra_dirs method to parse lib_extra_dirs from platformio.ini with PLATFORMIO_LIB_EXTRA_DIRS environment override; introduces parse_path_list for OS-specific (; on Windows, : elsewhere) list splitting; includes tests for INI and override precedence.
Library discovery and compilation APIs
crates/fbuild-build/src/pipeline/library.rs
Introduces discover_extra_library_roots to find library roots from config entries (supporting both direct roots and nested libraries), add_extra_library_include_dirs to augment include paths without duplicates, and compile_extra_libraries to build each root into archives; includes tests for root detection and include-dir augmentation.
Build pipeline integration
crates/fbuild-build/src/nxplpc/orchestrator.rs, crates/fbuild-build/src/pipeline/mod.rs, crates/fbuild-cli/src/cli/compile_many.rs
Orchestrator materializes Arduino stub and device header assets into build directory; discovers and precompiles extra library roots; adds CMSIS framework installation and include paths; passes precompiled archive inputs and LibraryBuildEnv to sequential build; compile_many canonicalizes lib paths; pipeline mod re-exports new discovery/compilation functions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • FastLED/fbuild#488: Both PRs modify the nxplpc orchestrator and main.cpp linkage to integrate new assets and manage the build pipeline for LPC8xx targets.

Poem

A rabbit hops through pins and ports,
With SPI and Serial shorts,
Stubs and headers pave the way,
LPC8xx can code today! 🐇✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/nxplpc-arduino-stub

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
crates/fbuild-build/src/nxplpc/assets/arduino_stub/wiring_time.c

crates/fbuild-build/src/nxplpc/assets/arduino_stub/wiring_time.c:9:2: error: "Unsupported NXP LPC8xx CPU"
9 | #error "Unsupported NXP LPC8xx CPU"
| ^
crates/fbuild-build/src/nxplpc/assets/arduino_stub/wiring_time.c:12:50: error: use of undeclared identifier 'F_CPU'
12 | attribute((weak)) uint32_t SystemCoreClock = F_CPU;
| ^
crates/fbuild-build/src/nxplpc/assets/arduino_stub/wiring_time.c:15:23: error: use of undeclared identifier 'F_CPU'
15 | SystemCoreClock = F_CPU;
| ^
crates/fbuild-build/src/nxplpc/assets/arduino_stub/wiring_time.c:22:12: error: use of undeclared identifier 'F_CPU'
22 | return F_CPU / 1000UL;
| ^
crates/fbuild-build/src/nxplpc/assets/arduino_stub/wiring_time.c:26:12: error: use of undeclared identifier 'F_CPU'
26 | return F_CPU / 1000000UL;
| ^
crates/fbuild-build/src/nxplpc/assets/arduino_stub/wiring_time.c:39:

... [truncated 2164 characters] ...

" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-clear-ast-before-backend" "-disable-llvm-verifier"
"-discard-value-names" "-main-file-name" "wiring_time.c"
"-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie"
"-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on"
"-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2"
"-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb"
"-fdebug-compilation-dir="
"-fcoverage-compilation-dir=" "-resource-dir"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/c


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees marked this pull request as ready for review June 8, 2026 21:06
@zackees
zackees merged commit e09e056 into mainJun 8, 2026
85 of 86 checks passed
@zackees
zackees deleted the codex/nxplpc-arduino-stub branch June 8, 2026 21:06
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant

@zackees