rust/cpu: Set value for cortex-m33#22289
Conversation
|
I tested it with #22175 (the STM32U3 has an M33) and it works as you described. The
|
It would appear that we currently default to Hard Float for all M33: RIOT/makefiles/arch/cortexm.inc.mk Lines 64 to 73 in 48322fb |
|
Thanks for the quick test & review! |
|
It seems hard float is not enabled for the RP2350 in the SDK version we're using: raspberrypi/pico-sdk#2783 |
Well great, it'll be part of the Ping @AnnsAnns, the residential RP2350 expert 👀 |
|
OK, if it's conditional on cortexm_fpu, that's almost actionable … except that the features only become available later, so I'll somehow need to set "yeah we have a RUST_TARGET" in at Makefile .features time, and then decide which value at MAkeile .include time (?). |
|
there is no reference in the datasheet from a quick look, we might be able to simply pin to the commit that added hardfp support to be safe? |
|
I appreciate updating this, but as there is an example of M33 using no hardfp for some reason, I'm also using this to ensure that things work on both sides. (I'm running into other trouble with the picosdk after a fix, but that might be a case of blocking Rust builds on that platform until that is resolved / opening a different issue). |
I must admit that I have no clue 😅 The only thing I can say is that Rust works on the Pico 2 Hazard3 but I dont remember how that target looks |
|
I've pushed a proposed workaround for the "some don't use FPU". Even outside the RP2350 troubles, this can be tested by building either for nrf5340dk-app or xg23-pk6068a and adding For the RP, I'm looking for a way to just block the combination until I find out what's precisely going on (something about the |
|
Can we defer the rp issue to #22294? With the "full build" flag set, if this goes through, there should be no surprises next time we attempt merging. |
|
|
||
| include $(RIOTCPU)/rp2350_common/Makefile.features | ||
| include $(RIOTCPU)/cortexm_common/Makefile.features | ||
|
|
||
| # Explicitly *not* supported, see <https://github.com/RIOT-OS/RIOT/issues/22294> | ||
| FEATURES_PROVIDED := $(filter-out rust_target,$(FEATURES_PROVIDED)) |
There was a problem hiding this comment.
| include $(RIOTCPU)/rp2350_common/Makefile.features | |
| include $(RIOTCPU)/cortexm_common/Makefile.features | |
| # Explicitly *not* supported, see <https://github.com/RIOT-OS/RIOT/issues/22294> | |
| FEATURES_PROVIDED := $(filter-out rust_target,$(FEATURES_PROVIDED)) | |
| # Explicitly *not* supported, see <https://github.com/RIOT-OS/RIOT/issues/22294> | |
| FEATURES_BLACKLIST += rust_target | |
| include $(RIOTCPU)/rp2350_common/Makefile.features | |
| include $(RIOTCPU)/cortexm_common/Makefile.features |
Why not use the official mechanism for that?
| ifeq ($(CPU_CORE),cortex-m33) | ||
| # See Makefile.features where RUST_TARGET is set the first time -- but it is | ||
| # set to "to-be-set-later". See there for full explanation. | ||
| ifneq (,$(filter cortexm_fpu,$(USEMODULE))) | ||
| RUST_TARGET = thumbv8m.main-none-eabihf | ||
| else | ||
| RUST_TARGET = thumbv8m.main-none-eabi | ||
| endif | ||
| endif |
There was a problem hiding this comment.
| ifeq ($(CPU_CORE),cortex-m33) | |
| # See Makefile.features where RUST_TARGET is set the first time -- but it is | |
| # set to "to-be-set-later". See there for full explanation. | |
| ifneq (,$(filter cortexm_fpu,$(USEMODULE))) | |
| RUST_TARGET = thumbv8m.main-none-eabihf | |
| else | |
| RUST_TARGET = thumbv8m.main-none-eabi | |
| endif | |
| endif | |
| ifeq (to-be-set-later, $(RUST_TARGET)) | |
| # RUST_TARGET is set in `cpu/cortexm_common/Makefile.features` for most cores, | |
| # manually set it here for `to-be-set-later`. See there for a full | |
| # explanation. | |
| ifeq (cortex-m33, $(CPU_CORE)) | |
| ifneq (,$(filter cortexm_fpu, $(USEMODULE))) | |
| RUST_TARGET = thumbv8m.main-none-eabihf | |
| else | |
| RUST_TARGET = thumbv8m.main-none-eabi | |
| endif | |
| else | |
| $(error RUST_TARGET set to 'to-be-set-later' but never actually set!) | |
| endif | |
| endif |
IMO it's nicer to catch it in our buildsystem than getting a weird and wonderful error message from the Rust compiler that it does not know what to-be-set-later is supposed to be 🤔😅

Contribution description
Updating some Rust tests I needed something to test on, and the nRF5340dk was closed but … oh my, no Rust support?
That was because the target triple (RUST_TARGET = thumbv8m.main-none-eabihf) was not set. More precisely, it was commented out because I mad an assumption originally but had no hardware to test it.
Testing procedure
CONTINUE_ON_EXPECTED_ERRORS=1, with "Error: No RUST_TARGET was set for this platform."hfsuffix), the linker complains about inconsistent calling conventions ("uses VFP register arguments, [...] does not").Note that I didn't have a built-in usable programmer; nrf53 doesn't have openocd support, and JLink is proprietary. I flashed using probe-rs (cf. #21466 but I did it manually here).
Open questions
Do we have a non-hard-float variant of m33 too? If so, there'd need to be another if/else, but probably then also have a different CPU_CORE value, so I think we just only support M33 with HF (it's optional in the ISA, but are there even any M33 we support that don't have it?).
Declaration of AI-Tools / LLMs usage:
AI-Tools / LLMs that were used are: