forked from LUCClass/pios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
71 lines (52 loc) · 1.58 KB
/
Makefile
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
CC := aarch64-linux-gnu-gcc
LD := aarch64-linux-gnu-ld
OBJDUMP := aarch64-linux-gnu--objdump
OBJCOPY := aarch64-linux-gnu-objcopy
CONFIGS := -DCONFIG_HEAP_SIZE=4096
CFLAGS := -O0 -ffreestanding -fno-pie -fno-stack-protector -g3 -mcpu=cortex-a53+nofp -Wall $(CONFIGS)
ODIR = obj
SDIR = src
OBJS = \
boot.o \
kernel_main.o \
serial.o \
rprintf.o \
page.o \
mmu.o \
sd.o \
fat.o \
OBJ = $(patsubst %,$(ODIR)/%,$(OBJS))
$(ODIR)/%.o: $(SDIR)/%.c
$(CC) $(CFLAGS) -c -g -o $@ $^
$(ODIR)/%.o: $(SDIR)/%.s
$(CC) $(CFLAGS) -c -g -o $@ $^
all: bin rootfs.img
bin: $(OBJ)
$(LD) obj/* -Tkernel.ld -o kernel8.img
cp kernel8.img kernel8.elf
$(OBJCOPY) -O binary kernel8.img
aarch64-linux-gnu-size kernel8.elf
clean:
rm -f obj/*
rm -f rootfs.img
rm -f rootfs.img
rm -f kernel8.img
rm -f kernel8.elf
debug:
screen -S qemu -d -m qemu-system-aarch64 -machine raspi3b -kernel kernel8.img -hda rootfs.img -S -s -serial null -serial stdio -monitor none -nographic -k en-us
TERM=xterm gdb-multiarch -x gdb_init_prot_mode.txt && killall qemu-system-aarch64
run:
qemu-system-aarch64 -machine raspi3b -kernel kernel8.img -hda rootfs.img -serial null -serial stdio -monitor none -nographic -k en-us
disassemble:
$(OBJDUMP) -D kernel8.elf
rootfs.img:
dd if=/dev/zero of=rootfs.img bs=1M count=16
sudo mkfs.fat -F12 rootfs.img
sudo mkdir -p /mnt/disk
sudo mount rootfs.img /mnt/disk
sudo mkdir -p /mnt/disk/boot/firmware
sudo mkdir /mnt/disk/bin
sudo mkdir /mnt/disk/etc
sudo touch /mnt/disk/file
sudo bash -c "echo test > /mnt/disk/test"
sudo umount /mnt/disk