forked from armbian/build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboards.sh
158 lines (129 loc) · 6.7 KB
/
boards.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
#!/bin/bash
#
# Copyright (c) 2015 Igor Pecovnik, igor.pecovnik@gma**.com
#
# This file is licensed under the terms of the GNU General Public
# License version 2. This program is licensed "as is" without any
# warranty of any kind, whether express or implied.
#
# This file is a part of tool chain https://github.com/igorpecovnik/lib
#
#
# Functions:
# install_board_specific
# install_kernel
install_board_specific (){
#---------------------------------------------------------------------------------------------------------------------------------
# Install board common and specific applications
#---------------------------------------------------------------------------------------------------------------------------------
# execute $LINUXFAMILY-specific tweaks from $BOARD.conf
[[ $(type -t family_tweaks) == function ]] && family_tweaks
# install custom root package
display_alert "Installing board support package" "$BOARD" "info"
chroot $CACHEDIR/sdcard /bin/bash -c "dpkg -i /tmp/$RELEASE/${CHOSEN_ROOTFS}_${REVISION}_${ARCH}.deb > /dev/null"
# enable first run script
chroot $CACHEDIR/sdcard /bin/bash -c "update-rc.d firstrun defaults >/dev/null 2>&1"
display_alert "Creating boot scripts" "$BOARD" "info"
rm -rf $CACHEDIR/sdcard/boot/dtb.old # remove .old on new image
if [[ $BOARD == udoo* ]] ; then
cp $SRC/lib/config/boot-$BOARD.cmd $CACHEDIR/sdcard/boot/boot.cmd
elif [[ $BOARD == cubox-i* ]]; then
cp $SRC/lib/config/boot-cubox.cmd $CACHEDIR/sdcard/boot/boot.cmd
elif [[ $BOARD == guitar* ]]; then
cp $SRC/lib/config/boot-guitar.cmd $CACHEDIR/sdcard/boot/boot.cmd
elif [[ $BOARD == roseapple* ]]; then
cp $SRC/lib/config/boot-roseapple.cmd $CACHEDIR/sdcard/boot/boot.cmd
elif [[ $BOARD == armada* ]]; then
cp $SRC/lib/config/boot-marvell.cmd $CACHEDIR/sdcard/boot/boot.cmd
elif [[ $BOARD == odroidxu4 ]]; then
cp $SRC/lib/config/boot-odroid-xu4.ini $CACHEDIR/sdcard/boot/boot.ini
elif [[ $BOARD == odroidc1 ]]; then
cp $SRC/lib/config/boot-odroid-c1.ini $CACHEDIR/sdcard/boot/boot.ini
elif [[ $BOARD == odroidc2 ]]; then
cp $SRC/lib/config/boot-odroid-c2.ini $CACHEDIR/sdcard/boot/boot.ini
elif [[ $BOARD == pine64* ]]; then
cp $SRC/lib/config/boot-pine64.cmd $CACHEDIR/sdcard/boot/boot.cmd
else
cp $SRC/lib/config/boot.cmd $CACHEDIR/sdcard/boot/boot.cmd
# orangepi h3 temp exceptions
[[ $LINUXFAMILY == "sun8i" ]] && sed -i -e '1s/^/gpio set PL10\ngpio set PG11\nsetenv machid 1029\nsetenv bootm_boot_mode sec\n/' \
-e 's/\ disp.screen0_output_mode=1920x1080p60//' -e 's/\ hdmi.audio=EDID:0//' $CACHEDIR/sdcard/boot/boot.cmd
# let's prepare for old kernel too
#chroot $CACHEDIR/sdcard /bin/bash -c \
#"ln -s /boot/bin/$BOARD.bin /boot/script.bin >/dev/null 2>&1 || cp /boot/bin/$BOARD.bin /boot/script.bin"
fi
# if we have a special fat boot partition, alter rootfs=
if [[ $BOOTSIZE -gt 0 ]]; then
display_alert "Adjusting boot scripts" "$BOARD" "info"
[[ -f $CACHEDIR/sdcard/boot/boot.cmd ]] && sed -e 's/p1 /p2 /g' -i $CACHEDIR/sdcard/boot/boot.cmd
echo "/dev/mmcblk0p1 /boot vfat defaults 0 0" >> $CACHEDIR/sdcard/etc/fstab
fi
# convert to uboot compatible script
[[ -f $CACHEDIR/sdcard/boot/boot.cmd ]] && \
mkimage -C none -A arm -T script -d $CACHEDIR/sdcard/boot/boot.cmd $CACHEDIR/sdcard/boot/boot.scr >> /dev/null
# initial date for fake-hwclock
date -u '+%Y-%m-%d %H:%M:%S' > $CACHEDIR/sdcard/etc/fake-hwclock.data
# configure MIN / MAX speed for cpufrequtils
echo "ENABLE=true" > $CACHEDIR/sdcard/etc/default/cpufrequtils
echo "MIN_SPEED=$CPUMIN" >> $CACHEDIR/sdcard/etc/default/cpufrequtils
echo "MAX_SPEED=$CPUMAX" >> $CACHEDIR/sdcard/etc/default/cpufrequtils
echo "GOVERNOR=$GOVERNOR" >> $CACHEDIR/sdcard/etc/default/cpufrequtils
# set hostname
echo $HOST > $CACHEDIR/sdcard/etc/hostname
# this is needed for ubuntu
rm $CACHEDIR/sdcard/etc/resolv.conf
echo "nameserver 8.8.8.8" >> $CACHEDIR/sdcard/etc/resolv.conf
# set hostname in hosts file
echo "127.0.0.1 localhost $HOST" > $CACHEDIR/sdcard/etc/hosts
echo "::1 localhost $HOST ip6-localhost ip6-loopback" >> $CACHEDIR/sdcard/etc/hosts
echo "fe00::0 ip6-localnet" >> $CACHEDIR/sdcard/etc/hosts
echo "ff00::0 ip6-mcastprefix" >> $CACHEDIR/sdcard/etc/hosts
echo "ff02::1 ip6-allnodes" >> $CACHEDIR/sdcard/etc/hosts
echo "ff02::2 ip6-allrouters" >> $CACHEDIR/sdcard/etc/hosts
# create modules file
if [[ $BRANCH == next || $BRANCH == dev ]]; then
tr ' ' '\n' <<< "$MODULES_NEXT" >> $CACHEDIR/sdcard/etc/modules
else
tr ' ' '\n' <<< "$MODULES" >> $CACHEDIR/sdcard/etc/modules
fi
# copy and create symlink to default interfaces configuration
cp $SRC/lib/config/network/interfaces.* $CACHEDIR/sdcard/etc/network/
ln -sf interfaces.default $CACHEDIR/sdcard/etc/network/interfaces
}
install_kernel (){
#--------------------------------------------------------------------------------------------------------------------------------
# Install kernel to prepared root file-system
#--------------------------------------------------------------------------------------------------------------------------------
display_alert "Installing packages" "$CHOSEN_KERNEL" "info"
# mount deb storage to tmp
mount --bind $DEST/debs/ $CACHEDIR/sdcard/tmp
# extract kernel version
VER=$(dpkg --info $DEST/debs/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb | grep Descr | awk '{print $(NF)}')
VER="${VER/-$LINUXFAMILY/}"
# we need package names for dtb, uboot and headers
DTB_TMP="${CHOSEN_KERNEL/image/dtb}"
FW_TMP="${CHOSEN_KERNEL/image/firmware-image}"
HEADERS_TMP="${CHOSEN_KERNEL/image/headers}"
# install kernel
chroot $CACHEDIR/sdcard /bin/bash -c "dpkg -i /tmp/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb >/dev/null 2>&1"
# install uboot
display_alert "Installing u-boot" "$CHOSEN_UBOOT" "info"
chroot $CACHEDIR/sdcard /bin/bash -c "DEVICE=/dev/null dpkg -i /tmp/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb > /dev/null"
# install headers
display_alert "Installing headers" "$HEADERS_TMP" "info"
chroot $CACHEDIR/sdcard /bin/bash -c "dpkg -i /tmp/${HEADERS_TMP}_${REVISION}_${ARCH}.deb > /dev/null"
# install firmware
if [[ -f $CACHEDIR/sdcard/tmp/${FW_TMP}_${REVISION}_${ARCH}.deb ]]; then
display_alert "Installing firmware" "$FW_TMP" "info"
chroot $CACHEDIR/sdcard /bin/bash -c "dpkg -i /tmp/${FW_TMP}_${REVISION}_${ARCH}.deb > /dev/null"
fi
# install DTB
if [[ -f $CACHEDIR/sdcard/tmp/${DTB_TMP}_${REVISION}_${ARCH}.deb ]]; then
display_alert "Installing DTB" "$DTB_TMP" "info"
chroot $CACHEDIR/sdcard /bin/bash -c "dpkg -i /tmp/${DTB_TMP}_${REVISION}_${ARCH}.deb > /dev/null"
fi
# copy boot splash image
cp $SRC/lib/bin/armbian.bmp $CACHEDIR/sdcard/boot/boot.bmp
# add our linux firmwares to cache image
unzip -q $SRC/lib/bin/linux-firmware.zip -d $CACHEDIR/sdcard/lib/firmware
}