imxrt-rs/imxrt-hal

Could you add some examples

RockySong opened this issue · 4 comments

I'm an engineer in NXP MCU system engineering team, I'm now learning Rust (in early stage) and I'd like to have a try and then later contribute.
I'm familiar with the i.MX RT devices and using Segger J-Link GDB server to debug it with GDB.
Could you just add some examples to let traditonal MCU users like me get started?
You can also contact me with rocky.song@nxp.com

Hi Rocky!

Most of the usage of the imxrt-hal and imxrt-ral crates are done through board packages, at the moment the teensy4-rs project has board and runtime specific crates for the teensy 4 and imxrt1060evk-bsp, located in this github org is another for the imxrt1060evk.

We have some examples that are part of the https://github.com/imxrt-rs/imxrt1060evk-bsp. Note that the https://github.com/imxrt-rs/imxrt-rt crate is not release yet, and may never be as it doesn't do enough to provide all the linker and reset handler work needed. imxrt1060evk-bsp expects that to be cloned next to it (../imxrt-rt). The examples are mostly working right now, the I2C and SPI devices need further testing. They require a segger jlink to run and only run from SRAM. It is definitely my intention to add more examples as time permits.

I've updated the instructions in the imxrt1060evk-bsp repo to help, let me know if you run into anything.

I'm excited to see interest from some folks at NXP!

Glad to get your response!At this moment though I still need to learn a lot to do real work, I can give some generic comments:

  1. For "provide all the linker and reset handler work needed", I am familiar with them and customization under C and asm language for ARMCC, IAR, and GCC, and I can help if I know how to connect my knowledge to Rust code.
  2. It is straightforward to configure the Segger JLink GDB server to initialize the SDRAM controller, just use "-jlinkscriptfile" option to run SDRAM init script (provided by NXP SDK, the file name is "evkmimxrt1060_sdram_init.jlinkscript").

For the linker script and reset handler customization the current goal is to allow a person to customize it in a build.rs, Cargo uses that to do custom build time work which you can code in Rust.

To solve the problem I'm working on creating a linker script and reset generator that an application creator may call in a build.rs file in their project, this work is ongoing https://github.com/imxrt-rs/imxrt-rt-gen. This will go alongside the boot configuration generator we have https://github.com/imxrt-rs/imxrt-boot-gen. With the two of those crates together hopefully any elf build and memory configuration should be possible, with perhaps the exception of the signed or signed and encrypted boot image support these chips have.

This is all based on feedback here, imxrt-rs/imxrt-rt#2

There's some links there which lead to some more useful information where the idea stems from originally, which is from @japaric

It's also somewhat of a loftier goal to avoid having to write a custom runtime crate altogether and instead let the rust embedded cortex-m-rt crate deal with it, since they are looking to solve the same sorts of problems, and could be done in a way more SoCs could benefit. Especially NXP ones with their Harvard architectures.

I did see the sdram init jlink script, I thought it was a very neat way of doing it! I'll certainly give it a try when I get there.

I'm going to close this for now as there are examples. If specific docs or examples are being looked for, let me know!