[{"element_type":"text","content":"\n  \n  \n        \u003cp\u003eThis is a crash course on how to get the Adafruit Feather RP2350 HSTX board up and running with Rust. We are going to use this GitHub repo below as a base to kick start our learning. But we will take pit stops at the interesting parts so you are not entirely lost at sea.\u003c/p\u003e\n\u003cp style=\"text-align: center;\"\u003e\u003ccode\u003egit clone \u003ca href=\"https://github.com/Dygear/rp2350-hstx.git\"\u003ehttps://github.com/Dygear/rp2350-hstx.git\u003c/a\u003e\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eOnce we have this cloned, we are good to go so long as we have the Adafruit Feather RP2350 board, and the Debug Probe already available and the software below installed.\u003c/p\u003e\n      \n\n","metadata":{}},{"element_type":"product","content":"https://www.adafruit.com/product/6000","metadata":{}},{"element_type":"image_url","content":"https://cdn-learn.adafruit.com/assets/assets/000/132/266/large1024/adafruit_products_debug.jpg?1726082648","metadata":{"alt":"Debug","caption":""}},{"element_type":"text","content":"\n  \n        \u003cp\u003eLet's start with the\u0026nbsp;\u003ca title=\"Debug Header\" href=\"https://learn.adafruit.com/adafruit-feather-rp2350/pinouts#debug-port-3182499\" target=\"_blank\"\u003eDebug Header\u003c/a\u003e, the little 3 pin interface lets you peek into the \u003ca title=\"Pons\" href=\"https://en.wikipedia.org/wiki/Pons\" target=\"_blank\"\u003ePons\u003c/a\u003e of the Raspberry Pi brain. You can find this header on the Raspberry Pi 5, the Raspberry Pi Pico (H, and WH), and now happily the Adafruit RP23XX boards thus far. By connecting a Pico Probe to this interface, you can get a lot of debug information back on your big main computer. ARM refers to this type of interfacing / debugging as \u003ca title=\"Semihosting\" href=\"https://developer.arm.com/documentation/dui0471/i/semihosting/what-is-semihosting-\" target=\"_blank\"\u003eSemihosting\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eWith the 3-Pin JST cable, cable plugged into the \u003cstrong\u003eD\u003c/strong\u003e header on the Pico Probe and the other end of that cable onto the Debug Header on your Feather (Shown above); With the Pico Probe connected to your computer, and you can connect the Feather to any USB power source, or back to your computer as well. Once you've done that, you're ready to issue the \u003ccode\u003ecargo run\u003c/code\u003e command, so long as you have the required software installed below.\u003c/p\u003e\n      \n","metadata":{}},{"element_type":"product","content":"https://www.adafruit.com/product/5699","metadata":{}},{"element_type":"alert","content":"\u003cp\u003eWe are going to install the latest and greatest version of Rust on your computer. The MSRV (Minimum Supported Rust Version) of the following code is 1.75.0. Everything you are about to see is stable Rust so long as we are using Rust 1.75.0 or better.\u003c/p\u003e","metadata":{"class":"element alert-element build-alert alert-info","markdown":"We are going to install the latest and greatest version of Rust on your computer. The MSRV (Minimum Supported Rust Version) of the following code is 1.75.0. Everything you are about to see is stable Rust so long as we are using Rust 1.75.0 or better.","alert_type":"info"}},{"element_type":"alert","content":"\u003cp\u003eDon't blindly past commands from the internet into your terminal. I trust rustup.rs and probe.rs, but maybe you shouldn't. Read what it's downloading and piping into your computer's terminal before you execute it. rustup.rs is a Rust Foundation supported way of installing Rust on your computer. But still, verify before you trust something blindly.\u003c/p\u003e","metadata":{"class":"element alert-element build-alert alert-warning","markdown":"Don't blindly past commands from the internet into your terminal. I trust rustup.rs and probe.rs, but maybe you shouldn't. Read what it's downloading and piping into your computer's terminal before you execute it. rustup.rs is a Rust Foundation supported way of installing Rust on your computer. But still, verify before you trust something blindly.","alert_type":"warning"}},{"element_type":"text","content":"\n        \u003cp\u003eThere are some items of software you'll need. Obviously the Rust programming language compiler would be a good thing to have on your system. We need a minimum version of 1.75.0 in order for the cloned repo linked above to work. This is because 1.75 landed some features we use in embedded Rust on the stable branch. To install Rust please go to \u003ca href=\"https://rustup.rs\" target=\"_blank\"\u003erustup.rs\u003c/a\u003e, it is the official way of installing Rust and is supported by the Rust Foundation.\u003c/p\u003e\n\u003cp\u003eOnce that is installed and ready, we also need one extra bit of software inside of Rust so that we can compile for the RP2350's chip architecture. We can issue the command \u003ccode\u003erustup target add thumbv8m.main-none-eabihf\u003c/code\u003e that will take care of cross compiling on our system for the RP2350 chip.\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"https://probe.rs\"\u003eProbe-rs\u003c/a\u003e is a very cool project. It's an embedded toolkit that allows you to talk to a wide range of chips using commodity hardware such as the Debug Probe. They landed support for the RP2350 chip that has a much more complicated debug interface than the RP2040's. Kudos to that team for making such an impressive bit of software. We need to install this on our hosting computer by going to their website\u0026nbsp;\u003ca href=\"https://probe.rs\"\u003eprobe.rs\u003c/a\u003e and copying the command it has listed for your operating system. (The caveat of not blindly pasting code into your terminal still applies. Make sure it's going to do what you expect it to do before you let it do it.)\u003c/p\u003e\n      ","metadata":{}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n        \u003cp\u003eBack to the code we cloned all of the way at the top of this article. With all of the software above installed, and your computer connected to the debug probe, the probe connected to the feather, and the feather connected to power or your computer you now have a system that is ready to go. We really can run that \u003ccode\u003ecargo run\u003c/code\u003e command and have Rust code on our feather. But what are all of these files and what do they do?\u003c/p\u003e\n\u003ch1\u003e\n\u003ccode\u003e.cargo/config.toml\u003c/code\u003e and \u003ccode\u003ecargo run\u003c/code\u003e\n\u003c/h1\u003e\n\u003cp\u003e\u003ca id=\"user-content-cargoconfigtoml-and-cargo-run\" class=\"anchor\" href=\"https://github.com/Dygear/rp2350-hstx#cargoconfigtoml-and-cargo-run\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003eThe \u003ccode\u003e.cargo/config.toml\u003c/code\u003e file configures \u003ccode\u003ecargo run\u003c/code\u003e to use \u003ca href=\"https://probe.rs/\"\u003e\u003ccode\u003eprobe-rs\u003c/code\u003e\u003c/a\u003e to flash to the boards ROM. You will need a \u003ca href=\"https://www.raspberrypi.com/products/debug-probe/\"\u003eRaspberry Pi Debug Probe\u003c/a\u003e in order to use this, but it makes development MUCH easier, faster, and more fun! You connect the Debug Probe's \u003ccode\u003eD\u003c/code\u003e (for debug, \u003ccode\u003eD\u003c/code\u003e for \u003ccode\u003edefmt\u003c/code\u003e 😉) side to the board's \u003ca href=\"https://learn.adafruit.com/adafruit-feather-rp2350/pinouts#debug-port-3182499\"\u003eDebug Port\u003c/a\u003e. Once done connect the Adafruit board, and Debug Probe to your computer. You can flash at will with \u003ccode\u003ecargo run\u003c/code\u003e and see any debug messages in your computer's terminal thanks to \u003ca href=\"https://defmt.ferrous-systems.com/\"\u003e\u003ccode\u003edefmt\u003c/code\u003e\u003c/a\u003e.\u003c/p\u003e\n\u003ch1\u003e\u003ccode\u003ememory.x\u003c/code\u003e\u003c/h1\u003e\n\u003cp\u003e\u003ca id=\"user-content-memoryx\" class=\"anchor\" href=\"https://github.com/Dygear/rp2350-hstx#memoryx\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003eIf you've never seen a \u003ccode\u003ememory.x\u003c/code\u003e file before, and have no clue what it is; I don't blame you for being curious. It's an odd file, filled with things that aren't Rust or C, or anything else that fits the norm. This file actually tells the linker where to put sections of the binary. It makes sure everything is in order so that when the microcontroller jumps to flash memory, the expected data is there ready for it. It also tells the the linker how much RAM the target board or chip has.\u003c/p\u003e\n\u003ch1\u003e\u003ccode\u003ebuild.rs\u003c/code\u003e\u003c/h1\u003e\n\u003cp\u003e\u003ca id=\"user-content-buildrs\" class=\"anchor\" href=\"https://github.com/Dygear/rp2350-hstx#buildrs\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003eThis build script copies the \u003ccode\u003ememory.x\u003c/code\u003e file from the crate root into a directory where the linker can always find it at build time. For many projects this is optional, as the linker always searches the project root directory -- wherever \u003ccode\u003eCargo.toml\u003c/code\u003e is. However, if you are using a workspace or have a more complicated build setup, this build script becomes required. Additionally, by requesting that Cargo re-run the build script whenever \u003ccode\u003ememory.x\u003c/code\u003e is changed, updating \u003ccode\u003ememory.x\u003c/code\u003e ensures a rebuild of the application with the new memory settings.\u003c/p\u003e\n      \n\n\n\n\n\n\n","metadata":{}},{"element_type":"text","content":"\n  \n  \n  \n        \u003cp\u003eThat's it. The bear minimum of what you need to know in order to get your system setup to flash Rust to the Adafruit Feather RP2350 HSTX board. Poke around in the \u003ccode\u003esrc/main.rs\u003c/code\u003e file. You'll notice for one thing that we are using the GPIO numbers directly, not any of the CircuitPython names. So if you want to toggle the \u003ccode\u003eboard.LED\u003c/code\u003e as you did in CircuitPython, you actually want \u003ccode\u003eGPIO7\u003c/code\u003e to interact with\u0026nbsp;\u003ccode\u003ep.PIN_7\u003c/code\u003e in Rust / Embassy. This is defined on the pinout diagram in Yellow (2nd item from center if you are colorblind.). The \u003ccode\u003eboard.NEOPIXEL\u003c/code\u003e for example is actually on \u003ccode\u003eGPIO21\u003c/code\u003e, or for Rust / Embassy that's \u003ccode\u003ep.PIN_21\u003c/code\u003e.\u003c/p\u003e\n      \n\n\n","metadata":{}},{"element_type":"image_url","content":"https://cdn-learn.adafruit.com/assets/assets/000/133/656/original/adafruit_products_Artboard_1-100.jpg","metadata":{"alt":"Adafruit","caption":""}}]