Skip to content

qemu/arm: Extend CI testing to include ArmV7-M hardfp targets. #17757

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

agatti
Copy link
Contributor

@agatti agatti commented Jul 24, 2025

Summary

As a followup to #17737, this PR introduces a QEMU Arm target that has a hardware floating point unit (MPS2_AN500), and then lets CI use it for selected operations.

MPS2_AN500 is a Cortex-M7 with a single- and double-precision floating point unit, but it is otherwise equivalent to the MPS2_AN385 target for MicroPython's needs.

To further validate that the FPU is used and initialised correctly, the machine exception handler for ArmV7-M targets was extended to dump the full set of debug registers. If the FPU is used incorrectly (as in, access to the appropriate machine coprocessor was not enabled beforehand) then the CFSR.NOCP bit should appear to be set in the exception handler dump.

In order to correctly test the hardfp natmods we need to have a validated hardfp interpreter, so we must have a full MPS2_AN500 build and test cycle as well. To reduce the impact on CI times I've split the original CI step into two discrete units, as in "ci_qemu_build_arm_thumb_softfp" and "ci_qemu_build_arm_thumb_hardfp", so they can run in parallel whenever possible.

Manual building and testing of the QEMU port isn't otherwise affected, the default Arm machine is still MPS2_AN385 and it will retain the same floating point configuration as before (MICROPY_FLOAT_IMPL_FLOAT).

Concidentally, I've made QEMU's Makefile a bit more flexible when it comes to floating point settings. I've replicated the setup from the stm32 port, so the same flag names apply here as well.

Testing

Besides manual testing, CI should (hopefully) run the relevant step without errors; tests passed on my branch.

Trade-offs and Alternatives

There will be a (hopefully) minor increase in CI build times. However, having two separate targets is necessary to catch issues with FPU opcodes being used in softfp contexts for example. Making the hardfp variant the default would still call for a softfp variant to be there anyway.

Things could still be improved though, as in ArmV6-M builds could be tested in an emulated Cortex-M0+ machine to make sure no ArmV7-M opcodes are used by GCC or by viper/native emitters.

agatti added 4 commits July 24, 2025 15:41
This commit lets board use a different floating point mode rather than
the usual soft-float that was the original default for all QEMU-based
boards.

The configuration options are the same available in the "stm32" port.
Boards can set "MICROPY_FLOAT_IMPL" to either "float", "double", or
"none" to indicate which floating point mode they want, and optionally
"SUPPORTS_HARDWARE_FP_SINGLE" or "SUPPORTS_HARDWARE_FP_DOUBLE" can be
set to 1 to further indicate the hardware capabilities of the hardware
floating point unit, if present.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit introduces a new target for the QEMU port called
"MPS2_AN500", an ARMv7-M machine with a Cortex-M7 CPU and
single-/double-precision floating point unit.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit extends the QEMU port's CPU error handler for the Arm target
by printing out in detail the ARMv7-M debug registers if the firmware is
compiled for such a target.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit lets CI extend the testing scope of the QEMU Arm target, by
letting it perform the usual battery of tests (interpreter and natmods)
also on hardfp targets.

The default board for Arm testing lacks hardware floating point support,
so natmods weren't tested in that specific configuration.  With the
introduction of the "MPS_AN500" QEMU target, now this is made possible
as said board emulates a Cortex-M7 machine with a single- and
double-precision floating point unit.

To reduce the impact on build times, the "ci_qemu_build_arm_thumb" CI
step was split in two: "ci_qemu_build_arm_thumb_softfp" and
"ci_qemu_build_arm_thumb_hardfp" - so hopefully those can run in
parallel whenever possible.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@agatti agatti force-pushed the natmod-test-arm-hardfp branch from e703b1e to cd829f2 Compare July 24, 2025 14:31
Copy link

codecov bot commented Jul 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.38%. Comparing base (096ff8b) to head (cd829f2).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17757   +/-   ##
=======================================
  Coverage   98.38%   98.38%           
=======================================
  Files         171      171           
  Lines       22239    22239           
=======================================
  Hits        21880    21880           
  Misses        359      359           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy