Commit 043c404
authored
Cortex-M backend: enable Cortex-M0+ builds against Corstone-300 (#19731)
### Summary
Extend the Cortex-M cross-CPU build pipeline to Armv6-M by patching two
upstream issues that block the Corstone-300 target source and the CMSIS
Cortex DFP from building for `cortex-m0plus`:
* `core_platform/0003-*.patch` guards the `HardFault_Handler` in
`targets/corstone-300/target.cpp`. The handler uses an `ite eq` IT-block
in inline asm and dereferences the SCB CFSR/BFAR/MMFAR fault-status
registers; both are Armv7-M / Armv8-M Mainline only. The patch wraps the
rich handler in `__ARM_ARCH_7M__ / 7EM / 8M_MAIN / 8_1M_MAIN` and falls
back to a minimal stub on Armv6-M / Armv8-M Baseline (M0/M0+/M23).
* `core_software/0002-*.patch` fixes `cmsis.cmake`'s handling of the M0+
device. The Cortex DFP names the device directory and headers
`ARMCM0plus` (lowercase suffix), while the device sources
(`startup_ARMCM0plus.c`, `system_ARMCM0plus.c`) gate their
implementations on the `ARMCM0P` preprocessor macro — three different
spellings. The previous `string(TOUPPER ...)` produced `ARMCM0PLUS`: the
include path lookup failed and the source files hit their `#error device
not specified!` guard. Override `ARM_CPU` to `ARMCM0plus` for the
directory + filename and introduce a separate `CMSIS_DEVICE_CPU_DEFINE`
set to `ARMCM0P` for the cmsis_startup and cmsis_system
compile-definitions; all other cores still drive both paths from the
uppercased default.
Both patches are layered via the existing `patch_repo` mechanism; the
`corstone_utils.cmake` TODO is updated so the deletion plan for 0002 and
0003 is documented together.
### Test Plan
Locally validated end-to-end on the Corstone-300 FVP with the `qadd`
model: `cortex-m0plus` build links a runner that includes
`startup_ARMCM0plus.c` / `system_ARMCM0plus.c` and the patched
`target.cpp`, and the FVP run prints
`TEST: BundleIO index[0] Test_result: PASS` with all error stats zero.
The bundled `libcmsis-nn.a` reports `Tag_CPU_arch: v6S-M` and
`Tag_THUMB_ISA_use: Thumb-1` with zero DSP / MVE / saturating
instructions, confirming the scalar code path was exercised.
Authored with Claude.
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils
@Sebastian-Larsson @robell1 parent 6128a45 commit 043c404
3 files changed
Lines changed: 132 additions & 5 deletions
File tree
- backends/arm/scripts
- examples/arm/ethos-u-setup
- core_platform
- core_software
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
Lines changed: 77 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
0 commit comments