Skip to content

Add PIC32MZ simulators#7

Merged
LinuxJedi merged 1 commit into
wolfSSL:mainfrom
LinuxJedi:PIC32MZ-Sim
May 18, 2026
Merged

Add PIC32MZ simulators#7
LinuxJedi merged 1 commit into
wolfSSL:mainfrom
LinuxJedi:PIC32MZ-Sim

Conversation

@LinuxJedi
Copy link
Copy Markdown
Member

@LinuxJedi LinuxJedi commented May 12, 2026

This simulates enough to run wolfCrypt test suite against PIC32MZ EC and EF microcontrollers. Testing the hardware crypto functions for regressions.

Temporarily patches a bug in wolfCrypt (free called on stack).

Also update ATECC608 now that wolfSSL has been updated.

Copilot AI review requested due to automatic review settings May 12, 2026 08:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces PIC32MZSim, a Unicorn-Engine-based simulator and accompanying firmware/CI plumbing to run the wolfCrypt test suite against simulated PIC32MZ EC/EF hardware-crypto peripherals (CE/RNG/UART), enabling regression testing without physical hardware or the proprietary XC32 toolchain.

Changes:

  • Adds a new Rust workspace (PIC32MZSim/pic32mz-sim) implementing a MIPS32LE CPU runner, MMIO bus, ELF loader, and PIC32MZ CE/RNG/UART peripherals plus EC/EF chip configs.
  • Adds smoke-test and wolfCrypt-test firmware images + build/run scripts (direct-register and MPLAB Harmony driver paths).
  • Adds Dockerfiles and GitHub Actions workflows to build and run the simulator and wolfCrypt tests in CI.

Reviewed changes

Copilot reviewed 56 out of 57 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
README.md Adds top-level documentation entry for PIC32MZSim.
PIC32MZSim/scripts/run-wolfcrypt-harmony-ef.sh Builds Harmony crypto objects + wolfSSL, runs EF harmony wolfCrypt firmware in simulator.
PIC32MZSim/scripts/run-wolfcrypt-harmony-ec.sh Builds Harmony crypto objects + wolfSSL, runs EC harmony wolfCrypt firmware in simulator.
PIC32MZSim/scripts/run-wolfcrypt-direct-ef.sh Builds wolfSSL for direct-register port and runs EF direct wolfCrypt firmware.
PIC32MZSim/scripts/run-wolfcrypt-direct-ec.sh Builds wolfSSL for direct-register port and runs EC direct wolfCrypt firmware.
PIC32MZSim/README.md Adds simulator architecture/build/run/docs for PIC32MZSim.
PIC32MZSim/pic32mz-sim/runner-bin/tests/smoke.rs Integration test that builds smoke firmware and runs it through the runner.
PIC32MZSim/pic32mz-sim/runner-bin/src/main.rs Adds pic32mz-sim CLI runner (chip selection, timeout, exit/result symbols).
PIC32MZSim/pic32mz-sim/runner-bin/Cargo.toml Defines runner binary crate and dependencies.
PIC32MZSim/pic32mz-sim/peripherals/src/uart.rs Implements UART MMIO model + stdout/capturing sinks.
PIC32MZSim/pic32mz-sim/peripherals/src/rng.rs Implements RNG MMIO model with deterministic ChaCha20 stream + tests.
PIC32MZSim/pic32mz-sim/peripherals/src/lib.rs Exposes CE/RNG/UART peripherals from the crate.
PIC32MZSim/pic32mz-sim/peripherals/src/ce/mod.rs Implements CE register model and BD-chain execution entrypoint.
PIC32MZSim/pic32mz-sim/peripherals/src/ce/bd.rs Defines BD/SA parsing/serialization helpers matching wolfSSL PIC32 layouts.
PIC32MZSim/pic32mz-sim/peripherals/src/ce/algo.rs Executes AES/DES/3DES/hash descriptor operations and writes back outputs.
PIC32MZSim/pic32mz-sim/peripherals/Cargo.toml Adds RustCrypto/rand dependencies for peripheral implementations.
PIC32MZSim/pic32mz-sim/core/src/runner.rs Adds run loop with exit flag/result polling + timeout/fault outcomes.
PIC32MZSim/pic32mz-sim/core/src/peripheral.rs Defines Peripheral/MemBus traits and test buses.
PIC32MZSim/pic32mz-sim/core/src/mem.rs Adds PIC32 segment helpers (to_phys, KSEG aliases).
PIC32MZSim/pic32mz-sim/core/src/lib.rs Re-exports core modules/types for the simulator workspace.
PIC32MZSim/pic32mz-sim/core/src/elf.rs Adds ELF parsing, segment extraction, and symbol lookup for runner exit polling.
PIC32MZSim/pic32mz-sim/core/src/cpu.rs Adds Unicorn-based MIPS32LE CPU wrapper, MMIO mapping, ELF load, and memory reads.
PIC32MZSim/pic32mz-sim/core/src/bus.rs Implements MMIO bus dispatch with optional tracing + page enumeration.
PIC32MZSim/pic32mz-sim/core/Cargo.toml Defines core crate dependencies (unicorn-engine, goblin, etc.).
PIC32MZSim/pic32mz-sim/chips/src/pic32mz_ef.rs Adds EF chip config (memory map + UART/RNG/CE wiring).
PIC32MZSim/pic32mz-sim/chips/src/pic32mz_ec.rs Adds EC chip config (CE no_out_swap quirk).
PIC32MZSim/pic32mz-sim/chips/src/lib.rs Adds chip registry/build logic and supported chip list.
PIC32MZSim/pic32mz-sim/chips/Cargo.toml Defines chip-config crate and dependencies.
PIC32MZSim/pic32mz-sim/Cargo.toml Adds the PIC32MZSim Rust workspace, shared dependency versions, and release profile.
PIC32MZSim/firmware/wolfcrypt-test-harmony-ef/Makefile Builds EF Harmony wolfCrypt firmware ELF.
PIC32MZSim/firmware/wolfcrypt-test-harmony-ef/main.c EF Harmony wolfCrypt test harness (UART + exit/result symbols).
PIC32MZSim/firmware/wolfcrypt-test-harmony-ec/Makefile Builds EC Harmony wolfCrypt firmware ELF.
PIC32MZSim/firmware/wolfcrypt-test-harmony-ec/main.c EC Harmony wolfCrypt test harness (UART + exit/result symbols).
PIC32MZSim/firmware/wolfcrypt-test-direct-ef/Makefile Builds EF direct-register wolfCrypt firmware ELF.
PIC32MZSim/firmware/wolfcrypt-test-direct-ef/main.c EF direct-register wolfCrypt test harness (UART + exit/result symbols).
PIC32MZSim/firmware/wolfcrypt-test-direct-ec/Makefile Builds EC direct-register wolfCrypt firmware ELF.
PIC32MZSim/firmware/wolfcrypt-test-direct-ec/main.c EC direct-register wolfCrypt test harness (UART + exit/result symbols).
PIC32MZSim/firmware/smoke-test-ef/Makefile Builds EF smoke-test firmware ELF.
PIC32MZSim/firmware/smoke-test-ef/main.c EF smoke firmware exercising CE AES/SHA and RNG paths.
PIC32MZSim/firmware/smoke-test-ec/Makefile Builds EC smoke-test firmware ELF.
PIC32MZSim/firmware/smoke-test-ec/main.c EC smoke firmware exercising CE AES/SHA with software byte-reverse.
PIC32MZSim/firmware/common/user_settings.h Adds wolfSSL user settings for direct vs Harmony builds.
PIC32MZSim/firmware/common/startup.S Minimal MIPS32 reset/startup (SP init, .data copy, .bss zero, call main).
PIC32MZSim/firmware/common/pic32mz_stubs.h Stub SFR/intrinsic definitions to avoid XC32 headers.
PIC32MZSim/firmware/common/pic32mz_link_kseg1.ld Linker script placing code/data/bss in KSEG1 layout for sim.
PIC32MZSim/firmware/common/mini_libc.h Declares minimal libc replacements for -nostdlib firmware builds.
PIC32MZSim/firmware/common/mini_libc.c Implements minimal memset/memcpy/memcmp for bare-metal builds.
PIC32MZSim/Dockerfile.wolfcrypt-harmony Docker tier for Harmony-based wolfCrypt test runs.
PIC32MZSim/Dockerfile.wolfcrypt-direct Docker tier for direct-register wolfCrypt test runs.
PIC32MZSim/Dockerfile Docker tier for building simulator + running Rust tests + smoke firmware.
PIC32MZSim/.gitignore Ignores PIC32MZSim build outputs (Cargo target, firmware artifacts).
.gitignore Adds root ignore entry.
.github/workflows/pic32mz-wolfcrypt-harmony-ef.yml CI workflow for Harmony+EF wolfCrypt test in Docker.
.github/workflows/pic32mz-wolfcrypt-harmony-ec.yml CI workflow for Harmony+EC wolfCrypt test in Docker.
.github/workflows/pic32mz-wolfcrypt-direct-ef.yml CI workflow for direct+EF wolfCrypt test in Docker.
.github/workflows/pic32mz-wolfcrypt-direct-ec.yml CI workflow for direct+EC wolfCrypt test in Docker.
.github/workflows/pic32mz-test-suite.yml CI workflow for building smoke firmware and running cargo test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PIC32MZSim/scripts/run-wolfcrypt-direct-ef.sh Outdated
Comment thread PIC32MZSim/scripts/run-wolfcrypt-direct-ec.sh Outdated
Comment thread PIC32MZSim/scripts/run-wolfcrypt-harmony-ef.sh
Comment thread PIC32MZSim/scripts/run-wolfcrypt-harmony-ec.sh
Comment thread PIC32MZSim/scripts/run-wolfcrypt-harmony-ec.sh
Comment thread PIC32MZSim/firmware/common/mini_libc.c Outdated
Comment thread PIC32MZSim/firmware/common/pic32mz_stubs.h Outdated
Comment thread PIC32MZSim/README.md Outdated
Comment thread PIC32MZSim/pic32mz-sim/peripherals/src/rng.rs Outdated
Comment thread PIC32MZSim/pic32mz-sim/chips/src/pic32mz_ef.rs Outdated
@LinuxJedi LinuxJedi force-pushed the PIC32MZ-Sim branch 2 times, most recently from a871504 to 205757b Compare May 12, 2026 13:39
This simulates enough to run wolfCrypt test suite against PIC32MZ EC and
EF microcontrollers. Testing the hardware crypto functions for
regressions.

Temporarily patches a bug in wolfCrypt (free called on stack).

Also update ATECC608 now that wolfSSL has been updated.
@LinuxJedi LinuxJedi mentioned this pull request May 13, 2026
@LinuxJedi LinuxJedi merged commit f7ee6e0 into wolfSSL:main May 18, 2026
20 checks passed
@LinuxJedi LinuxJedi deleted the PIC32MZ-Sim branch May 18, 2026 20:57
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.

3 participants