From f4d1c027307f74de1a126c7ee98a70e7965405d8 Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Tue, 18 Feb 2025 14:39:51 +0100 Subject: [PATCH] Fixed flash driver, added documentation, tested --- arch.mk | 33 +++++++-------- config/examples/mcxa.config | 6 +-- config/examples/mcxw.config | 8 ++-- docs/Targets.md | 80 +++++++++++++++++++++++++++++++++++++ hal/mcxw.c | 3 -- 5 files changed, 101 insertions(+), 29 deletions(-) diff --git a/arch.mk b/arch.mk index 3bab5372..d3abb701 100644 --- a/arch.mk +++ b/arch.mk @@ -617,7 +617,13 @@ ifeq ($(TARGET),mcxa) -I$(MCUXPRESSO)/drivers \ -I$(MCUXPRESSO)/drivers/common \ -I$(MCUXPRESSO_CMSIS)/Include \ - -I$(MCUXPRESSO_CMSIS)/Core/Include + -I$(MCUXPRESSO_CMSIS)/Core/Include \ + -I$(MCUXPRESSO)/drivers/flash \ + -I$(MCUXPRESSO)/drivers/mcx_spc \ + -I$(MCUXPRESSO)/drivers/sysmpu \ + -I$(MCUXPRESSO)/drivers/ltc \ + -I$(MCUXPRESSO)/drivers/port \ + -I$(MCUXPRESSO)/drivers/gpio CFLAGS+=-DCPU_$(MCUXPRESSO_CPU) -DDEBUG_CONSOLE_ASSERT_DISABLE=1 CFLAGS+=-DWOLFSSL_SP_NO_UMAAL CFLAGS+=-Wno-old-style-declaration @@ -627,14 +633,6 @@ ifeq ($(TARGET),mcxa) $(MCUXPRESSO_DRIVERS)/drivers/fsl_clock.o \ $(MCUXPRESSO)/drivers/mcx_spc/fsl_spc.o \ $(MCUXPRESSO_DRIVERS)/project_template/clock_config.o - - CFLAGS+=\ - -I$(MCUXPRESSO)/drivers/flash \ - -I$(MCUXPRESSO)/drivers/mcx_spc \ - -I$(MCUXPRESSO)/drivers/sysmpu \ - -I$(MCUXPRESSO)/drivers/ltc \ - -I$(MCUXPRESSO)/drivers/port \ - -I$(MCUXPRESSO)/drivers/gpio endif ifeq ($(TARGET),mcxw) @@ -648,7 +646,13 @@ ifeq ($(TARGET),mcxw) -I$(MCUXPRESSO)/drivers/ccm32k \ -I$(MCUXPRESSO)/drivers/common \ -I$(MCUXPRESSO_CMSIS)/Include \ - -I$(MCUXPRESSO_CMSIS)/Core/Include + -I$(MCUXPRESSO_CMSIS)/Core/Include \ + -I$(MCUXPRESSO)/drivers/flash \ + -I$(MCUXPRESSO)/drivers/spc \ + -I$(MCUXPRESSO)/drivers/sysmpu \ + -I$(MCUXPRESSO)/drivers/ltc \ + -I$(MCUXPRESSO)/drivers/port \ + -I$(MCUXPRESSO)/drivers/gpio CFLAGS+=-DCPU_$(MCUXPRESSO_CPU) -DDEBUG_CONSOLE_ASSERT_DISABLE=1 CFLAGS+=-DWOLFSSL_SP_NO_UMAAL CFLAGS+=-Wno-old-style-declaration @@ -660,15 +664,6 @@ ifeq ($(TARGET),mcxw) $(MCUXPRESSO_DRIVERS)/project_template/clock_config.o \ $(MCUXPRESSO)/drivers/ccm32k/fsl_ccm32k.o \ $(MCUXPRESSO_DRIVERS)/drivers/fsl_romapi.o - - CFLAGS+=\ - -I$(MCUXPRESSO)/drivers/flash \ - -I$(MCUXPRESSO)/drivers/spc \ - -I$(MCUXPRESSO)/drivers/sysmpu \ - -I$(MCUXPRESSO)/drivers/ltc \ - -I$(MCUXPRESSO)/drivers/port \ - -I$(MCUXPRESSO)/drivers/gpio - endif ifeq ($(TARGET),imx_rt) diff --git a/config/examples/mcxa.config b/config/examples/mcxa.config index 8599965b..6a3c20f2 100644 --- a/config/examples/mcxa.config +++ b/config/examples/mcxa.config @@ -2,9 +2,9 @@ ARCH?=ARM TARGET?=mcxa SIGN?=ECC256 HASH?=SHA256 -MCUXSDK?=0 -MCUXPRESSO?=$(PWD)/../NXP/MCXA153 -MCUXPRESSO_CMSIS?=$(MCUXPRESSO)/CMSIS +MCUXSDK?=1 +MCUXPRESSO?=$(PWD)/../NXP/mcux-sdk +MCUXPRESSO_CMSIS?=$(PWD)/../NXP/CMSIS_5/CMSIS MCUXPRESSO_CPU?=MCXA153VLH MCUXPRESSO_DRIVERS?=$(MCUXPRESSO)/devices/MCXA153 DEBUG?=0 diff --git a/config/examples/mcxw.config b/config/examples/mcxw.config index 86344f79..35d10e4e 100644 --- a/config/examples/mcxw.config +++ b/config/examples/mcxw.config @@ -2,9 +2,9 @@ ARCH?=ARM TARGET?=mcxw SIGN?=ECC256 HASH?=SHA256 -MCUXSDK?=0 -MCUXPRESSO?=$(PWD)/../NXP/MCXW71 -MCUXPRESSO_CMSIS?=$(MCUXPRESSO)/CMSIS +MCUXSDK?=1 +MCUXPRESSO?=$(PWD)/../NXP/mcux-sdk +MCUXPRESSO_CMSIS?=$(PWD)/../NXP/CMSIS_5/CMSIS MCUXPRESSO_CPU?=MCXW716CMFTA MCUXPRESSO_DRIVERS?=$(MCUXPRESSO)/devices/MCXW716C DEBUG?=0 @@ -15,7 +15,7 @@ NO_MPU=1 EXT_FLASH?=0 SPI_FLASH?=0 ALLOW_DOWNGRADE?=0 -NVM_FLASH_WRITEONCE?=0 +NVM_FLASH_WRITEONCE?=1 NO_ARM_ASM=1 WOLFBOOT_VERSION?=0 V?=0 diff --git a/docs/Targets.md b/docs/Targets.md index fdc1242c..bdfc3b9c 100644 --- a/docs/Targets.md +++ b/docs/Targets.md @@ -19,6 +19,7 @@ This README describes configuration of supported targets. * [NXP LPC54xxx](#nxp-lpc54xxx) * [NXP LS1028A](#nxp-ls1028a) * [NXP MCXA153](#nxp-mcxa153) +* [NXP MCXW716C](#nxp-mcxw716c) * [NXP P1021 PPC](#nxp-qoriq-p1021-ppc) * [NXP T1024 PPC](#nxp-qoriq-t1024-ppc) * [NXP T2080 PPC](#nxp-qoriq-t2080-ppc) @@ -2241,6 +2242,85 @@ mon reset c ``` +## NXP MCXW716 + +NXP MCXW716 is a Cortex-M33 microcontroller running at 96MHz. +The support has been tested using FRDM-MCXW716 with the onboard MCU-Link configured in JLink mode. + +This requires the MCXW SDK from the NXP MCUXpresso SDK Builder. We tested using [mcux-sdk](https://github.com/nxp-mcuxpresso/mcux-sdk) and [CMSIS_5](https://github.com/nxp-mcuxpresso/CMSIS_5)` +placed under "../NXP". Adjust the MCUXPRESSO and MCUXPRESSO_CMSIS variables in your .config file according to your paths. + +### MCX W: Configuring and compiling + +Copy the example configuration file and build with make: + +```sh +cp config/examples/mcxw.config .config` +make +``` + +### MCX W: Loading the firmware + +The NXP Freedom MCX W board debugger comes loaded with MCU Link, but it can be updated to JLink. See https://docs.nxp.com/bundle/UM12012/page/topics/Updating_MCU_Link_firmware.html + +Use JLinkExe tool to upload the initial firmware: `JLinkExe -if swd -Device MCXW716` + +At the Jlink prompt, type: + +``` +loadbin factory.bin 0 +Downloading file [factory.bin]... +J-Link: Flash download: Bank 0 @ 0x00000000: Skipped. Contents already match +O.K. +``` + +Reset or power cycle board. + +Once wolfBoot has performed validation of the partition and booted the D15 Green LED on P3_13 will illuminate. + +### MCX W: Testing firmware update + +1) Sign the test-app with version 2: + +```sh +./tools/keytools/sign --ecc256 test-app/image.bin wolfboot_signing_private_key.der 2 +``` + +2) Create a bin footer with wolfBoot trailer "BOOT" and "p" (ASCII for 0x70 == IMG_STATE_UPDATING): + +```sh +echo -n "pBOOT" > trigger_magic.bin +``` + +3) Assembly new factory update.bin: + +```sh +./tools/bin-assemble/bin-assemble \ + update.bin \ + 0x0 test-app/image_v2_signed.bin \ + 0xAFFB trigger_magic.bin +``` + +4) Flash update.bin to 0x13000 (`loadbin update.bin 0x13000`). The D15 RGB LED Blue P3_0 will show if version is > 1. + +Note: For alternate larger scheme flash `update.bin` to `0x14000` and place trigger_magic.bin at `0x9FFB`. + +### MCX W: Debugging + +Debugging with JLink: + +Note: We include a `.gdbinit` in the wolfBoot root that loads the wolfboot and test-app elf files. + +In one terminal: `JLinkGDBServer -if swd -Device MCXW716 -port 3333` + +In another terminal use `gdb`: + +``` +b main +mon reset +c +``` + ## TI Hercules TMS570LC435 diff --git a/hal/mcxw.c b/hal/mcxw.c index b6b70894..9faa794d 100644 --- a/hal/mcxw.c +++ b/hal/mcxw.c @@ -75,9 +75,6 @@ void hal_init(void) /* Clock setting */ BOARD_BootClockRUN(); #endif - - /* Flash driver init */ - flash_config_t pflash; /* Clear the FLASH configuration structure */ memset(&pflash, 0, sizeof(pflash)); /* FLASH driver init */