You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Andre Richter 1ca70bcd56
Check-in kernel8
Useful for assembly inspection via objdump
6 years ago
..
.cargo Use aarch64-unknown-none target in nightly 🎉 6 years ago
raspi3_boot Remove unused cortex-a imports. 6 years ago
src rust-fmt all 6 years ago
Cargo.lock Remove unused cortex-a imports. 6 years ago
Cargo.toml Bump register to v0.2.0 6 years ago
Makefile Use cargo-xbuild 6 years ago
README.md Rewrite for register-rs. 6 years ago
kernel8 Check-in kernel8 6 years ago
kernel8.img Bump cortex-a to v1.1.0 6 years ago
link.ld Correct linker issues 6 years ago

README.md

Tutorial 03 - UART1, Auxilary mini UART

It is time for the famous Hello World example. We're going to write on the UART1 first, as it's easier to program as it has a fixed clocked frequency.

NOTE: qemu does not redirect UART1 to terminal by default, only UART0!

gpio.rs

We have a new file that defines the GPIO controller addresses. It is going to be very popular, as many device will need it in the future.

We are using the register crate to modify MMIO addresses, because it allows easy wrapping of addresses to volatile types. It will also be used for UART registers.

uart.rs

A very minimal implementation.

MiniUart::init(&self) initializes the device and maps it to the GPIO ports.

MiniUart::send(&self, c: char) sends a character over the serial line.

MiniUart::getc(&self) receives a character. The carrige return character (13) will be converted into a newline character (10).

MiniUart::puts(&self, string: &str) prints out a string. On newline, a carrige return character will also be sent (13 + 10).

main.rs

First we have to call the uart initialization code. Then we wait for the first keypress from the user before we say "Hello Rustacean!". If you've purchased an USB serial cable, you should see it on screen's screen. After that, every character typed in screen will be echoed back. If you haven't turned off local echo, that means you'll see every pressed key twice.