Skip to content

Commit b9a3958

Browse files
authored
Merge pull request #551 from danielinux/mcxw71
Added support for NXP MCX W71
2 parents 71346b8 + ea79b86 commit b9a3958

File tree

11 files changed

+579
-71
lines changed

11 files changed

+579
-71
lines changed

.github/workflows/test-configs.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,17 @@ jobs:
159159
arch: ppc
160160
config-file: ./config/examples/nxp-t2080.config
161161

162-
# MCXA test disabled until MCXA is available in mcux
163-
# nxp_mcxa_test:
164-
# uses: ./.github/workflows/test-build-mcux-sdk.yml
165-
# with:
166-
# arch: arm
167-
# config-file: ./config/examples/mcxa.config
162+
nxp_mcxa_test:
163+
uses: ./.github/workflows/test-build-mcux-sdk.yml
164+
with:
165+
arch: arm
166+
config-file: ./config/examples/mcxa.config
167+
168+
nxp_mcxw_test:
169+
uses: ./.github/workflows/test-build-mcux-sdk.yml
170+
with:
171+
arch: arm
172+
config-file: ./config/examples/mcxw.config
168173

169174
raspi3_test:
170175
uses: ./.github/workflows/test-build.yml

arch.mk

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -613,29 +613,57 @@ ifeq ($(TARGET),mcxa)
613613
CFLAGS+=\
614614
-I$(MCUXPRESSO_DRIVERS) \
615615
-I$(MCUXPRESSO_DRIVERS)/drivers \
616+
-I$(MCUXPRESSO_DRIVERS)/drivers/common \
616617
-I$(MCUXPRESSO)/drivers \
617618
-I$(MCUXPRESSO)/drivers/common \
618619
-I$(MCUXPRESSO_CMSIS)/Include \
619-
-I$(MCUXPRESSO_CMSIS)/Core/Include
620+
-I$(MCUXPRESSO_CMSIS)/Core/Include \
621+
-I$(MCUXPRESSO)/drivers/flash \
622+
-I$(MCUXPRESSO)/drivers/mcx_spc \
623+
-I$(MCUXPRESSO)/drivers/sysmpu \
624+
-I$(MCUXPRESSO)/drivers/ltc \
625+
-I$(MCUXPRESSO)/drivers/port \
626+
-I$(MCUXPRESSO)/drivers/gpio
620627
CFLAGS+=-DCPU_$(MCUXPRESSO_CPU) -DDEBUG_CONSOLE_ASSERT_DISABLE=1
621628
CFLAGS+=-DWOLFSSL_SP_NO_UMAAL
622629
CFLAGS+=-Wno-old-style-declaration
623630
CFLAGS+=-mcpu=cortex-m33 -DCORTEX_M33 -U__ARM_FEATURE_DSP
624631
LDFLAGS+=-mcpu=cortex-m33
625632
OBJS+=\
626633
$(MCUXPRESSO_DRIVERS)/drivers/fsl_clock.o \
627-
$(MCUXPRESSO_DRIVERS)/drivers/fsl_spc.o
634+
$(MCUXPRESSO)/drivers/mcx_spc/fsl_spc.o \
635+
$(MCUXPRESSO_DRIVERS)/project_template/clock_config.o
636+
endif
628637

629-
ifeq ($(MCUXSDK),1)
630-
CFLAGS+=\
638+
ifeq ($(TARGET),mcxw)
639+
CORTEX_M33=1
640+
CFLAGS+=\
641+
-I$(MCUXPRESSO_DRIVERS) \
642+
-I$(MCUXPRESSO_DRIVERS)/drivers \
643+
-I$(MCUXPRESSO_DRIVERS)/periph2 \
644+
-I$(MCUXPRESSO)/drivers \
645+
-I$(MCUXPRESSO)/drivers/flash_k4 \
646+
-I$(MCUXPRESSO)/drivers/ccm32k \
647+
-I$(MCUXPRESSO)/drivers/common \
648+
-I$(MCUXPRESSO_CMSIS)/Include \
649+
-I$(MCUXPRESSO_CMSIS)/Core/Include \
631650
-I$(MCUXPRESSO)/drivers/flash \
651+
-I$(MCUXPRESSO)/drivers/spc \
632652
-I$(MCUXPRESSO)/drivers/sysmpu \
633653
-I$(MCUXPRESSO)/drivers/ltc \
634654
-I$(MCUXPRESSO)/drivers/port \
635655
-I$(MCUXPRESSO)/drivers/gpio
636-
637-
else
638-
endif
656+
CFLAGS+=-DCPU_$(MCUXPRESSO_CPU) -DDEBUG_CONSOLE_ASSERT_DISABLE=1
657+
CFLAGS+=-DWOLFSSL_SP_NO_UMAAL
658+
CFLAGS+=-Wno-old-style-declaration
659+
CFLAGS+=-mcpu=cortex-m33 -DCORTEX_M33 -U__ARM_FEATURE_DSP
660+
LDFLAGS+=-mcpu=cortex-m33
661+
OBJS+=\
662+
$(MCUXPRESSO_DRIVERS)/drivers/fsl_clock.o \
663+
$(MCUXPRESSO)/drivers/spc/fsl_spc.o \
664+
$(MCUXPRESSO_DRIVERS)/project_template/clock_config.o \
665+
$(MCUXPRESSO)/drivers/ccm32k/fsl_ccm32k.o \
666+
$(MCUXPRESSO_DRIVERS)/drivers/fsl_romapi.o
639667
endif
640668

641669
ifeq ($(TARGET),imx_rt)

config/examples/mcxa.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ ARCH?=ARM
22
TARGET?=mcxa
33
SIGN?=ECC256
44
HASH?=SHA256
5-
MCUXSDK?=0
6-
MCUXPRESSO?=$(PWD)/../NXP/MCXA153
7-
MCUXPRESSO_CMSIS?=$(MCUXPRESSO)/CMSIS
5+
MCUXSDK?=1
6+
MCUXPRESSO?=$(PWD)/../NXP/mcux-sdk
7+
MCUXPRESSO_CMSIS?=$(PWD)/../NXP/CMSIS_5/CMSIS
88
MCUXPRESSO_CPU?=MCXA153VLH
99
MCUXPRESSO_DRIVERS?=$(MCUXPRESSO)/devices/MCXA153
1010
DEBUG?=0

config/examples/mcxw.config

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
ARCH?=ARM
2+
TARGET?=mcxw
3+
SIGN?=ECC256
4+
HASH?=SHA256
5+
MCUXSDK?=1
6+
MCUXPRESSO?=$(PWD)/../NXP/mcux-sdk
7+
MCUXPRESSO_CMSIS?=$(PWD)/../NXP/CMSIS_5/CMSIS
8+
MCUXPRESSO_CPU?=MCXW716CMFTA
9+
MCUXPRESSO_DRIVERS?=$(MCUXPRESSO)/devices/MCXW716C
10+
DEBUG?=0
11+
VTOR?=1
12+
CORTEX_M0?=0
13+
NO_ASM?=0
14+
NO_MPU=1
15+
EXT_FLASH?=0
16+
SPI_FLASH?=0
17+
ALLOW_DOWNGRADE?=0
18+
NVM_FLASH_WRITEONCE?=1
19+
NO_ARM_ASM=1
20+
WOLFBOOT_VERSION?=0
21+
V?=0
22+
SPMATH?=1
23+
RAM_CODE?=1
24+
DUALBANK_SWAP?=0
25+
PKA?=1
26+
27+
# 8KB sectors
28+
WOLFBOOT_SECTOR_SIZE?=0x2000
29+
30+
# Default configuration
31+
# 32KB boot, 44KB partitions, 8KB swap
32+
WOLFBOOT_PARTITION_SIZE?=0xB000
33+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x8000
34+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x13000
35+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x1E000
36+
37+
# Alternate larger configuration for debugging or ARMASM
38+
# 40KB boot, 40KB partitions, 8KB swap
39+
#WOLFBOOT_PARTITION_SIZE?=0xA000
40+
#WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xA000
41+
#WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x14000
42+
#WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x1E000

docs/Targets.md

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This README describes configuration of supported targets.
1919
* [NXP LPC54xxx](#nxp-lpc54xxx)
2020
* [NXP LS1028A](#nxp-ls1028a)
2121
* [NXP MCXA153](#nxp-mcxa153)
22+
* [NXP MCXW716C](#nxp-mcxw716c)
2223
* [NXP P1021 PPC](#nxp-qoriq-p1021-ppc)
2324
* [NXP T1024 PPC](#nxp-qoriq-t1024-ppc)
2425
* [NXP T2080 PPC](#nxp-qoriq-t2080-ppc)
@@ -2181,7 +2182,15 @@ make
21812182

21822183
### MCX A: Loading the firmware
21832184

2184-
The NXP Freedom MCX A 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
2185+
The NXP Freedom MCX W board debugger comes loaded with MCU Link, but it can be updated to JLink.
2186+
- Download and install the tool to update MCU Link to support jlink:
2187+
[@NXP: LinkServer for microcontrollers](https://www.nxp.com/design/design-center/software/development-software/mcuxpresso-software-and-tools-/linkserver-for-microcontrollers:LINKERSERVER#downloads)
2188+
2189+
- put the rom bootloader in 'dfu' mode by adding a jumper JP8 (ISP_EN)
2190+
2191+
- run `scripts/program_JLINK` to update the onboard debugger
2192+
2193+
- when the update is complete, remove the jumper in JP8
21852194

21862195
Use JLinkExe tool to upload the initial firmware: `JLinkExe -if swd -Device MCXA153`
21872196

@@ -2241,6 +2250,96 @@ mon reset
22412250
c
22422251
```
22432252

2253+
## NXP MCXW716
2254+
2255+
NXP MCXW716 is a Cortex-M33 microcontroller running at 96MHz.
2256+
The support has been tested using FRDM-MCXW716 with the onboard MCU-Link configured in JLink mode.
2257+
2258+
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)`
2259+
placed under "../NXP". Adjust the MCUXPRESSO and MCUXPRESSO_CMSIS variables in your .config file according to your paths.
2260+
2261+
### MCX W: Configuring and compiling
2262+
2263+
Copy the example configuration file and build with make:
2264+
2265+
```sh
2266+
cp config/examples/mcxw.config .config`
2267+
make
2268+
```
2269+
2270+
### MCX W: Loading the firmware
2271+
2272+
The NXP Freedom MCX W board debugger comes loaded with MCU Link, but it can be updated to JLink.
2273+
- Download and install the tool to update MCU Link to support jlink:
2274+
[@NXP: LinkServer for microcontrollers](https://www.nxp.com/design/design-center/software/development-software/mcuxpresso-software-and-tools-/linkserver-for-microcontrollers:LINKERSERVER#downloads)
2275+
2276+
- put the rom bootloader in 'dfu' mode by adding a jumper in JP5 (ISP_EN)
2277+
2278+
- run `scripts/program_JLINK` to update the onboard debugger
2279+
2280+
- when the update is complete, remove the jumper in JP5
2281+
2282+
Use JLinkExe tool to upload the initial firmware: `JLinkExe -if swd -Device MCXW716`
2283+
2284+
At the Jlink prompt, type:
2285+
2286+
```
2287+
loadbin factory.bin 0
2288+
Downloading file [factory.bin]...
2289+
J-Link: Flash download: Bank 0 @ 0x00000000: Skipped. Contents already match
2290+
O.K.
2291+
```
2292+
2293+
Reset or power cycle board.
2294+
2295+
The blue led (PA20) will show to indicate version 1 of the firmware has been staged.
2296+
2297+
2298+
### MCX W: Testing firmware update
2299+
2300+
1) Sign the test-app with version 2:
2301+
2302+
```sh
2303+
./tools/keytools/sign --ecc256 test-app/image.bin wolfboot_signing_private_key.der 2
2304+
```
2305+
2306+
2) Create a bin footer with wolfBoot trailer "BOOT" and "p" (ASCII for 0x70 == IMG_STATE_UPDATING):
2307+
2308+
```sh
2309+
echo -n "pBOOT" > trigger_magic.bin
2310+
```
2311+
2312+
3) Assembly new factory update.bin:
2313+
2314+
```sh
2315+
./tools/bin-assemble/bin-assemble \
2316+
update.bin \
2317+
0x0 test-app/image_v2_signed.bin \
2318+
0xAFFB trigger_magic.bin
2319+
```
2320+
2321+
4) Flash update.bin to 0x13000 (`loadbin update.bin 0x13000`).
2322+
2323+
Once wolfBoot has performed validation of the partition and staged a firmware with version > 1, the D15 Green LED on PA19 will show.
2324+
2325+
Note: For alternate larger scheme flash `update.bin` to `0x14000` and place trigger_magic.bin at `0x9FFB`.
2326+
2327+
### MCX W: Debugging
2328+
2329+
Debugging with JLink:
2330+
2331+
Note: We include a `.gdbinit` in the wolfBoot root that loads the wolfboot and test-app elf files.
2332+
2333+
In one terminal: `JLinkGDBServer -if swd -Device MCXW716 -port 3333`
2334+
2335+
In another terminal use `gdb`:
2336+
2337+
```
2338+
b main
2339+
mon reset
2340+
c
2341+
```
2342+
22442343

22452344
## TI Hercules TMS570LC435
22462345

@@ -3224,7 +3323,7 @@ make
32243323

32253324
After running the above commands, you should find a file named `final_image.bin` in the root folder of the repository. The image can be flashed directly into the board.
32263325
By default wolfBoot tries to read a wolfBoot image from the SATA drive.
3227-
The drive should be partitioned with a GPT table, wolfBoot tries to load an image saved in the 5th or the 6th partition.
3326+
The drive should be partitioned with a GPT table, wolfBoot tries to load an image saved in the 5th or the 6th partition.
32283327
You can find more details in `src/update_disk.c`. wolfBoot doesn't try to read from a filesystem and the images need to be written directly into the partition.
32293328
This is an example boot log:
32303329
```

hal/mcxa.c

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
static flash_config_t pflash;
3939
static int flash_init = 0;
4040

41+
uint32_t SystemCoreClock;
42+
43+
extern void BOARD_BootClockFRO96M(void);
44+
4145
#ifdef __WOLFBOOT
4246
/* Assert hook needed by Kinetis SDK */
4347
void __assert_func(const char *a, int b, const char *c, const char *d)
@@ -46,57 +50,6 @@ void __assert_func(const char *a, int b, const char *c, const char *d)
4650
;
4751
}
4852

49-
/* The following clock setting function is autogenerated by the MCUXpresso IDE */
50-
void BOARD_BootClockFRO96M(void)
51-
{
52-
uint32_t coreFreq;
53-
spc_active_mode_core_ldo_option_t ldoOption;
54-
spc_sram_voltage_config_t sramOption;
55-
56-
/* Get the CPU Core frequency */
57-
coreFreq = CLOCK_GetCoreSysClkFreq();
58-
59-
/* The flow of increasing voltage and frequency */
60-
if (coreFreq <= BOARD_BOOTCLOCKFRO96M_CORE_CLOCK) {
61-
/* Set the LDO_CORE VDD regulator level */
62-
ldoOption.CoreLDOVoltage = kSPC_CoreLDO_NormalVoltage;
63-
ldoOption.CoreLDODriveStrength = kSPC_CoreLDO_NormalDriveStrength;
64-
(void)SPC_SetActiveModeCoreLDORegulatorConfig(SPC0, &ldoOption);
65-
/* Configure Flash to support different voltage level and frequency */
66-
FMU0->FCTRL = (FMU0->FCTRL & ~((uint32_t)FMU_FCTRL_RWSC_MASK)) | (FMU_FCTRL_RWSC(0x2U));
67-
/* Specifies the operating voltage for the SRAM's read/write timing margin */
68-
sramOption.operateVoltage = kSPC_sramOperateAt1P1V;
69-
sramOption.requestVoltageUpdate = true;
70-
(void)SPC_SetSRAMOperateVoltage(SPC0, &sramOption);
71-
}
72-
73-
CLOCK_SetupFROHFClocking(96000000U); /*!< Enable FRO HF(96MHz) output */
74-
75-
CLOCK_SetupFRO12MClocking(); /*!< Setup FRO12M clock */
76-
77-
CLOCK_AttachClk(kFRO_HF_to_MAIN_CLK); /* !< Switch MAIN_CLK to FRO_HF */
78-
79-
/* The flow of decreasing voltage and frequency */
80-
if (coreFreq > BOARD_BOOTCLOCKFRO96M_CORE_CLOCK) {
81-
/* Configure Flash to support different voltage level and frequency */
82-
FMU0->FCTRL = (FMU0->FCTRL & ~((uint32_t)FMU_FCTRL_RWSC_MASK)) | (FMU_FCTRL_RWSC(0x2U));
83-
/* Specifies the operating voltage for the SRAM's read/write timing margin */
84-
sramOption.operateVoltage = kSPC_sramOperateAt1P1V;
85-
sramOption.requestVoltageUpdate = true;
86-
(void)SPC_SetSRAMOperateVoltage(SPC0, &sramOption);
87-
/* Set the LDO_CORE VDD regulator level */
88-
ldoOption.CoreLDOVoltage = kSPC_CoreLDO_NormalVoltage;
89-
ldoOption.CoreLDODriveStrength = kSPC_CoreLDO_NormalDriveStrength;
90-
(void)SPC_SetActiveModeCoreLDORegulatorConfig(SPC0, &ldoOption);
91-
}
92-
93-
/*!< Set up clock selectors - Attach clocks to the peripheries */
94-
95-
/*!< Set up dividers */
96-
CLOCK_SetClockDiv(kCLOCK_DivAHBCLK, 1U); /* !< Set AHBCLKDIV divider to value 1 */
97-
CLOCK_SetClockDiv(kCLOCK_DivFRO_HF_DIV, 1U); /* !< Set FROHFDIV divider to value 1 */
98-
}
99-
10053
void hal_init(void)
10154
{
10255
/* Clock setting */

0 commit comments

Comments
 (0)