rust-embedded / wg

Coordination repository of the embedded devices Working Group
1.92k stars 97 forks source link

Add targets upstream for new ARM Cortex chips #88

Closed jamesmunns closed 4 months ago

jamesmunns commented 6 years ago

We should consider adding target JSONs and build rust-std compenents for the following targets before the 2018 era lands:

This may also require updates to low level crates like cortex-m, maybe compiler_builtins, though we should probably open separate issues for that.

We likely will need physical chips to verify functionality before adding them upstream, which may be difficult for chips based on thumbv8em, as they are not currently retailing at the moment (as far as I know, the Nordic nRF91 is the only one shipping, and it is only in a limited sample release).

Lakier15 commented 6 years ago

I have been working on a R5F for an year and a half with Rust without any problem.

I want to start working on other targets of the Cortex-R family so that I can PR and add official support for them.

thumbv7em, thumbv8em are not the only targets we would need pursuing. Remember that the ARMv7 instruction set differs a lot between their subset ( ARMv7-A, ARMv7-R, ARMv7E-M, ARMv7-M );

In order to support what is now commercially available we would need (for what regards the Cortex-R architecture):

I have been working with the TMS570LC4357, which is probably the most unique R5F processor in the market, as it is the only one that has a R5F architecture and is big endian.

Cortex-R chips on the market

Cortex-R4

Texas Instruments: RM41Lx, RM42Lx, TMS570LS02x, TMS570LS03x, TMS570LS04x Samsung: Artik 05x

Cortex-R4F

Texas Instruments: RM44Lx, RM46Lx, RM48Lx, TMS570LS07x, TMS570LS09x, TMS570LS11x, TMS570LS12x, TMS570LS21x, TMS570LS31x

Cortex-R5

Cypress: S6J31x

Cortex-R5F

Cypress: S6J32x, S6J33x, S6J34x, S6J35x

Cortex-R5F Big Endian

Texas Instruments: TMS570LC4357x, RM57Lx


I personally don't know about the R7(F), R8(F), R52(F). Maybe if anybody knows any better they can add to them to this list.

I have a R5F Big Endian (TMS570LC4357) and an R4 (Artik055s), so I could work to add support for those.

A word about the TMS570LC4357: Because this is the only Big Endian processor I found pretty impossible to have a GCC prebuild toolchain to use as a linker. My "hack" in this case is to compile everything as a library and link it in with the TI ARM CGT toolchain in order to produce a binary. This means that I cannot have a "pure" rust binary source code. If the LLD linker can this job instead, that would be the perfect solution!

paoloteti commented 6 years ago

Here https://github.com/paoloteti/ti-hercules-bsp you can find a board support package + JSON for TI TMS570LS3xx (tested on TMS570LS3137) that is a BigEndian Cortex-R4F (in LockStep mode).

Linaro toolchain (armeb-none-eabi) it is perfect and you don't need to use TI ARM CGT.

I already sent patches on compiler_builtins to add some missing features (mainly on VFP) , so it works as it is now!

Only the F021 flash memory need the TI F021 SDK because the algorithm is proprietary and the overall logic it is totally different form other flash memories. Mainly to ensure a set of safety constraints at silicon level. Here you can find a Rust binding.

I don't have time at the moment to add/integrate my work on upstream, but I can test on real hardware on my spare time.

BTW do not compare Cortex-R with Cortex-M: it is a different beast.

paoloteti commented 6 years ago

Cortex R4F/R5F (BE, ARM mode) is now upstream (PR 50813)

jamesmunns commented 6 years ago

It seems like some of the thumbv8em chips are now shipping.

ithinuel commented 6 years ago

I don't know if these devices are already available but I also heard about :

Nuvoton M2351

https://www.cnx-software.com/2017/03/21/numicro-m2351-trustzone-enabled-arm-cortex-m23-mcu-is-designed-for-fingerprint-applications/ http://armdevices.net/2017/03/20/worlds-first-arm-cortex-m23-in-nuvoton-m2351/ https://github.com/ARMmbed/mbed-os/pull/7302

Arm Musca A1

https://developer.arm.com/products/system-design/development-boards/iot-test-chips-and-boards/musca-a-test-chip-board https://github.com/zephyrproject-rtos/zephyr/pull/7645

japaric commented 6 years ago

I was looking at the LLVM features for the ARMv8-M architecture and there are two ATM: v8m for baseline ARMv8-M (i.e. Cortex-M23) and v8m.main for mainline ARMv8-M (i.e. Cortex-M33). What I'm not sure about is how to call these new targets: thumbv8m-none-eabi for the M23, but then what would the M33 be called? thumbv8m.main-none-eabi? Furthermore the M33 has an optional FPU so we'll want two targets for that one: eabi and eabihf.

paoloteti commented 6 years ago

@japaric

What I'm not sure about is how to call these new targets: thumbv8m-none-eabi for the M23, but then what would the M33 be called? thumbv8m.main-none-eabi? Furthermore the M33 has an optional FPU so we'll want two targets for that one: eabi and eabihf.

Exactly, infact llc accept both thumbv8m.main-none-eabi and thumbv8m.base-none-eabi and with eabihf sets the VFP attribute (as minimum). (something like .eabi_attribute 28, 1 @ Tag_ABI_VFP_args).

hannobraun commented 6 years ago

NXP has a Cortex-M33 MCU in pre-production now: https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/lpc-cortex-m-mcus/lpc5500-series/high-efficiency-arm-cortex-m33-based-microcontroller-family:LPC55S6x

evq commented 6 years ago

I opened a PR to add a target for baseline armv8-m https://github.com/rust-lang/rust/pull/55041

jamesmunns commented 6 years ago

Nice! Thanks @evq!

thejpster commented 5 years ago

@evq is there any chance you might be able to share the test code you have for the SAM L11?

evq commented 5 years ago

@thejpster sure, I will upload later today. I have an svd2rust crate with LED example code for the SAM L11 as well as needed changes to the cortex-m, cortex-m-rt, cortex-m-semihosting, and panic-semihosting crates.

thejpster commented 5 years ago

Awesome, thanks @evq !

evq commented 5 years ago

@thejpster You can find the svd2rust crate with example code here - https://github.com/evq/atsaml11xxx

hug-dev commented 5 years ago

Armv8-M is trendy! I have been working with Rust and Armv8-M at Arm for the past few months and just made a pull-request for Mainline support rust-lang/rust#56000 !

codido commented 5 years ago

FWIW, the LPC55S69-EVK development board from NXP which has two Cortex-M33 cores is now shipping as well.

Things appear to work well including basic peripheral functionality, and only required a few mild modifications to the svd file. The only minor gotcha was that cortex-m-rt includes the thumbv8m.base-none-eabi prebuilt library, but not thumbv8m.main-none-eabi.

By the way, it seems that out of the three thumbv8m targets, only thumbv8m.main-none-eabi is included in the manifests (and can be installed with rustup). Wasn't sure if that's intentional.

hug-dev commented 5 years ago

@codido I think thumbv8m.main is currently being added to cortex-m-rt at rust-embedded/cortex-m-rt#167 and rust-embedded/cortex-m-rt#182

thumbv8m.mainhf and thumbv8m.base are currently being added to Rust CI (for rustup to pull) here: rust-lang/rust#59182 (as soon as I have more time)

codido commented 5 years ago

Thanks @hug-dev, missed those cortex-m-rt PRs, guess I don't need to push my version :)

hug-dev commented 5 years ago

All the Armv8-M targets are now available with rustup in the latest nightly:

tarcieri commented 5 years ago

Will thumbv8m.base-none-eabi land on stable soon? I was able to use it on nightly.

thejpster commented 5 years ago

I assume it's riding the release train, and will turn up in two stable releases time?

joelimgu commented 1 year ago

Any news for the armv8-r for the R52?

thejpster commented 1 year ago

It won't happen until someone both needs it and has the ability to do it and has the time or the funding to do it and has the appropriate hardware or simulator to run it on, sadly. Cortex-R is a bit specialist compared to Cortex-M.

adamgreig commented 4 months ago

I believe these targets are all available now, including armv8r-none-eabihf.