-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
90 lines (69 loc) · 2.46 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
########################################################################################################################
# watch-micro-kernel build system
########################################################################################################################
#-----------------------------------------------------------------------------------------------------------------------
# The targets to combine it all
#-----------------------------------------------------------------------------------------------------------------------
.PHONY: all clean fetch-toolchain loader kernel rootfs
# Build all the targets
all: out/image.bin
# Clean everything
clean:
$(MAKE) -C loader clean
$(MAKE) -C kernel clean
$(MAKE) -C apps/init clean
rm -rf out
# Fetch the toolchain for the given target
fetch-toolchain:
$(MAKE) -C toolchain
#-----------------------------------------------------------------------------------------------------------------------
# Combine everything into a nice image
#-----------------------------------------------------------------------------------------------------------------------
out/image.bin: loader rootfs
@mkdir -p $(@D)
# set the loader at the start and resize it nicely
rm -rf $@
dd if=loader/out/bin/loader.bin of=$@ bs=1 seek=4k
truncate -s 16K $@
# put the rootfs afterwards
cat out/rootfs.bin >> $@
# create a version with a full size image
cp $@ [email protected]
truncate -s 16M [email protected]
rootfs: kernel init
./scripts/create_rootfs.py
loader:
$(MAKE) -C loader
kernel:
$(MAKE) -C kernel
init:
$(MAKE) -C apps/init
#-----------------------------------------------------------------------------------------------------------------------
# Target specific stuff
#-----------------------------------------------------------------------------------------------------------------------
TOOLCHAIN_PATH := toolchain
include toolchain/esptool.mk
include toolchain/toolchain.mk
include toolchain/qemu.mk
$(QEMU):
$(MAKE) -C toolchain fetch-qemu
objdump: kernel
$(OBJDUMP) -d kernel/out/build/kernel.elf > kernel.S
run: all
./scripts/run_esp32.py
qemu-debug: $(QEMU) all
$(QEMU) \
-machine esp32 \
-serial stdio \
-monitor telnet:localhost:1235,server,nowait \
-drive file=out/image.bin.full,if=mtd,format=raw \
-m 4M \
-s -S \
-d int
qemu: $(QEMU) all
$(QEMU) \
--trace "*mtd*" -machine esp32 \
-serial stdio \
-monitor telnet:localhost:1235,server,nowait \
-drive file=out/image.bin.full,if=mtd,format=raw \
-m 4M