-
Notifications
You must be signed in to change notification settings - Fork 36
feat(baremetal): Add m33-an524 platform support for bare-metal building and testing #861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
jricardini
commented
Jan 7, 2026
- Add comprehensive bare-metal testing platform for Cortex-M33 on MPS2-AN521
- Include platform-specific linker script (m33-an521.ld) for memory layout
- Add startup code (startup.c) for ARM Cortex-M33 initialization
- Implement functional test suite (comprehensive_func_test.c) for all ML-DSA parameter sets
- Implement performance benchmark suite (bench_baseline.c) with cycle counting
- Add Python execution wrapper (exec_wrapper.py) for QEMU integration
- Include platform makefile (platform.mk) for cross-compilation configuration
- Add comprehensive documentation (CROSS-BUILDING-AND-TESTING.md) with setup and troubleshooting
- Support testing all three security levels (ML-DSA-44, ML-DSA-65, ML-DSA-87)
- Enable automated testing via QEMU with semihosting support
test/baremetal/platform/m33-an521/CROSS-BUILDING-AND-TESTING.md
Outdated
Show resolved
Hide resolved
hanno-becker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @jricardini, I support the addition of a baremetal environment for Cortex-M33.
The primary areas of work, for me (@mkannwischer please chime in), are:
- Switching to AN524 so we can ensure that this works both on QEMU and on real HW (@mkannwischer has an MPS3, and we could even hook it into CI)
- Generalizing and reusing the existing test files rather than copy-adjusting them.
Probably optional, but strongly desired:
- Add CI job exercising this baremetal environment.
- Consider using CMSIS code as in pqmx (ideally, the environment moves into pqmx as for AN547, but I think this could be done in a follow-up)
|
Updated the PR with the following changes:
Ready for review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @jricardini, this is going in a good direction!
Some points:
- The off-the-shelf build fails for me because of nested comment warnings -> errors. Fixing those manually, though, I can see the build + test working, which is great! 🥳
- Could you clarify if, and if so, how, you had to modify the CMSIS files? Ideally, we'd freshly import them and merely provide a patch for the changes we need. Then, fetching the CMSIS files and applying the patch could be done as part of the nix setup, and we wouldn't need the CMSIS files in the repository in the first place.
| , fetchurl | ||
| }: | ||
|
|
||
| let |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkannwischer Could you review the nix files?
fceacfe to
5ae5708
Compare
hanno-becker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @jricardini, in principle I'm happy with the approach now.
Before it can be merged, we need to do a bit more cleanup, though. The patches are very large, unnecessarily so -- I think we should first get rid of all superficial changes such as formatting or headers, and for the functional changes, briefly explain that what and why. I was/am hoping that not more than a few dozen lines of patching would be needed -- at least it's not yet clear to me why we'd need more.
Also, please keep documentation crisp -- I personally don't like the overly verbose documents that LLMs tend to produce without further direction, and the new README is one example.
| -#define __SAUREGION_PRESENT 0U /* SAU regions present */ | ||
| +/* Configuration of the Cortex-M33 Processor and Core Peripherals */ | ||
| +#define __CM33_REV 0x0004U /* Core revision r0p4 */ | ||
| +#define __SAUREGION_PRESENT 1U /* SAU regions present */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the comments must be wrong, because both the old and the new comment say /* SAU regions present */.
Why do we need to change this?
| - __set_PSP((uint32_t)(&__INITIAL_SP)); | ||
| - | ||
| - __set_MSPLIM((uint32_t)(&__STACK_LIMIT)); | ||
| + // Remove these lines - they're causing the UsageFault |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they are causing a usage fault, are we overflowing the stack? The stack guard is a useful feature for us, we should keep it enabled if possible.
| -#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) | ||
| - TZ_SAU_Setup(); | ||
| + /* Enable fault handlers */ | ||
| + SCB->SHCSR |= (SCB_SHCSR_MEMFAULTENA_Msk | SCB_SHCSR_BUSFAULTENA_Msk | | ||
| + SCB_SHCSR_USGFAULTENA_Msk); | ||
| + | ||
| +#ifdef __ARM_FEATURE_CMSE | ||
| + SCB->SHCSR |= SCB_SHCSR_SECUREFAULTENA_Msk; /* Enable SecureFault handler (TrustZone) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this change made?
- Add comprehensive bare-metal testing platform for Cortex-M33 on MPS2-AN521 - Include platform-specific linker script (m33-an521.ld) for memory layout - Add startup code (startup.c) for ARM Cortex-M33 initialization - Implement functional test suite (comprehensive_func_test.c) for all ML-DSA parameter sets - Implement performance benchmark suite (bench_baseline.c) with cycle counting - Add Python execution wrapper (exec_wrapper.py) for QEMU integration - Include platform makefile (platform.mk) for cross-compilation configuration - Add comprehensive documentation (CROSS-BUILDING-AND-TESTING.md) with setup and troubleshooting - Support testing all three security levels (ML-DSA-44, ML-DSA-65, ML-DSA-87) - Enable automated testing via QEMU with semihosting support Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
- Add ARM Cortex-M33 device headers and CMSIS core definitions for MPS3 AN524 - Add linker script and platform configuration for m33-an524 target - Add startup code and system initialization for ARMCM33 processor - Add semihosting support for I/O operations on bare-metal environment - Add ARM MPU (Memory Protection Unit) headers for M-profile architecture - Add comprehensive functional test suite for m33-an524 platform - Add baseline benchmarking application for performance measurement - Add cross-compilation and testing documentation with execution wrapper - Extends bare-metal testing infrastructure to support additional ARM platform Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
- Remove m33-an521 platform directory and all associated files - Migrate m33-an521 test infrastructure into m33-an524 platform - Add cmdline.c and libfns.c utility modules to m33-an524 - Add m-profile architecture headers (armv7m_cachel1.h, armv8m_pmu.h) - Add mps3-an524.mk platform configuration file - Add uart.c and uart.h for serial communication support - Update exec_wrapper.py and platform.mk for consolidated platform - Refactor startup_ARMCM33.c and system_ARMCM33.c for improved compatibility - Update semihosting.c with enhanced functionality - Consolidates bare-metal testing infrastructure to reduce duplication - remove custom tests and made the code compatible with the general tests Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
- Move platform files from test/baremetal/platform/m33-an524/ to envs/m33-an524/ - Reorganize into standard structure: config/, src/platform/, and documentation - Create comprehensive README.md documenting platform features and usage - Update test/baremetal/platform/m33-an524/platform.mk to reference new locations - Establish reusable platform environment for multi-project deployment Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
- Create new Nix derivation for m33-an524-arm-none-eabi platform - Export m33-an524 package in util.nix for use in development shells - Add m33-an524 to flake.nix packages and arm-embedded devShell - Update platform.mk to use M33_AN524_PATH environment variable from Nix - Add validation check to ensure M33_AN524_PATH is set during builds - Enables seamless cross-compilation for Cortex-M33 (AN524) in Nix environment Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
- Add M33-AN524 platform to GitHub Actions baremetal test matrix - Use arm-embedded nix-shell environment for builds - Enables CI testing for M33-AN524 platform alongside existing M55-AN547 Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
…ents Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
- Fix indentation in core_cm33.h preprocessor comment (align continuation) - Reorder includes in uart.c to follow conventional ordering (local headers first) - Ensure consistent code style across platform files Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
- Move CMSIS header and source files from `src/platform/` to `src/platform/CMSIS/` - Consolidate all ARM CMSIS Core, Device, and m-profile headers in single directory - Update README.md with comprehensive documentation of all 18 platform file modifications - Document exact changes made to ARM CMSIS_5 and pqmx files with patch file references - Add detailed attribution and license information for all adapted files - Update build configuration and Nix flake to reference new CMSIS directory structure - Improve platform maintainability by organizing files by source origin Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
- Move CMSIS header and source files from src/platform/CMSIS to patches/cmsis5 - Convert static CMSIS files into patch files for reproducible builds - Remove embedded platform utilities (cmdline.c, libfns.c, semihosting.c, uart.*) - Reorganize Nix derivations to separate CMSIS and toolchain concerns - Update flake.nix and util.nix to support new patch-based CMSIS integration - Simplify platform maintenance by using patches instead of vendored sources Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
- Replace curly quote characters with straight quotes in m33-an524.ld.patch - Add newline at end of startup_ARMCM33.patch file - Ensure consistent text encoding and formatting across patch files Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
- Add SPDX-License-Identifier headers to all CMSIS patch files - Ensures proper license attribution for third-party ARM code Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
…tion - Remove redundant individual CMSIS header patches (cmsis_compiler.h, cmsis_gcc.h, cmsis_version.h, m-profile headers) - Simplify README.md to focus on essential platform information and build instructions Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
- Reduce Nix expression complexity and improve resilience to upstream URL changes Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
…onfiguration Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
… patch Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
Use secure memory regions (Flash 0x10000000, RAM 0x70000000) and increase stack to 256KB to accommodate ML-DSA-87 Sign (126KB peak). Update startup with AN524 interrupt vectors and restore stack checking. Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
- Move m33-an524 patches and config from envs/m33-an524 to test/baremetal/platform/m33-an524 - Update Nix derivations to reference new patch locations in test directory - Consolidate platform configuration under test/baremetal/platform for better organization - Update platform.mk to use PROJECT_PLATFORM_PATH for local builds Signed-off-by: Jefferson Ricardini <jeffricardini@gmail.com>
hanno-becker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rebase (no merge commits) and cleanup the history as well, @jricardini ?