Skip to content

Commit 4d251b9

Browse files
committed
Adapt READMEs
1 parent b3c9e04 commit 4d251b9

File tree

2 files changed

+51
-26
lines changed

2 files changed

+51
-26
lines changed

05_uart0/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This tutorial does the same as tutorial 04, but it prints the serial number on U
55
easily with qemu, like
66

77
```sh
8+
$ make # To build the kernel
89
$ make qemu
910
<Press any key>
1011
Hello Rustacean!

README.md

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
1-
Bare Metal Programming on Raspberry Pi 3
1+
Bare Metal Rust Programming on Raspberry Pi 3
22
========================================
33

4-
Hello there! This tutorial series are made for those who would like to compile their own bare metal application
4+
## About this repository
5+
6+
Hi all. This repository aims to provide easy reference code for programming bare metal on the Raspberry Pi 3
7+
in the [Rust] systems programming language.
8+
The repo is basically a combination of two awesome resources that are available on the web.
9+
1. First of all, it is a fork of [Zoltan Baldaszti]'s awesome [tutorial] on bare metal programming on RPi3 in C. Rust code is and will be translated based on his files, and READMEs are adapted were needed. Credits to this guy plz!
10+
2. The second props go to [Jorge Aparicio] for ["The Embedonomicon"], from which the glue code is taken.
11+
12+
[Rust]: https://www.rust-lang.org
13+
[Zoltan Baldaszti]: https://github.com/bztsrc
14+
[tutorial]: https://github.com/bztsrc/raspi3-tutorial
15+
[Jorge Aparicio]: https://github.com/japaric
16+
["The Embedonomicon"]: https://github.com/japaric/embedonomicon
17+
18+
This repo follows two main principles:
19+
1. Most importantly: No toolchain hassles. Users eager to try the code should not be bothered with complicated toolchain installation/compilation steps. This is achieved by trying to use the standard Rust toolchain as much as possible, and where not possible, using Docker containers. Please [install Docker for your distro].
20+
1. Compiler and linker can be used from Rust nightly.
21+
2. QEMU will be used for emulation, but RPi3 support in QEMU is very fresh and has not landed in most of the pre-packaged versions of popular distributions. [This] container will provide it ready to go.
22+
3. aarch64 toolchain binaries that are not provided Rust, like `objcopy`, will be provided with a container from the [dockcross] project, which does an awesome job of curating various toolchains in containers.
23+
2. Use as little assembler as possible. Do as much as possible in Rust.
24+
25+
Please notice that you won't need to download or prepare the containers upfront. As long as you have docker installed, they will be pulled automatically the first time the Makefile needs them.
26+
27+
[install Docker for your distro]: https://www.docker.com/community-edition#/download
28+
[This]: https://github.com/andre-richter/docker-raspi3-qemu
29+
[dockcross]: https://github.com/dockcross/dockcross
30+
31+
For now, only tutorial `05_uart0` is ready. It has been done first in order to provide a classic physical `Hello World` over a real UART. It is planned to add more examples later. Contributions welcome!
32+
33+
## Introduction
34+
35+
This tutorial series are made for those who would like to compile their own bare metal application
536
for the Raspberry Pi.
637

738
The target audience is hobby OS developers, who are new to this hardware. I'll give you examples on how to do the
@@ -37,46 +68,39 @@ For 32 bit tutorials, I'd recommend:
3768
Prerequisites
3869
-------------
3970

40-
Before you can start, you'll need a cross-compiler (see 00_crosscompiler directory for details)
41-
and a Micro SD card with [firmware files](https://github.com/raspberrypi/firmware/tree/master/boot) on a FAT filesystem.
71+
Before you can start, you'll need a suitable Rust toolchain.
72+
```bash
73+
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly
74+
rustup component add rust-src
75+
cargo install xargo
76+
```
77+
78+
Additionally, a Micro SD card with [firmware files](https://github.com/raspberrypi/firmware/tree/master/boot) on a FAT filesystem.
4279

4380
I recommend to get a [Micro SD card USB adapter](http://media.kingston.com/images/products/prodReader-FCR-MRG2-img.jpg)
4481
(many manufacturers ship SD cards with such an adapter), so that you can connect the card to any desktop computer just
4582
like an USB stick, no special card reader interface required (although many laptops have those these days).
4683

4784
You can create an MBR partitioning scheme on the SD card with an LBA FAT32 (type 0x0C) partition, format it
48-
and copy *bootcode.bin*, *start.elf* and *fixup.dat* onto it. Or alternatively you can download a raspbian image,
85+
and copy `bootcode.bin`, `start.elf` and `fixup.dat` onto it. **Delete all other files or booting might not work**. Or alternatively you can download a raspbian image,
4986
`dd` it to the SD card, mount it and delete the unnecessary .img files. Whichever you prefer. What's important, you'll
5087
create `kernel8.img` with these tutorials which must be copied to the root directory on the SD card, and no other `.img`
5188
files should exists there.
5289

5390
I'd also recommend to get an [USB serial debug cable](https://www.adafruit.com/product/954). You connect it to the
54-
GPIO pins 14/15, and run minicom on your desktop computer like
91+
GPIO pins 14/15.
5592

56-
```sh
57-
minicom -b 115200 -D /dev/ttyUSB0
58-
```
59-
60-
Emulation
61-
---------
62-
63-
Unfortunately official qemu binary does not support Raspberry Pi 3 yet. But good news, I've implemented that, so
64-
it's coming soon. Until then, you have to compile qemu from the latest source. Once compiled, you can use it with:
93+
Then, run `screen` on your desktop computer like
6594

66-
```sh
67-
qemu-system-aarch64 -M raspi3 -kernel kernel8.img -serial stdio
95+
```bash
96+
sudo screen /dev/ttyUSB0 115200
6897
```
6998

70-
Or (with the file system tutorials)
99+
Exit screen again by pressing <kbd>ctrl-a</kbd> <kbd>ctrl-d</kbd>
71100

72-
```sh
73-
qemu-system-aarch64 -M raspi3 -drive file=$(yourimagefile),if=sd,format=raw -serial stdio
74-
```
75-
76-
The first argument tells qemu to emulate Raspberry Pi 3 hardware. The second tells the kernel filename (or in second
77-
case the SD card image) to be used. Finally the last argument redirects the emulated UART0 to the standard input/output
78-
of the terminal running qemu, so that everything sent to the serial line will be displayed, and every key typed in the
79-
terminal will be received by the vm. Only works with the tutorials 05 and above, as UART1 is *not* redirected by default.
101+
Emulation
102+
---------
103+
QEMU currently only emulates UART0, so only the tutorials 05 and above will work, as UART1 is *not* redirected by default.
80104
For that, you would have to add something like `-chardev socket,host=localhost,port=1111,id=aux -serial chardev:aux` (thanks
81105
[@godmar](https://github.com/godmar) for the info).
82106

0 commit comments

Comments
 (0)