Skip to content

Conversation

@dgarske
Copy link
Contributor

@dgarske dgarske commented Dec 31, 2025

Summary

This PR adds wolfBoot support for the NXP S32K1xx family of automotive-grade Cortex-M4F microcontrollers (S32K142, S32K144, S32K146, S32K148). The implementation is a bare-metal port requiring no external SDK.

Target Hardware

  • Tested on: NXP S32K142 (256KB Flash, 32KB SRAM)
  • Architecture: ARM Cortex-M4F at up to 112 MHz (HSRUN) or 80 MHz (RUN mode)
  • Flash characteristics: 2KB sectors, 8-byte (phrase) programming unit

Files Added

File Description
hal/s32k1xx.c HAL implementation with flash, clock, UART, and watchdog drivers
hal/s32k1xx.h Register definitions for S32K1xx peripherals
hal/s32k1xx.ld Linker script for wolfBoot bootloader
config/examples/nxp-s32k142.config Example configuration for S32K142
test-app/app_s32k1xx.c Test application with LED toggle and UART output
test-app/ARM-s32k1xx.ld Linker script for test application

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

Key Features

  • Bare-metal implementation: No NXP SDK dependency required
  • Flash driver: Full support for flash erase (2KB sectors) and program (8-byte phrase) operations
  • Clock configuration: Defaults to RUN mode with FIRC (48 MHz internal RC oscillator)
  • Debug UART: LPUART1 output on PTC6/PTC7 at 115200 baud
  • Watchdog support: Configurable watchdog with LPO clock source
  • Flash Configuration Field (FCF): Properly configured at 0x400-0x40F

Build Instructions

# Copy configuration
cp config/examples/nxp-s32k142.config .config

# Build wolfBoot
make clean && make

# Build test application
make test-app/image.bin

Programming

Supports multiple debug probe options:

  • PEMicro (recommended for S32K EVB boards)
  • J-Link
  • OpenSDA

Documentation

Comprehensive documentation added to docs/Targets.md including:

  • Configuration options
  • Clock modes (RUN/HSRUN)
  • Debug UART setup
  • Programming and debugging instructions
  • GDB debugging tips

Future Enhancements (TODO)

  • SPLL + SOSC support for true 112 MHz HSRUN operation
  • CSEc hardware crypto acceleration integration
  • FlexNVM/EEPROM support
  • Support for larger S32K144/146/148 variants
  • CAN/LIN bootloader for automotive firmware updates

Testing

  • Verified boot and update flow on S32K142 EVB
  • Tested with ECC256/SHA256 signature verification
  • UART debug output confirmed working

@dgarske dgarske self-assigned this Dec 31, 2025
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