aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2019-10-03 11:00:21 +0200
committerWojtek Kosior <kwojtus@protonmail.com>2019-10-03 11:00:21 +0200
commit4e7666742e6089e7f0ff359c42f726acde7e2a0c (patch)
tree102d0dbf4983a81651d05f0c0ecaa86dc7c0a8e3 /Makefile
parent5f5df2cbe593b8d4365b5a20c2ec240746c9d914 (diff)
downloadrpi-MMU-example-4e7666742e6089e7f0ff359c42f726acde7e2a0c.tar.gz
rpi-MMU-example-4e7666742e6089e7f0ff359c42f726acde7e2a0c.zip
copy-paste broken code from wiki.osdev; fix it; add Makefile
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile29
1 files changed, 29 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..e465085
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,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