# Rust on Alarmo!
This project provides a convenient API to bootstrap firmware and access peripherals on the Nintendo Alarmo, using Rust.
## Status
This started as a Rust port of GaryOderNichts's MIT-licensed [alarmo](https://github.com/GaryOderNichts/alarmo) repository, which uses the [official hardware abstraction layer](https://github.com/STMicroelectronics/STM32CubeH7). As a proof-of-concept, I first made a Rust loader that would just call GaryOderNicht's implementation, then I incrementally rewrote each part in the Rust module.
Consider this list of goals tentative:
- [x] It works!
- [x] LCD frontend using the `display_interface` crate
- [ ] Better build environment (automate `objcopy` and firmware signing)
- [ ] Button inputs
- [ ] Dial input
- [ ] Dial LED
- [ ] Allocator with extended RAM
As a general goal, I'd like to use Rust-native HALs (e.g. [stm32h7xx-hal](https://crates.io/crates/stm32h7xx-hal)) whenever possible. In its current state, the project still depends on the official HAL, for which it generates bindings using `bindgen`.
## Usage
### Running an example
1. Compile the example, for example `lcd`:
```
cargo build --example lcd
```
2. Convert the example ELF into BINF:
```
arm-none-eabi-objcopy target/thumbv7em-none-eabihf/debug/examples/lcd lcd.bin
```
3. Sign the firmware to get the `a.bin`.
### Creating a project
1. After you've created the Cargo project, copy the `link.ld` file and `.cargo/` directory from this repository to the root of your crate.
2. Add the library as a dependency:
```sh
cargo add alarmo -F display
cargo add alarmo
```
3. Build the project:
```
cargo build
```
4. Convert the result ELF into BINF (change `debug` to `release` for `--release`):
```
arm-none-eabi-objcopy target/thumbv7em-none-eabihf/debug/your_crate your_crate.bin
```
3. Sign the firmware to get the `a.bin`.
## License
The library and its examples are dual-licensed under both [Apache-2.0](LICENSE-APACHE) and [MIT](LICENSE-MIT). Please also refer to the [license documentation](https://github.com/STMicroelectronics/STM32CubeH7/blob/master/LICENSE.md) for the official HAL.
## Credits
* [GaryOderNichts](https://github.com/GaryOderNichts/), whose [project](https://github.com/GaryOderNichts/alarmo) this repository is derived from, and for their [blog post](https://garyodernichts.blogspot.com/2024/10/looking-into-nintendo-alarmo.html) exploring the Alarmo.
* [Spinda](https://spinda.net/) and [hexkyz](https://twitter.com/hexkyz) for their incredible work reverse-engineering the Alarmo!