-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (40 loc) · 1.03 KB
/
Copy pathMakefile
File metadata and controls
52 lines (40 loc) · 1.03 KB
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
# I'm gonna be honest i asked chatgpt to generate this idk how this works
TARGET = aarch64-unknown-none
KERNEL = AtOS
BUILD = target/$(TARGET)/release/$(KERNEL)
OBJCOPY = aarch64-linux-gnu-objcopy
QEMU = qemu-system-aarch64
USER_DIR = src/user
# Default target
all: kernel8.img
# Build user programs
user:
$(MAKE) -C $(USER_DIR)
# Build release and debug
build: user
cargo build --release --target $(TARGET)
cargo build --target $(TARGET)
# Convert ELF to raw binary
kernel8.img: build
$(OBJCOPY) $(BUILD) -O binary kernel8.img
# Run in QEMU (Emulating Raspberry Pi 3B+ with Mini UART redirected to terminal)
run:
$(QEMU) -M raspi3b -kernel kernel8.img -serial null -serial stdio -display none
.PHONY: debug
debug:
$(QEMU) \
-M raspi3b \
-kernel kernel8.img \
-serial null \
-serial stdio \
-S \
-gdb tcp::1234
gdb:
gdb target/aarch64-unknown-none/debug/AtOS \
-ex "target remote :1234"
# Clean everything
clean:
$(MAKE) -C $(USER_DIR) clean
cargo clean
rm -f kernel8.img
.PHONY: all build user clean run debug gdb