Skip to content

Conversation

@dgarske
Copy link
Contributor

@dgarske dgarske commented Dec 31, 2025

Add NXP S32K1xx (S32K142/144/146/148) Support

Summary

This PR adds complete bare-metal wolfBoot support for the NXP S32K1xx family of automotive-grade Cortex-M4F microcontrollers. The implementation has been tested on the S32K142 and includes support for all variants (S32K142, S32K144, S32K146, S32K148).

Features

  • Bare-metal HAL implementation - No SDK required, fully self-contained
  • Flash programming support with 8-byte phrase programming and sector erase
  • FCF (Flash Configuration Field) protection - Prevents accidental device locking by refusing writes to the 0x400-0x40F region
  • Watchdog management - Proper disable during boot, optional re-enable before jumping to application
  • LPUART debug output on LPUART1 (PTC6=RX, PTC7=TX) at 115200 baud
  • Clock configuration using FIRC (48 MHz internal RC oscillator) - no external crystal required
  • Variant-aware flash sector sizing - 2KB sectors for S32K142 (256KB), 4KB sectors for larger variants

Configuration Options

Option Description
WOLFBOOT_RESTORE_CLOCK Restore clock to SIRC (8 MHz) before booting application
WOLFBOOT_DISABLE_WATCHDOG_ON_BOOT Keep watchdog disabled when jumping to application
WATCHDOG / WATCHDOG_TIMEOUT_MS Enable watchdog during wolfBoot operation
DEBUG_UART Enable LPUART1 debug output
S32K144, S32K146, S32K148 Select variant (default is S32K142)

Memory Layout (S32K142 - 256KB Flash)

Region Address Range Size
Bootloader 0x00000000 - 0x0000BFFF 48 KB
Boot Partition 0x0000C000 - 0x00024FFF 100 KB
Update Partition 0x00025000 - 0x0003DFFF 100 KB
Swap Sector 0x0003E000 - 0x0003E7FF 2 KB

Changes

  • New HAL: hal/s32k1xx.c and hal/s32k1xx.h with register definitions and flash/clock/UART drivers
  • New linker scripts: hal/s32k1xx.ld (bootloader) and test-app/ARM-s32k1xx.ld (application)
  • Configuration examples for all variants:
    • config/examples/nxp-s32k142.config
    • config/examples/nxp-s32k144.config
    • config/examples/nxp-s32k146.config
    • config/examples/nxp-s32k148.config
  • Test application: test-app/app_s32k1xx.c with LED blink and wolfBoot API usage
  • Build system updates in arch.mk and test-app/Makefile
  • CI workflow updates to test all S32K1xx configurations
  • Comprehensive documentation in docs/Targets.md including:
    • Build instructions
    • Programming/debugging with PEMicro, J-Link, and OpenSDA
    • Device recovery procedures for locked devices
    • Clock configuration details
  • VS Code integration with PEMicro GDB server launch configurations

Testing

  • Tested on S32K142 EVB board with:
    • Flash erase and program operations
    • Boot partition verification
    • Application handoff
    • UART debug output
    • Watchdog functionality

Future Work

  • SPLL + SOSC support for true 112 MHz HSRUN mode operation
  • CSEc hardware crypto acceleration integration
  • FlexNVM/EEPROM support
  • CAN/LIN bootloader for automotive update scenarios

@dgarske dgarske self-assigned this Dec 31, 2025
@dgarske dgarske closed this Jan 5, 2026
@dgarske dgarske reopened this Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant