CFLAGS=-mcpu=cortex-a7 -ffreestanding -std=gnu11 -Wall -Wextra -O2 -fPIC -I. ELFFLAGS=-nostdlib -lgcc ARM_OBJECTS=kernel.o paging.o demo_functionality.o PL0_test.o uart.o loader_stage1.o loader_stage2.o RAMFS_FILES=PL_0_test.img all : kernel.img %.o : %.c arm-none-eabi-gcc $(CFLAGS) -c $^ -o $@ %.o : %.S arm-none-eabi-as -mcpu=cortex-a7 $^ -o $@ %.img : %.elf arm-none-eabi-objcopy $^ -O binary $@ %_embeddable.o : %.img arm-none-eabi-objcopy -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata $^ $@ PL_0_test.elf : PL0_test.o uart.o arm-none-eabi-gcc -T PL0_test.ld -o $@ $(ELFFLAGS) $^ kernel.elf : boot.o kernel.o uart.o demo_functionality.o paging.o interrupt_vector.o interrupts.o ramfs_embeddable.o ramfs.o arm-none-eabi-gcc -T linker.ld -o $@ $(ELFFLAGS) $^ loader.elf : boot.o loader_stage1.o loader_stage2.o uart.o arm-none-eabi-gcc -T loader_linker.ld -o $@ $(ELFFLAGS) $^ loader.img : loader.elf arm-none-eabi-objcopy $^ -O binary $@ # check if the resulting image is not too big test -n "$$(find $@ -size -16384c)" || exit -1 qemu-elf : kernel.elf qemu-system-arm -m 256 -M raspi2 -serial stdio -kernel $^ qemu-bin : loader.elf 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 lib/rs232/rs232.c gcc -Wall -std=gnu99 -O3 $^ -o $@ makefs : makefs.c gcc -Wall -std=gnu99 -O3 $^ -o $@ ramfs.img : makefs $(RAMFS_FILES) ./makefs $(RAMFS_FILES) > $@ clean : -rm *.img *.elf *.o pipe_image makefs .PHONY: all qemu-elf qemu-bin clean