Lab0: Environment Setup

Requirement

Linker script

a.S

1
2
3
4
.section ".text"
_start:
wfe
b _start

linker.ld

1
2
3
4
5
SECTIONS
{
. = 0x80000;
.text : { *(.text) }
}

Build

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# From source code to object files
aarch64-linux-gnu-gcc -c a.S

# From object files to ELF
aarch64-linux-gnu-ld -T linker.ld -o kernel8.elf a.o

# From elf to kernel image
aarch64-linux-gnu-objcopy -O binary kernel8.elf kernel8.img

# Check on QEMU
qemu-system-aarch64 -M raspi3 -kernel kernel8.img -display none -d in_asm

# Debug on QEMU
qemu-system-aarch64 -M raspi3 -kernel kernel8.img -display none -S -s

Deploy to REAL rpi3

1
2
3
4
5
6
# Flash bootable image to SD card
# <https://github.com/GrassLab/osdi/raw/master/supplement/nctuos.img>
dd if=nctuos.img of=/dev/sdb

# Interact with rpi3
# <https://github.com/GrassLab/osdi/raw/master/supplement/kernel8.img>

Test functionality on QEMU

1
qemu-system-aarch64 -M raspi3 -kernel kernel8.img -display none -serial null -serial pty -monitor stdioProblem

According to FT232R Datasheet, baudrate@115200 is not available. However, it works well.

Baud Rate = 3000000 / (n + x)

Where ‘n’ can be any integer between 2 and 16,384 ( = 214 ) and ‘x’ can be a sub-integer of the value 0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, or 0.875. When n = 1, x = 0, i.e. baud rate divisors with values between 1 and 2 are not possible.

Reference