rust-raspberrypi-OS-tutorials/README.md

67 lines
2.4 KiB
Markdown
Raw Normal View History

2019-02-02 19:15:12 +00:00
# Bare-metal and Operating System development tutorials in Rust on the Raspberry Pi 3
2018-01-04 17:24:49 +00:00
2019-05-25 18:17:32 +00:00
## Notice
2019-09-20 13:11:22 +00:00
This is a work-in-progress rewrite started on September 2019. I will first add
code, and later write accompanying prose.
2019-05-25 18:17:32 +00:00
2019-10-21 20:20:30 +00:00
The rewrite also supports both, the Raspberry Pi 3 and the **Raspberry Pi 4**!
2019-05-25 18:17:32 +00:00
_Cheers,
Andre_
2018-10-21 18:16:27 +00:00
## Prerequisites
2018-01-04 17:24:49 +00:00
2018-03-31 18:12:42 +00:00
Before you can start, you'll need a suitable Rust toolchain.
2019-09-20 13:11:22 +00:00
Please browse to the [rustup components history] and note the date of the most recent
build that shows `clippy` as `present`.
[rustup components history]: https://rust-lang.github.io/rustup-components-history/
2019-09-10 16:31:42 +00:00
2019-09-20 13:11:22 +00:00
Then, proceed to install this nightly using your noted date:
2018-03-31 18:12:42 +00:00
```bash
2019-09-20 13:11:22 +00:00
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-YOUR_DATE_HERE
# For example:
# curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2019-09-05
2019-09-10 16:31:42 +00:00
2019-09-20 13:11:22 +00:00
rustup component add rust-src llvm-tools-preview clippy
cargo install cargo-xbuild cargo-binutils
2018-03-31 18:12:42 +00:00
```
Additionally, a Micro SD card with [firmware
files](https://github.com/raspberrypi/firmware/tree/master/boot) on a FAT
2019-09-10 16:31:42 +00:00
filesystem is needed.
2018-01-04 17:24:49 +00:00
I recommend to get a [Micro SD card USB
adapter](http://media.kingston.com/images/products/prodReader-FCR-MRG2-img.jpg)
(many manufacturers ship SD cards with such an adapter), so that you can connect
the card to any desktop computer just like an USB stick, no special card reader
interface required (although many laptops have those these days).
2018-01-04 17:24:49 +00:00
You can create an MBR partitioning scheme on the SD card with an LBA FAT32 (type
0x0C) partition, format it and copy `bootcode.bin`, `start.elf` and `fixup.dat`
2019-09-10 16:31:42 +00:00
onto it. **Delete all other files or booting might not work**. Alternatively,
you can download a raspbian image, `dd` it to the SD card, mount it and delete
the unnecessary .img files. Whichever you prefer. What's important, you'll
create `kernel8.img` with these tutorials which must be copied to the root
directory on the SD card, and no other `.img` files should exists there.
2018-01-04 17:24:49 +00:00
I'd also recommend to get an [USB serial debug
cable](https://www.adafruit.com/product/954). You connect it to the GPIO pins
14/15.
2018-01-04 17:24:49 +00:00
2018-03-31 18:19:22 +00:00
![UART wiring diagram](doc/wiring.png)
2018-03-31 18:12:42 +00:00
Then, run `screen` on your desktop computer like
2018-01-04 17:24:49 +00:00
2018-03-31 18:12:42 +00:00
```bash
sudo screen /dev/ttyUSB0 115200
2018-01-04 17:24:49 +00:00
```
2018-03-31 18:12:42 +00:00
Exit screen again by pressing <kbd>ctrl-a</kbd> <kbd>ctrl-d</kbd>
2018-01-04 17:24:49 +00:00
2018-10-21 18:16:27 +00:00
## License
Licensed under the MIT license ([LICENSE-MIT](LICENSE) or http://opensource.org/licenses/MIT).