Skip to content

Commit 40ddd44

Browse files
committed
Cleanups
1 parent 5e4f7d4 commit 40ddd44

3 files changed

Lines changed: 160 additions & 701 deletions

File tree

docs/Targets.md

Lines changed: 65 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,8 @@ The PolarFire SoC is a 64-bit RISC-V SoC featuring a five-core CPU cluster (1×
802802
`hal/mpfs250.ld` - Linker script for S-mode (HSS-based boot)
803803
`hal/mpfs250-m.ld` - Linker script for M-mode (eNVM + L2 SRAM)
804804
`hal/mpfs.dts` - Device tree source
805-
`hal/mpfs.yaml` - HSS payload generator configuration
805+
`hal/mpfs.yaml` - HSS payload generator configuration for use of DDR
806+
`hal/mpfs-l2lim.yaml` - HSS payload generator for the use of L2-LIM
806807
`hal/mpfs250.its` - Example FIT image creation template
807808

808809
### PolarFire SoC Building wolfBoot
@@ -906,25 +907,49 @@ Notes:
906907
907908
### PolarFire SoC M-Mode (bare-metal eNVM boot)
908909
909-
In M-Mode wolfBoot runs directly on the E51 monitor core from eNVM — no HSS required. The signed
910-
application is loaded from SC QSPI flash into L2 Scratchpad (on-chip RAM). This is the simplest
911-
bring-up path.
910+
wolfBoot supports running directly in Machine Mode (M-mode) on PolarFire SoC, replacing the Hart
911+
Software Services (HSS) as the first-stage bootloader. wolfBoot runs on the E51 monitor core from
912+
eNVM and loads a signed application from SC QSPI flash into L2 Scratchpad (on-chip RAM) — no HSS
913+
or DDR required. This is the simplest bring-up path.
914+
915+
**Features:**
916+
* Runs on E51 monitor core (hart 0) directly from eNVM
917+
* Executes from L2 Scratchpad SRAM (256 KB at `0x0A000000`)
918+
* Loads signed application from SC QSPI flash to L2 Scratchpad (`0x0A010200`)
919+
* No HSS or DDR required — boots entirely from on-chip memory
920+
* Wakes and manages secondary U54 harts via IPI
921+
* Per-hart UART output (each hart uses its own MMUART)
922+
* ECC384 + SHA384 signature verification
923+
924+
**Relevant files:**
925+
926+
| File | Description |
927+
|------|-------------|
928+
| `config/examples/polarfire_mpfs250_m_qspi.config` | M-mode + SC QSPI configuration |
929+
| `hal/mpfs250-m.ld` | M-mode linker script (eNVM + L2 SRAM) |
930+
| `hal/mpfs250.c` | HAL with QSPI driver, UART, L2 cache init |
931+
| `src/boot_riscv_start.S` | M-mode assembly startup |
912932
913933
**Boot flow:**
914-
1. CPU starts at eNVM reset vector (`0x20220100`)
915-
2. Startup code copies wolfBoot to L2 Scratchpad (`0x0A000000`) and jumps there
916-
3. wolfBoot reads the signed image from QSPI flash into L2 Scratchpad (`0x0A010200`)
917-
4. Signature is verified, then execution jumps to the application
934+
1. **eNVM reset vector** (`0x20220100`): CPU starts, startup code copies wolfBoot to L2 Scratchpad
935+
2. **L2 Scratchpad execution** (`0x0A000000`): wolfBoot runs from scratchpad
936+
3. **Hardware init**: L2 cache configuration, UART setup
937+
4. **QSPI init**: SC QSPI controller (`0x37020100`), JEDEC ID read, 4-byte address mode
938+
5. **Image load**: Read signed image from QSPI flash (`0x20000`) to L2 Scratchpad (`0x0A010200`)
939+
6. **Verify & boot**: SHA384 integrity check, ECC384 signature verification, jump to app
918940
919941
**Build:**
920942
```sh
921943
cp config/examples/polarfire_mpfs250_m_qspi.config .config
922944
make clean && make wolfboot.elf
923945
```
924946
925-
**Flash wolfBoot to eNVM** (requires SmartDesign / SmartFusion2 Libero SoC install):
947+
**Flash wolfBoot to eNVM** (requires SoftConsole / Libero SoC install):
926948
```sh
927-
java -jar $SC_INSTALL_DIR/extras/mpfs/mpfsBootmodeProgrammer.jar \
949+
export SC_INSTALL_DIR=/opt/Microchip/SoftConsole-v2022.2-RISC-V-747
950+
951+
$SC_INSTALL_DIR/eclipse/jre/bin/java -jar \
952+
$SC_INSTALL_DIR/extras/mpfs/mpfsBootmodeProgrammer.jar \
928953
--bootmode 1 --die MPFS250T --package FCG1152 --workdir $PWD wolfboot.elf
929954
```
930955
@@ -946,7 +971,25 @@ The script:
946971
3. Transfers the binary in 256-byte ACK-driven chunks
947972
4. wolfBoot erases, writes, and then continues booting the new image
948973
949-
Use `0x20000` for the boot partition and `0x2000000` for the update partition.
974+
Use `0x20000` for the boot partition and `0x02000000` for the update partition.
975+
976+
**QSPI partition layout** (Micron MT25QL01G, 128 MB):
977+
978+
| Region | Address | Size |
979+
|--------|---------|------|
980+
| Boot partition | `0x00020000` | ~32 MB |
981+
| Update partition | `0x02000000` | ~32 MB |
982+
| Swap partition | `0x04000000` | 64 KB |
983+
984+
**UART mapping:**
985+
986+
| Hart | Core | MMUART | USB device |
987+
|------|------|--------|------------|
988+
| 0 | E51 | MMUART0 | /dev/ttyUSB0 |
989+
| 1 | U54_1 | MMUART1 | /dev/ttyUSB1 |
990+
| 2 | U54_2 | MMUART2 | N/A |
991+
| 3 | U54_3 | MMUART3 | N/A |
992+
| 4 | U54_4 | MMUART4 | N/A |
950993
951994
**Expected serial output on successful boot:**
952995
```
@@ -963,21 +1006,25 @@ Booting at 0x...
9631006
```
9641007
9651008
**Notes:**
966-
- The E51 is `rv64imac`; the `rdtime` CSR instruction is not available in bare-metal M-mode.
967-
wolfBoot uses a calibrated busy-loop for all delays (`udelay()` in `hal/mpfs250.c`).
1009+
- The E51 is `rv64imac` (no FPU or crypto extensions). wolfBoot is compiled with `NO_ASM=1` to
1010+
use portable C crypto implementations and `-march=rv64imac -mabi=lp64` for correct code
1011+
generation. The `rdtime` CSR instruction is not available in bare-metal M-mode; wolfBoot uses a
1012+
calibrated busy-loop for all delays (`udelay()` in `hal/mpfs250.c`).
9681013
- `UART_QSPI_PROGRAM=1` adds a 3-second boot pause every time. Set to `0` once the flash
9691014
contents are stable.
9701015
- The config uses `WOLFBOOT_LOAD_ADDRESS=0x0A010200` to place the application in L2 Scratchpad
971-
above wolfBoot code (~64KB at `0x0A000000`), with the stack at the top of the 256KB region.
972-
- **LIM instruction fetch limitation:** The on-chip LIM (`0x08000000`, 2MB) is backed by L2
973-
cache ways. When `L2_WAY_ENABLE` is set to `0x0B` (all cache ways 0-7 active for caching),
1016+
above wolfBoot code (~64 KB at `0x0A000000`), with the stack at the top of the 256 KB region.
1017+
- **LIM instruction fetch limitation:** The on-chip LIM (`0x08000000`, 2 MB) is backed by L2
1018+
cache ways. When `L2_WAY_ENABLE` is set to `0x0B` (all cache ways 07 active for caching),
9741019
no ways remain for LIM backing SRAM. Data reads from LIM work through the L2 cache, but
9751020
instruction fetch silently hangs — the CPU stalls with no trap generated. For this reason the
9761021
application is loaded into L2 Scratchpad (`0x0A000000`), which is always accessible regardless
9771022
of `L2_WAY_ENABLE`. To use LIM, reduce `L2_WAY_ENABLE` to free cache ways for LIM backing.
978-
- **Strip debug symbols** before signing the test-app ELF. The debug build is ~150KB but the
979-
stripped ELF is ~5KB. L2 Scratchpad has ~150KB available between wolfBoot code and the stack:
1023+
- **Strip debug symbols** before signing the test-app ELF. The debug build is ~150 KB but the
1024+
stripped ELF is ~5 KB. L2 Scratchpad has ~150 KB available between wolfBoot code and the stack:
9801025
`riscv64-unknown-elf-strip --strip-debug test-app/image.elf`
1026+
- **DDR support:** DDR initialization is available on the `polarfire_ddr` branch for use cases
1027+
that require loading larger applications to DDR memory.
9811028
9821029
### PolarFire testing
9831030
@@ -1439,108 +1486,6 @@ ML-DSA 87 verify 200 ops took 1.077 sec, avg 5.385 ms, 185.704 ops/
14391486
Benchmark complete
14401487
```
14411488
1442-
### PolarFire Machine Mode (M-Mode) Support
1443-
1444-
wolfBoot supports running directly in Machine Mode (M-mode) on PolarFire SoC,
1445-
replacing the Hart Software Services (HSS) as the first-stage bootloader. In
1446-
M-mode, wolfBoot runs on the E51 monitor core and loads a signed application
1447-
from SC QSPI flash to L2 Scratchpad SRAM. LIM is not used as an execute region
1448-
due to instruction-fetch limitations (see note below).
1449-
1450-
#### M-Mode Features
1451-
1452-
* Runs on E51 monitor core (hart 0) directly from eNVM
1453-
* Executes from L2 Scratchpad SRAM (256KB at 0x0A000000)
1454-
* Loads signed application from SC QSPI flash to L2 Scratchpad (0x0A010200)
1455-
* No HSS or DDR required — boots entirely from on-chip memory
1456-
* Wakes and manages secondary U54 harts via IPI
1457-
* Per-hart UART output (each hart uses its own MMUART)
1458-
* ECC384 + SHA384 signature verification
1459-
1460-
#### M-Mode Files
1461-
1462-
| File | Description |
1463-
|------|-------------|
1464-
| `config/examples/polarfire_mpfs250_m_qspi.config` | M-mode + SC QSPI configuration |
1465-
| `hal/mpfs250-m.ld` | M-mode linker script (eNVM + L2 SRAM) |
1466-
| `hal/mpfs250.c` | HAL with QSPI driver, UART, L2 cache init |
1467-
| `src/boot_riscv_start.S` | M-mode assembly startup |
1468-
1469-
#### Building for M-Mode
1470-
1471-
```sh
1472-
# Copy M-mode QSPI configuration
1473-
cp config/examples/polarfire_mpfs250_m_qspi.config .config
1474-
1475-
# Build wolfBoot and signed test-app
1476-
make clean
1477-
make
1478-
```
1479-
1480-
This produces:
1481-
- `wolfboot.elf` — bootloader for eNVM (~26KB)
1482-
- `test-app/image_v1_signed.bin` — signed application for QSPI flash
1483-
1484-
#### Flashing
1485-
1486-
M-mode requires programming two targets:
1487-
1488-
1. **eNVM** (wolfBoot): Programmed via JTAG using mpfsBootmodeProgrammer (bootmode 1)
1489-
2. **QSPI flash** (signed application): Programmed via Libero/FPExpress SPI programming
1490-
1491-
```sh
1492-
# Set SoftConsole installation directory
1493-
export SC_INSTALL_DIR=/opt/Microchip/SoftConsole-v2022.2-RISC-V-747
1494-
1495-
# Flash wolfboot.elf to eNVM
1496-
$SC_INSTALL_DIR/eclipse/jre/bin/java -jar \
1497-
$SC_INSTALL_DIR/extras/mpfs/mpfsBootmodeProgrammer.jar \
1498-
--bootmode 1 --die MPFS250T --package FCG1152 --workdir $PWD wolfboot.elf
1499-
1500-
# Flash test-app/image_v1_signed.bin to QSPI at offset 0x20000
1501-
# (use Libero SoC Design Suite SPI flash programming)
1502-
```
1503-
1504-
#### M-Mode Boot Flow
1505-
1506-
1. **eNVM Reset Vector** (0x20220100): CPU starts, copies code to L2 SRAM
1507-
2. **L2 SRAM Execution** (0x0A000000): wolfBoot runs from scratchpad
1508-
3. **Hardware Init**: L2 cache configuration, UART setup
1509-
4. **QSPI Init**: SC QSPI controller (0x37020100), JEDEC ID read, 4-byte address mode
1510-
5. **Image Load**: Read signed image from QSPI flash (0x20000) to L2 Scratchpad (0x0A010200)
1511-
6. **Verify & Boot**: SHA384 integrity check, ECC384 signature verification, jump to app
1512-
1513-
#### M-Mode QSPI Partition Layout
1514-
1515-
The SC QSPI flash (Micron MT25QL01G, 128MB) is partitioned as:
1516-
1517-
| Region | Address | Size |
1518-
|--------|---------|------|
1519-
| Boot partition | 0x00020000 | ~32MB |
1520-
| Update partition | 0x02000000 | ~32MB |
1521-
| Swap partition | 0x04000000 | 64KB |
1522-
1523-
#### M-Mode UART Mapping
1524-
1525-
| Hart | Core | MMUART | USB Device |
1526-
|------|------|--------|------------|
1527-
| 0 | E51 | MMUART0 | /dev/ttyUSB0 |
1528-
| 1 | U54_1 | MMUART1 | /dev/ttyUSB1 |
1529-
| 2 | U54_2 | MMUART2 | N/A |
1530-
| 3 | U54_3 | MMUART3 | N/A |
1531-
| 4 | U54_4 | MMUART4 | N/A |
1532-
1533-
#### M-Mode Notes
1534-
1535-
* The E51 core is rv64imac (no FPU or crypto extensions). wolfBoot is compiled
1536-
with `NO_ASM=1` to use portable C crypto implementations and
1537-
`-march=rv64imac -mabi=lp64` for correct code generation.
1538-
* CLINT MTIME counter is not running in bare-metal M-mode (no HSS), so
1539-
`udelay()` uses a calibrated busy loop instead of the timer CSR.
1540-
* DDR initialization support is available on the `polarfire_ddr` branch for
1541-
use cases that require loading larger applications to DDR memory.
1542-
1543-
15441489
## STM32F7
15451490
15461491
The STM32-F76x and F77x offer dual-bank hardware-assisted swapping.

0 commit comments

Comments
 (0)