Skip to content

Commit c71f1bc

Browse files
committed
Update readme for correctness
1 parent b770468 commit c71f1bc

1 file changed

Lines changed: 40 additions & 3 deletions

File tree

  • test/baremetal/platform/nucleo-n657x0-q

test/baremetal/platform/nucleo-n657x0-q/README.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!--
22
Copyright (c) The mldsa-native project authors
3+
Copyright (c) The mlkem-native project authors
34
Copyright (c) Arm Ltd.
45
SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
56
-->
@@ -18,6 +19,15 @@ This platform runs ML-KEM tests on the ST NUCLEO‑N657X0‑Q board using STM32C
1819
- macOS app: `<CLT>/STM32CubeProgrammer/stlink/STLinkUpgrade.app`
1920
- CLI: `<CLT>/STM32CubeProgrammer/stlink/STLinkUpgrade`
2021

22+
## DevShell (required)
23+
Run gdb, make and exec_wrapper.py commands in this README from within the project’s Nix devshell for this board:
24+
25+
```
26+
nix develop .#nucleo-n657x0-q
27+
```
28+
29+
Then, in that shell, run the Make targets and Python scripts below.
30+
2131
## Environment Variables (exec_wrapper.py)
2232
- `GDB` (default: `arm-none-eabi-gdb`) – gdb binary.
2333
- `GDB_PORT` (default: `3333`) – gdbserver port.
@@ -57,7 +67,17 @@ STM32_Programmer_CLI -c port={transport} freq={speed} {serial_prog} -gdbserver p
5767
- Add `--verbose` (or `-v`) to print wrapper diagnostics, gdbserver output, and gdb chatter.
5868

5969
## Argv injection
60-
- Tests receive arguments via a memory block named `mlkem_cmdline_block`.
70+
- Tests receive arguments via a reserved BSS block symbol `mlk_cmdline_block`.
71+
- The wrapper resolves the numeric base address via `arm-none-eabi-nm` (fallback: `readelf -s`);
72+
override with `ARG_BLOCK_ADDR` (hex) or choose a different symbol with `ARG_BLOCK_SYMBOL`.
73+
74+
### Argv blob layout (authoritative)
75+
- 4 bytes: `u32 argc` (little-endian).
76+
- `argc` × 4 bytes: `u32 argv_ptrs[i]` (absolute addresses): `base + string_offset[i]`.
77+
- NUL-terminated UTF-8 strings placed sequentially after the pointer table.
78+
- Alignment: strings start at offset `4 + 4*argc` (4-byte aligned).
79+
- Helper: `test/baremetal/platform/nucleo-n657x0-q/make_argv_bin.py` can generate `argv.bin` manually.
80+
6181
- The wrapper packs argv into a temporary `argv.bin` and restores it via GDB:
6282
- Resolves the symbol’s numeric address using `arm-none-eabi-nm` (fallback: `readelf -s`).
6383
- Uses `restore <argv.bin> binary <addr>` in the GDB batch.
@@ -92,8 +112,9 @@ ST-LINK_gdbserver -p 61234 -l 1 -d -s -cp "$ST_CUBE_PROG_PATH" -m 1 --semihost
92112
(gdb) target remote :61234
93113
(gdb) monitor reset
94114
(gdb) load
95-
(gdb) restore /tmp/argv.bin binary &mlkem_cmdline_block # or numeric address
96-
(gdb) monitor reset
115+
(gdb) tbreak __wrap_main
116+
(gdb) continue
117+
(gdb) restore /tmp/argv.bin binary &mlk_cmdline_block # or numeric address
97118
(gdb) continue
98119
```
99120

@@ -107,3 +128,19 @@ ST-LINK_gdbserver -p 61234 -l 1 -d -s -cp "$ST_CUBE_PROG_PATH" -m 1 --semihost
107128
## Notes
108129
- ST‑LINK gdbserver does not implement the QEMU semihost `SYS_EXIT_EXTENDED`. A sentinel‑based exit workaround is planned in the proposal.
109130
- This platform uses FSBL‑LRUN startup/system/linker from the Cube template and a 128 KiB stack for tests.
131+
132+
- Clock configuration: `SystemClock_Config()` is generated from the STM32CubeN6 FSBL template (`Projects/NUCLEO-N657X0-Q/Templates/Template_FSBL_LRUN/FSBL/Src/main.c`) into `${NUCLEO_N657X0_Q_PATH}/clock_config.c` by `nix/nucleo-n657x0-q/default.nix`. The devshell build also ensures `${NUCLEO_N657X0_Q_PATH}/Inc/main.h` declares `void SystemClock_Config(void);` and `void Error_Handler(void);`. Do not edit the generated file directly; update the Cube template or the extraction logic if adjustments are needed.
133+
134+
## HW‑testing
135+
- Run from inside the Nix devshell: `nix develop .#nucleo-n657x0-q`.
136+
- Hardware runs are opt‑in. Include this platform’s Makefile to target the NUCLEO‑N657X0‑Q board:
137+
138+
```
139+
make test EXTRA_MAKEFILE=test/baremetal/platform/nucleo-n657x0-q/platform.mk -j1 V=1
140+
```
141+
142+
- Examples:
143+
- Single test: `make run_func_512 EXTRA_MAKEFILE=test/baremetal/platform/nucleo-n657x0-q/platform.mk -j1 V=1`
144+
- Direct wrapper: `python3 test/baremetal/platform/nucleo-n657x0-q/exec_wrapper.py test/build/mlkem512/bin/test_mlkem512`
145+
146+
- Without `EXTRA_MAKEFILE`, tests run on the host (no hardware).

0 commit comments

Comments
 (0)