Repository navigation
Conversation
dgarske
force-pushed
the
samd21
branch
3 times, most recently
from
October 29, 2026 04:39
6cc2361 to
5f280ce
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Two commits: the hybrid signing fixes first, then the SAMD21 target that depends on them.
hybrid: fix LMS/XMSS keystore import and PQ secondary builds
A hybrid LMS or XMSS image never verified. The LMS and XMSS verify paths imported the public key at
KEYSTORE_PUBKEY_SIZE, the keystore slot width, but a universal keystore sizes every slot for the widest algorithm in the build, so the key arrived padded and the import rejected it. The ML-DSA path already asked the key for its own length.Three related problems came from the same assumption that the primary algorithm describes the whole keystore: a classic primary with a post-quantum secondary defined
wolfBoot_verify_signature_primarytwice and did not build, the slot width and the stack ceiling followed the primary alone, andkeygen -imistook slot padding for a DER header when reading the first public key back out.Also fixed: an LMS key could not produce a second signature in one run, which a delta image needs for its own header, because the callback setters and
wc_LmsKey_Reload()reject a key that is already working. And the manifest is now sized from its contents for every image rather than only when a certificate chain, custom TLV or DTS is present, with the delta path resolving the same growth before it computes the inverse-patch offset.samd21: add example configs, SERCOM console and NVMCTRL fixes
hal/samr21.cis a SAM D21 HAL, clocked for a SAMD21G18A at 48MHz, but nothing could reach it: no example config, no docs, no CI build. Addssamd21.config,samd21_j18.configandsamd21_j18_hybrid.config(LMS plus ECDSA P-256), a SERCOM console, adocs/Targets.mdsection, CI jobs, andwolfBoot_success()in the test app so an A/B update confirms instead of rolling back.WOLFBOOT_RAM_SIZEis now a linker substitution, as the script hardcoded 16KB and capped the 32KB parts. Both layouts use a 32KB bootloader region, the largest the NVMCTRLBOOTPROTfuse can protect.HAL fixes:
hal_init()andhal_prepare_boot()clearedAPBBMASK.NVMCTRL, set out of reset, gating the flash controller's clock off before any write or erase;PAC_WP_NVMCTLwas the DSU bit, where NVMCTRL is peripheral 34 against PAC1's base 32, so bit 2;hal_flash_write()issued one page-write per transfer and now setsCTRLB.MANWand commits each page; and write and erase always returned success, where they now reportNVMCTRL.STATUSerrors.Testing
Simulator: both orderings of LMS and XMSS against ECC256, ML-DSA as a secondary, and an LMS delta image whose inverse-patch offset tracks the grown header.
sim-lms,sim-xmss,sim-ml-dsa-ecc-hybridandsim.configare unchanged, and the unit tests pass.SAMD21 is not validated on hardware; the console pinout is from the Xplained Pro schematic. All three configs build, and
unit-samr21-erase-advanceandunit-flash-write-samr21cover the erase stride, a multi-page write and the error returns.