MAX32666 port#804
Draft
mattia-moffa wants to merge 6 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new hardware target port for Analog Devices/Maxim MAX32666 (and MAX32665 family overlap), including bootloader HAL support plus an optional wolfCrypt hardware-acceleration test application flow.
Changes:
- Introduces MAX32666 HAL implementation (clock/UART/flash) and linker scripts for both wolfBoot and the test app.
- Adds MAX32666-specific build options and test-app wiring for MSDK TPU/MAA/TRNG acceleration.
- Updates shared infrastructure (string/memset behavior for ARM, wolfSSL user settings gating, keytools flags) to support the new target.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/openocd/max32665.cfg | Adds OpenOCD configuration for MAX32665/MAX32666 dual-bank flash programming. |
| tools/keytools/Makefile | Adjusts keytools build flags for ML-DSA/Dilithium configuration. |
| test-app/syscalls.c | Enhances bare-metal heap allocator to reclaim top-of-heap allocations and support in-place realloc. |
| test-app/Makefile | Adds MAX32666-specific build/test knobs, linker script selection, and MSDK object wiring for HW crypto tests. |
| test-app/ARM-max32666.ld | Adds a MAX32666 test-app linker script (FLASH/RAM layout, heap/stack symbols). |
| test-app/app_max32666.c | New MAX32666 test application including optional AES-GCM and ECDHE KATs using hardware acceleration. |
| src/string.c | Updates memset to use aligned word writes on ARM/AARCH64; adds stdint include. |
| include/user_settings.h | Adjusts wolfSSL feature gating for the MAX32666 crypto test mode and SP math defines. |
| hal/max32666.ld | New MAX32666 wolfBoot linker script. |
| hal/max32666.h | New MAX32666 register/bitfield definitions and debug UART selection. |
| hal/max32666.c | New MAX32666 HAL implementation (watchdog/clock/cache/UART/flash operations). |
| docs/Targets.md | Documents MAX32666 target build/flash/run instructions and configuration options. |
| config/examples/max32666.config | Adds an example configuration for building wolfBoot for MAX32666 (TPU enabled). |
| arch.mk | Adds MAX32666 target build logic, MSDK include/obj wiring, and enables FAST_MEMCPY for ARM builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+522
to
526
| /* Not the most recent allocation: allocate new and copy */ | ||
| newp = malloc(new_size); | ||
| if (newp) | ||
| memcpy(newp, ptr, size); /* may over-copy, but safe for bump alloc */ | ||
| memcpy(newp, ptr, new_size); /* may over-copy, safe for bump alloc */ | ||
| return newp; |
Comment on lines
+128
to
+131
| static void RAMFUNCTION flc_lock(volatile uint32_t *flc_base) | ||
| { | ||
| FLC_REG(flc_base, FLC_ACNTL_OFF) = 0; | ||
| } |
Comment on lines
+66
to
+73
| /* Partition addresses for wolfBoot */ | ||
| _wolfboot_partition_boot_address = @WOLFBOOT_PARTITION_BOOT_ADDRESS@; | ||
| _wolfboot_partition_size = @WOLFBOOT_PARTITION_SIZE@; | ||
| _wolfboot_partition_update_address = @WOLFBOOT_PARTITION_UPDATE_ADDRESS@; | ||
| _wolfboot_partition_swap_address = @WOLFBOOT_PARTITION_SWAP_ADDRESS@; | ||
|
|
||
| /* Stack at end of SRAM (grows down) */ | ||
| END_STACK = ORIGIN(RAM) + LENGTH(RAM); |
Comment on lines
+8508
to
+8512
| - Bare-metal implementation (no MSDK required for boot) | ||
| - UART0 debug output: | ||
| - P1.13 TX, P1.12 RX on FTHR board | ||
| - P0.9 TX, P0.10 RX on FTHR2 board | ||
|
|
Comment on lines
+592
to
+598
| APP_OBJS += $(MSDK_DIR)/Libraries/PeriphDrivers/Source/TPU/tpu_me14.o | ||
| APP_OBJS += $(MSDK_DIR)/Libraries/PeriphDrivers/Source/TPU/tpu_reva.o | ||
| APP_OBJS += $(MSDK_DIR)/Libraries/PeriphDrivers/Source/TRNG/trng_reva.o | ||
| APP_OBJS += $(MSDK_DIR)/Libraries/PeriphDrivers/Source/SYS/sys_me14.o | ||
| APP_OBJS += $(MSDK_DIR)/Libraries/PeriphDrivers/Source/SYS/mxc_delay.o | ||
| APP_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/maxim/max3266x.o | ||
| endif |
Comment on lines
+104
to
+124
| #if defined(ARCH_ARM) || defined(ARCH_AARCH64) | ||
| /* Use word-sized writes when aligned — required for MMIO peripheral | ||
| * registers on ARM (APB bus does not support sub-word writes). */ | ||
|
|
||
| /* Write bytes until the pointer is 4-byte aligned */ | ||
| while (n > 0 && ((uintptr_t)d & 3U)) { | ||
| *d++ = uc; | ||
| n--; | ||
| } | ||
|
|
||
| if (n >= 4) { | ||
| uint32_t w = ((uint32_t)uc) | ((uint32_t)uc << 8) | | ||
| ((uint32_t)uc << 16) | ((uint32_t)uc << 24); | ||
| volatile uint32_t *dw = (volatile uint32_t *)d; | ||
| while (n >= 4) { | ||
| *dw++ = w; | ||
| n -= 4; | ||
| } | ||
| d = (unsigned char *)dw; | ||
| } | ||
| #endif /* ARCH_ARM || ARCH_AARCH64 */ |
Comment on lines
+284
to
+287
| /* Select debug UART instance | ||
| * MAX32666FTHR uses UART1 MAP_B (P1.12 RX, P1.13 TX) through external PICO | ||
| * MAX32666FTHR2 uses UART0 MAP_A (P0.0 TX, P0.1 RX) through onboard DAPLINK | ||
| */ |
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.
Port for Maxim's MAX32666, including hardware-acceleration.