An open API service indexing awesome lists of open source software.

https://github.com/bp7968h/embedded_microbit

Learning embedded rust using microbit
https://github.com/bp7968h/embedded_microbit

embedded microbit rust rust-embedded

Last synced: 11 months ago
JSON representation

Learning embedded rust using microbit

Awesome Lists containing this project

README

          

# Embedded Rust Discovery with micro:bit
This project follows the [Embedded Rust Discovery Book](https://docs.rust-embedded.org/discovery/microbit/index.html), focusing on learning and experimenting with Embedded Rust on the micro:bit platform, also added some of my own different experiments.

## Project Overview
The purpose of this repository is to document and track progress as I work through the Embedded Discovery book, using the Rust programming language to program a micro:bit device. The repository contains various examples, exercises, and personal explorations as I learn how to write embedded software using Rust.

## Branches Overview
This repository contains different branches, each corresponding to a specific chapter, example, or project code from the book or personal experiments. Each branch can be checked out and flashed onto the micro:bit.

- **`main`**: The default branch contains the starting template or most recent examples.
- **`led_roulette`**: This branch contains code that makes the LEDs on the micro:bit flash in a `roulette` pattern along the borders of the matrix.
- **`led_spiral`**: This branch contains code that lights the LEDs in a `spiral` fashion, starting from the outer border and moving towards the inner LEDs.
- **`uart`**: This branch contains code that makes microcontroller and pc to communicate using uart protocol. Below are the available binary:
- `uart-send`: Sends data from `micro-controller` to `pc`.
- `uart-receive`: Receives data from `pc` to `micro-controller` and prints to rtt console.
- `echo-server`: Two way communication, `micro-controller` acts as echo server, when data is send from pc via serial port, data is printed in rtt console, and echoed back to the `pc`.
Run the above binary using the below command:
```bash
# update the `bin-name` before running
cargo embed --bin --target thumbv7em-none-eabihf
```

## Getting Started
To get started with this project, ensure you have the following:

### Prerequisites

1. **Rust**: Make sure you have the Rust toolchain installed. Install Rust using [rustup](https://rustup.rs/), and add the target device.
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add thumbv7em-none-eabihf
```

2. **cargo-embed**: You will need cargo-embed for flashing the programs onto your micro. Install it via:
```bash
cargo install cargo-embed
```

3. **GDB and OpenOCD**: You may also need GDB and OpenOCD to debug and flash (load to microcontoller) your code.
4. **microbit**: Of course, you'll need a microbit board.

## How to Flash the Code?
Below command will build and flash your microbit with the current code for microbit v2:
```bash
cargo embed --features v2 --target thumbv7em-none-eabihf
```

## How to interact with serial device using keyboard?
We can use `minicom` to interact with the serial device using the keyboard. Below command tells `minicom` to open the serial device at `/dev/ttyACM0` and set its baud rate to 115200.
```bash
# might need a config file at `~/.minirc.dfl` with respective configurations
minicom -D /dev/ttyACM0 -b 115200
```

## Learning Resources
This project follows along with the Discovery Book for embedded Rust:

- [The Embedded Rust Discovery Book](https://docs.rust-embedded.org/discovery/microbit/index.html)
- [The Embedded Rust Book](https://docs.rust-embedded.org/book/intro/index.html)
- [The Rust Book](https://doc.rust-lang.org/book/)

## Acknowledgements
Thanks to the Rust Embedded Working Group for creating and maintaining the Rust Embedded Books.