Skip to content

jonlamb-gh/rpi4-rust-workspace

Repository files navigation

rpi4-rust-workspace

Rust workspace for RPi4 bare metal things

A lot of the things in here were inspired by rust-raspi3-OS-tutorials and circle.

Crates

Examples

Building

rustc 1.44.0-nightly (94d346360 2020-04-09)

cargo xbuild

Copy elf to binary:

cargo objcopy -- -O binary target/$(TARGET)/release/img /tmp/img.bin

Simulating

Comming soon?

https://gitlab.com/philmd/qemu/commits/raspi4_wip

# For output on UART1
qemu-system-aarch64 -M raspi4 -nographic -serial null -serial mon:stdio -kernel /path/to/binary

TODO - cusomer runner / cargo xrun support:

[target.'cfg(target_os = "none")']
runner = "tools/qemu-runner"

U-boot

Using 64 bit U-boot:

git clone --depth 1 https://github.com/u-boot/u-boot.git u-boot
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make rpi_4_defconfig
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make
U-Boot 2020.04-rc2-00048-gf2a73d6867 (Feb 16 2020 - 08:29:41 -0800)

aarch64-linux-gnu-gcc (Ubuntu/Linaro 8.3.0-6ubuntu1) 8.3.0
GNU ld (GNU Binutils for Ubuntu) 2.32

Environment:

setenv imgname img.bin

# Normally for bare metal
#setenv loadaddr 0x80000

# Put it somewhere else, so we don't overwrite u-boot
setenv loadaddr 0x01000000

# Make sure the caches are on
setenv bootimg 'tftp ${loadaddr} ${serverip}:${imgname}; dcache flush; dcache on; go ${loadaddr}'

SD Card

Files:

/card
├── config.txt
├── fixup4.dat
├── start4.elf
├── u-boot.bin
└── uboot.env

Contents of config.txt:

enable_uart=1
arm_64bit=1
kernel=u-boot.bin

Links