-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathbspsetup.sh
174 lines (150 loc) · 4.64 KB
/
bspsetup.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
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
#!/bin/bash
################################################################################
##
## To support:
## 1. bspsetup: toolchain, kernel and u-boot source setup
## 2. l4tout_setup: setup Linux_for_Tegra
##
################################################################################
function _later_check()
{
[ -d $L4TOUT ] || (echo "${red} _early_check failed${normal}" && return 1)
[ -f ${KERNEL_TOOLCHAIN}gcc ] || (echo "${red} ${KERNEL_TOOLCHAIN}gcc check failed${normal}" && return 1)
[ -f ${BSP_TOOLCHAIN}gcc ] || (echo "${red} ${BSP_TOOLCHAIN}gcc check failed${normal}" && return 1)
[ -d $KERNEL_PATH ] || (echo "$KERNEL_PATH check failed${normal}" && return 1)
}
function _toolchain_setup()
{
# for bsp
if [ ! -f ${BSP_TOOLCHAIN}gcc ]
then
if [ ! -f $BSP_TOOLCHAIN_PACKAGE ] || [ $(wget_size $BSP_TOOLCHAIN_LINK) -ne $(local_size $BSP_TOOLCHAIN_PACKAGE) ]
then
edo wget $BSP_TOOLCHAIN_LINK -O $BSP_TOOLCHAIN_PACKAGE
fi
edo tar xpf $BSP_TOOLCHAIN_PACKAGE -C $BSP_TOOLCHAIN_ROOT
if [ ! -f ${BSP_TOOLCHAIN}gcc ] && [ -x $BSP_TOOLCHAIN_ROOT/make-arm-hf-toolchain.sh ]
then
pushd $BSP_TOOLCHAIN_ROOT &> /dev/null
edo ./make-arm-hf-toolchain.sh
popd &> /dev/null
fi
fi
# for kernel
if [ ! -f ${KERNEL_TOOLCHAIN}gcc ]
then
if [ ! -f $KERNEL_TOOLCHAIN_PACKAGE ] || [ $(wget_size $KERNEL_TOOLCHAIN_LINK) -ne $(local_size $KERNEL_TOOLCHAIN_PACKAGE) ]
then
edo wget $KERNEL_TOOLCHAIN_LINK -O $KERNEL_TOOLCHAIN_PACKAGE
fi
edo tar xpf $KERNEL_TOOLCHAIN_PACKAGE -C $KERNEL_TOOLCHAIN_ROOT
if [ ! -f ${KERNEL_TOOLCHAIN}gcc ] && [ -x $KERNEL_TOOLCHAIN_ROOT/make-aarch64-toolchain.sh ]
then
pushd $KERNEL_TOOLCHAIN_ROOT &> /dev/null
edo ./make-aarch64-toolchain.sh
popd &> /dev/null
fi
fi
}
function _sources_setup()
{
# Source download
if [ ! -f $SOURCE_PACKAGE ] || [ $(wget_size $SOURCES_LINK) -ne $(local_size $SOURCE_PACKAGE) ]
then
edo mkdir -p $DOANLOAD_ROOT
echo; echo "download source code..."
edo wget $SOURCES_LINK -O $SOURCE_PACKAGE
fi
if [ ! -d $SOURCE_UNPACK ]
then
echo; echo "Unpack source..."
edo tar xpf $SOURCE_PACKAGE -C $DOANLOAD_ROOT
fi
# kernel source
if [ -z "$(ls -A $KERNEL_ROOT)" ]
then
echo; echo "Setup kernel source code..."
edo git init $KERNEL_ROOT
edo tar xpf $KERNEL_PACKAGE -C $KERNEL_ROOT
pushd $KERNEL_ROOT &> /dev/null
edo git add .
edo git commit -s -m "${TARGET_DEV}-${TARGET_RELEASE}"
popd &> /dev/null
fi
edo rm -rf $DOANLOAD_ROOT
if [ ! -f $CBOOT_PACKAGE ]
then
echo; echo "${yel}************************************************************"
echo "If you need cboot, please download cboot source code from"
echo "$CBOOT_SOURCE_LINK"
echo "move to below place and rerun bspsetup."
dirname $CBOOT_PACKAGE
echo "************************************************************${normal}"
echo
return 0
edo wget $CBOOT_SOURCE_LINK -O $CBOOT_PACKAGE
else
if [ -z "$(ls -A $CBOOT_ROOT)" ]
then
edo git init $CBOOT_ROOT
echo; echo "Setup cboot source code..."
edo tar xpf $CBOOT_PACKAGE -C $CBOOT_ROOT
pushd $CBOOT_ROOT &> /dev/null
edo git add .
edo git commit -s -m "${TARGET_DEV}-${TARGET_RELEASE}"
popd &> /dev/null
fi
fi
}
function l4tout_setup()
{
mkdir -p `dirname $L4TOUT`
echo -n "${yel}Are you sure to setup l4tout? [n/y] "
read ANSWER
if [ "$ANSWER"x != "y"x ]
then
return 0
fi
echo "${normal}"
edo sudo rm -rf $L4TOUT
mkdir -p $DOANLOAD_ROOT
mkdir -p $TMP_ROOT
if [ ! -f $BSP_PACKAGE ] || [ $(wget_size $BSP_LINK) -ne $(local_size $BSP_PACKAGE) ]
then
echo; echo "download BSP package..."
edo wget $BSP_LINK -O $BSP_PACKAGE
fi
edo tar xpf $BSP_PACKAGE -C $TMP_ROOT
edo mv $TMP_ROOT/Linux_for_Tegra $L4TOUT
edo rm -rf $TMP_ROOT
if [ ! -f $ROOTFS_PACKAGE ] || [ $(wget_size $ROOTFS_LINK) -ne $(local_size $ROOTFS_PACKAGE) ]
then
echo; echo "download root file system package..."
edo wget $ROOTFS_LINK -O $ROOTFS_PACKAGE
fi
edo sudo tar xpf $ROOTFS_PACKAGE -C $TARGET_ROOTFS
pushd $L4TOUT &> /dev/null
edo sudo ./apply_binaries.sh
popd &> /dev/null
sync
}
function bspsetup()
{
if [ ! -d $L4TOUT ]
then
echo "${red}Linux_for_Tegra is missing."
echo "plaese run \"${yel}l4tout_setup${red}\" to setup${normal}"
return 1;
fi
## Toolochain
mkdir -p $KERNEL_TOOLCHAIN_ROOT
mkdir -p $BSP_TOOLCHAIN_ROOT
mkdir -p $KERNEL_ROOT
mkdir -p $CBOOT_ROOT
#_toolchain_setup && _sources_setup
_sources_setup
_later_check || (echo "${red}_later_check failed, BSP setup failed!${normal}" && return 1)
echo "${mag}BSP setup successfully!${normal}"; echo
}
echo -e "${red}bspsetup${normal}: \t\tsetup toolchain, kernel source"
echo -e "${red}l4tout_setup${normal}: \t\tsetup Xavier/Linux_for_Tegra"