-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmake_image
More file actions
executable file
·104 lines (83 loc) · 3.06 KB
/
make_image
File metadata and controls
executable file
·104 lines (83 loc) · 3.06 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
#!/bin/bash
# wheatfox 2025
set -e
HVISOR_SRC_DIR=$(grep "^CONFIG_HVISOR_SRC_DIR=" .config | cut -d'"' -f2)
HVISOR_LINUX_SRC=$(grep "^CONFIG_HVISOR_LA64_LINUX_DIR=" .config | cut -d'"' -f2)
BUILDROOT_DIR=$(grep "^CONFIG_BUILDROOT_DIR=" .config | cut -d'"' -f2)
HVISOR_TOOL_DIR=$(grep "^CONFIG_HVISOR_TOOL_DIR=" .config | cut -d'"' -f2)
CROSS_COMPILE=$(grep "^CONFIG_CROSS_COMPILE=" .config | cut -d'"' -f2)
if [ ! -d "${HVISOR_SRC_DIR}" ]; then
echo "Error: hvisor source code directory not found: ${HVISOR_SRC_DIR}"
echo "Please change the HVISOR_SRC_DIR variable in make_image.sh to your hvisor source code directory"
exit 1
fi
# Read ARCH and BOARD from environment variables (default values if not set)
ARCH=${ARCH:-loongarch64}
BOARD=${BOARD:-ls3a5000}
# Log level - error, warn, info, debug, trace
HVISOR_LOG_LEVEL=$(grep CONFIG_HVISOR_LOG_LEVEL .config | cut -d'"' -f2)
HVISOR_ARGS="BID=${ARCH}/${BOARD} LOG=${HVISOR_LOG_LEVEL}"
# Make hvisor
make -C "${HVISOR_SRC_DIR}" ${HVISOR_ARGS}
# ANSI color codes
YELLOW="\033[1;33m"
GREEN="\033[1;32m"
BOLD="\033[1m"
RESET="\033[0m"
make ARCH="${ARCH}" clean
cd lib/gnu-efi && ./build-"${ARCH}".sh
cd ../..
VERBOSE=0
CMD="make ARCH=${ARCH} V=${VERBOSE}"
echo -e "${BOLD}${YELLOW}Building hvisor UEFI Boot Image, CMD=$CMD${RESET}"
$CMD
echo -e "${BOLD}${YELLOW}Building hvisor shared object, now building hvisor UEFI Boot Image${RESET}"
# Set the cross-compile tools according to ARCH
case "${ARCH}" in
aarch64)
PREFIX="${CROSS_COMPILE}"
EFI_NAME="BOOTAA64.EFI"
;;
loongarch64)
PREFIX="${CROSS_COMPILE}"
EFI_NAME="BOOTLOONGARCH64.EFI"
;;
riscv64)
PREFIX="${CROSS_COMPILE}"
EFI_NAME="BOOTRISCV64.EFI"
;;
*)
echo "Error: unsupported ARCH: ${ARCH}"
exit 1
;;
esac
OBJCOPY="${PREFIX}objcopy"
READELF="${PREFIX}readelf"
OBJDUMP="${PREFIX}objdump"
TARGET_SO="main/built-in.o"
TARGET_EFI="hvisor.efi"
rm -f "${EFI_NAME}" # Remove previous EFI output
CMD2="${OBJCOPY} -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* \
-j .rela.* -j .rel* -j .rela* -j .reloc -O binary ${TARGET_SO} ${TARGET_EFI}"
echo -e "${BOLD}${YELLOW}Building hvisor UEFI Boot Image, CMD=$CMD2${RESET}"
$CMD2
$READELF -a main/built-in.o > main/built-in.map
$OBJDUMP -d main/built-in.o > main/built-in.dis
# Rename output EFI file according to ARCH
cp "${TARGET_EFI}" "${EFI_NAME}"
# Print file info and size of generated EFI file
ls -lh "${EFI_NAME}"
file "${EFI_NAME}"
echo -e "${BOLD}${GREEN}Building hvisor UEFI Boot Image done: ${EFI_NAME}${RESET}"
# # Dump the .config file
# if [ -f ".config" ]; then
# echo -e "${BOLD}${YELLOW}Dumping .config${RESET}"
# terminal_width=$(tput cols)
# # print = * terminal_width
# printf '=%.0s' $(seq 1 $terminal_width)
# cat .config
# printf '=%.0s' $(seq 1 $terminal_width)
# echo -e "${BOLD}${YELLOW}Done, please check the important options like (vmlinux.bin) and make sure they are correct${RESET}"
# else
# echo -e "${BOLD}${YELLOW}.config file not found${RESET}"
# fi