Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/test-configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ jobs:
arch: arm
config-file: ./config/examples/mcxw-tz.config

nxp_s32k142_test:
uses: ./.github/workflows/test-build.yml
with:
arch: arm
config-file: ./config/examples/nxp-s32k142.config

microchip_mpfs250_test:
uses: ./.github/workflows/test-build-riscv.yml
with:
Expand Down
6 changes: 6 additions & 0 deletions .vscode/arm-gdb-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# Wrapper script for arm-none-eabi-gdb that skips .gdbinit
# This is needed because cortex-debug doesn't support passing --nx to GDB

exec /opt/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb --nx "$@"

96 changes: 96 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Flash and Debug wolfBoot",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceFolder}",
"executable": "${workspaceFolder}/wolfboot.elf",
"servertype": "external",
"gdbTarget": "127.0.0.1:7224",
"device": "S32K142",
"runToEntryPoint": "main",
"showDevDebugOutput": "raw",
"svdFile": "",
"gdbPath": "${workspaceFolder}/.vscode/arm-gdb-wrapper.sh",
"toolchainPath": "/opt/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/bin",
"toolchainPrefix": "arm-none-eabi",
"preLaunchTask": "Start PEMicro GDB Server",
"preLaunchCommands": [
"set mem inaccessible-by-default off"
],
"postLaunchCommands": [
"monitor reset halt",
"load",
"monitor programbin test-app/image_v1_signed.bin 0xc000"
]
},
{
"name": "Flash and Debug wolfBoot (with UART)",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceFolder}",
"executable": "${workspaceFolder}/wolfboot.elf",
"servertype": "external",
"gdbTarget": "127.0.0.1:7224",
"device": "S32K142",
"runToEntryPoint": "main",
"showDevDebugOutput": "raw",
"svdFile": "",
"gdbPath": "${workspaceFolder}/.vscode/arm-gdb-wrapper.sh",
"toolchainPath": "/opt/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/bin",
"toolchainPrefix": "arm-none-eabi",
"preLaunchTask": "Start GDB Server and UART",
"preLaunchCommands": [
"set mem inaccessible-by-default off"
],
"postLaunchCommands": [
"monitor reset halt",
"load",
"monitor programbin test-app/image_v1_signed.bin 0xc000"
]
},
{
"name": "Flash Only wolfBoot",
"type": "cortex-debug",
"request": "launch",
"cwd": "${workspaceFolder}",
"executable": "${workspaceFolder}/wolfboot.elf",
"servertype": "external",
"gdbTarget": "127.0.0.1:7224",
"device": "S32K142",
"showDevDebugOutput": "raw",
"svdFile": "",
"gdbPath": "${workspaceFolder}/.vscode/arm-gdb-wrapper.sh",
"toolchainPath": "/opt/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/bin",
"toolchainPrefix": "arm-none-eabi",
"preLaunchTask": "Start PEMicro GDB Server",
"preLaunchCommands": [
"set mem inaccessible-by-default off"
],
"postLaunchCommands": [
"monitor reset halt",
"load",
"monitor reset run",
"quit"
]
},
{
"name": "Attach Only wolfBoot",
"type": "cortex-debug",
"request": "attach",
"cwd": "${workspaceFolder}",
"executable": "${workspaceFolder}/wolfboot.elf",
"servertype": "external",
"gdbTarget": "127.0.0.1:7224",
"device": "S32K142",
"showDevDebugOutput": "raw",
"svdFile": "",
"gdbPath": "${workspaceFolder}/.vscode/arm-gdb-wrapper.sh",
"toolchainPath": "/opt/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/bin",
"toolchainPrefix": "arm-none-eabi",
"preLaunchTask": "Start PEMicro GDB Server"
}
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cortex-debug.gdbPath": "${workspaceFolder}/.vscode/arm-gdb-wrapper.sh",
"cortex-debug.armToolchainPath": "/opt/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/bin",
"cortex-debug.showDevDebugOutput": "raw"
}
42 changes: 42 additions & 0 deletions .vscode/start-pemicro-gdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# Start PEMicro GDB Server for S32K142 debugging
#
# Usage: ./start-pemicro-gdb.sh [options]
#
# Options are passed directly to pegdbserver_console

PEMICRO_DIR="$HOME/.local/pemicro"
DEVICE="NXP_S32K1xx_S32K142F256M15"
INTERFACE="OPENSDA"
PORT="USB1"
SERVER_PORT="7224"
SPEED="5000"

# Set library path
export LD_LIBRARY_PATH="$PEMICRO_DIR/gdi:$PEMICRO_DIR/gdi/P&E:$LD_LIBRARY_PATH"

cd "$PEMICRO_DIR"

# Check if server is already running
if pgrep -f pegdbserver_console > /dev/null; then
echo "PEMicro GDB Server is already running. Stopping it first..."
pkill -f pegdbserver_console
sleep 1
fi

echo "Starting PEMicro GDB Server..."
echo " Device: $DEVICE"
echo " Interface: $INTERFACE"
echo " Port: $PORT"
echo " Server Port: $SERVER_PORT"
echo ""

./pegdbserver_console \
-startserver \
-device=$DEVICE \
-interface=$INTERFACE \
-port=$PORT \
-serverport=$SERVER_PORT \
-speed=$SPEED \
"$@"

124 changes: 124 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Start PEMicro GDB Server",
"type": "shell",
"command": "${env:HOME}/.local/pemicro/pegdbserver_console",
"args": [
"-startserver",
"-device=NXP_S32K1xx_S32K142F256M15",
"-interface=OPENSDA",
"-port=USB1",
"-serverport=7224",
"-speed=5000"
],
"options": {
"env": {
"LD_LIBRARY_PATH": "${env:HOME}/.local/pemicro/gdi:${env:HOME}/.local/pemicro/gdi/P&E:${env:LD_LIBRARY_PATH}"
},
"cwd": "${env:HOME}/.local/pemicro"
},
"isBackground": true,
"problemMatcher": {
"pattern": {
"regexp": "^ERROR:(.*)$",
"message": 1
},
"background": {
"activeOnStart": true,
"beginsPattern": "^P&E GDB Server",
"endsPattern": "^All Servers Running"
}
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": false,
"clear": true
}
},
{
"label": "Start UART Monitor",
"type": "shell",
"command": "echo 'UART Monitor Started' && stty -F /dev/ttyACM0 115200 raw -echo && cat /dev/ttyACM0",
"isBackground": true,
"problemMatcher": {
"pattern": {
"regexp": "^ERROR:(.*)$",
"message": 1
},
"background": {
"activeOnStart": true,
"beginsPattern": "^UART Monitor",
"endsPattern": "^UART Monitor Started"
}
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": false,
"clear": true
}
},
{
"label": "Start GDB Server and UART",
"dependsOn": [
"Start PEMicro GDB Server",
"Start UART Monitor"
],
"dependsOrder": "parallel",
"problemMatcher": []
},
{
"label": "Stop PEMicro GDB Server",
"type": "shell",
"command": "pkill",
"args": ["-f", "pegdbserver_console"],
"problemMatcher": []
},
{
"label": "Stop UART Monitor",
"type": "shell",
"command": "pkill",
"args": ["-f", "cat /dev/ttyACM0"],
"problemMatcher": []
},
{
"label": "Stop GDB Server and UART",
"dependsOn": [
"Stop PEMicro GDB Server",
"Stop UART Monitor"
],
"dependsOrder": "parallel",
"problemMatcher": []
},
{
"label": "Build wolfBoot",
"type": "shell",
"command": "make",
"args": [],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": ["$gcc"],
"presentation": {
"reveal": "always",
"panel": "shared"
}
},
{
"label": "Clean wolfBoot",
"type": "shell",
"command": "make",
"args": ["clean"],
"problemMatcher": []
}
]
}

8 changes: 8 additions & 0 deletions arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,14 @@ ifeq ($(ARCH),PPC)
endif
endif

# NXP S32K1xx (S32K142, S32K144, S32K146, S32K148)
# Bare-metal implementation, no SDK required
ifeq ($(TARGET),s32k1xx)
ARCH_FLASH_OFFSET=0x00000000
CFLAGS+=-DCPU_S32K142
# S32K1xx is Cortex-M4 by default (handled by default case in arch.mk)
endif

ifeq ($(TARGET),kinetis)
CFLAGS+=\
-I$(MCUXPRESSO_DRIVERS) \
Expand Down
52 changes: 52 additions & 0 deletions config/examples/nxp-s32k142.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# wolfBoot configuration for NXP S32K142
#
# S32K142: Cortex-M4F, 256KB Flash, 32KB SRAM
# Flash sector size: 2KB
# Default: RUN mode at 48 MHz (FIRC - internal RC oscillator)
#
# Build: cp config/examples/nxp-s32k142.config .config && make

ARCH?=ARM
CORTEX_M4?=1
TARGET?=s32k1xx
SIGN?=ECC256
HASH?=SHA256
DEBUG?=0
VTOR?=1
NO_ASM?=0
EXT_FLASH?=0
SPI_FLASH?=0
ALLOW_DOWNGRADE?=0
NVM_FLASH_WRITEONCE?=0
WOLFBOOT_VERSION?=0
V?=0
SPMATH?=1
RAM_CODE?=0
DUALBANK_SWAP?=0

# Disable MPU (S32K1xx MPU configuration needs customization)
WOLFBOOT_NO_MPU?=1

# Enable hardfault debugging
DEBUG_HARDFAULT?=1

# Debug UART on LPUART1 (PTC6=RX, PTC7=TX)
DEBUG_UART?=1

# 2KB sectors
WOLFBOOT_SECTOR_SIZE?=0x800

# Memory layout for S32K142 (256KB Flash):
# Bootloader: 0x00000000 - 0x0000BFFF (48 KB)
# Boot Partition: 0x0000C000 - 0x00024FFF (100 KB)
# Update Partition: 0x00025000 - 0x0003DFFF (100 KB)
# Swap Sector: 0x0003E000 - 0x0003E7FF (2 KB)
WOLFBOOT_PARTITION_SIZE?=0x19000
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xC000
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x25000
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x3E000

# Clock mode: Default is RUN mode with FIRC (48 MHz internal RC)
# To enable HSRUN mode (112 MHz), uncomment below (requires SOSC + SPLL, not fully implemented):
#CFLAGS_EXTRA+=-DS32K1XX_CLOCK_HSRUN

Loading