Skip to content

fix(nxplpc): bake LPC8xx boot-ROM vector checksum into linked image - #556

Merged
zackees merged 1 commit into
mainfrom
fix/lpc8xx-boot-checksum
Jun 13, 2026
Merged

zackees merged 1 commit into
mainfrom
fix/lpc8xx-boot-checksum

Conversation

@zackees

@zackees zackees commented Jun 13, 2026

Copy link
Copy Markdown
Member

Summary

The LPC8xx boot ROM only executes an image whose first 8 vector words sum to zero (mod 2³²); the word at offset 0x1C is reserved for the two's-complement that closes the sum. lpc21isp patches this slot during ISP-over-UART flashing, but raw SWD programmers (pyocd / J-Link / CMSIS-DAP) do not — so fbuild's linked image was non-bootable over SWD because the slot was left zero.

This bakes the checksum into the image itself so no external linker script or board_build.ldscript declaration is required anywhere for the firmware to boot:

  • lpc845.ld / lpc804.ld: compute _isr_vector_checksum = 0 - (_estack + (Reset_Handler+1) + (NMI_Handler+1) + (HardFault_Handler+1)). Only the linker can sum these relocatable vector symbols; the +1 terms add the thumb bit that the assembler's .word <Handler> carries in the emitted table.
  • startup_lpc845.S / startup_lpc804.S: emit .word _isr_vector_checksum at the 0x1C vector slot (was .word 0).
  • New unit test boot_checksum_is_baked_into_assets guards both halves (linker formula + startup emission) for both MCUs.
  • README documents the boot-ROM checksum requirement.

Part of the LPC8xx end-to-end effort (#487 / #479).

Verification

End-to-end build of the lpc845 fixture (arm-none-eabi-gcc 15.2.1) links cleanly, and the produced firmware.bin's first 8 vector words sum to exactly zero:

0x00: 0x10004000   (_estack)
0x04: 0x00000105   (Reset_Handler | thumb)
0x08: 0x00000135   (NMI_Handler   | thumb)
0x0C: 0x00000135   (HardFault     | thumb)
0x10..0x18: 0
0x1C: 0xEFFFBC91   (computed checksum)
sum mod 2^32 = 0x00000000  => BOOTABLE

Test plan

  • soldr cargo test -p fbuild-build --lib nxplpc (20/20 pass, incl. new checksum guard)
  • soldr cargo clippy -p fbuild-build --all-targets -- -D warnings clean
  • Real lpc845 fixture build + firmware.bin checksum inspection (sum = 0)
  • On-hardware SWD boot confirmation (no LPC845 board on hand)

🤖 Generated with Claude Code

The LPC8xx boot ROM only runs an image whose first 8 vector words sum to
zero (mod 2^32); offset 0x1C holds the two's-complement that closes the
sum. lpc21isp patches this during ISP flashing, but raw SWD programmers
(pyocd/jlink/cmsis-dap) do not, so fbuild's image was non-bootable over
SWD because the slot was left zero.

Compute the checksum in the bundled linker scripts (only the linker can
sum the relocatable vector symbols) and emit it from the startup tables
at 0x1C, so no external linker script or board_build.ldscript is needed
anywhere for the firmware to boot. The +1 terms add the thumb bit that
.word <Handler> carries in the emitted table.

Verified end-to-end: the linked lpc845 firmware.bin's first 8 vector
words sum to 0x00000000 (checksum slot 0x1C = 0xEFFFBC91).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@zackees, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 55 minutes. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f5edbebe-4a17-407c-9a7d-88767947009e

📥 Commits

Reviewing files that changed from the base of the PR and between 3bcd747 and dc54dc4.

📒 Files selected for processing (6)
  • crates/fbuild-build/src/nxplpc/README.md
  • crates/fbuild-build/src/nxplpc/assets/lpc804.ld
  • crates/fbuild-build/src/nxplpc/assets/lpc845.ld
  • crates/fbuild-build/src/nxplpc/assets/startup_lpc804.S
  • crates/fbuild-build/src/nxplpc/assets/startup_lpc845.S
  • crates/fbuild-build/src/nxplpc/orchestrator.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/lpc8xx-boot-checksum

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 merged commit 1d8ae0e into main Jun 13, 2026
89 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 14, 2026
@zackees
zackees deleted the fix/lpc8xx-boot-checksum branch October 16, 2026 11:20
Sign up for free to 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