Repository navigation
Adding minimal SAMD51 port based on uf2-samdx1 implementation #616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hathach
wants to merge
25
commits into
master
Choose a base branch
from
samd51-port
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
b145d96
Add SAMD51 port with the Intech Studio Grid bootloader boards
SukuWc 0b89790
samd51: add NEOPIXEL_POWER_STATE like the espressif boards
SukuWc cfc2459
samd51: follow the UF2 Board-ID format with a revision token
SukuWc ecb44d2
samd51: count NeoPixel timing in cycles
SukuWc ced86cf
samd51: derive the application flash size from the board
SukuWc 2d7eb06
samd51: reject a bootloader image with an even reset vector
SukuWc 5edf587
Merge pull request #10 from adafruit/master
SukuWc 26786ba
Merge master into samd51-port
hathach dc9ff8f
samd51: address review findings on flash bounds, page writes and app …
hathach 98083d4
samd51: share the vector table check and bound app entries by usable …
hathach 094cf44
samd51: bound new bootloader reset entry by its image and fix Debug u…
hathach a892dd6
Merge remote-tracking branch 'origin/master' into samd51-port
hathach 927409c
samd51: share one linker script body, define the flash size once, add…
hathach 1e2480f
samd51: take the flash size from the device header, let the linker ch…
hathach 0869137
samd51: name the boards Grid and Wrid in USB and the board list
hathach 3c42aa1
samd51: add Metro M4 Express with double tap, J-Link target and HIL f…
hathach fe59557
supported_boards: add Metro M4 Express
hathach 8f44299
samd51: re-enable DWT in the cycle counter waits
hathach a68bb97
hil-contract: find the Microchip DFP startup's vector table, exceptio…
hathach 9b470ab
samd51: name the initialised data output section .data
hathach ea2f479
hil: keep the rig job running past files another user left in its wor…
hathach 04befa8
hil: add the Metro M4 Express on ci.lan, pending re-entry commissioning
hathach 41d6909
hil: commission the Metro M4 Express on ci.lan, retained-register re-…
hathach d94b2e6
hil: simplify the workspace clean and the pending-board check
hathach 1cda275
hil-contract: date the Metro M4 Express's commissioning apart from th…
hathach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,6 +75,7 @@ jobs: | |
| - 'lpc55' | ||
| - 'maxim' | ||
| - 'mimxrt10xx' | ||
| - 'samd51' | ||
| - 'stm32f3' | ||
| - 'stm32f4' | ||
| - 'stm32h5' | ||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| cmake_minimum_required(VERSION 3.20) | ||
|
|
||
| include(${CMAKE_CURRENT_LIST_DIR}/../family_support.cmake) | ||
|
|
||
| project(tinyuf2 C ASM) | ||
| set(CMAKE_EXECUTABLE_SUFFIX .elf) | ||
|
|
||
| #------------------------------------ | ||
| # TinyUF2 | ||
| #------------------------------------ | ||
| add_executable(tinyuf2 | ||
| board_flash.c | ||
| boards.c | ||
| ${TOP}/lib/tinyusb/src/portable/microchip/samd/dcd_samd.c | ||
| ) | ||
| target_link_options(tinyuf2 PUBLIC | ||
| "LINKER:--script=${CMAKE_CURRENT_LIST_DIR}/linker/samd51_boot.ld" | ||
| "LINKER:--script=${CMAKE_CURRENT_LIST_DIR}/linker/samd51_common.ld" | ||
| ) | ||
|
|
||
| family_configure_tinyuf2(tinyuf2 OPT_MCU_SAMD51) | ||
| family_flash_openocd(tinyuf2) | ||
| family_flash_jlink(tinyuf2 hex) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| #------------------------------------ | ||
| # Application | ||
| #------------------------------------ | ||
| family_add_app(update-tinyuf2 ${TOP}/apps/self_update SELF_UPDATE) | ||
| family_add_app(blinky ${TOP}/apps/blinky) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # TinyUF2 for SAMD51 | ||
|
|
||
| Port for SAMD51. Boards: | ||
|
|
||
| | Board | Notes | | ||
| | --- | --- | | ||
| | `intech_grid` | Intech Studio Grid modules (SAMD51N20A), volume `GRID26` | | ||
| | `intech_wrid` | Same hardware and USB IDs as `intech_grid`, volume `WRID26`, to tell the two bootloaders apart | | ||
| | `metro_m4_express` | Adafruit Metro M4 Express (SAMD51J19A), volume `METROM4BOOT` | | ||
|
|
||
| ## Flash layout | ||
|
|
||
| | Address | Content | | ||
| | --- | --- | | ||
| | `0x00000000` | TinyUF2, 16 KB, write protected with BOOTPROT | | ||
| | `0x00004000` | Application | | ||
|
|
||
| With the default 16 KB boot size the application must be linked at `0x4000`. To create a UF2 image from a `.bin` | ||
| file: | ||
|
|
||
| ``` | ||
| uf2conv.py -c -b 0x4000 -f 0x55114460 firmware.bin | ||
| ``` | ||
|
|
||
| UF2 blocks must carry 256 bytes at a 256-byte aligned address, as uf2conv.py writes them. Other blocks are skipped yet | ||
| counted as written (#629), so such a file "completes" with parts of the application missing. | ||
|
|
||
| ## Entering the bootloader | ||
|
|
||
| - Grid and Wrid: hold the button (`PC11`, active low) while the board resets or is plugged in. | ||
| - Metro M4 Express: double tap reset. An application enters it by writing `0xf01669ef` to the last RAM word and | ||
| resetting, as with uf2-samdx1. | ||
| - The bootloader also stays when the application is missing or invalid. | ||
|
|
||
| ## Self-update | ||
|
|
||
| `update-tinyuf2.uf2` is built next to the bootloader in `_bin/<board>/apps`. Copy it to the bootloader drive: it runs | ||
| from the application area, rewrites the bootloader and invalidates itself, then the new bootloader starts. The | ||
| application area is overwritten, so copy the application again afterwards. | ||
|
|
||
| - The bootloader protects itself on every boot: if the BOOTPROT fuse in the user page does not match the 16 KB boot | ||
| size, it is rewritten and the board resets once. The self-update lifts the protection until the next reset | ||
| (`SBPDIS`) to write the new bootloader. | ||
| - Rewriting the BOOTPROT fuse erases the user page before it is programmed again. A power cut in between leaves the | ||
| user page blank, and the bootloader then leaves it alone: restore it with an SWD probe. The user page holds the | ||
| factory BOD12 calibration (bits 25:15), which exists nowhere else: read out and keep the user page of each board | ||
| before its first boot with this bootloader. | ||
| - Updating between `intech_grid` and `intech_wrid` works the same way, the drive label shows which one is installed. | ||
| - A power cut while the bootloader area is erased, or a write that still fails after three tries, leaves the board | ||
| without a bootloader: recover it with an SWD probe. To program the bootloader over SWD, first remove the protection | ||
| with `atsame5 bootloader 0` in OpenOCD and reset. | ||
|
|
||
| ## Debugging | ||
|
|
||
| - `BOD33` is set to 2.7 V at start. The default level is too low and flash writes can store zeros. | ||
| - The application usually takes over the SWD pins. Hold the button while powering up so the bootloader runs and SWD | ||
| stays usable. | ||
| - The bootloader must fit in 16 KB. A Debug build or logging (`-DLOG=1 -DLOGGER=RTT`) does not: the Debug build type | ||
| increases the boot size to 64 KB, and the application then has to be linked at `0x10000` and converted with | ||
| `uf2conv.py -c -b 0x10000 -f 0x55114460 firmware.bin`. The port has no UART: `LOG` without a `LOGGER` selection | ||
| prints nothing. | ||
| - Flash with openocd and a CMSIS-DAP probe: `cmake --build build --target tinyuf2-openocd`. It lifts the bootloader | ||
| protection first, the bootloader protects itself again at boot. | ||
| - Erratum 2.6.10 (DS80000748, silicon revisions A, D and F): a power-up can corrupt the reset vector fetch. Its | ||
| workaround sets the user page fuses WDT Enable to 1 and WDT Period to 0; the bootloader does not set them. With them | ||
| set, the watchdog runs from reset until `board_init` disables it. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| include_guard(GLOBAL) | ||
|
|
||
| function(family_configure_app TARGET) | ||
| family_configure_common(${TARGET}) | ||
| target_link_options(${TARGET} PUBLIC | ||
| "LINKER:--script=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/samd51_app.ld" | ||
| "LINKER:--script=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/linker/samd51_common.ld" | ||
| ) | ||
| endfunction() |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.