Repository navigation
fix(nxplpc): bake LPC8xx boot-ROM vector checksum into linked image - #556
Conversation
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]>
|
Warning Review limit reached
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 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary
The LPC8xx boot ROM only executes an image whose first 8 vector words sum to zero (mod 2³²); the word at offset
0x1Cis reserved for the two's-complement that closes the sum.lpc21isppatches 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.ldscriptdeclaration 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+1terms 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_checksumat the0x1Cvector slot (was.word 0).boot_checksum_is_baked_into_assetsguards both halves (linker formula + startup emission) for both MCUs.Part of the LPC8xx end-to-end effort (#487 / #479).
Verification
End-to-end build of the
lpc845fixture (arm-none-eabi-gcc 15.2.1) links cleanly, and the producedfirmware.bin's first 8 vector words sum to exactly zero: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 warningscleanfirmware.binchecksum inspection (sum = 0)🤖 Generated with Claude Code