Repository navigation
Conversation
dgarske
force-pushed
the
samd21
branch
3 times, most recently
from
October 29, 2026 04:39
6cc2361 to
5f280ce
Compare
dgarske
force-pushed
the
samd21
branch
2 times, most recently
from
October 29, 2026 05:19
8771890 to
7b02878
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
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.Adds
config/examples/samd21.configandsamd21_j18.configfor the 128KB/16KB and 256KB/32KB parts, 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, because the NVMCTRL
BOOTPROTfuse protects 8KB, 16KB or 32KB and nothing in between: any other boundary either leaves the bootloader writable or pushes the protected region into the boot partition, where it would block the swap.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; NVMCTRL is peripheral 34 vs PAC1's base 32, so bit 2.hal_flash_write()issued one page-write per transfer; now setsCTRLB.MANWand commits each page.NVMCTRL.STATUSerrors.Testing
Not validated on hardware; the console pinout is from the Xplained Pro schematic. Both configs build, and
unit-samr21-erase-advanceandunit-flash-write-samr21cover the erase stride, a multi-page write and the error returns.