forked from jtagxhub/jetpack-agx-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernelbuild.sh
117 lines (91 loc) · 3.23 KB
/
kernelbuild.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
#!/bin/bash
################################################################################
##
## To support:
## 1. krebuild: kernel Image and dtb build
## 2. kmenuconfig & ksavedefconfig: kernel defconfig update
##
################################################################################
_kernel_prepare_dirs()
{
mkdir -p $KERNEL_OUT
mkdir -p $INSTALL_KERNEL_MODULES_PATH
}
function kmenuconfig()
{
_kernel_prepare_dirs
local MAKE_OPTIONS="ARCH=arm64 CROSS_COMPILE=$KERNEL_TOOLCHAIN O=$KERNEL_OUT LOCALVERSION=-tegra"
edo make -C $KERNEL_PATH $MAKE_OPTIONS menuconfig
}
function kdefconfig()
{
_kernel_prepare_dirs
local MAKE_OPTIONS="ARCH=arm64 CROSS_COMPILE=$KERNEL_TOOLCHAIN O=$KERNEL_OUT LOCALVERSION=-tegra"
edo make -C $KERNEL_PATH $MAKE_OPTIONS $TARGET_KERNEL_CONFIG
}
function ksavedefconfig()
{
local MAKE_OPTIONS="ARCH=arm64 CROSS_COMPILE=$KERNEL_TOOLCHAIN O=$KERNEL_OUT LOCALVERSION=-tegra"
edo make -C $KERNEL_PATH $MAKE_OPTIONS savedefconfig
edo cp $KERNEL_OUT/defconfig $KERNEL_PATH/arch/arm64/configs/$TARGET_KERNEL_CONFIG
}
function kinstall()
{
_kernel_prepare_dirs
echo; echo "kernel install..."
edo cp $KERNEL_OUT/arch/arm64/boot/Image $L4TOUT/kernel/
edo cp $KERNEL_OUT/arch/arm64/boot/dts/*.dtb $L4TOUT/kernel/dtb/
if [ "X-a" == "X$1" ]
then
pushd $INSTALL_KERNEL_MODULES_PATH &> /dev/null
edo tar --owner root --group root -cjf kernel_supplements.tbz2 lib/modules
popd &> /dev/null
edo mv $INSTALL_KERNEL_MODULES_PATH/kernel_supplements.tbz2 $L4TOUT/kernel/
pushd $L4TOUT/rootfs/ &> /dev/null
edo sudo rm -rf $L4TOUT/rootfs/lib/modules/*
edo sudo tar jxpfm "${L4TOUT}/kernel/kernel_supplements.tbz2"
popd &> /dev/null
fi
echo "Done"; echo
}
function kbuildimage()
{
_kernel_prepare_dirs
_getnumcpus
local MAKE_OPTIONS="ARCH=arm64 CROSS_COMPILE=$KERNEL_TOOLCHAIN O=$KERNEL_OUT LOCALVERSION=-tegra -j${NUMCPUS} V=0"
echo; echo "start Image build..."
edo make -C $KERNEL_PATH $MAKE_OPTIONS Image
}
function kbuilddtb()
{
_kernel_prepare_dirs
_getnumcpus
local MAKE_OPTIONS="ARCH=arm64 CROSS_COMPILE=$KERNEL_TOOLCHAIN O=$KERNEL_OUT LOCALVERSION=-tegra -j${NUMCPUS} V=0"
echo; echo "start dtbs build..."
edo make -C $KERNEL_PATH $MAKE_OPTIONS dtbs
}
function kbuildmodule()
{
_kernel_prepare_dirs
_getnumcpus
local MAKE_OPTIONS="ARCH=arm64 CROSS_COMPILE=$KERNEL_TOOLCHAIN O=$KERNEL_OUT LOCALVERSION=-tegra -j${NUMCPUS} V=0"
if [ "X-a" == "X$1" ]
then
KERNEL_VERSION=`make -s -C $KERNEL_PATH $MAKE_OPTIONS kernelversion`
echo ; echo; echo "start modules build (kernel version: ${KERNEL_VERSION})..."
edo make -C $KERNEL_PATH $MAKE_OPTIONS modules DESTDIR=$INSTALL_KERNEL_MODULES_PATH
edo make -C $KERNEL_PATH $MAKE_OPTIONS modules_install INSTALL_MOD_PATH=$INSTALL_KERNEL_MODULES_PATH
fi
}
function kbuild()
{
_kernel_prepare_dirs
[ -f $KERNEL_OUT/.config ] || kdefconfig
kbuildimage && kbuilddtb && kbuildmodule $1 && kinstall $1
echo "Done"; echo
}
echo -e "${red}kmenuconfig${normal}: \t\tkernel menuconfig"
echo -e "${red}kdefconfig${normal}: \t\tkernel defconfig"
echo -e "${red}ksavedefconfig${normal}: \tupdate kernel defconfig"
echo -e "${red}kbuild${normal}: \t\tbuild and install kernel image, dtb"
echo -e "${red}kbuild -a${normal}: \t\tbuild and install kernel image, dtb, module"