Skip to content

Commit 840da2f

Browse files
authored
Merge pull request #8 from LinuxJedi/simulator-stm32mp1
Add STM32MP135 support
2 parents f7ee6e0 + 4cd817e commit 840da2f

33 files changed

Lines changed: 2096 additions & 101 deletions

‎.github/workflows/stm32-test-suite.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@ jobs:
3232
- name: Build smoke firmware (U5)
3333
run: make -C STM32Sim/firmware/smoke-test-u5
3434

35+
- name: Build smoke firmware (MP135)
36+
run: make -C STM32Sim/firmware/smoke-test-mp135
37+
3538
- name: cargo test
3639
run: cargo test --manifest-path STM32Sim/stm32-sim/Cargo.toml --release
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: STM32Sim wolfCrypt test (MP135)
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: ['**']
8+
workflow_dispatch:
9+
10+
jobs:
11+
wolfcrypt-test:
12+
name: wolfCrypt on STM32Sim MP135
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- name: Checkout simulator-stm32
16+
uses: actions/checkout@v4
17+
with:
18+
path: simulator-stm32
19+
20+
- name: Checkout wolfSSL
21+
uses: actions/checkout@v4
22+
with:
23+
repository: wolfSSL/wolfssl
24+
ref: master
25+
path: wolfssl
26+
27+
- name: Build stm32sim-wolfcrypt image
28+
run: |
29+
docker build \
30+
-t stm32sim-wolfcrypt:ci \
31+
-f simulator-stm32/STM32Sim/Dockerfile.wolfcrypt \
32+
simulator-stm32/STM32Sim
33+
34+
- name: Run MP135 wolfCrypt test on stm32-sim
35+
run: |
36+
docker run --rm \
37+
-v "${{ github.workspace }}/wolfssl:/opt/wolfssl:ro" \
38+
stm32sim-wolfcrypt:ci \
39+
run-wolfcrypt-mp135.sh

‎README.md‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,18 @@ its `hal/posix/tcp/` HAL.
3636
## STM32Sim
3737

3838
The [STM32Sim](STM32Sim/) is a Unicorn-Engine-based simulator for STM32
39-
microcontrollers focused on the on-chip cryptographic accelerators
40-
(CRYP/AES, HASH, RNG, PKA) that wolfSSL uses. It is intended to replace
41-
the Renode-based CI flow for wolfSSL on STM32 targets and to close the
42-
gaps Renode has in hardware-crypto modelling (HASH peripheral, full AES
43-
mode set, PKA).
39+
microcontrollers and application processors focused on the on-chip
40+
cryptographic accelerators (CRYP/AES, HASH, RNG, PKA) that wolfSSL
41+
uses. It is intended to replace the Renode-based CI flow for wolfSSL
42+
on STM32 targets and to close the gaps Renode has in hardware-crypto
43+
modelling (HASH peripheral, full AES mode set, PKA). Currently
44+
supported targets:
45+
46+
- **STM32H753** (Cortex-M7, HAL v1)
47+
- **STM32U575 / U585** (Cortex-M33 with TrustZone, HAL v2, PKA v2)
48+
- **STM32MP135** (Cortex-A7 with MMU, runs out of DDR with no
49+
internal flash; CRYP1/HASH1/RNG1/PKA modelled, including SHA3 and
50+
SHAKE on HASH1)
4451

4552
## PIC32MZSim
4653

‎STM32Sim/Dockerfile.wolfcrypt‎

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@
99
# the Free Software Foundation; either version 3 of the License, or
1010
# (at your option) any later version.
1111

12-
# Builds the wolfCrypt-on-STM32 firmwares (H753 and U585) that today
13-
# run under Renode CI, then runs them through stm32-sim instead. The
14-
# wolfSSL source tree is expected to be mounted at /opt/wolfssl at
15-
# runtime (the GitHub workflow does `docker run -v $(pwd):/opt/wolfssl
16-
# ...`). Default CMD runs the H7 firmware; override with
17-
# `run-wolfcrypt-u5.sh` for U585.
12+
# Builds the wolfCrypt-on-STM32 firmwares (H753, U585, MP135) that
13+
# today run under Renode CI, then runs them through stm32-sim
14+
# instead. The wolfSSL source tree is expected to be mounted at
15+
# /opt/wolfssl at runtime (the GitHub workflow does
16+
# `docker run -v $(pwd):/opt/wolfssl ...`). Default CMD runs the H7
17+
# firmware; override with `run-wolfcrypt-u5.sh` or
18+
# `run-wolfcrypt-mp135.sh` for the other targets.
1819
# Image contents:
1920
# - arm-none-eabi-gcc cross toolchain
2021
# - CMSIS_5, cmsis-device-h7, STM32CubeH7 v1.11.2 (vendored under /opt)
2122
# - cmsis-device-u5, STM32CubeU5 (vendored under /opt)
23+
# - STM32CubeMP13 (vendored under /opt for the MP135 build)
2224
# - stm32-sim runner binary (built from this same repo)
23-
# - run-wolfcrypt-h7.sh and run-wolfcrypt-u5.sh entrypoints
25+
# - run-wolfcrypt-{h7,u5,mp135}.sh entrypoints
2426

2527
# =============================================================================
2628
# Stage 1: build stm32-sim (Rust)
@@ -76,7 +78,15 @@ RUN git clone --depth 1 \
7678
/opt/STM32CubeU5 \
7779
&& cd /opt/STM32CubeU5 \
7880
&& git submodule update --init --recursive --depth 1)) \
79-
&& find /opt/STM32CubeH7 /opt/STM32CubeU5 -name '.git' -prune -exec rm -rf {} + \
81+
&& (git clone --depth 1 --recurse-submodules \
82+
https://github.com/STMicroelectronics/STM32CubeMP13.git \
83+
/opt/STM32CubeMP13 \
84+
|| (git clone --depth 1 \
85+
https://github.com/STMicroelectronics/STM32CubeMP13.git \
86+
/opt/STM32CubeMP13 \
87+
&& cd /opt/STM32CubeMP13 \
88+
&& git submodule update --init --recursive --depth 1)) \
89+
&& find /opt/STM32CubeH7 /opt/STM32CubeU5 /opt/STM32CubeMP13 -name '.git' -prune -exec rm -rf {} + \
8090
&& rm -rf /opt/cmsis-device-h7/.git /opt/cmsis-device-u5/.git /opt/CMSIS_5/.git
8191

8292
COPY --from=sim-builder /app/stm32-sim/target/release/stm32-sim /usr/local/bin/stm32-sim
@@ -88,13 +98,18 @@ COPY --from=sim-builder /app/stm32-sim/target/release/stm32-sim /usr/local/bin/s
8898
# disable because Renode could not model them.
8999
COPY firmware/wolfcrypt-test-h7/ /opt/firmware-h7/
90100
COPY firmware/wolfcrypt-test-u5/ /opt/firmware-u5/
101+
COPY firmware/wolfcrypt-test-mp135/ /opt/firmware-mp135/
91102

92103
COPY scripts/run-wolfcrypt-h7.sh /usr/local/bin/run-wolfcrypt-h7.sh
93104
COPY scripts/run-wolfcrypt-u5.sh /usr/local/bin/run-wolfcrypt-u5.sh
94-
RUN chmod +x /usr/local/bin/run-wolfcrypt-h7.sh /usr/local/bin/run-wolfcrypt-u5.sh
105+
COPY scripts/run-wolfcrypt-mp135.sh /usr/local/bin/run-wolfcrypt-mp135.sh
106+
RUN chmod +x /usr/local/bin/run-wolfcrypt-h7.sh \
107+
/usr/local/bin/run-wolfcrypt-u5.sh \
108+
/usr/local/bin/run-wolfcrypt-mp135.sh
95109

96110
ENV WOLFSSL_ROOT=/opt/wolfssl
97111

98112
# Default entrypoint runs the H7 wolfCrypt test. Override by passing
99-
# `run-wolfcrypt-u5.sh` as the command for the U585 build.
113+
# `run-wolfcrypt-u5.sh` (U585) or `run-wolfcrypt-mp135.sh` (MP135) as
114+
# the command for the other targets.
100115
CMD ["run-wolfcrypt-h7.sh"]

‎STM32Sim/README.md‎

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ track on its own schedule.
2626
## Architecture
2727

2828
We use [Unicorn Engine](https://www.unicorn-engine.org/) (QEMU-derived)
29-
for ARM Cortex-M CPU emulation, and provide our own MMIO peripheral
30-
models in Rust. The repo is a Cargo workspace under
31-
[`stm32-sim/`](stm32-sim):
29+
for ARM CPU emulation, and provide our own MMIO peripheral models in
30+
Rust. The Cortex-M targets boot in Thumb/MCLASS mode; the MP135
31+
target boots in ARM mode as a Cortex-A7 (with MMU). The repo is a
32+
Cargo workspace under [`stm32-sim/`](stm32-sim):
3233

3334
```
3435
stm32-sim/
3536
core/ CPU + MMIO bus + ELF loader + Runner
3637
peripherals/ USART, RCC, RNG, CRYP, HASH, PKA
37-
chips/ STM32H753 / STM32U575 / STM32U585 chip configurations
38-
(memory map + peripheral wiring)
38+
chips/ STM32H753 / STM32U575 / STM32U585 / STM32MP135 chip
39+
configurations (memory map + peripheral wiring)
3940
runner-bin/ `stm32-sim` CLI binary
4041
```
4142

@@ -50,18 +51,26 @@ even though three chips might present three different DIN/HR layouts.
5051

5152
## Status
5253

53-
Both **STM32H753** (Cortex-M7, HAL v1, no PKA) and **STM32U575**
54-
(Cortex-M33, HAL v2, PKA v2) chip targets boot, run firmware, and
55-
drive their on-chip cryptographic peripherals end-to-end:
56-
57-
| Peripheral | H7 (v1) | U5 (v2) |
58-
|------------|---------|---------|
59-
| USART | OK | OK |
60-
| RCC | stub | stub |
61-
| RNG | OK | OK |
62-
| CRYP/AES | ECB/CBC/CTR/GCM (HAL-driven) | ECB/CBC/CTR/GCM |
63-
| HASH | SHA-1/224/256, MD5 (HAL-driven, hardware HMAC mode supported) | SHA-1/224/256, MD5 |
64-
| PKA | n/a | ECC mul (P-256/P-384), RSA modexp, mod arithmetic |
54+
**STM32H753** (Cortex-M7, HAL v1, no PKA), **STM32U575/U585**
55+
(Cortex-M33, HAL v2, PKA v2), and **STM32MP135** (Cortex-A7,
56+
HAL v2 with the H7-style CRYP block, PKA v2) chip targets all boot,
57+
run firmware, and drive their on-chip cryptographic peripherals end-
58+
to-end:
59+
60+
| Peripheral | H7 (v1) | U5 (v2) | MP135 |
61+
|------------|----------------------------------|--------------------|---------------------------------------|
62+
| USART | OK | OK | OK (UART4) |
63+
| RCC | stub | stub | stub |
64+
| RNG | OK | OK | OK (RNG1) |
65+
| CRYP/AES | ECB/CBC/CTR/GCM (HAL-driven) | ECB/CBC/CTR/GCM | ECB/CBC/CTR/GCM (CRYP1, aliased CRYP) |
66+
| HASH | SHA-1/224/256, MD5 | SHA-1/224/256, MD5 | SHA-1/224/256, MD5, SHA-384/512, SHA3-224/256/384/512, SHAKE-128/256 (HASH1) |
67+
| PKA | n/a | ECC mul (P-256/P-384), RSA modexp, mod arithmetic | same as U5 |
68+
69+
The MP135 is bare-metal Cortex-A7 with no internal flash. The firmware
70+
links at the DDR base (0xC0000000); the simulator maps DDR as plain
71+
RAM and the ELF loader writes segments straight there, so no DDR_Init
72+
helper is needed. The firmware enables a flat 1 MiB-section MMU map
73+
during early boot to mirror the real-hardware path.
6574

6675
The peripheral register adapters are split into `v1.rs` (H7 / HAL v1)
6776
and `v2.rs` (U5 / HAL v2) modules sharing the same cryptographic
@@ -90,6 +99,7 @@ toolchain:
9099
```sh
91100
make -C firmware/smoke-test-h7
92101
make -C firmware/smoke-test-u5
102+
make -C firmware/smoke-test-mp135
93103
```
94104

95105
## Running
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Makefile for the STM32Sim MP135 smoke-test firmware.
2+
#
3+
# Copyright (C) 2026 wolfSSL Inc.
4+
5+
CROSS ?= arm-none-eabi-
6+
CC := $(CROSS)gcc
7+
OBJCOPY := $(CROSS)objcopy
8+
SIZE := $(CROSS)size
9+
10+
CFLAGS := -mcpu=cortex-a7 -marm -mfpu=neon-vfpv4 -mfloat-abi=hard \
11+
-O0 -g -ffreestanding -nostartfiles -Wall -Wextra \
12+
-fno-common -ffunction-sections -fdata-sections
13+
ASFLAGS := -mcpu=cortex-a7 -marm -mfpu=neon-vfpv4 -mfloat-abi=hard \
14+
-g -ffreestanding
15+
LDFLAGS := -mcpu=cortex-a7 -marm -mfpu=neon-vfpv4 -mfloat-abi=hard \
16+
-nostartfiles -Wl,--gc-sections -T smoke.ld -Wl,-Map,smoke.map
17+
18+
OBJS := startup.o mmu.o main.o
19+
TARGET := smoke.elf
20+
21+
all: $(TARGET)
22+
23+
$(TARGET): $(OBJS) smoke.ld
24+
$(CC) $(LDFLAGS) -o $@ $(OBJS)
25+
$(SIZE) $@
26+
27+
%.o: %.c
28+
$(CC) $(CFLAGS) -c -o $@ $<
29+
30+
%.o: %.S
31+
$(CC) $(ASFLAGS) -c -o $@ $<
32+
33+
clean:
34+
rm -f $(OBJS) $(TARGET) smoke.map
35+
36+
.PHONY: all clean

0 commit comments

Comments
 (0)