Skip to content

Commit 22fda7f

Browse files
bremoranhanno-becker
authored andcommitted
Add NUCLEO-N657X0-Q Zephyr hardware platform
Add the Zephyr host wrapper, board overlay, OpenOCD tooling, and benchmark integration needed to run ML-KEM tests and component benchmarks on the NUCLEO-N657X0-Q target. Keep QEMU and existing baremetal CI coverage unchanged; the NUCLEO functional-test CI job is intentionally left out of this squash. Signed-off-by: Brendan Moran <brendan.moran@arm.com>
1 parent cd2f8fb commit 22fda7f

23 files changed

Lines changed: 1755 additions & 25 deletions

.github/actionlint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ self-hosted-runner:
1212
- pqcp-x64
1313
# RISE RISC-V runner
1414
- ubuntu-24.04-riscv
15+
- self-hosted-nucleo-n657x0

.github/workflows/bench.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636
ldflags: "-flto"
3737
bench_extra_args: ""
3838
nix_shell: bench
39+
extra_makefile: ""
40+
zephyr_target: ""
3941
- system: rpi5
4042
name: Arm Cortex-A76 (Raspberry Pi 5) benchmarks
4143
bench_pmu: PERF
@@ -45,6 +47,8 @@ jobs:
4547
bench_extra_args: ""
4648
nix_shell: bench
4749
cross_prefix: ""
50+
extra_makefile: ""
51+
zephyr_target: ""
4852
- system: a55
4953
name: Arm Cortex-A55 (Snapdragon 888) benchmarks
5054
bench_pmu: PERF
@@ -53,6 +57,8 @@ jobs:
5357
ldflags: "-flto -static"
5458
bench_extra_args: -w exec-on-a55
5559
nix_shell: bench
60+
extra_makefile: ""
61+
zephyr_target: ""
5662
- system: bpi
5763
name: SpacemiT K1 8 (Banana Pi F3) benchmarks
5864
bench_pmu: PERF
@@ -62,6 +68,8 @@ jobs:
6268
bench_extra_args: -w exec-on-bpi
6369
cross_prefix: riscv64-unknown-linux-gnu-
6470
nix_shell: cross-riscv64
71+
extra_makefile: ""
72+
zephyr_target: ""
6573
- system: m1-mac-mini
6674
name: Mac Mini (M1, 2020) benchmarks
6775
bench_pmu: MAC
@@ -70,6 +78,8 @@ jobs:
7078
ldflags: "-flto"
7179
bench_extra_args: "-r"
7280
nix_shell: bench
81+
extra_makefile: ""
82+
zephyr_target: ""
7383
- system: pqcp-ppc64
7484
name: ppc64le (POWER10) benchmarks
7585
bench_pmu: PERF
@@ -79,11 +89,27 @@ jobs:
7989
bench_extra_args: "-r"
8090
nix_shell: ''
8191
cross_prefix: ""
92+
extra_makefile: ""
93+
zephyr_target: ""
94+
- system: nucleo-n657x0
95+
name: Arm Cortex-M55 (NUCLEO-N657X0-Q) benchmarks
96+
bench_pmu: NO
97+
archflags: ""
98+
cflags: ""
99+
ldflags: ""
100+
bench_extra_args: ""
101+
nix_shell: zephyr
102+
cross_prefix: ""
103+
extra_makefile: test/zephyr/platform.mk
104+
zephyr_target: nucleo-n657x0-q
82105
if: github.repository_owner == 'pq-code-package' && !github.event.pull_request.head.repo.fork && (github.event.label.name == 'benchmark' || github.ref == 'refs/heads/main')
83106
runs-on: self-hosted-${{ matrix.target.system }}
84107
steps:
85108
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
86109
- uses: ./.github/actions/bench
110+
env:
111+
EXTRA_MAKEFILE: ${{ matrix.target.extra_makefile }}
112+
ZEPHYR_TARGET: ${{ matrix.target.zephyr_target }}
87113
with:
88114
name: ${{ matrix.target.name }}
89115
cflags: ${{ matrix.target.cflags }}

.github/workflows/zephyr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ jobs:
5353
ZEPHYR_TARGET: ${{ matrix.target.board }}
5454
run: |
5555
opt=${{ matrix.target.opt == 'all' && 'opt' || 'no_opt' }}
56-
nix develop .#zephyr --command ./scripts/tests bench --no-auto -c PMU --opt=$opt
57-
nix develop .#zephyr --command ./scripts/tests bench --no-auto --components -c PMU --opt=$opt
56+
nix develop .#zephyr --command ./scripts/tests bench --no-auto -c NO --opt=$opt
57+
nix develop .#zephyr --command ./scripts/tests bench --no-auto --components -c NO --opt=$opt

flake.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
export HOLLIGHT_LOAD_PATH="$IMPORTS_DIR:$S2N_BIGNUM_DIR''${HOLLIGHT_LOAD_PATH:+:$HOLLIGHT_LOAD_PATH}"
5858
export HOLDIR="$HOLLIGHT_DIR"
5959
'';
60+
6061
in
6162
{
6263
_module.args.pkgs = import inputs.nixpkgs {
@@ -94,6 +95,19 @@
9495
} ++ holLightToolchain;
9596
}).overrideAttrs (old: { shellHook = holLightShellHook; });
9697

98+
# arm-none-eabi-gcc + platform files from pqmx
99+
packages.m55-an547 = util.m55-an547;
100+
packages.avr-toolchain = util.avr-toolchain;
101+
packages.openocd = util.openocd;
102+
devShells.arm-embedded = util.mkShell {
103+
packages = builtins.attrValues
104+
{
105+
inherit (config.packages) m55-an547;
106+
inherit (pkgs) gcc-arm-embedded qemu coreutils python3 git;
107+
};
108+
};
109+
110+
devShells.avr = util.mkShell (import ./nix/avr { inherit pkgs; });
97111
packages.hol_server = util.hol_server.hol_server_start;
98112
devShells.hol_light = (util.mkShell {
99113
packages = builtins.attrValues { inherit (config.packages) linters hol_light s2n_bignum hol_server; } ++ holLightToolchain;
@@ -153,6 +167,7 @@
153167
devShells.zephyr = util.mkShell {
154168
packages = builtins.attrValues
155169
{
170+
inherit (config.packages) openocd;
156171
inherit (util) zephyr;
157172
inherit (pkgs) gcc-arm-embedded qemu cmake ninja dtc gperf coreutils git;
158173
} ++ [ util.zephyrPythonEnv ];

nix/openocd/default.nix

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) The mlkem-native project authors
2+
# SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
3+
4+
{ fetchFromGitHub
5+
, openocd
6+
, autoreconfHook
7+
}:
8+
9+
openocd.overrideAttrs (old: rec {
10+
pname = "openocd";
11+
version = "unstable-2026-05-01";
12+
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ autoreconfHook ];
13+
14+
src = fetchFromGitHub {
15+
owner = "openocd-org";
16+
repo = "openocd";
17+
rev = "4e9b167e1ae5ccb437eb0538440988b3f0ec53cb";
18+
fetchSubmodules = true;
19+
hash = "sha256-8aYl7JzulPxH6vgSeTKTMIZVH6d55JJlXTBkfgAPTbU=";
20+
};
21+
})

nix/util.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ rec {
118118
intelhex
119119
colorama
120120
]);
121+
openocd = pkgs.callPackage ./openocd { };
121122
avr-toolchain = pkgs.callPackage ./avr { };
122123

123124
# Helper function to build individual cross toolchains

nix/zephyr/default.nix

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
# Board-agnostic Zephyr build environment: a pinned Zephyr tree plus the
1111
# modules needed by the boards we target, exposed via a setup hook so a plain
12-
# `cmake` build works with no west workspace. CMSIS-6 covers the Cortex-M
13-
# boards; add further modules here as more boards are wired up.
12+
# `cmake` build works with no west workspace.
1413
let
1514
zephyr = fetchFromGitHub {
1615
owner = "zephyrproject-rtos";
@@ -26,6 +25,14 @@ let
2625
rev = "30a859f44ef8ab4dc8f84b03ed586fd16ccf9d74";
2726
hash = "sha256-nTehISN0pu9gnOZMpGaBQ3DFmNxAqAZPGpvbKfEM35o=";
2827
};
28+
29+
# Revision pinned by the Zephyr v4.4.1 manifest (west.yml).
30+
hal_stm32 = fetchFromGitHub {
31+
owner = "zephyrproject-rtos";
32+
repo = "hal_stm32";
33+
rev = "fc11896dd39cfca37bf9b4aeaaa2df8861b81875";
34+
hash = "sha256-AtNq2yTZsTFMTlWn/Ns0wuEiN4Wv/OTV2vWPRu0SnOE=";
35+
};
2936
in
3037
stdenvNoCC.mkDerivation {
3138
pname = "mlkem-native-zephyr";
@@ -37,11 +44,14 @@ stdenvNoCC.mkDerivation {
3744
mkdir -p $out
3845
ln -s ${zephyr} $out/zephyr
3946
ln -s ${cmsis_6} $out/cmsis_6
47+
ln -s ${hal_stm32} $out/hal_stm32
4048
'';
4149

4250
setupHook = writeText "setup-hook.sh" ''
4351
export ZEPHYR_BASE="$1/zephyr"
44-
export ZEPHYR_MODULES="$1/cmsis_6"
52+
export ZEPHYR_CMSIS_6_MODULE="$1/cmsis_6"
53+
export ZEPHYR_HAL_STM32_MODULE="$1/hal_stm32"
54+
export ZEPHYR_MODULES="$1/cmsis_6;$1/hal_stm32"
4555
export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
4656
export GNUARMEMB_TOOLCHAIN_PATH=${gcc-arm-embedded}
4757
'';

scripts/tests

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,11 @@ class Tests:
762762
test_type, self.do_opt(), suppress_output=False
763763
)
764764

765-
if resultss is None:
765+
# Nothing below should write benchmark output unless the run produced
766+
# results and all compile/run steps succeeded.
767+
if resultss is None or len(self.failed) > 0:
766768
self.check_fail()
769+
return
767770

768771
# NOTE: There will only be one items in resultss, as we haven't yet decided how to write both opt/no-opt benchmark results
769772
for k, results in resultss.items():

test/hal/hal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ uint64_t get_cyclecounter(void) { return DWT->CYCCNT; }
124124
#elif defined(ARMCM55)
125125
/* Cortex-M55: Use dedicated PMU */
126126
#include <ARMCM55.h>
127+
#include <pmu_armv8.h>
127128
#include <system_ARMCM55.h>
128-
#include "pmu_armv8.h"
129129

130130
void enable_cyclecounter(void)
131131
{

test/mk/components.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ $(call MAKE_OBJS, $(MLKEM1024_DIR), $(EXTRA_SOURCES)): CFLAGS += $(EXTRA_SOURCES
155155
endif
156156
else
157157
$(ALL_BINS): $$(TEST_SRCS) $(LIB_SRCS)
158+
# Extra per-binary prerequisites a custom-build platform needs (e.g. Zephyr's
159+
# app inputs and active-target marker, set in test/zephyr/platform.mk).
160+
$(ALL_BINS): $(CUSTOM_BUILD_DEPS)
158161
endif
159162

160163
# ABI checker

0 commit comments

Comments
 (0)