-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.toml
More file actions
226 lines (199 loc) · 7 KB
/
project.toml
File metadata and controls
226 lines (199 loc) · 7 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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name = "Matte OS"
version = "0.1"
[targets]
[targets.clean]
action = """
ninja clean
cd toolchain/opensbi && make clean
cd toolchain/u-boot && make clean
"""
description = "Clean the project"
[targets.fresh]
action = """
rm -rf toolchain/clang
rm -rf toolchain/riscv
"""
dependencies = ["clean"]
description = "Clean the project, OpenSBI, Cross Compiler."
[targets.riscv-gnu-toolchain]
action = """
if [ ! -f 'toolchain/riscv.tar.gz' ]; then
wget -c https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2024.04.12/riscv64-glibc-ubuntu-22.04-gcc-nightly-2024.04.12-nightly.tar.gz -O toolchain/riscv.tar.gz
fi
if [ ! -d 'toolchain/riscv' ]; then
tar -xvf toolchain/riscv.tar.gz -C toolchain
fi
export PATH=$PATH:$(realpath toolchain/riscv/bin)
"""
description = "Download and extract RISC-V GNU Toolchain"
[targets.clang]
action = """
if ! which clang++ 2>/dev/null 1>&2; then
echo "Missing clang++"
exit 1
fi
if ! clang++ --target=riscv64 -mcpu=help 2>/dev/null 1>&2; then
echo "Your current clang++ doesn't support the riscv64 arch."
exit 1
fi
"""
description = "Download and extract Clang"
[targets.python3-10]
action = """
if [ ! -f 'toolchain/python3.10.tar.xz' ]; then
wget -c https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tar.xz -O toolchain/python3.10.tar.xz
fi
if [ ! -d 'toolchain/python3.10-build' ]; then
mkdir -p toolchain/python3.10-build
tar -xvf toolchain/python3.10.tar.xz -C toolchain/python3.10-build/ --strip-components=1
fi
cd toolchain/python3.10-build
if [ ! -d '../python3.10' ]; then
./configure --prefix=$(realpath "$(pwd)/../python3.10") --enable-optimizations --enable-shared
fi
if [ ! -f '../python3.10/lib/libpython3.10.so' ]; then
make -j$(nproc) all
make install
fi
"""
description = "Download and extract Python 3.10, that is needed by GDB"
[targets.doxygen-latest]
action = """
if [ ! -f 'toolchain/doxygen.tar.gz' ]; then
wget -c https://github.com/doxygen/doxygen/releases/download/Release_1_13_0/doxygen-1.13.0.linux.bin.tar.gz -O toolchain/doxygen.tar.gz
fi
if [ ! -d 'toolchain/doxygen' ]; then
mkdir -p toolchain/doxygen
tar -xvf toolchain/doxygen.tar.gz -C toolchain/doxygen --strip-components=1
fi
"""
[targets.toolchain]
dependencies = ["riscv-gnu-toolchain", "clang", "python3-10", "doxygen-latest", "qemu"]
description = "Download and extract toolchains"
[targets.opensbi]
dependencies = ["toolchain"]
action = """
scripts/build_opensbi.sh
"""
description = "Build OpenSBI"
check_for_file = "toolchain/opensbi/install/usr/share/opensbi/lp64/generic/firmware/fw_dynamic.bin"
[targets.uboot]
dependencies = ["toolchain"]
action = """
scripts/build_uboot.sh
"""
description = "Build U-Boot"
check_for_file = "toolchain/u-boot/u-boot.itb"
[targets.qemu]
action = """
if [ ! -f 'toolchain/qemu.tar.xz' ]; then
wget -c https://download.qemu.org/qemu-9.2.0.tar.xz -O toolchain/qemu.tar.xz
fi
if [ ! -d 'toolchain/qemu' ]; then
mkdir -p toolchain/qemu
tar -xvf toolchain/qemu.tar.xz -C toolchain/qemu --strip-components=1
fi
if [ ! -f 'toolchain/qemu/build/qemu-system-riscv64' ]; then
cd toolchain/qemu
./configure --target-list=riscv64-softmmu
make
fi
"""
description = "Download and builds QEMU"
[targets.kernel]
dependencies = ["toolchain", "opensbi", "uboot"]
action = """
if [ ! -f 'build.ninja' ]; then
cmake -GNinja .
fi
ninja
"""
description = "Build the kernel"
[targets.image]
dependencies = ["kernel"]
action = """
riscv64-unknown-linux-gnu-objcopy -O binary -R .note -R .comment -S build/dist/riscv/kernel.elf build/dist/riscv/kernel.bin
gzip -f -9 build/dist/riscv/kernel.bin
mkimage -f kernel.its build/dist/riscv/kernel.itb
"""
description = "Build the image"
[targets.disk]
action = """
qemu-img create -f raw build/dist/riscv/disk.img 1G
mkfs.fat -F 32 build/dist/riscv/disk.img
mkdir -p build/dist/riscv/mnt
sudo mount -o loop build/dist/riscv/disk.img build/dist/riscv/mnt
echo 'Hello, World!' | sudo tee build/dist/riscv/mnt/hello.txt > /dev/null
sudo cp build/dist/riscv/modules/TestModule.ko build/dist/riscv/mnt/TestModule.ko
sudo sync
sudo umount -l build/dist/riscv/mnt
"""
description = "Create a 1G disk image"
[targets.run]
dependencies = ["image", "disk", "print-boot-info"]
action = """
toolchain/qemu/build/qemu-system-riscv64 \
-cpu rv64 \
-nographic \
-serial mon:stdio \
-machine virt \
-smp 1 -m 2G \
-bios toolchain/u-boot/spl/u-boot-spl.bin \
-kernel toolchain/u-boot/u-boot.itb \
-device loader,file=build/dist/riscv/kernel.itb,addr=0x82000000,force-raw=on \
-drive if=none,format=raw,file=build/dist/riscv/disk.img,id=rootfs \
-device virtio-blk-device,drive=rootfs \
-device virtio-rng-device -s -d guest_errors
"""
description = "Run the image"
[targets.dir]
action = """
ls
"""
description = "List files in the current directory"
[targets.all]
dependencies = ["image"]
description = "Build everything"
[targets.check]
action = """
echo 'This script is going to check for needed libraries and tools: '
"""
description = "Check for needed libraries and tools"
[targets.debug]
dependencies = ["image", "disk", "print-boot-info"]
action = """
toolchain/qemu/build/qemu-system-riscv64 -cpu rv64 -nographic -serial mon:stdio -machine virt -smp 1 -m 2G -bios toolchain/u-boot/spl/u-boot-spl.bin -kernel toolchain/u-boot/u-boot.itb -device loader,file=build/dist/riscv/kernel.itb,addr=0x82000000,force-raw=on -drive if=none,format=raw,file=build/dist/riscv/disk.img,id=rootfs -device virtio-blk-device,drive=rootfs -device virtio-rng-device -s -S -d guest_errors
"""
description = "Run QEMU in debug mode"
[targets.debug-client]
dependencies = ["riscv-gnu-toolchain", "python3-10"]
action = """
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:toolchain/python3.10/lib/
export PYTHONHOME=$(realpath "toolchain/python3.10")
export PYTHONPATH=$PYTHONHOME/lib/python3.10
toolchain/riscv/bin/riscv64-unknown-linux-gnu-gdb -ex 'target remote localhost:1234' build/dist/riscv/kernel.elf
"""
description = "Run GDB in debug mode"
[targets.doxygen]
action = """
toolchain/doxygen/bin/doxygen Doxyfile
"""
description = "Generate doxygen documentation"
[targets.documentation]
action = """
cd docs/latex
make
"""
description = "Generate latex documentation"
[targets.docs]
dependencies = ["doxygen", "documentation"]
description = "Generate all documentations"
[targets.print-boot-info]
action = """
echo '===================================================================='
echo 'In U-Boot, you can use the following commands to boot the kernel:'
echo 'cp.l ${fdtcontroladdr} ${fdt_addr_r} 0x10000
bootm 0x82000000 - ${fdt_addr_r}'
echo '===================================================================='
"""
description = "Print boot information"