-
Notifications
You must be signed in to change notification settings - Fork 2
/
buildscript.sh
127 lines (103 loc) · 2.54 KB
/
buildscript.sh
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
#!/bin/zsh
# 初始化目录
cleanDir()
{
if [ -f "u-boot" ];then
rm -rf ./u-boot/*
fi
if [ -f "armv7-lpae-multiplatform" ];then
rm -rf ./armv7-lpae-multiplatform/*
fi
if [ -f "bootloader" ];then
rm -rf ./bootloader/*
fi
if [ -f "kernelfile" ];then
rm -rf ./kernelfile/*
fi
if [ -f "rootfs" ];then
rm -rf ./rootfs/*
fi
}
initDir()
{
if [ ! -d "bootloader" ];then
mkdir bootloader
fi
if [ ! -d "kernelfile" ];then
mkdir kernelfile
fi
if [ ! -d "rootfs" ];then
mkdir rootfs
fi
}
# 设置交叉编译器
initCompiler()
{
sudo apt-get update
sudo apt install gcc-arm-linux-gnueabihf bison flex swig lzop lzma libmpc-dev u-boot-tools libncurses5-dev:amd64
export ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
}
# U-Boot
ubootScript()
{
git clone -b v2022.04-rc1 https://github.com/u-boot/u-boot/ --depth=1
cd u-boot
# 编译U-Boot
make distclean
make stm32mp15_basic_defconfig
make DEVICE_TREE=stm32mp157a-dk1 all -j $(nproc)
# 拷贝启动文件
cp ./u-boot-spl.stm32 ../bootloader/u-boot-spl.stm32
cp ./u-boot.img ../bootloader/u-boot.img
cd ..
rm -rf u-boot
}
# Linux Kernel
kernelScript()
{
git clone https://github.com/RobertCNelson/armv7-lpae-multiplatform
cd armv7-lpae-multiplatform/
git checkout origin/v5.16.x -b tmp
sed -i "s/git.kernel.org\/pub\/scm\/linux\/kernel\/git\/stable/mirrors.tuna.tsinghua.edu.cn\/git/g" ./scripts/git.sh
./build_kernel.sh
kernel_version=$(cat "$PWD/KERNEL/include/generated/utsrelease.h" | awk '{print $3}' | sed 's/\"//g' )
sudo cp ./deploy/${kernel_version}.zImage ../kernelfile/${kernel_version}.zImage
sudo cp ./deploy/${kernel_version}-dtbs.tar.gz ../kernelfile/${kernel_version}-dtbs.tar.gz
sudo cp ./deploy/${kernel_version}-modules.tar.gz ../kernelfile/${kernel_version}-modules.tar.gz
cd ..
rm -rf armv7-lpae-multiplatform
}
# Ubuntu Rootfs
rootfsScript()
{
cd rootfs
wget -c https://rcn-ee.com/rootfs/eewiki/minfs/ubuntu-20.04.3-minimal-armhf-2021-12-20.tar.xz
}
case $1 in
c|clean)
cleanDir
initDir
;;
u|uboot)
initDir
initCompiler
ubootScript
;;
k|kernel)
initDir
initCompiler
kernelScript
;;
r|rootfs)
initDir
rootfsScript
;;
*)
cleanDir
initDir
initCompiler
ubootScript
kernelScript
rootfsScript
;;
esac