Fixes for old Maxim SDK

pull/840/head
Mattia Moffa 2026-06-25 04:24:45 +02:00 committed by Daniele Lacamera
parent d750f46723
commit 357734d691
4 changed files with 24 additions and 15 deletions

View File

@ -253,6 +253,7 @@ ifeq ($(ARCH),ARM)
NO_ARM_ASM=1
CFLAGS+=-DMAX3266X_SHA -DFAST_MEMCPY
CFLAGS+=-ffunction-sections -fdata-sections
CFLAGS+=-DTARGET=MAX32665 -DTARGET_REV=0x4131
ifeq ($(MAX3266X_OLD),1)
# Older Maxim SDK tree (flat MAX32665PeriphDriver layout)
CFLAGS+=-DWOLFSSL_MAX3266X_OLD
@ -265,7 +266,6 @@ ifeq ($(ARCH),ARM)
$(MSDK_DIR)/Libraries/MAX32665PeriphDriver/Source/mxc_delay.o
else
CFLAGS+=-DWOLFSSL_MAX3266X
CFLAGS+=-DTARGET=MAX32665 -DTARGET_REV=0x4131
MAX3266X_CFLAGS:= \
-I$(MSDK_DIR)/Libraries/PeriphDrivers/Include/MAX32665/ \
-I$(MSDK_DIR)/Libraries/CMSIS/Device/Maxim/MAX32665/Include/ \

View File

@ -44,9 +44,8 @@
#include "max32666.h"
/* CMSIS variable required by MSDK drivers (mxc_delay.c).
* Only define in bootloader; test-app provides its own. */
#if defined(WOLFSSL_MAX3266X) && defined(__WOLFBOOT)
/* CMSIS variable required by MSDK drivers (mxc_delay.c). */
#if defined(WOLFSSL_MAX3266X) || defined(WOLFSSL_MAX3266X_OLD)
uint32_t SystemCoreClock = 96000000;
#endif

View File

@ -696,13 +696,24 @@ endif
ifeq ($(TARGET),max32666)
LSCRIPT_TEMPLATE=ARM-max32666.ld
ifeq ($(WOLFCRYPT_MAX32666_TEST),1)
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/TRNG/trng_me14.o
APP_OBJS += $(MSDK_DIR)/Libraries/PeriphDrivers/Source/TRNG/trng_revb.o
APP_OBJS += $(MSDK_DIR)/Libraries/PeriphDrivers/Source/SYS/sys_me14.o
APP_OBJS += $(MSDK_DIR)/Libraries/PeriphDrivers/Source/SYS/mxc_delay.o
ifeq ($(MAX3266X_OLD),1)
MAX3266X_SRC := $(MSDK_DIR)/Libraries/MAX32665PeriphDriver/Source
APP_OBJS += $(MAX3266X_SRC)/hash.o
APP_OBJS += $(MAX3266X_SRC)/cipher.o
APP_OBJS += $(MAX3266X_SRC)/maa.o
APP_OBJS += $(MAX3266X_SRC)/mem_utils.o
APP_OBJS += $(MAX3266X_SRC)/trng.o
APP_OBJS += $(MAX3266X_SRC)/mxc_sys.o
APP_OBJS += $(MAX3266X_SRC)/mxc_delay.o
else
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/TRNG/trng_me14.o
APP_OBJS += $(MSDK_DIR)/Libraries/PeriphDrivers/Source/TRNG/trng_revb.o
APP_OBJS += $(MSDK_DIR)/Libraries/PeriphDrivers/Source/SYS/sys_me14.o
APP_OBJS += $(MSDK_DIR)/Libraries/PeriphDrivers/Source/SYS/mxc_delay.o
endif
APP_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/maxim/max3266x.o
endif
endif

View File

@ -19,10 +19,6 @@
#include "hal/max32666.h"
#ifdef WOLFCRYPT_MAX32666_TEST
/* MSDK's mxc_delay.c references SystemCoreClock (CMSIS).
* wolfBoot configures HIRC96M = 96 MHz in hal_init(). */
uint32_t SystemCoreClock = 96000000;
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/aes.h>
#include <wolfssl/wolfcrypt/ecc.h>
@ -169,6 +165,9 @@ static int test_ecdhe_p256(void)
/* Enable TRNG peripheral clock before wc_InitRng seeds from hardware */
GCR_PERCKCN1 &= ~GCR_PERCKCN1_TRNGD;
/* Wait for the entropy source to come up before wc_InitRng's health test */
while ((MXC_TRNG->st & MXC_F_TRNG_ST_RND_RDY) == 0) {}
ret = wc_InitRng(&rng);
if (ret != 0) {
wolfBoot_printf("FAIL (InitRng: %d)\n", ret);