forked from flatmax/buildroot.rk3399.external
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·93 lines (81 loc) · 3.11 KB
/
setup.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
#! /bin/bash
# Author : Matt Flax <flatmax@flatmax.org>
# Date : Nov 2017
if [ $# -lt 1 ]; then
echo usage :
me=`basename "$0"`
echo " " $me path.to.buildroot.raspberrypi
else
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
CUSTOM_PATH=$DIR
BR_REPO_PATH=$1
# pi3 64 bit
BR_STOCK_DEFCONFIG=$BR_REPO_PATH/configs/raspberrypi3_64_defconfig
BR_NEW_DEFCONFIG_FILE=raspberrypi3_64_ai_defconfig
BR_STOCK_POSTIMAGE=$BR_REPO_PATH/board/raspberrypi3-64/post-image.sh
BR_EXTRA_POSTIMAGE=$CUSTOM_PATH/board/raspberrypi3-64/post-image-extra.sh
BR_STOCK_GENIMAGE=$BR_REPO_PATH/board/raspberrypi3-64/genimage-raspberrypi3-64.cfg
# pi3 32 bit
BR_STOCK_DEFCONFIG=$BR_REPO_PATH/configs/raspberrypi3_defconfig
BR_NEW_DEFCONFIG_FILE=raspberrypi3_32_ai_defconfig
BR_STOCK_POSTIMAGE=$BR_REPO_PATH/board/raspberrypi3/post-image.sh
BR_EXTRA_POSTIMAGE=$CUSTOM_PATH/board/raspberrypi3/post-image-extra.sh
BR_STOCK_GENIMAGE=$BR_REPO_PATH/board/raspberrypi3/genimage-raspberrypi3.cfg
# common target genimage file
BR_NEW_DEFCONFIG=$CUSTOM_PATH/configs/$BR_NEW_DEFCONFIG_FILE
BR_EXTRA_DEFCONFIG=$CUSTOM_PATH/configs/raspberrypi_ai_defconfig
BR_POSTIMAGE=$BR_REPO_PATH/output/build/post-image.sh
BR_GENIMAGE=$BR_REPO_PATH/output/build/genimage-pi.cfg
mkdir -p $BR_REPO_PATH/output/build
if [ ! -d "$BR_REPO_PATH" ]; then
echo Can\'t find the directory $BR_REPO_PATH please correct the bash script.
return;
fi
if [ ! -e "$BR_STOCK_DEFCONFIG" ]; then
echo can\'t find the file $BR_STOCK_DEFCONFIG
echo please fix this script
return;
fi
if [ ! -e "$BR_STOCK_POSTIMAGE" ]; then
echo can\'t find the file $BR_STOCK_POSTIMAGE
echo please fix this script
return;
fi
if [ ! -d "$CUSTOM_PATH" ]; then
echo Can\'t find the directory $CUSTOM_PATH please correct the bash script.
return;
fi
if [ ! -e $BR_EXTRA_DEFCONFIG ]; then
echo can\'t find the file $BR_EXTRA_DEFCONFIG
echo please fix this script
return;
fi
if [ ! -e $BR_EXTRA_POSTIMAGE ]; then
echo can\'t find the file $BR_EXTRA_POSTIMAGE
echo please fix this script
return;
fi
# generate the buildroot config file
echo \#autogenerated do not edit, put changes in $BR_EXTRA_DEFCONFIG > $BR_NEW_DEFCONFIG
cat $BR_STOCK_DEFCONFIG >> $BR_NEW_DEFCONFIG
cat $BR_EXTRA_DEFCONFIG >> $BR_NEW_DEFCONFIG
# generate the post-image file
echo "#!/bin/bash
#autogenerated do not edit, put changes in $BR_EXTRA_POSTIMAGE" > $BR_POSTIMAGE
echo "set -e
mkdir -p \${BINARIES_DIR}/overlays
" >> $BR_POSTIMAGE
cat $BR_STOCK_POSTIMAGE >> $BR_POSTIMAGE
sed -i 's/^genimage/genimage -h /;s/exit/#exit/' $BR_POSTIMAGE
cat $BR_EXTRA_POSTIMAGE >> $BR_POSTIMAGE
chmod u+x $BR_POSTIMAGE
# generate the genimage file
cat $BR_STOCK_GENIMAGE > $BR_GENIMAGE
sed -i '/rpi-firmware\/overlays/d' $BR_GENIMAGE # remove rpi-firmware/overlays if present
sed -i 's/zImage"/Image",\
"overlays"/' $BR_GENIMAGE # add the kernel's overlays
# sed -i '/"Image"/"Image",\
# "overlays"/' $BR_GENIMAGE # add the kernel's overlays
cd $1
make BR2_EXTERNAL=$CUSTOM_PATH $BR_NEW_DEFCONFIG_FILE
fi