wg icon indicating copy to clipboard operation
wg copied to clipboard

Add targets upstream for new ARM Cortex chips

Open jamesmunns opened this issue 6 years ago • 23 comments

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

  • ARM Cortex-R Target(s) based on thumbv7em (Cortex-R4, R5, R7, R8)
  • ARM Cortex-M Target(s) based on thumbv8em (Cortex-M23 and Cortex-M33)
  • ARM Cortex-R Target(s) based on thumbv8em (Cortex-R52)

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).

jamesmunns avatar Apr 17 '18 19:04 jamesmunns

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):

  • thumbv7r-none-eabi (Cortex-R4, R5, R7, R8)
  • thumbv7r-none-eabihf (Cortex-R4F, R5F, R7F, R8F)
  • thumbv7rbe-none-eabihf (Cortex-R5F Big Endian)
  • thumbv8r-none-eabi (Cortex-R52)
  • thumbv8r-none-eabihf (Cortex-R52F)

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!

Lakier15 avatar May 03 '18 17:05 Lakier15

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 avatar May 14 '18 21:05 paoloteti

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

paoloteti avatar May 20 '18 09:05 paoloteti

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

jamesmunns avatar Jul 08 '18 09:07 jamesmunns

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

ithinuel avatar Jul 09 '18 17:07 ithinuel

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.

japaric avatar Aug 31 '18 14:08 japaric

@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).

paoloteti avatar Aug 31 '18 16:08 paoloteti

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

hannobraun avatar Oct 11 '18 13:10 hannobraun

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

evq avatar Oct 13 '18 15:10 evq

Nice! Thanks @evq!

jamesmunns avatar Oct 13 '18 16:10 jamesmunns

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

thejpster avatar Oct 28 '18 22:10 thejpster

@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.

evq avatar Oct 29 '18 21:10 evq

Awesome, thanks @evq !

thejpster avatar Oct 29 '18 22:10 thejpster

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

evq avatar Nov 04 '18 05:11 evq

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 !

hug-dev avatar Nov 16 '18 11:11 hug-dev

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.

codido avatar Mar 17 '19 16:03 codido

@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)

hug-dev avatar Mar 17 '19 21:03 hug-dev

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

codido avatar Mar 17 '19 21:03 codido

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

  • thumbv8m.base-none-eabi: Cortex-M23
  • thumbv8m.main-none-eabi: Cortex-M33
  • thumbv8m.main-none-eabihf: Cortex-M33 with FPU

hug-dev avatar Apr 04 '19 10:04 hug-dev

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

tarcieri avatar May 25 '19 14:05 tarcieri

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

thejpster avatar May 27 '19 18:05 thejpster

Any news for the armv8-r for the R52?

joelimgu avatar Jul 26 '23 11:07 joelimgu

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.

thejpster avatar Aug 01 '23 20:08 thejpster

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

adamgreig avatar Jun 11 '24 18:06 adamgreig