|
@@ -31,228 +31,47 @@ PROJECT_NAME='freedombone'
|
31
|
31
|
export TEXTDOMAIN=${PROJECT_NAME}-image-hardware-setup
|
32
|
32
|
export TEXTDOMAINDIR="/usr/share/locale"
|
33
|
33
|
|
34
|
|
-enable_serial_console() {
|
35
|
|
- # By default, spawn a console on the serial port
|
36
|
|
- device="$1"
|
37
|
|
- echo $"Adding a getty on the serial port"
|
38
|
|
- echo "T0:12345:respawn:/sbin/getty -L $device 115200 vt100" >> /etc/inittab
|
39
|
|
-}
|
40
|
|
-
|
41
|
|
-beaglebone_setup_boot() {
|
42
|
|
- bbb_version=$1
|
43
|
|
-
|
44
|
|
- # Setup uEnv.txt
|
45
|
|
- if grep -q btrfs /etc/fstab ; then
|
46
|
|
- fstype=btrfs
|
47
|
|
- else
|
48
|
|
- fstype=ext4
|
49
|
|
- fi
|
50
|
|
- if [ ! $bbb_version ]; then
|
51
|
|
- kernelVersion=$(ls /usr/lib/*/am335x-boneblack.dtb | head -1 | cut -d/ -f4)
|
52
|
|
- else
|
53
|
|
- kernelVersion=$(ls /usr/lib/*/am335x-boneblack-${1}.dtb | head -1 | cut -d/ -f4)
|
54
|
|
- fi
|
55
|
|
- version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
|
56
|
|
- initRd=initrd.img-$version
|
57
|
|
- vmlinuz=vmlinuz-$version
|
58
|
|
-
|
59
|
|
- bbb_loadaddr='0x80200000'
|
60
|
|
- bbb_initrd_addr='0x81000000'
|
61
|
|
- bbb_fdtaddr='0x80F80000'
|
62
|
|
- if [[ "$bbb_version" == "wireless" ]]; then
|
63
|
|
- bbb_loadaddr='0x82000000'
|
64
|
|
- bbb_initrd_addr='0x88080000'
|
65
|
|
- bbb_fdtaddr='0x88000000'
|
66
|
|
- fi
|
67
|
|
-
|
68
|
|
- # uEnv.txt for Beaglebone
|
69
|
|
- # based on https://github.com/beagleboard/image-builder/blob/master/target/boot/beagleboard.org.txt
|
70
|
|
- cat >> /boot/uEnv.txt <<EOF
|
71
|
|
-mmcroot=/dev/mmcblk0p2 ro
|
72
|
|
-mmcrootfstype=$fstype rootwait fixrtc
|
73
|
|
-mmcrootflags=subvol=@
|
74
|
|
-
|
75
|
|
-console=ttyO0,115200n8
|
76
|
|
-
|
77
|
|
-kernel_file=$vmlinuz
|
78
|
|
-initrd_file=$initRd
|
79
|
|
-
|
80
|
|
-loadaddr=$bbb_loadaddr
|
81
|
|
-initrd_addr=$bbb_initrd_addr
|
82
|
|
-fdtaddr=$bbb_fdtaddr
|
83
|
|
-
|
84
|
|
-initrd_high=0xffffffff
|
85
|
|
-fdt_high=0xffffffff
|
86
|
|
-
|
87
|
|
-loadkernel=load mmc \${mmcdev}:\${mmcpart} \${loadaddr} \${kernel_file}
|
88
|
|
-loadinitrd=load mmc \${mmcdev}:\${mmcpart} \${initrd_addr} \${initrd_file}; setenv initrd_size \${filesize}
|
89
|
|
-loadfdt=load mmc \${mmcdev}:\${mmcpart} \${fdtaddr} /dtbs/\${fdtfile}
|
90
|
|
-
|
91
|
|
-loadfiles=run loadkernel; run loadinitrd; run loadfdt
|
92
|
|
-mmcargs=setenv bootargs console=tty0 console=\${console} root=\${mmcroot} rootfstype=\${mmcrootfstype} rootflags=\${mmcrootflags}
|
93
|
|
-
|
94
|
|
-uenvcmd=run loadfiles; run mmcargs; bootz \${loadaddr} \${initrd_addr}:\${initrd_size} \${fdtaddr}
|
95
|
|
-EOF
|
96
|
|
-
|
97
|
|
- mkdir -p /boot/dtbs
|
98
|
|
- cp /usr/lib/linux-image-*-armmp/* /boot/dtbs
|
99
|
|
-}
|
100
|
|
-
|
101
|
|
-beaglebone_flash() {
|
102
|
|
- # allow flash-kernel to work without valid /proc contents
|
103
|
|
- # ** this doesn't *really* work, since there are too many checks
|
104
|
|
- # that fail in an emulated environment! We'll have to do it by
|
105
|
|
- # hand below anyway...
|
106
|
|
- export FK_MACHINE="TI AM335x BeagleBone"
|
107
|
|
- apt-get install -y flash-kernel
|
108
|
|
-}
|
109
|
|
-
|
110
|
|
-beaglebone_repack_kernel() {
|
111
|
|
- bbb_version=$1
|
112
|
|
- # process installed kernel to create uImage, uInitrd, dtb
|
113
|
|
- # using flash-kernel would be a good approach, except it fails in the
|
114
|
|
- # cross build environment due to too many environment checks...
|
115
|
|
- #FK_MACHINE="TI AM335x BeagleBone" flash-kernel
|
116
|
|
- # so, let's do it manually...
|
117
|
|
-
|
118
|
|
- # flash-kernel's hook-functions provided to mkinitramfs have the
|
119
|
|
- # unfortunate side-effect of creating /conf/param.conf in the initrd
|
120
|
|
- # when run from our emulated chroot environment, which means our root=
|
121
|
|
- # on the kernel command line is completely ignored! repack the initrd
|
122
|
|
- # to remove this evil...
|
123
|
|
-
|
124
|
|
- echo "info: repacking beaglebone kernel and initrd"
|
125
|
|
-
|
126
|
|
- if [ ! $bbb_version ]; then
|
127
|
|
- kernelVersion=$(ls /usr/lib/*/am335x-boneblack.dtb | head -1 | cut -d/ -f4)
|
128
|
|
- else
|
129
|
|
- kernelVersion=$(ls /usr/lib/*/am335x-boneblack-${1}.dtb | head -1 | cut -d/ -f4)
|
|
34
|
+setup_flash_kernel() {
|
|
35
|
+ if [ ! -d /etc/flash-kernel ] ; then
|
|
36
|
+ mkdir /etc/flash-kernel
|
130
|
37
|
fi
|
131
|
|
- version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
|
132
|
|
- initRd=initrd.img-$version
|
133
|
|
- vmlinuz=vmlinuz-$version
|
134
|
|
-
|
135
|
|
- mkdir /tmp/initrd-repack
|
136
|
|
-
|
137
|
|
- (cd /tmp/initrd-repack ; \
|
138
|
|
- zcat /boot/$initRd | cpio -i ; \
|
139
|
|
- rm -f conf/param.conf ; \
|
140
|
|
- find . | cpio --quiet -o -H newc | \
|
141
|
|
- gzip -9 > /boot/$initRd )
|
|
38
|
+ echo -n "$1" > /etc/flash-kernel/machine
|
142
|
39
|
|
143
|
|
- rm -rf /tmp/initrd-repack
|
144
|
|
-
|
145
|
|
- if [ ! $bbb_version ]; then
|
146
|
|
- (cd /boot ; \
|
147
|
|
- cp /usr/lib/$kernelVersion/am335x-boneblack.dtb dtb ; \
|
148
|
|
- cat $vmlinuz dtb >> temp-kernel ; \
|
149
|
|
- mkimage -A arm -O linux -T kernel -n "Debian kernel ${version}" \
|
150
|
|
- -C none -a 0x80200000 -e 0x80200000 -d temp-kernel uImage ; \
|
151
|
|
- rm -f temp-kernel ; \
|
152
|
|
- mkimage -A arm -O linux -T ramdisk -C gzip -a 0x81000000 -e 0x81000000 \
|
153
|
|
- -n "Debian ramdisk ${version}" \
|
154
|
|
- -d $initRd uInitrd )
|
155
|
|
- else
|
156
|
|
- (cd /boot ; \
|
157
|
|
- cp /usr/lib/$kernelVersion/am335x-boneblack-${bbb_version}.dtb dtb ; \
|
158
|
|
- cat $vmlinuz dtb >> temp-kernel ; \
|
159
|
|
- mkimage -A arm -O linux -T kernel -n "Debian kernel ${version}" \
|
160
|
|
- -C none -a 0x82000000 -e 0x82000000 -d temp-kernel uImage ; \
|
161
|
|
- rm -f temp-kernel ; \
|
162
|
|
- mkimage -A arm -O linux -T ramdisk -C gzip -a 0x88080000 -e 0x88080000 \
|
163
|
|
- -n "Debian ramdisk ${version}" \
|
164
|
|
- -d $initRd uInitrd )
|
|
40
|
+ command_line=""
|
|
41
|
+ if [ -n "$2" ] ; then
|
|
42
|
+ command_line="console=$2"
|
165
|
43
|
fi
|
166
|
|
-}
|
167
|
|
-
|
168
|
|
-a20_setup_boot() {
|
169
|
|
- dtb="$1"
|
170
|
44
|
|
171
|
|
- # Setup boot.cmd
|
172
|
|
- if grep -q btrfs /etc/fstab ; then
|
173
|
|
- fstype=btrfs
|
174
|
|
- else
|
175
|
|
- fstype=ext4
|
|
45
|
+ if [ -n "$command_line" ] ; then
|
|
46
|
+ echo flash-kernel flash-kernel/linux_cmdline string "$command_line" | debconf-set-selections
|
176
|
47
|
fi
|
177
|
|
- kernelVersion=$(ls /usr/lib/*/$dtb | head -1 | cut -d/ -f4)
|
178
|
|
- version=$(echo $kernelVersion | sed 's/linux-image-\(.*\)/\1/')
|
179
|
|
- initRd=initrd.img-$version
|
180
|
|
- vmlinuz=vmlinuz-$version
|
181
|
|
-
|
182
|
|
- # Create boot.cmd
|
183
|
|
- cat >> /boot/boot.cmd <<EOF
|
184
|
|
-setenv mmcdev 0
|
185
|
|
-setenv mmcpart 1
|
186
|
|
-
|
187
|
|
-setenv mmcroot /dev/mmcblk0p2 ro
|
188
|
|
-setenv mmcrootfstype $fstype rootwait fixrtc
|
189
|
|
-setenv mmcrootflags subvol=@
|
190
|
48
|
|
191
|
|
-setenv console ttyS0,115200n8
|
192
|
|
-
|
193
|
|
-setenv kernel_file $vmlinuz
|
194
|
|
-setenv initrd_file $initRd
|
195
|
|
-setenv fdtfile $dtb
|
196
|
|
-
|
197
|
|
-setenv loadaddr 0x46000000
|
198
|
|
-setenv initrd_addr 0x48000000
|
199
|
|
-setenv fdtaddr 0x47000000
|
200
|
|
-
|
201
|
|
-setenv initrd_high 0xffffffff
|
202
|
|
-setenv fdt_high 0xffffffff
|
203
|
|
-
|
204
|
|
-setenv loadkernel load mmc \${mmcdev}:\${mmcpart} \${loadaddr} \${kernel_file}
|
205
|
|
-setenv loadinitrd load mmc \${mmcdev}:\${mmcpart} \${initrd_addr} \${initrd_file}\\; setenv initrd_size \\\${filesize}
|
206
|
|
-setenv loadfdt load mmc \${mmcdev}:\${mmcpart} \${fdtaddr} /dtbs/\${fdtfile}
|
207
|
|
-
|
208
|
|
-setenv loadfiles run loadkernel\\; run loadinitrd\\; run loadfdt
|
209
|
|
-setenv mmcargs setenv bootargs console=\${console} root=\${mmcroot} rootfstype=\${mmcrootfstype} rootflags=\${mmcrootflags}
|
210
|
|
-
|
211
|
|
-run loadfiles; run mmcargs; bootz \${loadaddr} \${initrd_addr}:\${initrd_size} \${fdtaddr}
|
212
|
|
-EOF
|
213
|
|
-
|
214
|
|
- # boot.scr for Allwinner A20 based device
|
215
|
|
- mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
|
216
|
|
-
|
217
|
|
- # Copy all DTBs
|
218
|
|
- mkdir -p /boot/dtbs
|
219
|
|
- cp /usr/lib/$kernelVersion/* /boot/dtbs
|
220
|
|
-
|
221
|
|
- # extra boot modules
|
222
|
|
- echo "rtc_sunxi" >> /etc/initramfs-tools/modules
|
|
49
|
+ apt-get -yq install flash-kernel
|
223
|
50
|
}
|
224
|
51
|
|
225
|
52
|
case "$MACHINE" in
|
226
|
53
|
beaglebone)
|
227
|
|
- beaglebone_setup_boot
|
228
|
|
- #beaglebone_flash
|
229
|
|
- #beaglebone_repack_kernel
|
230
|
|
- enable_serial_console ttyO0
|
|
54
|
+ setup_flash_kernel 'TI AM335x BeagleBone Black' 'ttyO0'
|
231
|
55
|
;;
|
232
|
56
|
beaglebonewifi)
|
233
|
|
- beaglebone_setup_boot wireless
|
234
|
|
- #beaglebone_flash
|
235
|
|
- #beaglebone_repack_kernel wireless
|
236
|
|
- enable_serial_console ttyO0
|
|
57
|
+ setup_flash_kernel 'TI AM335x BeagleBone Black Wireless' 'ttyO0'
|
237
|
58
|
;;
|
238
|
59
|
cubietruck)
|
239
|
|
- a20_setup_boot sun7i-a20-cubietruck.dtb
|
240
|
|
- enable_serial_console ttyS0
|
|
60
|
+ setup_flash_kernel 'Cubietech Cubietruck'
|
241
|
61
|
;;
|
242
|
62
|
a20-olinuxino-lime)
|
243
|
|
- a20_setup_boot sun7i-a20-olinuxino-lime.dtb
|
244
|
|
- enable_serial_console ttyS0
|
|
63
|
+ setup_flash_kernel 'Olimex A20-OLinuXino-LIME'
|
245
|
64
|
;;
|
246
|
65
|
a20-olinuxino-lime2)
|
247
|
|
- a20_setup_boot sun7i-a20-olinuxino-lime2.dtb
|
248
|
|
- enable_serial_console ttyS0
|
|
66
|
+ setup_flash_kernel 'Olimex A20-OLinuXino-LIME2'
|
249
|
67
|
;;
|
250
|
68
|
a20-olinuxino-micro)
|
251
|
|
- a20_setup_boot sun7i-a20-olinuxino-micro.dtb
|
252
|
|
- enable_serial_console ttyS0
|
|
69
|
+ setup_flash_kernel 'Olimex A20-Olinuxino Micro'
|
253
|
70
|
;;
|
254
|
71
|
cubieboard2)
|
255
|
|
- a20_setup_boot sun7i-a20-cubieboard2.dtb
|
256
|
|
- enable_serial_console ttyS0
|
|
72
|
+ setup_flash_kernel 'Cubietech Cubieboard2'
|
|
73
|
+ ;;
|
|
74
|
+ pcduino3)
|
|
75
|
+ setup_flash_kernel 'LinkSprite pcDuino3'
|
257
|
76
|
;;
|
258
|
77
|
esac
|