mirror of
https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials.git
synced 2024-11-19 15:25:29 +00:00
8175639399
The new target is not automatically using PIC. Need some linker script corrections for errors that were hiding previously, so that we don't accidentally generate alignment exceptions on bss size variables that cause the target to fail. |
||
---|---|---|
.. | ||
.cargo | ||
raspi3_boot | ||
src | ||
Cargo.lock | ||
Cargo.toml | ||
kernel8.img | ||
link.ld | ||
Makefile | ||
README.md |
Tutorial 08 - Hardware Random Number Generator
This going to be an easy tutorial. We query a number from the (undocumented) hardware random number generator. You can use this to implement a simple, but accurate dice throw in any game. It is important as without hardware support you can only generate pseudo-random numbers.
rand.s
Due to lack of documentation, we [mimic the respective Linux driver] (https://github.com/torvalds/linux/blob/master/drivers/char/hw_random/bcm2835-rng.c).
Rng::init(&self)
initializes the hardware.
Rng::rand(&self, min: u32, max: u32)
returns a random number between min and
max.
main.rs
Press a key to query a random value and then display it on the serial console.