@@ -2880,12 +2880,15 @@ The following build options are available for the S32K1xx HAL:
28802880
28812881| Option | Description |
28822882| --------| -------------|
2883+ | ` NVM_FLASH_WRITEONCE ` | ** Required for S32K1xx.** Flash can only be written once between erases. Enables proper sector swap trailer management. |
2884+ | ` RAM_CODE ` | ** Required for S32K1xx.** Run flash operations from RAM (no read-while-write on same block). |
28832885| ` WOLFBOOT_RESTORE_CLOCK ` | Restore clock to SIRC (8 MHz) before booting application. Recommended for applications that configure their own clocks. |
28842886| ` WOLFBOOT_DISABLE_WATCHDOG_ON_BOOT ` | Keep watchdog disabled when jumping to application. By default, the watchdog is re-enabled before boot since it is enabled out of reset. |
28852887| ` WATCHDOG ` | Enable watchdog during wolfBoot operation. Recommended for production. |
28862888| ` WATCHDOG_TIMEOUT_MS ` | Watchdog timeout in milliseconds when ` WATCHDOG ` is enabled (default: 1000ms). |
28872889| ` S32K1XX_CLOCK_HSRUN ` | Enable HSRUN mode (112 MHz). Requires external crystal and SPLL (not fully implemented). |
28882890| ` DEBUG_UART ` | Enable LPUART1 debug output. |
2891+ | ` DEBUG_HARDFAULT ` | Enable detailed hard fault debugging output. |
28892892| ` S32K144 ` , ` S32K146 ` , ` S32K148 ` | Select variant (default is S32K142). Affects flash/SRAM size definitions. |
28902893
28912894** IMPORTANT:** Flash sector size depends on the S32K variant:
@@ -2948,6 +2951,41 @@ cp factory.srec /media/<user>/S32K142EVB/
29482951
29492952The board will automatically program the flash and reset.
29502953
2954+ ### NXP S32K1XX: Flash Script
2955+
2956+ A convenience script is provided for building and flashing S32K142:
2957+
2958+ ``` sh
2959+ ./tools/scripts/nxp-s32k142-flash.sh [OPTIONS]
2960+ ```
2961+
2962+ ** Options:**
2963+
2964+ | Option | Description |
2965+ | --------| -------------|
2966+ | (none) | Build and flash ` factory.srec ` (v1 only) |
2967+ | ` --test-update ` | Build with v2 in update partition (use ` trigger ` command to start update) |
2968+ | ` --update ` | Build with v2 and auto-trigger (starts update on boot) |
2969+ | ` --skip-build ` | Skip build, use existing ` .srec ` file |
2970+ | ` --skip-flash ` | Skip flashing (just build) |
2971+ | ` --skip-uart ` | Skip UART monitoring |
2972+ | ` --uart-only ` | Only monitor UART (no build/flash) |
2973+ | ` --interactive ` | Keep UART open until Ctrl+C |
2974+ | ` --timeout SECS ` | UART capture duration (default: 5s) |
2975+
2976+ ** Examples:**
2977+
2978+ ``` sh
2979+ # Build and flash factory image, monitor UART for 5 seconds
2980+ ./tools/scripts/nxp-s32k142-flash.sh
2981+
2982+ # Build with v2 update, flash, and stay on UART
2983+ ./tools/scripts/nxp-s32k142-flash.sh --test-update --interactive
2984+
2985+ # Just monitor UART
2986+ ./tools/scripts/nxp-s32k142-flash.sh --uart-only --interactive
2987+ ```
2988+
29512989### NXP S32K1XX: Test Application
29522990
29532991The S32K1xx test application (` test-app/app_s32k1xx.c ` ) provides a feature-rich demo application for testing wolfBoot functionality.
@@ -2963,12 +3001,14 @@ The S32K1xx test application (`test-app/app_s32k1xx.c`) provides a feature-rich
29633001
29643002| Command | Description |
29653003| ---------| -------------|
2966- | ` help ` or ` ? ` | Show available commands |
2967- | ` info ` | Display system and partition information |
3004+ | ` help ` | Show available commands |
3005+ | ` info ` | Display partition and keystore information |
3006+ | ` status ` | Show partition versions and states |
29683007| ` success ` | Mark current firmware as successful (wolfBoot_success) |
2969- | ` update ` | Trigger firmware update (wolfBoot_update_trigger) |
2970- | ` reset ` | Perform software reset |
2971- | ` xmodem ` | Receive firmware image via XMODEM protocol |
3008+ | ` trigger ` | Set update flag if update image is in flash |
3009+ | ` update ` | Receive firmware via XMODEM and trigger update |
3010+ | ` timestamp ` | Show current system time (ms) |
3011+ | ` reboot ` | Perform software reset |
29723012
29733013** UART Configuration:**
29743014- LPUART1: PTC7 (TX), PTC6 (RX)
@@ -2984,23 +3024,32 @@ Copyright 2025 wolfSSL Inc.
29843024Firmware Version: 1
29853025
29863026=== Partition Information ===
2987- Boot Partition:
2988- Address: 0x0000C000
3027+ Boot Partition @ 0xC000:
29893028 Version: 1
2990- State: SUCCESS
2991- Update Partition:
2992- Address: 0x00025000
2993- Version: 0
2994- State: SUCCESS
2995- Swap Partition:
2996- Address: 0x0003E000
2997- Size: 2048 bytes
3029+ State: SUCCESS (0x00)
3030+ Update Partition @ 0x25000 :
3031+ Version: 0 (empty)
3032+ State: (no trailer)
3033+
3034+ === Keystore Information ===
3035+ Number of keys: 1
3036+ Key 0: ECDSA P-256 (secp256r1), SHA-256
29983037
29993038Type 'help' for available commands.
30003039
30013040cmd>
30023041```
30033042
3043+ ** Testing Firmware Update:**
3044+
3045+ 1 . Flash with v2 image: ` ./tools/scripts/nxp-s32k142-flash.sh --test-update `
3046+ 2 . Connect to UART: ` picocom -b 115200 /dev/ttyACM1 `
3047+ 3 . Run ` status ` to verify v1 in boot, v2 in update
3048+ 4 . Run ` trigger ` to set update flag
3049+ 5 . Run ` reboot ` to start update
3050+ 6 . After reboot, LED changes from Green (v1) to Blue (v2)
3051+ 7 . Run ` success ` to mark v2 as good
3052+
30043053### NXP S32K1XX: Flash Configuration Field (FCF)
30053054
30063055The bootloader includes the Flash Configuration Field (FCF) at address 0x400-0x40F with the following settings:
@@ -3043,6 +3092,10 @@ Then power cycle the board.
30433092
30443093The following features are planned or available for contribution:
30453094
3095+ - [x] ** Sector swap update** : Full firmware update with sector swapping (completed)
3096+ - [x] ** Interactive test application** : Console with status, trigger, success commands (completed)
3097+ - [x] ** Flash automation script** : ` tools/scripts/nxp-s32k142-flash.sh ` (completed)
3098+ - [ ] ** XMODEM improvements** : ISR-based UART RX for reliable high-speed transfers
30463099- [ ] ** SPLL + SOSC support** : Add external crystal oscillator and SPLL configuration for true 112 MHz operation in HSRUN mode
30473100- [ ] ** Hardware crypto acceleration** : Integrate CSEc (Cryptographic Services Engine) for hardware-accelerated crypto operations
30483101- [ ] ** FlexNVM/EEPROM support** : Add support for FlexNVM partitioning and EEPROM emulation
0 commit comments