aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2020-01-13 14:33:48 +0100
committerWojtek Kosior <kwojtus@protonmail.com>2020-01-13 14:33:48 +0100
commitb90be038ad473aa3e1d662d21a94dfca1eb6df78 (patch)
treea806fee1c1e2feb1b8bf177ecb6bc3c1825131d4 /build
parent63b45f687868af38d21930790f0d0e517b50b2e2 (diff)
downloadrpi-MMU-example-b90be038ad473aa3e1d662d21a94dfca1eb6df78.tar.gz
rpi-MMU-example-b90be038ad473aa3e1d662d21a94dfca1eb6df78.zip
move building to build/
Diffstat (limited to 'build')
-rw-r--r--build/Makefile85
1 files changed, 85 insertions, 0 deletions
diff --git a/build/Makefile b/build/Makefile
new file mode 100644
index 0000000..25f2da9
--- /dev/null
+++ b/build/Makefile
@@ -0,0 +1,85 @@
+CFLAGS=-mcpu=cortex-a7 -ffreestanding -std=gnu11 -Wall -Wextra $(addprefix -I, $(dirs))
+ELFFLAGS=-nostdlib -lgcc
+
+ARM_OBJECTS=kernel.o paging.o demo_functionality.o PL0_test.o uart.o loader_stage1.o loader_stage2.o
+
+KERNEL_STAGE2_OBJECTS=setup.o interrupt_vector.o interrupts.o uart.o demo_functionality.o paging.o ramfs_embeddable.o ramfs.o strings.o io.o atags.o scheduler.o
+
+PL_0_TEST_OBJECTS=PL0_utils.o svc.o PL0_test.o strings.o io.o
+
+LOADER_STAGE2_OBJECTS=uart.o strings.o io.o loader_stage2.o
+
+RAMFS_FILES=PL0_test.img
+
+all : kernel.img
+
+empty:=
+space:= $(empty) $(empty)
+
+dirs:=$(shell find ../src/ -type d)
+dirs_colon:=$(subst $(space),:,$(dirs))
+vpath %.S $(dirs_colon)
+vpath %.c $(dirs_colon)
+vpath %.ld $(dirs_colon)
+
+echo :
+ echo $(VPATH)
+ echo $(CFLAGS)
+
+%.o : %.c
+ arm-none-eabi-gcc $(CFLAGS) -c $^ -o $@
+
+%.img : %.elf
+ arm-none-eabi-objcopy $^ -O binary $@
+
+%.o: %.S
+ arm-none-eabi-as -mcpu=cortex-a7 $^ -o $@
+
+%_embeddable.o : %.img
+ arm-none-eabi-objcopy -I binary -O elf32-littlearm -B arm $^ $@
+
+%.elf : %.ld
+ arm-none-eabi-gcc -T $< -o $@ $(ELFFLAGS) $(filter %.o,$^)
+
+PL0_test.elf : $(PL_0_TEST_OBJECTS)
+
+kernel.elf : kernel_stage1.o
+
+kernel_stage2.elf : $(KERNEL_STAGE2_OBJECTS)
+
+loader_stage2.elf : $(LOADER_STAGE2_OBJECTS)
+
+loader.elf : loader_stage1.o
+
+kernel_stage1.o : kernel_stage1.S kernel_stage2.img
+ arm-none-eabi-as -mcpu=cortex-a7 $< -o $@
+
+loader_stage1.o : loader_stage1.S loader_stage2.img
+ arm-none-eabi-as -mcpu=cortex-a7 $< -o $@
+
+qemu-elf : kernel.elf
+ qemu-system-arm -m 256 -M raspi2 -serial stdio -kernel $^
+
+qemu-bin : kernel.img
+ qemu-system-arm -m 256 -M raspi2 -serial stdio -kernel $^
+
+qemu-loader : loader.img kernel.img pipe_image
+ ./pipe_image --stdout | qemu-system-arm -m 256 -M raspi2 -serial stdio -kernel $<
+
+run-on-rpi : kernel.img pipe_image
+ ./pipe_image --stdout | sudo socat FILE:/dev/ttyUSB0,b115200,raw -
+ screen /dev/ttyUSB0 115200,cs8,-parenb,-cstopb,-hupcl
+
+pipe_image : pipe_image.c rs232.c
+ gcc -Wall -std=gnu99 -I../src/lib/rs232 -O3 $^ -o $@
+
+makefs : makefs.c
+ gcc -Wall -std=gnu99 -O3 $^ -o $@
+
+ramfs.img : makefs $(RAMFS_FILES)
+ ./makefs $(RAMFS_FILES) > $@
+
+clean :
+ -rm -f *.img *.elf *.o pipe_image makefs
+
+.PHONY: all qemu-elf qemu-bin clean