Merge pull request #3209 from jenkins101/cuboxi-boot

u-boot: bootwork
This commit is contained in:
Stephan Raue 2014-05-16 16:42:00 +02:00
commit d2ccda669d
5 changed files with 309 additions and 21 deletions

View File

@ -0,0 +1,270 @@
#!/bin/sh
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
#
# OpenELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# OpenELEC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
# usage: sudo ./create_sdcard <drive>
# example: sudo ./create_sdcard /dev/sdb
# loop example: sudo ./create_sdcard /dev/loop0 ~/vSD.img
# create an empty image file for use with loop device like this:
# dd if=/dev/zero of=~/vSD.img bs=1M count=910
if [ "$(id -u)" != "0" ]; then
clear
echo "#########################################################"
echo "# please execute with 'sudo' or -DANGEROUS!!!- as root #"
echo "# example: sudo ./create_sdcard <drive> #"
echo "#########################################################"
exit 1
fi
if [ -z "$1" ]; then
clear
echo "#########################################################"
echo "# please execute with your drive as option #"
echo "# example: sudo ./create_sdcard /dev/sdb #"
echo "# or: sudo ./create_sdcard /dev/mmcblk0 #"
echo "# or: sudo ./create_sdcard /dev/loop0 ~/vSD.img #"
echo "# to create an image file for /dev/loop0 option: #"
echo "# sudo dd if=/dev/zero of=~/vSD.img bs=1M count=910 #"
echo "#########################################################"
exit 1
fi
DISK="$1"
case $DISK in
"/dev/mmcblk"*)
PART1="${DISK}p1"
PART2="${DISK}p2"
;;
"/dev/loop"*)
PART1="${DISK}p1"
PART2="${DISK}p2"
IMGFILE="$2"
losetup $DISK $IMGFILE
;;
*)
PART1="${DISK}1"
PART2="${DISK}2"
;;
esac
clear
echo "#########################################################"
echo "# #"
echo "# OpenELEC.tv USB Installer #"
echo "# #"
echo "#########################################################"
echo "# #"
echo "# This will wipe any data off your chosen drive #"
echo "# Please read the instructions and use very carefully.. #"
echo "# #"
echo "#########################################################"
# check for some required tools
# this is needed to partion the drive
which parted > /dev/null
if [ "$?" = "1" ]; then
clear
echo "#########################################################"
echo "# #"
echo "# OpenELEC.tv missing tool - Installation will quit #"
echo "# #"
echo "# We can't find the required tool \"parted\" #"
echo "# on your system. #"
echo "# Please install it via your package manager. #"
echo "# #"
echo "#########################################################"
exit 1
fi
# this is needed to format the drive
which mkfs.vfat > /dev/null
if [ "$?" = "1" ]; then
clear
echo "#########################################################"
echo "# #"
echo "# OpenELEC.tv missing tool - Installation will quit #"
echo "# #"
echo "# We can't find the required tool \"mkfs.vfat\" #"
echo "# on your system. #"
echo "# Please install it via your package manager. #"
echo "# #"
echo "#########################################################"
exit 1
fi
# this is needed to format the drive
which mkfs.ext4 > /dev/null
if [ "$?" = "1" ]; then
clear
echo "#########################################################"
echo "# #"
echo "# OpenELEC.tv missing tool - Installation will quit #"
echo "# #"
echo "# We can't find the required tool \"mkfs.ext4\" #"
echo "# on your system. #"
echo "# Please install it via your package manager. #"
echo "# #"
echo "#########################################################"
exit 1
fi
# this is needed to tell the kernel for partition changes
which partprobe > /dev/null
if [ "$?" = "1" ]; then
clear
echo "#########################################################"
echo "# #"
echo "# OpenELEC.tv missing tool - Installation will quit #"
echo "# #"
echo "# We can't find the required tool \"partprobe\" #"
echo "# on your system. #"
echo "# Please install it via your package manager. #"
echo "# #"
echo "#########################################################"
exit 1
fi
# this is needed to tell the kernel for partition changes
which md5sum > /dev/null
if [ "$?" = "1" ]; then
clear
echo "#########################################################"
echo "# #"
echo "# OpenELEC.tv missing tool - Installation will quit #"
echo "# #"
echo "# We can't find the required tool \"md5sum\" #"
echo "# on your system. #"
echo "# Please install it via your package manager. #"
echo "# #"
echo "#########################################################"
exit 1
fi
# check MD5 sums
echo "checking MD5 sum..."
md5sumFailed()
{
clear
echo "#########################################################"
echo "# #"
echo "# OpenELEC.tv failed md5 check - Installation will quit #"
echo "# #"
echo "# Your original download was probably corrupt. #"
echo "# Please visit www.openelec.tv and get another copy #"
echo "# #"
echo "#########################################################"
exit 1
}
md5sum -c target/KERNEL.md5
if [ "$?" = "1" ]; then
md5sumFailed
fi
md5sum -c target/SYSTEM.md5
if [ "$?" = "1" ]; then
md5sumFailed
fi
# (TODO) umount everything (if more than one partition)
umount ${DISK}*
# remove all partitions from the drive
echo "writing new disklabel on $DISK (removing all partitions)..."
parted -s "$DISK" mklabel msdos
# create a single partition
echo "creating partitions on $DISK..."
parted -s "$DISK" unit cyl mkpart primary fat32 -- 0 16
# align the partition on 4mb boundary, starting at 132mb (132 % 4 == 0), which
# is right after the first partition
parted -s "$DISK" mkpart primary ext2 -- 132MiB -2cyl
# make partition active (bootable)
echo "marking partition active..."
parted -s "$DISK" set 1 boot on
# tell kernel we have a new partition table
echo "telling kernel we have a new partition table..."
partprobe "$DISK"
# create filesystem
echo "creating filesystem on $PART1..."
mkfs.vfat "$PART1" -I -n System
# create ext4 partition with optimized settings for running on flash/sd
# See http://blogofterje.wordpress.com/2012/01/14/optimizing-fs-on-sd-card/ for reference.
echo "creating filesystem on $PART2..."
mkfs.ext4 -O ^has_journal -E stride=2,stripe-width=1024 -b 4096 "$PART2" -L Storage
# remount loopback device
if [ "$DISK" = "/dev/loop0" ]; then
sync
losetup -d $DISK
losetup $DISK $IMGFILE -o 1048576 --sizelimit 131071488
PART1=$DISK
fi
# mount partition
echo "mounting partition $PART1 ..."
rm -rf /tmp/openelec_install
mkdir -p /tmp/openelec_install
mount -t vfat "$PART1" /tmp/openelec_install
MOUNTPOINT=/tmp/openelec_install
# install u-boot image, u-boot.imx if new u-boot. else SPL
echo "installing the bootloader..."
if [ -e "3rdparty/bootloader/u-boot.imx" ] ;then
dd if=3rdparty/bootloader/u-boot.imx of="$DISK" bs=1k seek=1 conv=fsync
elif [ -e "3rdparty/bootloader/SPL" ];then
dd if=3rdparty/bootloader/SPL of="$DISK" bs=1k seek=1 conv=fsync
else
echo "ERROR: no bootloader image found!! please execute in archive folder"
fi
# copy files
echo "copying files to $MOUNTPOINT..."
cp target/KERNEL $MOUNTPOINT
cp target/SYSTEM $MOUNTPOINT
cp 3rdparty/bootloader/* $MOUNTPOINT
cp openelec.ico $MOUNTPOINT
cp README.md $MOUNTPOINT
# sync disk
echo "syncing disk..."
sync
# unmount partition
echo "unmounting partition $MOUNTPOINT ..."
umount $MOUNTPOINT
# cleaning
echo "cleaning tempdir..."
rmdir $MOUNTPOINT
# unmount loopback device
if [ "$DISK" = "/dev/loop0" ]; then
losetup -d $DISK
fi
echo "...installation finished"

View File

@ -81,29 +81,26 @@ makeinstall_target() {
fi
mkdir -p $INSTALL/usr/share/bootloader
cp ./u-boot.bin $INSTALL/usr/share/bootloader
if [ -f "./u-boot.imx" ]; then
cp ./u-boot.imx $INSTALL/usr/share/bootloader
fi
if [ -f "./u-boot.img" ]; then
cp ./u-boot.img $INSTALL/usr/share/bootloader
fi
if [ -f "./MLO" ]; then
cp ./MLO $INSTALL/usr/share/bootloader
fi
if [ -f "./SPL" ]; then
cp ./SPL $INSTALL/usr/share/bootloader
fi
if [ -f "./boot.cfg" ]; then
cp ./boot.cfg $INSTALL/usr/share/bootloader
fi
if [ -f "./$UBOOT_CONFIGFILE" ]; then
cp ./$UBOOT_CONFIGFILE $INSTALL/usr/share/bootloader
fi
for config in $PROJECT_DIR/$PROJECT/bootloader/*; do
cp -PR $config $INSTALL/usr/share/bootloader
done
cp -PRv $PKG_DIR/scripts/update.sh $INSTALL/usr/share/bootloader
if [ -f "$PROJECT_DIR/$PROJECT/bootloader/uEnv.txt" ]; then
cp -PR $PROJECT_DIR/$PROJECT/bootloader/uEnv.txt $INSTALL/usr/share/bootloader
fi
}

View File

@ -25,14 +25,22 @@ if [ -z "$UBOOT_CONFIGFILE" ]; then
fi
mkdir -p $RELEASE_DIR/3rdparty/bootloader
cp -PR $BUILD/u-boot-*/$UBOOT_CONFIGFILE $RELEASE_DIR/3rdparty/bootloader
cp -PR $BUILD/u-boot-*/SPL $RELEASE_DIR/3rdparty/bootloader
if [ -e $BUILD/u-boot-*/$UBOOT_CONFIGFILE ] ;then
cp -PR $BUILD/u-boot-*/$UBOOT_CONFIGFILE $RELEASE_DIR/3rdparty/bootloader
fi
if [ -e $BUILD/u-boot-*/SPL ] ;then
cp -PR $BUILD/u-boot-*/SPL $RELEASE_DIR/3rdparty/bootloader
elif [ -e $BUILD/u-boot-*/u-boot.imx ] ;then
cp -PR $BUILD/u-boot-*/u-boot.imx $RELEASE_DIR/3rdparty/bootloader
fi
cp -PR $BUILD/u-boot-*/u-boot.img $RELEASE_DIR/3rdparty/bootloader
for dtb in $BUILD/linux-*/arch/arm/boot/dts/*.dtb; do
cp -PR $dtb $RELEASE_DIR/3rdparty/bootloader
done
for config in $PROJECT_DIR/$PROJECT/bootloader/*; do
cp -PR $config $RELEASE_DIR/3rdparty/bootloader
done
if [ -f "$PROJECT_DIR/$PROJECT/bootloader/uEnv.txt" ]; then
cp -PR $PROJECT_DIR/$PROJECT/bootloader/uEnv.txt $RELEASE_DIR/3rdparty/bootloader
fi

View File

@ -19,6 +19,7 @@
################################################################################
[ -z "$BOOT_ROOT" ] && BOOT_ROOT="/flash"
[ -z "$BOOT_DISK" ] && BOOT_DISK=$(df "$BOOT_ROOT" |tail -1 |awk {' print $1 '})
[ -z "$SYSTEM_ROOT" ] && SYSTEM_ROOT=""
# mount $BOOT_ROOT r/w
@ -34,7 +35,22 @@
done
# update bootloader files
# todo
if [ -f $SYSTEM_ROOT/usr/share/bootloader/u-boot.img ]; then
echo "*** updating u-boot image: $BOOT_ROOT/u-boot.img ..."
cp -p $SYSTEM_ROOT/usr/share/bootloader/u-boot.img $BOOT_ROOT
fi
if [ -f $SYSTEM_ROOT/usr/share/bootloader/SPL ]; then
echo "*** updating u-boot SPL Blob on: $DISK ..."
dd if="$SYSTEM_ROOT/usr/share/bootloader/SPL" of="$BOOT_DISK" bs=1k seek=1 conv=fsync
fi
# prefer uEnv.txt over boot.scr
if [ -f $SYSTEM_ROOT/usr/share/bootloader/uEnv.txt ]; then
cp -p $SYSTEM_ROOT/usr/share/bootloader/uEnv.txt $BOOT_ROOT
elif [ -f $SYSTEM_ROOT/usr/share/bootloader/boot.scr ]; then
cp -p $SYSTEM_ROOT/usr/share/bootloader/boot.scr $BOOT_ROOT
fi
# mount $BOOT_ROOT r/o
sync

View File

@ -1,3 +0,0 @@
setenv bootargs 'boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 debugging quiet video=mxcfb0:dev=hdmi,1920x1080M@60,if=RGB24,bpp=32 dmfc=3'
fatload mmc 0:1 0x10800000 /KERNEL
bootz 0x10800000