Skip to content

MAX32666 port#804

Draft
mattia-moffa wants to merge 6 commits into
wolfSSL:masterfrom
mattia-moffa:20260323-max32666
Draft

MAX32666 port#804
mattia-moffa wants to merge 6 commits into
wolfSSL:masterfrom
mattia-moffa:20260323-max32666

Conversation

@mattia-moffa

Copy link
Copy Markdown
Member

Port for Maxim's MAX32666, including hardware-acceleration.

@mattia-moffa mattia-moffa self-assigned this Jun 19, 2026
Copilot AI review requested due to automatic review settings June 19, 2026 21:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread test-app/syscalls.c
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 thread hal/max32666.c
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 thread hal/max32666.ld
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 thread docs/Targets.md
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 thread test-app/Makefile
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 thread src/string.c
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 thread hal/max32666.h
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
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants