From 19be404ad899701b655b2da78e57b34d7fb686be Mon Sep 17 00:00:00 2001 From: Alessandro Gatti Date: Thu, 24 Jul 2025 15:36:28 +0200 Subject: [PATCH] qemu/arm: Add definition for the MPS2_AN500 machine. 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 --- ports/qemu/README.md | 1 + ports/qemu/boards/MPS2_AN500/mpconfigboard.mk | 15 +++++++++++++++ ports/qemu/mcu/arm/startup.c | 6 ++++++ 3 files changed, 22 insertions(+) create mode 100644 ports/qemu/boards/MPS2_AN500/mpconfigboard.mk diff --git a/ports/qemu/README.md b/ports/qemu/README.md index aab88ab589..d8ef3ac551 100644 --- a/ports/qemu/README.md +++ b/ports/qemu/README.md @@ -59,6 +59,7 @@ Available boards are: | ----------------- | ------------ | ------------------------ | | `MICROBIT` | `arm` | `microbit` | | `MPS2_AN385` | `arm` | `mps2-an385` | +| `MPS2_AN500` | `arm` | `mps2-an500` | | `NETDUINO2` | `arm` | `netduino2` | | `SABRELITE` | `arm` | `sabrelite` | | `VIRT_RV32` | `riscv32` | `virt` | diff --git a/ports/qemu/boards/MPS2_AN500/mpconfigboard.mk b/ports/qemu/boards/MPS2_AN500/mpconfigboard.mk new file mode 100644 index 0000000000..b7b54a8056 --- /dev/null +++ b/ports/qemu/boards/MPS2_AN500/mpconfigboard.mk @@ -0,0 +1,15 @@ +QEMU_ARCH = arm +QEMU_MACHINE = mps2-an500 + +CFLAGS += -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 +CFLAGS += -DQEMU_SOC_MPS2 +CFLAGS += -DMICROPY_HW_MCU_NAME='"Cortex-M7"' + +LDSCRIPT = mcu/arm/mps2.ld + +SRC_BOARD_O = shared/runtime/gchelper_native.o shared/runtime/gchelper_thumb2.o + +MPY_CROSS_FLAGS += -march=armv7emdp + +MICROPY_FLOAT_IMPL = double +SUPPORTS_HARDWARE_FP_DOUBLE = 1 diff --git a/ports/qemu/mcu/arm/startup.c b/ports/qemu/mcu/arm/startup.c index a7e9efb9fb..56d246b143 100644 --- a/ports/qemu/mcu/arm/startup.c +++ b/ports/qemu/mcu/arm/startup.c @@ -47,6 +47,12 @@ __attribute__((naked)) void Reset_Handler(void) { for (uint32_t *dest = &_sbss; dest < &_ebss;) { *dest++ = 0; } + #if MICROPY_HW_FPU && defined(__ARM_ARCH_ISA_THUMB) && __ARM_ARCH == 7 + // initialise the FPU (full access to CP10 and CP11, as per B3.2.20) + *((volatile uint32_t *)0xE000ED88) |= 0x00F00000; + __asm volatile ("dsb"); + __asm volatile ("isb"); + #endif // jump to board initialisation void _start(void); _start();