Create Nucleo N657x0-Q Platform#1547
Conversation
c71f1bc to
32c4136
Compare
|
@bremoran What's your plan for this? |
|
I am hoping to finalise this but I'm not able to spend time on it right now. |
Thanks for the update. Marking it as draft for now. Please mark it as ready when you have finished it. |
e3776fa to
c95d72a
Compare
Done! |
CBMC Results (ML-KEM-512)Full Results (191 proofs)
|
CBMC Results (ML-KEM-1024)Full Results (191 proofs)
|
CBMC Results (ML-KEM-768)
Full Results (191 proofs)
|
54df290 to
dd9798a
Compare
dd9798a to
1ad95e2
Compare
8cd8188 to
0d5bd05
Compare
3f291fd to
6b8a791
Compare
| nix-shell: linter | ||
| gh_token: ${{ secrets.GITHUB_TOKEN }} | ||
| cross-prefix: "aarch64-unknown-linux-gnu-" | ||
| ubuntu_arm: |
There was a problem hiding this comment.
Is this not subsumed by the quickcheck job?
There was a problem hiding this comment.
Yes, I suspect it is. I think this is because of a bad rebase; I'll prune it.
| outp="$out/platform/nucleo-n657x0-q/src/platform" | ||
| mkdir -p "$outp" | ||
|
|
||
| tpl="Projects/NUCLEO-N657X0-Q/Templates/Template" | ||
|
|
||
| if [ ! -d "$tpl" ]; then | ||
| echo "ERROR: expected Cube template at $tpl" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Copy CMSIS headers needed by system/startup from the Cube tree | ||
| mkdir -p "$outp/Drivers/CMSIS/Core" | ||
| mkdir -p "$outp/Drivers/CMSIS/Device" |
There was a problem hiding this comment.
The install phase seems pretty long. Could you provide some overview in the beginning as to what is happening here?
There was a problem hiding this comment.
Yes, I have added some comments that will hopefully make things clearer. I have also simplified the nix file.
| env: | ||
| EXTRA_MAKEFILE: ${{ matrix.target.system == 'nucleo-n657x0' && 'test/baremetal/platform/nucleo-n657x0-q/platform.mk' || '' }} |
There was a problem hiding this comment.
Can this be part of the matrix?
There was a problem hiding this comment.
Yes, agreed. I’ll add an extra_makefile field to the benchmark matrix and pass that through as EXTRA_MAKEFILE, with an empty value for the existing non-baremetal targets. That removes the target-specific expression from the step.
| nix-shell: '' | ||
| gh_token: ${{ secrets.GITHUB_TOKEN }} | ||
| cflags: "-DMLKEM_DEBUG -DMLK_FORCE_PPC64LE" | ||
| nucleo_n657x0_q_tests: |
There was a problem hiding this comment.
Why is this done here and not alongside the existing baremetal tests?
There was a problem hiding this comment.
Good point. This should live with the existing baremetal workflow. I’ll move the NUCLEO-N657X0-Q job into .github/workflows/baremetal.yml as a matrix target, while keeping the self-hosted/fork guard because this one needs attached hardware rather than QEMU.
There was a problem hiding this comment.
This still seems open
|
|
||
| # NUCLEO-N657X0-Q Baremetal Platform | ||
|
|
||
| This platform runs ML-KEM tests on the ST NUCLEO-N657X0-Q board using the |
There was a problem hiding this comment.
Does QEMU support this board, so one could, alternatively, emulate the final binary?
There was a problem hiding this comment.
I don’t think QEMU currently supports the STM32N657/NUCLEO-N657X0-Q machine model. QEMU’s Arm docs list only a small set of STM32 boards, and this board is not among them; they also note that firmware images generally need an exact matching board model to boot. I’ll add a short note to the README saying this platform currently requires hardware. (qemu.org)
That said, I have just stumbled across https://renode.io which may be relevant to simulating hardware targets outside the baseline supported by QEMU.
| @@ -0,0 +1,179 @@ | |||
| #!/usr/bin/env python3 | |||
There was a problem hiding this comment.
Shallow comment: Can we keep the top-level of the platform clean and ideally confined to exec_wrapper.py, platform.mk, README.md?
There was a problem hiding this comment.
Yes. I’ll move host-side helpers such as flexmem_configure.py, run_test_after_flexmem.py, make_argv_bin.py, and the host tests under the existing nucleo_host/ area, leaving only exec_wrapper.py, platform.mk, and README.md at the platform top level.
There was a problem hiding this comment.
I have a fix staged, but I don't have my nucleo with me today so I cannot test it until later in the day.
| # Build hal.c without pedantic diagnostics (overrides global -pedantic/-Wpedantic) | ||
| $(MLKEM512_DIR)/test/hal/hal.c.o: CFLAGS := $(filter-out -pedantic -Wpedantic -Werror -Wconversion -Wsign-conversion,$(CFLAGS)) -Wno-pedantic -Wno-conversion -Wno-sign-conversion -Wno-error | ||
| $(MLKEM768_DIR)/test/hal/hal.c.o: CFLAGS := $(filter-out -pedantic -Wpedantic -Werror -Wconversion -Wsign-conversion,$(CFLAGS)) -Wno-pedantic -Wno-conversion -Wno-sign-conversion -Wno-error | ||
| $(MLKEM1024_DIR)/test/hal/hal.c.o: CFLAGS := $(filter-out -pedantic -Wpedantic -Werror -Wconversion -Wsign-conversion,$(CFLAGS)) -Wno-pedantic -Wno-conversion -Wno-sign-conversion -Wno-error |
There was a problem hiding this comment.
hal.c seems small enough that one should be able to adjust the code instead of silencing the warnings?
There was a problem hiding this comment.
Agreed. I’ll remove this per-target warning suppression and fix the warnings in test/hal/hal.c directly. The warning relaxation should stay limited to vendor/Cube sources in the platform makefile.
| return | ||
|
|
||
| if len(self.failed) > 0: | ||
| self.check_fail() |
There was a problem hiding this comment.
This block exists because failed benchmark runs return booleans instead of output strings, and the code was bailing out before parsing those booleans. I’ll make that explicit in control flow.
199f5d7 to
3890d1d
Compare
| # nucleo-n657x0-q benchmarks. The package copies only the required Cube headers | ||
| # and sources, then patches selected files where needed to get the intended | ||
| # RAM-loaded benchmark behavior. | ||
| stdenvNoCC.mkDerivation { |
There was a problem hiding this comment.
Would it be an option to just move all the patched files to pqmx and consume them from there?
There was a problem hiding this comment.
The issue with this is the license here. If this is acceptable in pqmx, then we can move the files.
| @@ -0,0 +1,60 @@ | |||
| /* | |||
| * Copyright (c) The mldsa-native project authors | |||
There was a problem hiding this comment.
Is this file needed? It doesn't seem to be listed in the extra sources.
| @@ -0,0 +1,635 @@ | |||
| # Copyright (c) The mlkem-native project authors | |||
There was a problem hiding this comment.
This file is not exercised, it seems. Can it be removed?
| - `.data`, `.bss`: expanded 256 KiB DTCM at `0x30000000` | ||
| - argv block: expanded 256 KiB ITCM at `0x00000000` | ||
| - stdout capture: AXI SRAM at `0x34080000` | ||
| - stack: top 192 KiB of DTCM, with `_estack = 0x30040000` and |
There was a problem hiding this comment.
This seems out of date with the linker script which uses 240 KiB. Can you sync the README with the current state of the PR?
| @@ -0,0 +1,22 @@ | |||
| #!/usr/bin/env python3 | |||
There was a problem hiding this comment.
(Where) is this exercised? Drop it or add to CI?
| openocd.overrideAttrs (old: rec { | ||
| pname = "st-openocd"; | ||
| version = "unstable-2026-05-01"; | ||
|
|
There was a problem hiding this comment.
I have moved this directly into nixpkgs and I'll try to upstream it so we do not have to compile thsi from source: 47c5987
Build the mlkem-native tests as Zephyr applications so they run on QEMU-emulated Arm MPS boards spanning Cortex-M3/M4/M7/M33/M55. This greatly simplifies supporting more hardware without the need for dedicated hardware abstraction layers. Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
The Zephyr platform now covers the QEMU MPS boards, so the baremetal m55-an547 and m33-an524 platforms and the pqmx package they used are no longer needed. Also drops the cross-arm-embedded dev shell and the two baremetal.yml jobs. Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
Add support for running bare-metal tests and benchmarks on the STM32 NUCLEO-N657X0-Q. This adds the platform linker scripts, semihosting glue, argv/result helpers, FLEXMEM configuration and recovery tooling, and an OpenOCD-based execution backend with host-side tests. Package the required ST OpenOCD tooling in Nix and expose a nucleo-n657x0-q development shell. Wire the platform into functional tests, component benchmarks, CI workflows, and shared bare-metal result handling, including Cortex-M cycle counter support. Signed-off-by: Brendan Moran <brendan.moran@arm.com>
3890d1d to
f97c538
Compare
Signed-off-by: Brendan Moran <brendan.moran@arm.com>
Signed-off-by: Brendan Moran <brendan.moran@arm.com>
f97c538 to
7a0b873
Compare
Route NUCLEO-N657X0-Q CI and benchmarks through the Zephyr platform makefile, add the Zephyr board config/overlay/shim, and keep the FLEXMEM/OpenOCD hardware helpers needed by that path. Remove the obsolete baremetal platform makefile, linker script, command-line shim, semihosting runtime, and unused host package marker. Signed-off-by: Brendan Moran <brendan.moran@arm.com>
Remove the standalone NUCLEO-N657X0-Q bare-metal platform and fold the board into the Zephyr test platform with board-specific config, overlay, and shim handling. Move the NUCLEO host helpers under test/zephyr, configure FLEXMEM with direct OpenOCD register writes before each run, load RAM-resident Zephyr ELFs with GDB, inject argv after Zephyr startup, and capture stdout through ITM/SWO. Add the OpenOCD package and Zephyr shell/module wiring needed for STM32N6, update CI and benchmark flows for the Zephyr hardware target, and keep host regression coverage for the runner helpers. Signed-off-by: Brendan Moran <brendan.moran@arm.com>
Signed-off-by: Brendan Moran <brendan.moran@arm.com>
This change introduces a new bare-metal test platform for the Nucleo N657x0-Q board and integrates it into the project’s Nix devshell and test build system.
Summary
nucleo-n657x0-q.test/baremetal/platform/nucleo-n657x0-q/, including build rules, execution wrapper, argument packing utility, and platform sources.Changes
flake.nix: Add.#nucleo-n657x0-qdevshell.nix/nucleo-n657x0-q/default.nix: Define board devshell and tooling.nix/util.nix: Utility update for new platform.test/baremetal/platform/nucleo-n657x0-q/README.md: Platform documentation.test/baremetal/platform/nucleo-n657x0-q/platform.mk: Makefile integration for the platform.test/baremetal/platform/nucleo-n657x0-q/exec_wrapper.py: Execution wrapper for running tests on target.test/baremetal/platform/nucleo-n657x0-q/make_argv_bin.py: Helper to pack argv for target.test/baremetal/platform/nucleo-n657x0-q/src/*.c,*.h: Platform sources (cmdline, semihosting syscall, helpers).test/hal/hal.c,test/hal/pmu_armv8.h: Minor HAL updates for compatibility.test/mk/components.mk: Include the new platform components.Why
Usage
nix develop .#nucleo-n657x0-qmake test EXTRA_MAKEFILE=test/baremetal/platform/nucleo-n657x0-q/platform.mkNotes
README.md.