-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev
executable file
·62 lines (51 loc) · 1.29 KB
/
dev
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
#!/usr/bin/env bash
command=${1:-run}
target=${2:-vf2}
TOOL_CHAIN_PREFIX=./xpacks/.bin/riscv-none-elf
BIN_DIR=zig-out/bin
BIN_FILE=${BIN_DIR}/kernel.bin
PATH=tools/bin:$PATH
function download_nezha () {
echo "Download to Nezha"
xfel version && xfel ddr d1
test $? -eq 0 || exit
set -x
serial-term &
xfel write 0x40000000 ${BIN_FILE}
{ set +x; } 2>/dev/null
sleep 2
xfel exec 0x40000000
}
function download_vf2 () {
echo "Download to VisionFive2"
set -x
spl_tool -c -f ${BIN_FILE}
# boot directly from L2 LIM at 0x8000000, but the linker must use linker.l2lim.lds
# vf2flash -l 0 -t -f ${BIN_FILE}.normal.out
# boot through SPL (ddr init) and then from DRAM at 0x40000000
vf2flash -l 1 -t -f ${BIN_FILE}
{ set +x; } 2>/dev/null
}
function download () {
if [[ "${target}" == "nezha" ]]; then
download_nezha
fi
if [[ "${target}" == "vf2" ]]; then
download_vf2
fi
}
function build () {
rm $BIN_DIR/*
set -x
zig build kernel -Dboard="${target}"
${TOOL_CHAIN_PREFIX}-objdump -h -d -S ${BIN_DIR}/kernel.elf > ${BIN_DIR}/kernel.elf.objdump
{ set +x; } 2>/dev/null
}
if [ "$command" == "build" ]; then
build
elif [ "$command" == "download" ]; then
download
else
build
download
fi