-
Notifications
You must be signed in to change notification settings - Fork 9
/
build-boot-root.sh
executable file
·215 lines (198 loc) · 8.43 KB
/
build-boot-root.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/bin/bash
#
# This scripts builds Allwinner sunxi kernels + per board u-boot, spl and fex
# It will then place all the build files into 2 directories:
# $DESTDIR/uboot and $DESTDIR/rootfs
# and then tars up these directories to:
# $DESTDIR/uboot.tar.gz and $DESTDIR/rootfs.tar.gz
# Note that it also leaves the directories in place for easy inspection
#
# These tarbals are intended to be untarred to respectively the uboot and
# rootfs partition of a Fedora panda sdcard image, thereby turning this image
# into an Fedora sunxi sdcard image. See build-image.sh for a script automating
# this.
#
# The latest version of this script can be found here:
# https://github.com/jwrdegoede/sunxi-fedora-scripts.git
#
# To get the exact same versions as used on your sdcard, use the copy of
# this script found on your sdcard, as that contains all the git-tags used
# to build the sdcard image.
#
# This script must be run under Fedora-20, with the following
# packages installed:
# gcc-arm-linux-gnu
# uboot-tools
# sunxi-tools
#
# This script must be run from a directory which contains clones of the
# following git repositories:
# https://github.com/jwrdegoede/sunxi-fedora-scripts.git
# https://github.com/jwrdegoede/u-boot-sunxi.git
# https://github.com/jwrdegoede/sunxi-boards.git
# https://github.com/jwrdegoede/sunxi-kernel-config.git
# https://github.com/jwrdegoede/linux-sunxi.git
KERNER_VER=3.4
A10_BOARDS="a10_mid_1gb ba10_tv_box coby_mid7042 coby_mid8042 coby_mid9742 cubieboard cubieboard_512 dns_m82 eoma68_a10 gooseberry_a721 h6 hackberry hyundai_a7hd inet97f-ii jesurun-q5 marsboard_a10 mele_a1000 mele_a1000g mele_a3700 mini-x mini-x-1gb mk802 mk802-1gb mk802ii pcduino pov_protab2_ips9 pov_protab2_ips_3g sanei_n90 uhost_u1a"
A13_BOARDS="a13_mid a13-olinuxino a13-olinuxinom xzpad700"
A10S_BOARDS="a10s-olinuxino-m auxtek-t003 auxtek-t004 megafeis_a08 mini-x_a10s mk802_a10s r7-tv-dongle wobo-i5"
A20_BOARDS="a20-olinuxino_micro cubieboard2 cubietruck eu3000"
UBOOT_TAG=fedora-20-07022014
KERNEL_CONFIG_TAG=fedora-20-07022014
KERNEL_TAG=fedora-20-07022014
SUNXI_BOARDS_TAG=fedora-20-07022014
SCRIPTS_TAG=fedora-20-07022014
for i in "$@"; do
case $i in
--noclean)
NOCLEAN=1
;;
--nocheckout)
NOCHECKOUT=1
;;
*)
echo "Usage $0 [--noclean] [--nocheckout]"
exit 1
esac
done
if [ -z "$DESTDIR" ]; then
DESTDIR=$(pwd)
fi
set -e
set -x
[ -d $DESTDIR/uboot ] && rm -r $DESTDIR/uboot
[ -d $DESTDIR/rootfs ] && rm -r $DESTDIR/rootfs
mkdir $DESTDIR/uboot
mkdir $DESTDIR/rootfs
pushd u-boot-sunxi
[ -z "$NOCHECKOUT" ] && git checkout $UBOOT_TAG
[ -z "$NOCLEAN" ] && git clean -dxf
mkdir $DESTDIR/uboot/boards
# Note the changing board configs always force a rebuild
mkdir $DESTDIR/uboot/boards/sun4i
for i in $A10_BOARDS; do
make -j4 CROSS_COMPILE=arm-linux-gnu- O=$i ${i}_config
make -j4 CROSS_COMPILE=arm-linux-gnu- O=$i
mkdir $DESTDIR/uboot/boards/sun4i/$i
cp $i/u-boot-sunxi-with-spl.bin $DESTDIR/uboot/boards/sun4i/$i
done
mkdir $DESTDIR/uboot/boards/sun5i
for i in $A13_BOARDS; do
make -j4 CROSS_COMPILE=arm-linux-gnu- O=$i ${i}_config
make -j4 CROSS_COMPILE=arm-linux-gnu- O=$i
mkdir $DESTDIR/uboot/boards/sun5i/$i
cp $i/u-boot-sunxi-with-spl.bin $DESTDIR/uboot/boards/sun5i/$i
done
for i in $A10S_BOARDS; do
make -j4 CROSS_COMPILE=arm-linux-gnu- O=$i ${i}_config
make -j4 CROSS_COMPILE=arm-linux-gnu- O=$i
mkdir $DESTDIR/uboot/boards/sun5i/$i
cp $i/u-boot-sunxi-with-spl.bin $DESTDIR/uboot/boards/sun5i/$i
done
mkdir $DESTDIR/uboot/boards/sun7i
for i in $A20_BOARDS; do
make -j4 CROSS_COMPILE=arm-linux-gnu- O=$i ${i}_config
make -j4 CROSS_COMPILE=arm-linux-gnu- O=$i
mkdir $DESTDIR/uboot/boards/sun7i/$i
cp $i/u-boot-sunxi-with-spl.bin $DESTDIR/uboot/boards/sun7i/$i
done
popd
pushd sunxi-boards
[ -z "$NOCHECKOUT" ] && git checkout $SUNXI_BOARDS_TAG
[ -z "$NOCLEAN" ] && git clean -dxf
for lcd in "" "-lcd7" "-lcd10"; do
for i in $A10_BOARDS; do
if [ ! -f sys_config/a10/$i$lcd.fex ]; then
continue
fi
cp -p sys_config/a10/$i$lcd.fex $DESTDIR/uboot/boards/sun4i/$i
fex2bin sys_config/a10/$i$lcd.fex \
$DESTDIR/uboot/boards/sun4i/$i/script$lcd.bin
done
for i in $A13_BOARDS; do
if [ ! -f sys_config/a13/$i$lcd.fex ]; then
continue
fi
cp -p sys_config/a13/$i$lcd.fex $DESTDIR/uboot/boards/sun5i/$i
fex2bin sys_config/a13/$i$lcd.fex \
$DESTDIR/uboot/boards/sun5i/$i/script$lcd.bin
done
for i in $A10S_BOARDS; do
if [ ! -f sys_config/a10s/$i$lcd.fex ]; then
continue
fi
cp -p sys_config/a10s/$i$lcd.fex $DESTDIR/uboot/boards/sun5i/$i
fex2bin sys_config/a10s/$i$lcd.fex \
$DESTDIR/uboot/boards/sun5i/$i/script$lcd.bin
done
for i in $A20_BOARDS; do
if [ ! -f sys_config/a20/$i$lcd.fex ]; then
continue
fi
cp -p sys_config/a20/$i$lcd.fex $DESTDIR/uboot/boards/sun7i/$i
fex2bin sys_config/a20/$i$lcd.fex \
$DESTDIR/uboot/boards/sun7i/$i/script$lcd.bin
done
done
popd
pushd sunxi-kernel-config
[ -z "$NOCHECKOUT" ] && git checkout $KERNEL_CONFIG_TAG
[ -z "$NOCLEAN" ] && git clean -dxf
make VERSION=$KERNER_VER -f Makefile.config kernel-$KERNER_VER-armv7hl-sun4i.config
make VERSION=$KERNER_VER -f Makefile.config kernel-$KERNER_VER-armv7hl-sun5i.config
make VERSION=$KERNER_VER -f Makefile.config kernel-$KERNER_VER-armv7hl-sun7i.config
popd
pushd linux-sunxi
[ -z "$NOCHECKOUT" ] && git checkout $KERNEL_TAG
[ -z "$NOCLEAN" ] && git clean -dxf
mkdir -p sun4i sun5i sun7i
cp ../sunxi-kernel-config/kernel-$KERNER_VER-armv7hl-sun4i.config sun4i/.config
cp ../sunxi-kernel-config/kernel-$KERNER_VER-armv7hl-sun5i.config sun5i/.config
cp ../sunxi-kernel-config/kernel-$KERNER_VER-armv7hl-sun7i.config sun7i/.config
make O=sun4i ARCH=arm CROSS_COMPILE=arm-linux-gnu- CONFIG_DEBUG_SECTION_MISMATCH=y -j4 uImage modules
make O=sun5i ARCH=arm CROSS_COMPILE=arm-linux-gnu- CONFIG_DEBUG_SECTION_MISMATCH=y -j4 uImage modules
make O=sun7i ARCH=arm CROSS_COMPILE=arm-linux-gnu- CONFIG_DEBUG_SECTION_MISMATCH=y -j4 uImage modules
cp sun4i/arch/arm/boot/uImage $DESTDIR/uboot/uImage.sun4i
cp sun5i/arch/arm/boot/uImage $DESTDIR/uboot/uImage.sun5i
cp sun7i/arch/arm/boot/uImage $DESTDIR/uboot/uImage.sun7i
mkdir $DESTDIR/rootfs/usr
make O=sun4i ARCH=arm CROSS_COMPILE=arm-linux-gnu- CONFIG_DEBUG_SECTION_MISMATCH=y INSTALL_MOD_PATH=$DESTDIR/rootfs/usr modules_install
make O=sun5i ARCH=arm CROSS_COMPILE=arm-linux-gnu- CONFIG_DEBUG_SECTION_MISMATCH=y INSTALL_MOD_PATH=$DESTDIR/rootfs/usr modules_install
make O=sun7i ARCH=arm CROSS_COMPILE=arm-linux-gnu- CONFIG_DEBUG_SECTION_MISMATCH=y INSTALL_MOD_PATH=$DESTDIR/rootfs/usr modules_install
find $DESTDIR/rootfs/usr/lib/modules -name "*.ko" -exec arm-linux-gnu-strip --strip-debug '{}' \;
mkdir $DESTDIR/uboot/scripts
cp sun4i/.config $DESTDIR/uboot/scripts/kernel-$KERNER_VER-armv7hl-sun4i.config
cp sun5i/.config $DESTDIR/uboot/scripts/kernel-$KERNER_VER-armv7hl-sun5i.config
cp sun7i/.config $DESTDIR/uboot/scripts/kernel-$KERNER_VER-armv7hl-sun7i.config
popd
pushd sunxi-fedora-scripts
[ -z "$NOCHECKOUT" ] && git checkout $SCRIPTS_TAG
[ -z "$NOCLEAN" ] && git clean -dxf
../u-boot-sunxi/mele_a1000/tools/mkenvimage -s 131072 \
-o $DESTDIR/uboot/boards/uEnv-img.bin uEnv-full.txt
mkimage -C none -A arm -T script -d boot.cmd $DESTDIR/uboot/boot.scr
cp -p boot.cmd README select-board.sh $DESTDIR/uboot
cp -p uEnv-boot.txt $DESTDIR/uboot/uEnv.txt
cp -p build-boot-root.sh build-image.sh $DESTDIR/uboot/scripts
# Add F-18 rootfs-resize (+ patch for no initrd + hack for rhbz#974631)
mkdir -p $DESTDIR/rootfs/usr/sbin
mkdir -p $DESTDIR/rootfs/usr/lib/systemd/system
mkdir -p $DESTDIR/rootfs/etc/systemd/system/multi-user.target.wants
cp -p rootfs-resize $DESTDIR/rootfs/usr/sbin
cp -p rootfs-resize.service $DESTDIR/rootfs/usr/lib/systemd/system
ln -s /usr/lib/systemd/system/rootfs-resize.service \
$DESTDIR/rootfs/etc/systemd/system/multi-user.target.wants/rootfs-resize.service
touch $DESTDIR/rootfs/.rootfs-repartition
# Add rc.local
mkdir -p $DESTDIR/rootfs/etc/rc.d
cp -p rc.local $DESTDIR/rootfs/etc/rc.d
popd
echo
echo "Successfully build uboot and rootfs directories, packing ..."
pushd $DESTDIR/uboot
tar --group=root --owner=root -czf $DESTDIR/uboot.tar.gz *
popd
pushd $DESTDIR/rootfs
tar --group=root --owner=root -czf $DESTDIR/rootfs.tar.gz .rootfs-repartition *
popd
echo "Successfully generated uboot.tar.gz and rootfs.tar.gz"