aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: e46508551d614b3746fa7598f808f63a6116f724 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
all : kernel7.img

kernel.o : kernel.c
	arm-none-eabi-gcc -mcpu=cortex-a7 -ffreestanding -std=gnu99 -c -O2 -Wall -Wextra $^ -o $@

boot.o : boot.S
	arm-none-eabi-as -mcpu=cortex-a7 boot.S -o boot.o

kernel.elf : boot.o kernel.o
	arm-none-eabi-gcc -T linker.ld -o $@ -ffreestanding -O2 -nostdlib boot.o kernel.o -lgcc

kernel_padded.img : kernel.elf
	arm-none-eabi-objcopy $^ -O binary $@

# objcopy pads 0x0000 to 0x8000 with zeros, we need to get rid of them
kernel7.img : kernel_padded.img
	-rm $@
	dd bs=4096 skip=8 if=$^ of=$@

qemu-elf : kernel.elf
	qemu-system-arm -m 256 -M raspi2 -serial stdio -kernel $^

qemu-bin : kernel7.img
	qemu-system-arm -m 256 -M raspi2 -serial stdio -kernel $^

clean :
	-rm kernel7.img kernel_padded.img kernel.elf boot.o kernel.o

.PHONY: all qemu-elf qemu-bin clean