Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sharpcoder/teensycore
A rust kernel for the Teensy 4.0
https://github.com/sharpcoder/teensycore
baremetal kernel rust teensy4
Last synced: 6 days ago
JSON representation
A rust kernel for the Teensy 4.0
- Host: GitHub
- URL: https://github.com/sharpcoder/teensycore
- Owner: SharpCoder
- License: mit
- Created: 2022-01-13T03:17:11.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-04T03:32:25.000Z (about 1 year ago)
- Last Synced: 2024-12-10T08:42:29.359Z (16 days ago)
- Topics: baremetal, kernel, rust, teensy4
- Language: Rust
- Homepage: https://crates.io/crates/teensycore
- Size: 224 KB
- Stars: 68
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Teensycore
Teensycore is a kernel written in rust for the [Teensy-4.0 microcontroller](https://www.pjrc.com/store/teensy40.html).
## Installation
To properly build teensycore and any subsequent project, you'll need the following:
```bash
# Install build tools
sudo apt-get install build-essential gcc-arm-none-eabi jq# Configure rust
rustup default nightly
rustup target add thumbv7em-none-eabihf
```## Usage
You must first configure your project as a library. Your Cargo.toml should look something like this:
```
[package]
name = "my_project"
version = "0.1.0"
edition = "2021"[lib]
crate-type = ["staticlib"]
path = "src/lib.rs"[dependencies]
teensycore = "^0.1.0"
```Teensycore exports a convenient macro that helps to configure the entrypoint of your application. It takes care of the default panic handler, initializing system clocks, setting up irq, enabling debug UART, and much more. In this way, you can just focus on what your project needs to get going. Replace your `src/lib.rs` with something like this:
```rust
#![feature(lang_items)]
#![crate_type = "staticlib"]
#![no_std]use teensycore::prelude::*;
teensycore::main!({
/* Application code here */
});
```You are now ready to start writing some baremetal rust!
## Building
In order for your project to build correctly, you'll need the following:
- Configure your project as a library
- Put your entrypoint code in src/lib.rs
- Download the build template [bash script](https://raw.githubusercontent.com/SharpCoder/teensycore/main/build-template.sh)
- Execute `build-template.sh` in lieu of `cargo build`.The build script will generate a `.hex` file and place it in a folder called `out`. This hex file is compatible with the teensy 4.0 and can be flashed with the teensy-loader utility.
**CAUTION**: Do not build this in release mode. It optimizes a lot of stuff away, and can cause problems.
## Example
Here is a very basic blinky example. To see more examples, check out the `/examples` folder.
```rust
#![feature(lang_items)]
#![crate_type = "staticlib"]
#![no_std]use teensycore::prelude::*;
main!({
pin_mode(13, Mode::Output);loop {
pin_out(13, Power::High);
wait_ns(1 * S_TO_NANO);
pin_out(13, Power::Low);
wait_ns(1 * S_TO_NANO);
}
});
```## Contributing
This project is a work-in-progress and will be undergoing significant development over the coming months and years as I make it suitable for my own needs. Contributions are welcome. Please open an issue if you'd like to discuss anything specific.
## License
[MIT](https://choosealicense.com/licenses/mit/)