Skip to content

Commit 810be2d

Browse files
authored
Merge pull request #671 from mattia-moffa/20260107-mcxn
NXP MCXN non-TrustZone + TrustZone port
2 parents 1e35087 + b790276 commit 810be2d

File tree

14 files changed

+1106
-0
lines changed

14 files changed

+1106
-0
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Wolfboot Reusable Build Workflow for west-based MCUXpresso SDK
2+
3+
on:
4+
5+
workflow_call:
6+
inputs:
7+
arch:
8+
required: true
9+
type: string
10+
config-file:
11+
required: true
12+
type: string
13+
board-name:
14+
required: true
15+
type: string
16+
make-args:
17+
required: false
18+
type: string
19+
20+
jobs:
21+
22+
build:
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 30
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
submodules: true
30+
31+
- uses: actions/checkout@main
32+
with:
33+
repository: nxp-mcuxpresso/CMSIS_5
34+
path: CMSIS_5
35+
36+
- name: Workaround for sources.list
37+
run: |
38+
# Replace sources
39+
40+
set -euxo pipefail
41+
42+
# Peek (what repos are active now)
43+
apt-cache policy
44+
grep -RInE '^(deb|Types|URIs)' /etc/apt || true
45+
46+
# Enable nullglob so *.list/*.sources that don't exist don't break sed
47+
shopt -s nullglob
48+
49+
echo "Replace sources.list (legacy)"
50+
sudo sed -i \
51+
-e "s|https\?://azure\.archive\.ubuntu\.com/ubuntu/?|http://mirror.arizona.edu/ubuntu/|g" \
52+
/etc/apt/sources.list || true
53+
54+
echo "Replace sources.list.d/*.list (legacy)"
55+
for f in /etc/apt/sources.list.d/*.list; do
56+
sudo sed -i \
57+
-e "s|https\?://azure\.archive\.ubuntu\.com/ubuntu/?|http://mirror.arizona.edu/ubuntu/|g" \
58+
"$f"
59+
done
60+
61+
echo "Replace sources.list.d/*.sources (deb822)"
62+
for f in /etc/apt/sources.list.d/*.sources; do
63+
sudo sed -i \
64+
-e "s|https\?://azure\.archive\.ubuntu\.com/ubuntu/?|http://mirror.arizona.edu/ubuntu/|g" \
65+
-e "s|https\?://azure\.archive\.ubuntu\.com|http://mirror.arizona.edu|g" \
66+
"$f"
67+
done
68+
69+
echo "Fix /etc/apt/apt-mirrors.txt (used by URIs: mirror+file:...)"
70+
if grep -qE '^[[:space:]]*https?://azure\.archive\.ubuntu\.com/ubuntu/?' /etc/apt/apt-mirrors.txt; then
71+
# Replace azure with our mirror (idempotent)
72+
sudo sed -i 's|https\?://azure\.archive\.ubuntu\.com/ubuntu/|http://mirror.arizona.edu/ubuntu/|g' /etc/apt/apt-mirrors.txt
73+
fi
74+
75+
# Peek (verify changes)
76+
grep -RIn "azure.archive.ubuntu.com" /etc/apt || true
77+
grep -RInE '^(deb|Types|URIs)' /etc/apt || true
78+
echo "--- apt-mirrors.txt ---"
79+
cat /etc/apt/apt-mirrors.txt || true
80+
81+
- name: Update repository
82+
run: sudo apt-get update
83+
84+
- name: Install software
85+
run: |
86+
sudo apt-get install -y gcc-arm-none-eabi
87+
88+
- name: Cache MCUXpresso SDK
89+
id: cache-mcuxpresso
90+
uses: actions/cache@v4
91+
with:
92+
path: |
93+
mcuxpresso-sdk
94+
venv
95+
key: mcuxpresso-sdk-${{inputs.board-name}}-${{hashFiles('.github/workflows/test-build-mcux-sdk-manifests.yml')}}
96+
97+
- name: Setup MCUXpresso SDK
98+
if: steps.cache-mcuxpresso.outputs.cache-hit != 'true'
99+
run: |
100+
python -m venv venv
101+
source venv/bin/activate
102+
pip install west
103+
west init -m https://github.com/nxp-mcuxpresso/mcuxsdk-manifests.git mcuxpresso-sdk
104+
cd mcuxpresso-sdk
105+
sed -i '/se_hostlib\|emwin/d' manifests/boards/${{inputs.board-name}}.yml
106+
west update_board --set board ${{inputs.board-name}}
107+
108+
- name: make distclean
109+
run: |
110+
make distclean
111+
112+
- name: Select config
113+
run: |
114+
cp ${{inputs.config-file}} .config && make include/target.h
115+
116+
- name: Build tools
117+
run: |
118+
make -C tools/keytools && make -C tools/bin-assemble
119+
120+
- name: Build wolfboot
121+
run: |
122+
make MCUXSDK=1 MCUXPRESSO="$GITHUB_WORKSPACE/mcuxpresso-sdk/mcuxsdk" MCUXPRESSO_CMSIS="$GITHUB_WORKSPACE/CMSIS_5/CMSIS" ${{inputs.make-args}} V=1

.github/workflows/test-configs.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,20 @@ jobs:
216216
arch: arm
217217
config-file: ./config/examples/mcxw-tz.config
218218

219+
nxp_mcxn_test:
220+
uses: ./.github/workflows/test-build-mcux-sdk-manifests.yml
221+
with:
222+
arch: arm
223+
config-file: ./config/examples/mcxn.config
224+
board-name: frdmmcxn947
225+
226+
nxp_mcxn_tz_test:
227+
uses: ./.github/workflows/test-build-mcux-sdk-manifests.yml
228+
with:
229+
arch: arm
230+
config-file: ./config/examples/mcxn-tz.config
231+
board-name: frdmmcxn947
232+
219233
nxp_s32k142_test:
220234
uses: ./.github/workflows/test-build.yml
221235
with:

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ if(NOT DEFINED ARM_TARGETS)
390390
lpc54606j512
391391
mcxa
392392
mcxw
393+
mcxn
393394
nrf52
394395
nrf52840
395396
nrf5340

arch.mk

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ else
351351
CORTEXM_ARM_EXTRA_OBJS=
352352
CORTEXM_ARM_EXTRA_CFLAGS=
353353
SECURE_OBJS+=./src/wc_callable.o
354+
WOLFCRYPT_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/random.o
354355
CFLAGS+=-DWOLFCRYPT_SECURE_MODE
355356
SECURE_LDFLAGS+=-Wl,--cmse-implib -Wl,--out-implib=./src/wc_secure_calls.o
356357
endif
@@ -743,6 +744,43 @@ ifeq ($(TARGET),mcxw)
743744
$(MCUXPRESSO_DRIVERS)/drivers/fsl_romapi.o
744745
endif
745746

747+
ifeq ($(TARGET),mcxn)
748+
CORTEX_M33=1
749+
ifneq ($(TZEN),1)
750+
LSCRIPT_IN=hal/$(TARGET)-ns.ld
751+
endif
752+
CFLAGS+=\
753+
-I$(MCUXPRESSO_DRIVERS) \
754+
-I$(MCUXPRESSO_DRIVERS)/drivers \
755+
-I$(MCUXPRESSO_DRIVERS)/drivers/romapi/flash \
756+
-I$(MCUXPRESSO_DRIVERS)/../periph \
757+
-I$(MCUXPRESSO) \
758+
-I$(MCUXPRESSO)/drivers \
759+
-I$(MCUXPRESSO)/drivers/gpio \
760+
-I$(MCUXPRESSO)/drivers/port \
761+
-I$(MCUXPRESSO)/drivers/common \
762+
-I$(MCUXPRESSO)/drivers/lpflexcomm \
763+
-I$(MCUXPRESSO)/drivers/lpuart \
764+
-I$(MCUXPRESSO_PROJECT_TEMPLATE) \
765+
-I$(MCUXPRESSO_CMSIS)/Include \
766+
-I$(MCUXPRESSO_CMSIS)/Core/Include
767+
CFLAGS+=-DCPU_$(MCUXPRESSO_CPU) -DDEBUG_CONSOLE_ASSERT_DISABLE=1
768+
CFLAGS+=-Wno-old-style-declaration
769+
CFLAGS+=-mcpu=cortex-m33 -DCORTEX_M33 -U__ARM_FEATURE_DSP
770+
LDFLAGS+=-mcpu=cortex-m33
771+
OBJS+=\
772+
$(MCUXPRESSO_DRIVERS)/drivers/fsl_clock.o \
773+
$(MCUXPRESSO_PROJECT_TEMPLATE)/clock_config.o \
774+
$(MCUXPRESSO_DRIVERS)/drivers/romapi/flash/src/fsl_flash.o
775+
776+
ifeq ($(DEBUG_UART),1)
777+
OBJS+=\
778+
$(MCUXPRESSO)/drivers/lpflexcomm/fsl_lpflexcomm.o \
779+
$(MCUXPRESSO)/drivers/lpuart/fsl_lpuart.o \
780+
$(MCUXPRESSO_DRIVERS)/drivers/fsl_reset.o
781+
endif
782+
endif
783+
746784
ifeq ($(TARGET),nrf5340)
747785
ifneq ($(TZEN), 1)
748786
LSCRIPT_IN=hal/$(TARGET)-ns.ld

config/examples/mcxn-tz.config

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
ARCH?=ARM
2+
TZEN?=1
3+
TARGET?=mcxn
4+
SIGN?=ECC384
5+
HASH?=SHA384
6+
MCUXSDK?=1
7+
MCUXPRESSO?=$(PWD)/../NXP/mcuxpresso-sdk/mcuxsdk
8+
MCUXPRESSO_CMSIS?=$(PWD)/../NXP/CMSIS_5/CMSIS
9+
MCUXPRESSO_CPU?=MCXN947VDF_cm33_core0
10+
MCUXPRESSO_DRIVERS?=$(MCUXPRESSO)/devices/MCX/MCXN/MCXN947
11+
MCUXPRESSO_PROJECT_TEMPLATE?=$(MCUXPRESSO)/examples/_boards/frdmmcxn947/project_template
12+
DEBUG?=0
13+
DEBUG_UART?=1
14+
VTOR?=1
15+
CORTEX_M0?=0
16+
CORTEX_M33?=1
17+
NO_ASM?=0
18+
NO_MPU=1
19+
EXT_FLASH?=0
20+
SPI_FLASH?=0
21+
ALLOW_DOWNGRADE?=0
22+
NVM_FLASH_WRITEONCE?=1
23+
NO_ARM_ASM=1
24+
WOLFBOOT_VERSION?=0
25+
V?=0
26+
SPMATH?=1
27+
RAM_CODE?=1
28+
DUALBANK_SWAP?=0
29+
PKA?=1
30+
WOLFCRYPT_TZ?=1
31+
32+
# 8KB sectors
33+
WOLFBOOT_SECTOR_SIZE?=0x2000
34+
35+
# Default configuration
36+
# 64KB boot, 80KB keyvault, 8KB NSC, 60KB partitions, 8KB swap
37+
WOLFBOOT_KEYVAULT_ADDRESS?=0x10000
38+
WOLFBOOT_KEYVAULT_SIZE?=0x14000
39+
WOLFBOOT_NSC_ADDRESS?=0x24000
40+
WOLFBOOT_NSC_SIZE?=0x2000
41+
WOLFBOOT_PARTITION_SIZE?=0xF000
42+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x26000
43+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x35000
44+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x44000
45+
46+
# Alternate larger configuration for debugging or ARMASM
47+
# 128KB boot, 80KB keyvault, 8KB NSC, 60KB partitions, 8KB swap
48+
#WOLFBOOT_KEYVAULT_ADDRESS?=0x20000
49+
#WOLFBOOT_KEYVAULT_SIZE?=0x14000
50+
#WOLFBOOT_NSC_ADDRESS?=0x34000
51+
#WOLFBOOT_NSC_SIZE?=0x2000
52+
#WOLFBOOT_PARTITION_SIZE?=0xF000
53+
#WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x36000
54+
#WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x45000
55+
#WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x54000

config/examples/mcxn.config

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
ARCH?=ARM
2+
TZEN?=0
3+
TARGET?=mcxn
4+
SIGN?=ECC384
5+
HASH?=SHA384
6+
MCUXSDK?=1
7+
MCUXPRESSO?=$(PWD)/../NXP/mcuxpresso-sdk/mcuxsdk
8+
MCUXPRESSO_CMSIS?=$(PWD)/../NXP/CMSIS_5/CMSIS
9+
MCUXPRESSO_CPU?=MCXN947VDF_cm33_core0
10+
MCUXPRESSO_DRIVERS?=$(MCUXPRESSO)/devices/MCX/MCXN/MCXN947
11+
MCUXPRESSO_PROJECT_TEMPLATE?=$(MCUXPRESSO)/examples/_boards/frdmmcxn947/project_template
12+
DEBUG?=0
13+
DEBUG_UART?=1
14+
VTOR?=1
15+
CORTEX_M0?=0
16+
CORTEX_M33?=1
17+
NO_ASM?=0
18+
NO_MPU=1
19+
EXT_FLASH?=0
20+
SPI_FLASH?=0
21+
ALLOW_DOWNGRADE?=0
22+
NVM_FLASH_WRITEONCE?=1
23+
NO_ARM_ASM=1
24+
WOLFBOOT_VERSION?=0
25+
V?=0
26+
SPMATH?=1
27+
RAM_CODE?=1
28+
DUALBANK_SWAP?=0
29+
PKA?=1
30+
31+
# 8KB sectors
32+
WOLFBOOT_SECTOR_SIZE?=0x2000
33+
34+
# Default configuration
35+
# 40KB boot, 44KB partitions, 8KB swap
36+
WOLFBOOT_PARTITION_SIZE?=0xB000
37+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xA000
38+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x15000
39+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x20000
40+
41+
# Alternate larger configuration for debugging or ARMASM
42+
# 64KB boot, 64KB partitions, 8KB swap
43+
#WOLFBOOT_PARTITION_SIZE?=0x10000
44+
#WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x12000
45+
#WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x22000
46+
#WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x32000

0 commit comments

Comments
 (0)