~beagleboard-kernel/+junk/image-builder

16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
1
#!/bin/bash -e
145 by Robert Nelson
move to MIT/X11 license
2
#
3
# Copyright (c) 2009-2010 Robert Nelson <robertcnelson@gmail.com>
4
# Copyright (c) 2010 Mario Di Francesco <mdf-code@digitalexile.it>
5
#
6
# Permission is hereby granted, free of charge, to any person obtaining a copy
7
# of this software and associated documentation files (the "Software"), to deal
8
# in the Software without restriction, including without limitation the rights
9
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
# copies of the Software, and to permit persons to whom the Software is
11
# furnished to do so, subject to the following conditions:
12
#
13
# The above copyright notice and this permission notice shall be included in
14
# all copies or substantial portions of the Software.
15
#
16
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
# THE SOFTWARE.
23
#
24
# Latest can be found at:
25
# http://bazaar.launchpad.net/~beagleboard-kernel/%2Bjunk/image-builder/annotate/head:/tools/setup_sdcard.sh
139 by Robert Nelson
find latest
26
19 by Robert Nelson
user parted mklable to clear partition table
27
#Notes: need to check for: parted, fdisk, wget, mkfs.*, mkimage, md5sum
28
144 by Robert Nelson
add note for debug
29
#Debug Tips
30
#oem-config username/password
31
#add: "debug-oem-config" to bootargs
32
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
33
unset MMC
142 by Robert Nelson
work around early xM proto button bug
34
unset SWAP_BOOT_USER
159 by Robert Nelson
add workaround for broken oem-config, --use-default-user
35
unset DEFAULT_USER
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
36
27 by Robert Nelson
implement rootfs selections, default to ext3 if not used
37
#Defaults
135 by Robert Nelson
use ext4 as default, hide ext2 but still valid
38
RFS=ext4
28 by Robert Nelson
implement partition labeling
39
BOOT_LABEL=boot
40
RFS_LABEL=rootfs
69 by Robert Nelson
added /dev/mmcblk0[p] support from Mario Di Francesco
41
PARTITION_PREFIX=""
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
42
43
DIR=$PWD
44
74 by Robert Nelson
gui works...
45
function detect_software {
46
47
#Currently only Ubuntu and Debian..
111 by Robert Nelson
combine xm with normal beagle, check beaglerev variable in uboot
48
#Working on Fedora...
74 by Robert Nelson
gui works...
49
unset PACKAGE
50
unset APT
51
52
if [ ! $(which mkimage) ];then
53
 echo "Missing uboot-mkimage"
148 by Robert Nelson
sync with how i do this in other scripts
54
 PACKAGE="uboot-mkimage "
74 by Robert Nelson
gui works...
55
 APT=1
56
fi
57
58
if [ ! $(which wget) ];then
59
 echo "Missing wget"
148 by Robert Nelson
sync with how i do this in other scripts
60
 PACKAGE+="wget "
74 by Robert Nelson
gui works...
61
 APT=1
62
fi
63
64
if [ ! $(which pv) ];then
65
 echo "Missing pv"
148 by Robert Nelson
sync with how i do this in other scripts
66
 PACKAGE+="pv "
74 by Robert Nelson
gui works...
67
 APT=1
68
fi
69
70
if [ "${APT}" ];then
151 by Robert Nelson
misc spelling mistakes
71
 echo "Installing Dependencies"
74 by Robert Nelson
gui works...
72
 sudo aptitude install $PACKAGE
73
fi
74
}
75
136 by Robert Nelson
move beagle scripts out of xload function
76
function beagle_boot_scripts {
56 by Robert Nelson
lucid final
77
98 by Robert Nelson
generate script files on the fly
78
cat > /tmp/boot.cmd <<beagle_boot_cmd
111 by Robert Nelson
combine xm with normal beagle, check beaglerev variable in uboot
79
if test "\${beaglerev}" = "xMA"; then
80
echo "Kernel is not ready for 1Ghz limiting to 800Mhz"
81
setenv mpurate 800
82
fi
112 by Robert Nelson
seperate out dvimode
83
setenv dvimode 1280x720MR-16@60
84
setenv vram 12MB
98 by Robert Nelson
generate script files on the fly
85
setenv bootcmd 'mmc init; fatload mmc 0:1 0x80300000 uImage; fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80300000 0x81600000'
112 by Robert Nelson
seperate out dvimode
86
setenv bootargs console=ttyS2,115200n8 console=tty0 root=/dev/mmcblk0p2 rootwait ro vram=\${vram} omapfb.mode=dvi:\${dvimode} fixrtc buddy=\${buddy} mpurate=\${mpurate}
98 by Robert Nelson
generate script files on the fly
87
boot
88
89
beagle_boot_cmd
90
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
91
 if test "-$ADDON-" = "-pico-"
92
 then
93
94
cat > /tmp/boot.cmd <<beagle_pico_boot_cmd
111 by Robert Nelson
combine xm with normal beagle, check beaglerev variable in uboot
95
if test "\${beaglerev}" = "xMA"; then
96
echo "Kernel is not ready for 1Ghz limiting to 800Mhz"
97
setenv mpurate 800
98
fi
112 by Robert Nelson
seperate out dvimode
99
setenv dvimode 800x600MR-16@60
100
setenv vram 12MB
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
101
setenv bootcmd 'mmc init; fatload mmc 0:1 0x80300000 uImage; fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80300000 0x81600000'
112 by Robert Nelson
seperate out dvimode
102
setenv bootargs console=ttyS2,115200n8 console=tty0 root=/dev/mmcblk0p2 rootwait ro vram=\${vram} omapfb.mode=dvi:\${dvimode} fixrtc buddy=\${buddy} mpurate=\${mpurate}
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
103
boot
104
105
beagle_pico_boot_cmd
106
107
 fi
108
98 by Robert Nelson
generate script files on the fly
109
cat > /tmp/user.cmd <<beagle_user_cmd
111 by Robert Nelson
combine xm with normal beagle, check beaglerev variable in uboot
110
111
if test "\${beaglerev}" = "xMA"; then
141 by Robert Nelson
offical xMA user button works correctly
112
echo "xMA doesnt have NAND"
113
exit
111 by Robert Nelson
combine xm with normal beagle, check beaglerev variable in uboot
114
else
98 by Robert Nelson
generate script files on the fly
115
echo "Starting NAND UPGRADE, do not REMOVE SD CARD or POWER till Complete"
116
fatload mmc 0:1 0x80200000 MLO
117
nandecc hw
118
nand erase 0 80000
119
nand write 0x80200000 0 20000
120
nand write 0x80200000 20000 20000
121
nand write 0x80200000 40000 20000
122
nand write 0x80200000 60000 20000
123
124
fatload mmc 0:1 0x80300000 u-boot.bin
125
nandecc sw
126
nand erase 80000 160000
127
nand write 0x80300000 80000 160000
128
nand erase 260000 20000
129
echo "UPGRADE Complete, REMOVE SD CARD and DELETE this boot.scr"
130
exit
111 by Robert Nelson
combine xm with normal beagle, check beaglerev variable in uboot
131
fi
98 by Robert Nelson
generate script files on the fly
132
133
beagle_user_cmd
134
136 by Robert Nelson
move beagle scripts out of xload function
135
}
136
154 by Robert Nelson
add initial touchbook support, still working on a good mlo/uboot combo
137
function touchbook_boot_scripts {
138
139
cat > /tmp/boot.cmd <<touchbook_boot_cmd
140
setenv dvimode 1024x600MR-16@60
141
setenv vram 12MB
156 by Robert Nelson
touchbook can now use mmc init, use debug console for now
142
setenv bootcmd 'mmc init; fatload mmc 0:1 0x80300000 uImage; fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80300000 0x81600000'
157 by Robert Nelson
touchbook, no more needed debug console, also bump speed to 600mhz
143
setenv bootargs console=tty1 root=/dev/mmcblk0p2 rootwait ro vram=\${vram} omapfb.mode=dvi:\${dvimode} fixrtc mpurate=600
154 by Robert Nelson
add initial touchbook support, still working on a good mlo/uboot combo
144
boot
145
146
touchbook_boot_cmd
147
148
}
136 by Robert Nelson
move beagle scripts out of xload function
149
150
function dl_xload_uboot {
151
 sudo rm -rfd ${DIR}/deploy/ || true
152
 mkdir -p ${DIR}/deploy/
153
154
case "$SYSTEM" in
155
    beagle)
156
157
beagle_boot_scripts
158
56 by Robert Nelson
lucid final
159
 #beagle
59 by Robert Nelson
now less UBOOT version bumps
160
 MIRROR="http://rcn-ee.net/deb/"
56 by Robert Nelson
lucid final
161
30 by Robert Nelson
language tweaks and getting prepared for the RC
162
 echo ""
163
 echo "Downloading X-loader and Uboot"
164
 echo ""
165
65 by Robert Nelson
wrong dir
166
 rm -f ${DIR}/deploy/bootloader || true
59 by Robert Nelson
now less UBOOT version bumps
167
 wget -c --no-verbose --directory-prefix=${DIR}/deploy/ ${MIRROR}tools/latest/bootloader
168
65 by Robert Nelson
wrong dir
169
 MLO=$(cat ${DIR}/deploy/bootloader | grep "ABI:1 MLO" | awk '{print $3}')
170
 UBOOT=$(cat ${DIR}/deploy/bootloader | grep "ABI:1 UBOOT" | awk '{print $3}')
59 by Robert Nelson
now less UBOOT version bumps
171
172
 wget -c --no-verbose --directory-prefix=${DIR}/deploy/ ${MLO}
173
 wget -c --no-verbose --directory-prefix=${DIR}/deploy/ ${UBOOT}
174
175
 MLO=${MLO##*/}
176
 UBOOT=${UBOOT##*/}
177
134 by Robert Nelson
convert board if to case
178
        ;;
138 by Robert Nelson
add igepv2 support-ish
179
    igepv2)
180
181
 #MLO=${MLO##*/}
182
 #UBOOT=${UBOOT##*/}
183
 MLO=NA
184
 UBOOT=NA
154 by Robert Nelson
add initial touchbook support, still working on a good mlo/uboot combo
185
        ;;
186
    touchbook)
187
188
touchbook_boot_scripts
189
190
 MIRROR="http://rcn-ee.net/deb/"
191
192
 echo ""
193
 echo "Downloading X-loader and Uboot"
194
 echo ""
195
196
 rm -f ${DIR}/deploy/bootloader || true
197
 wget -c --no-verbose --directory-prefix=${DIR}/deploy/ ${MIRROR}tools/latest/bootloader
198
199
 MLO=$(cat ${DIR}/deploy/bootloader | grep "ABI:5 MLO" | awk '{print $3}')
200
 UBOOT=$(cat ${DIR}/deploy/bootloader | grep "ABI:5 UBOOT" | awk '{print $3}')
201
202
 wget -c --no-verbose --directory-prefix=${DIR}/deploy/ ${MLO}
203
 wget -c --no-verbose --directory-prefix=${DIR}/deploy/ ${UBOOT}
204
205
 MLO=${MLO##*/}
206
 UBOOT=${UBOOT##*/}
138 by Robert Nelson
add igepv2 support-ish
207
208
        ;;
134 by Robert Nelson
convert board if to case
209
    fairlane)
88 by Robert Nelson
add custom board
210
211
 MIRROR="http://rcn-ee.net/deb/"
212
213
 echo ""
214
 echo "Downloading X-loader and Uboot"
215
 echo ""
216
217
 rm -f ${DIR}/deploy/bootloader || true
218
 wget -c --no-verbose --directory-prefix=${DIR}/deploy/ ${MIRROR}tools/latest/bootloader
219
165 by Robert Nelson
fairlane updates
220
 MLO=$(cat ${DIR}/deploy/bootloader | grep "ABI:2 MLO" | awk '{print $3}')
221
 UBOOT=$(cat ${DIR}/deploy/bootloader | grep "ABI:2 UBOOT" | awk '{print $3}')
88 by Robert Nelson
add custom board
222
223
 wget -c --no-verbose --directory-prefix=${DIR}/deploy/ ${MLO}
224
 wget -c --no-verbose --directory-prefix=${DIR}/deploy/ ${UBOOT}
225
226
 MLO=${MLO##*/}
227
 UBOOT=${UBOOT##*/}
228
134 by Robert Nelson
convert board if to case
229
        ;;
230
esac
88 by Robert Nelson
add custom board
231
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
232
}
233
234
function cleanup_sd {
30 by Robert Nelson
language tweaks and getting prepared for the RC
235
236
 echo ""
151 by Robert Nelson
misc spelling mistakes
237
 echo "Unmountting Partitions"
30 by Robert Nelson
language tweaks and getting prepared for the RC
238
 echo ""
239
146 by Robert Nelson
remove number of partitions limitation on umount
240
 NUM_MOUNTS=$(mount | grep -v none | grep "$MMC" | wc -l)
241
242
 for (( c=1; c<=$NUM_MOUNTS; c++ ))
243
 do
244
  DRIVE=$(mount | grep -v none | grep "$MMC" | tail -1 | awk '{print $1}')
245
  sudo umount ${DRIVE} &> /dev/null || true
246
 done
28 by Robert Nelson
implement partition labeling
247
248
 sudo parted -s ${MMC} mklabel msdos
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
249
}
250
251
function create_partitions {
252
253
sudo fdisk -H 255 -S 63 ${MMC} << END
254
n
255
p
256
1
257
1
258
+64M
259
a
260
1
261
t
262
e
263
p
264
w
265
END
266
30 by Robert Nelson
language tweaks and getting prepared for the RC
267
echo ""
151 by Robert Nelson
misc spelling mistakes
268
echo "Formatting Boot Partition"
30 by Robert Nelson
language tweaks and getting prepared for the RC
269
echo ""
270
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
271
sudo mkfs.vfat -F 16 ${MMC}${PARTITION_PREFIX}1 -n ${BOOT_LABEL} &> ${DIR}/sd.log
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
272
34 by Robert Nelson
respining for karmic, changed last ./ to dirs
273
sudo rm -rfd ${DIR}/disk || true
274
275
mkdir ${DIR}/disk
69 by Robert Nelson
added /dev/mmcblk0[p] support from Mario Di Francesco
276
sudo mount ${MMC}${PARTITION_PREFIX}1 ${DIR}/disk
34 by Robert Nelson
respining for karmic, changed last ./ to dirs
277
56 by Robert Nelson
lucid final
278
if [ "$DO_UBOOT" ];then
137 by Robert Nelson
check if MLO and uboot exist
279
 if ls ${DIR}/deploy/${MLO} >/dev/null 2>&1;then
56 by Robert Nelson
lucid final
280
 sudo cp -v ${DIR}/deploy/${MLO} ${DIR}/disk/MLO
140 by Robert Nelson
make it easier to switch between dev boards
281
 rm -f ${DIR}/deploy/${MLO} || true
137 by Robert Nelson
check if MLO and uboot exist
282
 fi
283
284
 if ls ${DIR}/deploy/${UBOOT} >/dev/null 2>&1;then
56 by Robert Nelson
lucid final
285
 sudo cp -v ${DIR}/deploy/${UBOOT} ${DIR}/disk/u-boot.bin
140 by Robert Nelson
make it easier to switch between dev boards
286
 rm -f ${DIR}/deploy/${UBOOT} || true
137 by Robert Nelson
check if MLO and uboot exist
287
 fi
56 by Robert Nelson
lucid final
288
fi
34 by Robert Nelson
respining for karmic, changed last ./ to dirs
289
290
cd ${DIR}/disk
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
291
sync
69 by Robert Nelson
added /dev/mmcblk0[p] support from Mario Di Francesco
292
cd ${DIR}/
34 by Robert Nelson
respining for karmic, changed last ./ to dirs
293
sudo umount ${DIR}/disk || true
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
294
echo "done"
295
296
sudo fdisk ${MMC} << ROOTFS
297
n
298
p
299
2
300
301
302
p
303
w
304
ROOTFS
305
27 by Robert Nelson
implement rootfs selections, default to ext3 if not used
306
echo ""
30 by Robert Nelson
language tweaks and getting prepared for the RC
307
echo "Formating ${RFS} Partition"
27 by Robert Nelson
implement rootfs selections, default to ext3 if not used
308
echo ""
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
309
sudo mkfs.${RFS} ${MMC}${PARTITION_PREFIX}2 -L ${RFS_LABEL} &>> ${DIR}/sd.log
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
310
311
}
312
313
function populate_boot {
30 by Robert Nelson
language tweaks and getting prepared for the RC
314
 echo ""
315
 echo "Populating Boot Partition"
316
 echo ""
69 by Robert Nelson
added /dev/mmcblk0[p] support from Mario Di Francesco
317
 sudo mount ${MMC}${PARTITION_PREFIX}1 ${DIR}/disk
165 by Robert Nelson
fairlane updates
318
 echo "uImage"
34 by Robert Nelson
respining for karmic, changed last ./ to dirs
319
 sudo mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 -n "Linux" -d ${DIR}/vmlinuz-* ${DIR}/disk/uImage
165 by Robert Nelson
fairlane updates
320
 echo "uInitrd"
34 by Robert Nelson
respining for karmic, changed last ./ to dirs
321
 sudo mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 -n initramfs -d ${DIR}/initrd.img-* ${DIR}/disk/uInitrd
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
322
152 by Robert Nelson
for the other guys, non beagle uboots should now get an image
323
324
if [ "$DO_UBOOT" ];then
325
142 by Robert Nelson
work around early xM proto button bug
326
#Some boards, like my xM Prototype have the user button polarity reversed
327
#in that case user.scr gets loaded over boot.scr
328
if [ "$SWAP_BOOT_USER" ] ; then
329
 if ls /tmp/boot.cmd >/dev/null 2>&1;then
330
  sudo mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Boot Script" -d /tmp/boot.cmd ${DIR}/disk/user.scr
331
  sudo cp /tmp/boot.cmd ${DIR}/disk/user.cmd
332
  rm -f /tmp/user.cmd || true
333
 fi
334
fi
335
140 by Robert Nelson
make it easier to switch between dev boards
336
 if ls /tmp/boot.cmd >/dev/null 2>&1;then
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
337
 sudo mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Boot Script" -d /tmp/boot.cmd ${DIR}/disk/boot.scr
338
 sudo cp /tmp/boot.cmd ${DIR}/disk/boot.cmd
140 by Robert Nelson
make it easier to switch between dev boards
339
 rm -f /tmp/boot.cmd || true
340
 fi
341
342
 if ls /tmp/user.cmd >/dev/null 2>&1;then
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
343
 sudo mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Reset Nand" -d /tmp/user.cmd ${DIR}/disk/user.scr
111 by Robert Nelson
combine xm with normal beagle, check beaglerev variable in uboot
344
 sudo cp /tmp/user.cmd ${DIR}/disk/user.cmd
140 by Robert Nelson
make it easier to switch between dev boards
345
 rm -f /tmp/user.cmd || true
346
 fi
98 by Robert Nelson
generate script files on the fly
347
30 by Robert Nelson
language tweaks and getting prepared for the RC
348
 #for igepv2 users
165 by Robert Nelson
fairlane updates
349
 if ls ${DIR}/disk/boot.scr >/dev/null 2>&1;then
34 by Robert Nelson
respining for karmic, changed last ./ to dirs
350
 sudo cp -v ${DIR}/disk/boot.scr ${DIR}/disk/boot.ini
165 by Robert Nelson
fairlane updates
351
 fi
42 by Robert Nelson
add a couple sync calls to help make sure mmc card is correct
352
152 by Robert Nelson
for the other guys, non beagle uboots should now get an image
353
fi
354
97 by Robert Nelson
switch away from echo version
355
cat > /tmp/rebuild_uinitrd.sh <<rebuild_uinitrd
356
#!/bin/sh
357
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
358
cd /boot/uboot
359
sudo mount -o remount,rw /boot/uboot
97 by Robert Nelson
switch away from echo version
360
sudo update-initramfs -u -k \$(uname -r)
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
361
sudo mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 -n initramfs -d /boot/initrd.img-\$(uname -r) /boot/uboot/uInitrd
97 by Robert Nelson
switch away from echo version
362
363
rebuild_uinitrd
45 by Robert Nelson
add script to sd card for rebuilding uInitrd, not sure how to tie into ubuntu so it gets called when /boot/initrd.img-* is updated
364
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
365
cat > /tmp/boot_scripts.sh <<rebuild_scripts
366
#!/bin/sh
367
368
cd /boot/uboot
369
sudo mount -o remount,rw /boot/uboot
153 by Robert Nelson
boot scripts check for cmd file
370
if ls /boot/uboot/boot.cmd >/dev/null 2>&1;then
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
371
sudo mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Boot Script" -d /boot/uboot/boot.cmd /boot/uboot/boot.scr
153 by Robert Nelson
boot scripts check for cmd file
372
fi
111 by Robert Nelson
combine xm with normal beagle, check beaglerev variable in uboot
373
sudo cp /boot/uboot/boot.scr /boot/uboot/boot.ini
153 by Robert Nelson
boot scripts check for cmd file
374
if ls /boot/uboot/user.cmd >/dev/null 2>&1;then
111 by Robert Nelson
combine xm with normal beagle, check beaglerev variable in uboot
375
sudo mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Reset Nand" -d /boot/uboot/user.cmd /boot/uboot/user.scr
153 by Robert Nelson
boot scripts check for cmd file
376
fi
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
377
378
rebuild_scripts
379
380
cat > /tmp/fix_zippy2.sh <<fix_zippy2
381
#!/bin/sh
382
#based off a script from cwillu
383
#make sure to have a jumper on JP1 (write protect)
384
385
if sudo i2cdump -y 2 0x50 | grep "00: 00 01 00 01 01 00 00 00"; then
386
    sudo i2cset -y 2 0x50 0x03 0x02
387
fi
388
389
fix_zippy2
390
121 by Robert Nelson
add kernel upgrade script to base image
391
cat > /tmp/latest_kernel.sh <<latest_kernel
128 by Robert Nelson
force bash for this script
392
#!/bin/bash
121 by Robert Nelson
add kernel upgrade script to base image
393
DIST=\$(lsb_release -cs)
394
395
#enable testing
396
#TESTING=1
397
398
function run_upgrade {
399
400
 wget --no-verbose --directory-prefix=/tmp/ \${KERNEL_DL}
401
402
 if [ -f /tmp/install-me.sh ] ; then
403
  . /tmp/install-me.sh
404
 fi
405
406
}
407
128 by Robert Nelson
force bash for this script
408
function check_latest {
409
410
 if [ -f /tmp/LATEST ] ; then
411
  rm -f /tmp/LATEST &> /dev/null
412
 fi
121 by Robert Nelson
add kernel upgrade script to base image
413
414
 wget --no-verbose --directory-prefix=/tmp/ http://rcn-ee.net/deb/\${DIST}/LATEST
415
416
 KERNEL_DL=\$(cat /tmp/LATEST | grep "ABI:1 STABLE" | awk '{print \$3}')
417
418
 if [ "\$TESTING" ] ; then
419
  KERNEL_DL=\$(cat /tmp/LATEST | grep "ABI:1 TESTING" | awk '{print \$3}')
420
 fi
421
422
 KERNEL_DL_VER=\$(echo \${KERNEL_DL} | awk -F'/' '{print \$6}')
423
128 by Robert Nelson
force bash for this script
424
 CURRENT_KER="v\$(uname -r)"
121 by Robert Nelson
add kernel upgrade script to base image
425
426
 if [ \${CURRENT_KER} != \${KERNEL_DL_VER} ]; then
427
  run_upgrade
428
 fi
429
}
430
128 by Robert Nelson
force bash for this script
431
check_latest
121 by Robert Nelson
add kernel upgrade script to base image
432
433
latest_kernel
434
164 by Robert Nelson
chrome tweaks
435
cat > /tmp/minimal_xfce.sh <<basic_xfce
436
#!/bin/sh
437
438
sudo aptitude -y install xfce4 gdm xubuntu-gdm-theme xubuntu-artwork xserver-xorg-video-omap3
439
440
basic_xfce
441
162 by Robert Nelson
add chrome web browser
442
cat > /tmp/get_chrome.sh <<latest_chrome
443
#!/bin/sh
444
445
#setup libs
446
164 by Robert Nelson
chrome tweaks
447
sudo apt-get -y install libnss3-1d unzip libxss1
162 by Robert Nelson
add chrome web browser
448
449
sudo ln -sf /usr/lib/libsmime3.so /usr/lib/libsmime3.so.12
450
sudo ln -sf /usr/lib/libnssutil3.so /usr/lib/libnssutil3.so.12
451
sudo ln -sf /usr/lib/libnss3.so /usr/lib/libnss3.so.12
452
453
sudo ln -sf /usr/lib/libplds4.so /usr/lib/libplds4.so.8
454
sudo ln -sf /usr/lib/libplc4.so /usr/lib/libplc4.so.8
163 by Robert Nelson
too much copied
455
sudo ln -sf /usr/lib/libnspr4.so /usr/lib/libnspr4.so.8
162 by Robert Nelson
add chrome web browser
456
457
if [ -f /tmp/LATEST ] ; then
458
 rm -f /tmp/LATEST &> /dev/null
459
fi
460
461
if [ -f /tmp/chrome-linux.zip ] ; then
462
 rm -f /tmp/chrome-linux.zip &> /dev/null
463
fi
464
465
wget --no-verbose --directory-prefix=/tmp/ http://build.chromium.org/buildbot/snapshots/chromium-rel-arm/LATEST
466
467
CHROME_VER=\$(cat /tmp/LATEST)
468
469
wget --directory-prefix=/tmp/ http://build.chromium.org/buildbot/snapshots/chromium-rel-arm/\${CHROME_VER}/chrome-linux.zip
470
164 by Robert Nelson
chrome tweaks
471
sudo mkdir -p /opt/chrome-linux/
472
sudo chown -R \$USER:\$USER /opt/chrome-linux/
473
162 by Robert Nelson
add chrome web browser
474
if [ -f /tmp/chrome-linux.zip ] ; then
164 by Robert Nelson
chrome tweaks
475
 unzip -o /tmp/chrome-linux.zip -d /opt/
162 by Robert Nelson
add chrome web browser
476
fi
477
164 by Robert Nelson
chrome tweaks
478
cat > /tmp/chrome.desktop <<chrome_launcher
479
[Desktop Entry]
480
Version=1.0
481
Type=Application
482
Encoding=UTF-8
483
Exec=/opt/chrome-linux/chrome %u
484
Icon=web-browser
485
StartupNotify=false
486
Terminal=false
487
Categories=X-XFCE;X-Xfce-Toplevel;
488
OnlyShowIn=XFCE;
489
Name=Chromium
490
491
chrome_launcher
492
493
sudo mv /tmp/chrome.desktop /usr/share/applications/chrome.desktop
494
162 by Robert Nelson
add chrome web browser
495
latest_chrome
496
169 by Robert Nelson
add dsp stuff to setup_sdcard
497
cat > /tmp/gst-dsp.sh <<gst_dsp
498
#!/bin/sh
499
500
sudo apt-get -y install git-core pkg-config build-essential gstreamer-tools libgstreamer0.10-dev
501
502
git clone git://github.com/felipec/gst-dsp.git
503
cd gst-dsp
504
make CROSS_COMPILE= 
505
sudo make install
506
507
cd ..
508
509
gst_dsp
510
511
cat > /tmp/gst-omapfb.sh <<gst_omapfb
512
#!/bin/sh
513
514
git clone git://github.com/felipec/gst-omapfb.git
515
cd gst-omapfb
516
make CROSS_COMPILE= 
517
sudo make install
518
cd ..
519
520
gst_omapfb
521
522
 sudo mkdir -p ${DIR}/disk/tools/dsp
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
523
 sudo cp -v /tmp/rebuild_uinitrd.sh ${DIR}/disk/tools/rebuild_uinitrd.sh
524
 sudo chmod +x ${DIR}/disk/tools/rebuild_uinitrd.sh
525
526
 sudo cp -v /tmp/boot_scripts.sh ${DIR}/disk/tools/boot_scripts.sh
527
 sudo chmod +x ${DIR}/disk/tools/boot_scripts.sh
528
529
 sudo cp -v /tmp/fix_zippy2.sh ${DIR}/disk/tools/fix_zippy2.sh
530
 sudo chmod +x ${DIR}/disk/tools/fix_zippy2.sh
45 by Robert Nelson
add script to sd card for rebuilding uInitrd, not sure how to tie into ubuntu so it gets called when /boot/initrd.img-* is updated
531
121 by Robert Nelson
add kernel upgrade script to base image
532
 sudo cp -v /tmp/latest_kernel.sh ${DIR}/disk/tools/latest_kernel.sh
533
 sudo chmod +x ${DIR}/disk/tools/latest_kernel.sh
534
164 by Robert Nelson
chrome tweaks
535
 sudo cp -v /tmp/minimal_xfce.sh ${DIR}/disk/tools/minimal_xfce.sh
536
 sudo chmod +x ${DIR}/disk/tools/minimal_xfce.sh
537
162 by Robert Nelson
add chrome web browser
538
 sudo cp -v /tmp/get_chrome.sh ${DIR}/disk/tools/get_chrome.sh
539
 sudo chmod +x ${DIR}/disk/tools/get_chrome.sh
540
169 by Robert Nelson
add dsp stuff to setup_sdcard
541
 sudo cp -v /tmp/gst-dsp.sh  ${DIR}/disk/tools/dsp/gst-dsp.sh
542
 sudo chmod +x ${DIR}/disk/tools/dsp/gst-dsp.sh
543
544
 sudo cp -v /tmp/gst-omapfb.sh ${DIR}/disk/tools/dsp/gst-omapfb.sh
545
 sudo chmod +x ${DIR}/disk/tools/dsp/gst-omapfb.sh
546
42 by Robert Nelson
add a couple sync calls to help make sure mmc card is correct
547
 cd ${DIR}/disk/
548
 sync
549
 sync
550
 cd ${DIR}/
551
34 by Robert Nelson
respining for karmic, changed last ./ to dirs
552
 sudo umount ${DIR}/disk || true
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
553
}
554
555
function populate_rootfs {
29 by Robert Nelson
implement swap file creation
556
 echo ""
557
 echo "Populating rootfs Partition"
558
 echo "Be patient, this may take a few minutes"
559
 echo ""
69 by Robert Nelson
added /dev/mmcblk0[p] support from Mario Di Francesco
560
 sudo mount ${MMC}${PARTITION_PREFIX}2 ${DIR}/disk
29 by Robert Nelson
implement swap file creation
561
131 by Robert Nelson
support normal rootstock images too
562
 if ls ${DIR}/armel-rootfs-*.tgz >/dev/null 2>&1;then
563
   pv ${DIR}/armel-rootfs-*.tgz | sudo tar xzfp - -C ${DIR}/disk/
564
 fi
565
566
 if ls ${DIR}/armel-rootfs-*.tar >/dev/null 2>&1;then
567
   pv ${DIR}/armel-rootfs-*.tar | sudo tar xfp - -C ${DIR}/disk/
568
 fi
29 by Robert Nelson
implement swap file creation
569
159 by Robert Nelson
add workaround for broken oem-config, --use-default-user
570
if [ "$DEFAULT_USER" ] ; then
571
 sudo rm -f ${DIR}/disk/var/lib/oem-config/run || true
572
fi
573
29 by Robert Nelson
implement swap file creation
574
 if [ "$CREATE_SWAP" ] ; then
30 by Robert Nelson
language tweaks and getting prepared for the RC
575
576
  echo ""
577
  echo "Creating SWAP File"
578
  echo ""
579
69 by Robert Nelson
added /dev/mmcblk0[p] support from Mario Di Francesco
580
  SPACE_LEFT=$(df ${DIR}/disk/ | grep ${MMC}${PARTITION_PREFIX}2 | awk '{print $4}')
29 by Robert Nelson
implement swap file creation
581
582
  let SIZE=$SWAP_SIZE*1024
583
584
  if [ $SPACE_LEFT -ge $SIZE ] ; then
34 by Robert Nelson
respining for karmic, changed last ./ to dirs
585
   sudo dd if=/dev/zero of=${DIR}/disk/mnt/SWAP.swap bs=1M count=$SWAP_SIZE
586
   sudo mkswap ${DIR}/disk/mnt/SWAP.swap
587
   echo "/mnt/SWAP.swap  none  swap  sw  0 0" | sudo tee -a ${DIR}/disk/etc/fstab
29 by Robert Nelson
implement swap file creation
588
   else
589
   echo "FIXME Recovery after user selects SWAP file bigger then whats left not implemented"
590
  fi
591
 fi
30 by Robert Nelson
language tweaks and getting prepared for the RC
592
42 by Robert Nelson
add a couple sync calls to help make sure mmc card is correct
593
 cd ${DIR}/disk/
594
 sync
595
 sync
596
 cd ${DIR}/
597
34 by Robert Nelson
respining for karmic, changed last ./ to dirs
598
 sudo umount ${DIR}/disk || true
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
599
}
600
25 by Robert Nelson
quiet wget, move disk check to function
601
function check_mmc {
133 by Robert Nelson
use LC_ALL=C to solve localization issues, recommended by Loïc Minier
602
 FDISK=$(sudo LC_ALL=C sfdisk -l 2>/dev/null | grep "[Disk] ${MMC}" | awk '{print $2}')
25 by Robert Nelson
quiet wget, move disk check to function
603
26 by Robert Nelson
fixed disk check, now correctly finds valid disks and exits when not found
604
 if test "-$FDISK-" = "-$MMC:-"
605
 then
25 by Robert Nelson
quiet wget, move disk check to function
606
  echo ""
30 by Robert Nelson
language tweaks and getting prepared for the RC
607
  echo "I see..."
133 by Robert Nelson
use LC_ALL=C to solve localization issues, recommended by Loïc Minier
608
  echo "sudo sfdisk -l:"
609
  sudo LC_ALL=C sfdisk -l 2>/dev/null | grep "[Disk] /dev/" --color=never
25 by Robert Nelson
quiet wget, move disk check to function
610
  echo ""
30 by Robert Nelson
language tweaks and getting prepared for the RC
611
  echo "mount:"
25 by Robert Nelson
quiet wget, move disk check to function
612
  mount | grep -v none | grep "/dev/" --color=never
613
  echo ""
30 by Robert Nelson
language tweaks and getting prepared for the RC
614
  read -p "Are you 100% sure, on selecting [${MMC}] (y/n)? "
25 by Robert Nelson
quiet wget, move disk check to function
615
  [ "$REPLY" == "y" ] || exit
26 by Robert Nelson
fixed disk check, now correctly finds valid disks and exits when not found
616
  echo ""
25 by Robert Nelson
quiet wget, move disk check to function
617
 else
618
  echo ""
619
  echo "Are you sure? I Don't see [${MMC}], here is what I do see..."
620
  echo ""
133 by Robert Nelson
use LC_ALL=C to solve localization issues, recommended by Loïc Minier
621
  echo "sudo sfdisk -l:"
622
  sudo LC_ALL=C sfdisk -l 2>/dev/null | grep "[Disk] /dev/" --color=never
25 by Robert Nelson
quiet wget, move disk check to function
623
  echo ""
30 by Robert Nelson
language tweaks and getting prepared for the RC
624
  echo "mount:"
25 by Robert Nelson
quiet wget, move disk check to function
625
  mount | grep -v none | grep "/dev/" --color=never
626
  echo ""
627
  exit
628
 fi
629
}
630
56 by Robert Nelson
lucid final
631
function check_uboot_type {
632
 IN_VALID_UBOOT=1
633
 unset DO_UBOOT
634
138 by Robert Nelson
add igepv2 support-ish
635
case "$UBOOT_TYPE" in
636
    beagle)
637
56 by Robert Nelson
lucid final
638
 SYSTEM=beagle
639
 unset IN_VALID_UBOOT
640
 DO_UBOOT=1
138 by Robert Nelson
add igepv2 support-ish
641
642
        ;;
142 by Robert Nelson
work around early xM proto button bug
643
    beagle-proto)
644
#hidden: proto button bug
645
646
 SYSTEM=beagle
647
 SWAP_BOOT_USER=1
648
 unset IN_VALID_UBOOT
649
 DO_UBOOT=1
650
651
        ;;
138 by Robert Nelson
add igepv2 support-ish
652
    igepv2)
653
654
 SYSTEM=igepv2
655
 unset IN_VALID_UBOOT
656
 DO_UBOOT=1
657
658
        ;;
154 by Robert Nelson
add initial touchbook support, still working on a good mlo/uboot combo
659
    touchbook)
660
661
 SYSTEM=touchbook
662
 unset IN_VALID_UBOOT
663
 DO_UBOOT=1
664
665
        ;;
138 by Robert Nelson
add igepv2 support-ish
666
    fairlane)
142 by Robert Nelson
work around early xM proto button bug
667
#hidden: unreleased
138 by Robert Nelson
add igepv2 support-ish
668
88 by Robert Nelson
add custom board
669
 SYSTEM=fairlane
670
 unset IN_VALID_UBOOT
671
 DO_UBOOT=1
138 by Robert Nelson
add igepv2 support-ish
672
673
        ;;
674
esac
88 by Robert Nelson
add custom board
675
56 by Robert Nelson
lucid final
676
 if [ "$IN_VALID_UBOOT" ] ; then
677
   usage
678
 fi
679
}
680
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
681
function check_addon_type {
682
 IN_VALID_ADDON=1
683
684
 if test "-$ADDON_TYPE-" = "-pico-"
685
 then
686
 ADDON=pico
687
 unset IN_VALID_ADDON
688
 fi
689
690
 if [ "$IN_VALID_ADDON" ] ; then
691
   usage
692
 fi
693
}
694
695
27 by Robert Nelson
implement rootfs selections, default to ext3 if not used
696
function check_fs_type {
697
 IN_VALID_FS=1
698
138 by Robert Nelson
add igepv2 support-ish
699
case "$FS_TYPE" in
700
    ext2)
701
27 by Robert Nelson
implement rootfs selections, default to ext3 if not used
702
 RFS=ext2
703
 unset IN_VALID_FS
138 by Robert Nelson
add igepv2 support-ish
704
705
        ;;
706
    ext3)
707
27 by Robert Nelson
implement rootfs selections, default to ext3 if not used
708
 RFS=ext3
709
 unset IN_VALID_FS
138 by Robert Nelson
add igepv2 support-ish
710
711
        ;;
712
    ext4)
713
27 by Robert Nelson
implement rootfs selections, default to ext3 if not used
714
 RFS=ext4
715
 unset IN_VALID_FS
716
138 by Robert Nelson
add igepv2 support-ish
717
        ;;
718
    btrfs)
86 by Robert Nelson
btrfs fixes
719
720
  if [ ! $(which mkfs.btrfs) ];then
721
   echo "Missing btrfs tools"
722
   sudo aptitude install btrfs-tools
723
  fi
724
27 by Robert Nelson
implement rootfs selections, default to ext3 if not used
725
 RFS=btrfs
726
 unset IN_VALID_FS
138 by Robert Nelson
add igepv2 support-ish
727
728
        ;;
729
esac
27 by Robert Nelson
implement rootfs selections, default to ext3 if not used
730
731
 if [ "$IN_VALID_FS" ] ; then
732
   usage
733
 fi
734
}
735
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
736
function usage {
159 by Robert Nelson
add workaround for broken oem-config, --use-default-user
737
    echo "usage: $(basename $0) --mmc /dev/sdX --uboot <dev board> --swap_file <50Mb mininum>"
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
738
cat <<EOF
739
740
required options:
741
--mmc </dev/sdX>
742
    Unformated MMC Card
743
27 by Robert Nelson
implement rootfs selections, default to ext3 if not used
744
Additional/Optional options:
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
745
-h --help
746
    this help
747
56 by Robert Nelson
lucid final
748
--uboot <dev board>
111 by Robert Nelson
combine xm with normal beagle, check beaglerev variable in uboot
749
    beagle - <Bx, C2/C3/C4, xMA>
159 by Robert Nelson
add workaround for broken oem-config, --use-default-user
750
    igepv2 - <no u-boot or MLO yet>
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
751
752
--addon <device>
753
    pico
56 by Robert Nelson
lucid final
754
159 by Robert Nelson
add workaround for broken oem-config, --use-default-user
755
--use-default-user
756
    (useful for serial only modes and when oem-config is broken)
757
27 by Robert Nelson
implement rootfs selections, default to ext3 if not used
758
--rootfs <fs_type>
135 by Robert Nelson
use ext4 as default, hide ext2 but still valid
759
    ext3
760
    ext4 - <set as default>
27 by Robert Nelson
implement rootfs selections, default to ext3 if not used
761
    btrfs
762
28 by Robert Nelson
implement partition labeling
763
--boot_label <boot_label>
764
    boot partition label
765
766
--rfs_label <rfs_label>
767
    rootfs partition label
768
29 by Robert Nelson
implement swap file creation
769
--swap_file <xxx>
770
    Creats a Swap file of (xxx)MB's
771
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
772
EOF
24 by Robert Nelson
use exit
773
exit
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
774
}
775
776
function checkparm {
777
    if [ "$(echo $1|grep ^'\-')" ];then
778
        echo "E: Need an argument"
779
        usage
780
    fi
781
}
782
783
# parse commandline options
784
while [ ! -z "$1" ]; do
785
    case $1 in
786
        -h|--help)
787
            usage
788
            MMC=1
789
            ;;
790
        --mmc)
791
            checkparm $2
792
            MMC="$2"
69 by Robert Nelson
added /dev/mmcblk0[p] support from Mario Di Francesco
793
	    if [[ "${MMC}" =~ "mmcblk" ]]
794
            then
795
	        PARTITION_PREFIX="p"
796
            fi
25 by Robert Nelson
quiet wget, move disk check to function
797
            check_mmc 
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
798
            ;;
56 by Robert Nelson
lucid final
799
        --uboot)
800
            checkparm $2
801
            UBOOT_TYPE="$2"
802
            check_uboot_type 
803
            ;;
107 by Robert Nelson
lots of little things getting ready for 10.04.1 and 10.10 alpha 3
804
        --addon)
805
            checkparm $2
806
            ADDON_TYPE="$2"
807
            check_addon_type 
808
            ;;
27 by Robert Nelson
implement rootfs selections, default to ext3 if not used
809
        --rootfs)
810
            checkparm $2
811
            FS_TYPE="$2"
812
            check_fs_type 
813
            ;;
159 by Robert Nelson
add workaround for broken oem-config, --use-default-user
814
        --use-default-user)
815
            DEFAULT_USER=1
816
            ;;
28 by Robert Nelson
implement partition labeling
817
        --boot_label)
818
            checkparm $2
819
            BOOT_LABEL="$2"
820
            ;;
821
        --rfs_label)
822
            checkparm $2
823
            RFS_LABEL="$2"
824
            ;;
29 by Robert Nelson
implement swap file creation
825
        --swap_file)
826
            checkparm $2
827
            SWAP_SIZE="$2"
828
            CREATE_SWAP=1
829
            ;;
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
830
    esac
831
    shift
832
done
833
834
if [ ! "${MMC}" ];then
835
    usage
836
fi
837
74 by Robert Nelson
gui works...
838
 detect_software
839
56 by Robert Nelson
lucid final
840
if [ "$DO_UBOOT" ];then
39 by Robert Nelson
remove md5sum check, till after lucid
841
 dl_xload_uboot
56 by Robert Nelson
lucid final
842
fi
39 by Robert Nelson
remove md5sum check, till after lucid
843
 cleanup_sd
844
 create_partitions
845
 populate_boot
846
 populate_rootfs
16 by Robert Nelson
ubuntu-lucid-beta2-minimal-armel here we go, if all succeeds this will be the commit of the upload
847
848