diff options
author | Timo Teräs <timo.teras@iki.fi> | 2016-07-29 14:47:56 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2016-07-29 12:04:17 +0000 |
commit | 29342e7fec72ee44bc0f12c0fad15f2daf3e91fb (patch) | |
tree | f5c1aac27621fc0a06ea822ff86ea74f2bf97109 | |
parent | a600a036424adc98d633178efe8289adb411df24 (diff) | |
download | aports-29342e7fec72ee44bc0f12c0fad15f2daf3e91fb.tar.bz2 aports-29342e7fec72ee44bc0f12c0fad15f2daf3e91fb.tar.xz |
main/u-boot: add update-u-boot script for upgrading bootloader
-rw-r--r-- | main/u-boot/APKBUILD | 45 | ||||
-rwxr-xr-x | main/u-boot/update-u-boot | 115 |
2 files changed, 144 insertions, 16 deletions
diff --git a/main/u-boot/APKBUILD b/main/u-boot/APKBUILD index e8eb64560a..a14c76fd39 100644 --- a/main/u-boot/APKBUILD +++ b/main/u-boot/APKBUILD @@ -3,8 +3,8 @@ # Maintainer: Leonardo Arena <rnalrd@alpinelinux.org> pkgname=u-boot pkgver=2016.07 -pkgrel=1 -pkgdesc="Bootloader for ARM" +pkgrel=2 +pkgdesc="u-boot bootloader common files" url="http://www.denx.de/wiki/U-Boot/" arch="armhf" license="GPL2" @@ -12,9 +12,9 @@ depends="" depends_dev="" makedepends="$depends_dev bc dtc" install="" -subpackages="" source="ftp://ftp.denx.de/pub/u-boot/u-boot-${pkgver//_/-}.tar.bz2 README.txt + update-u-boot " _srcdir="$srcdir"/u-boot-${pkgver//_/-} @@ -27,10 +27,11 @@ board_configs=" wandboard:wandboard " +local allboards="" for board_config in $board_configs; do - subpackages="$subpackages $pkgname-${board_config%%:*}" + allboards="$allboards $pkgname-${board_config%%:*}" done -depends="$subpackages" +subpackages="$pkgname-all $allboards" build() { cd "$_srcdir" @@ -53,14 +54,22 @@ build() { package() { cd "$builddir" - mkdir -p "$pkgdir"/usr/share/$pkgname - install "$srcdir"/README.txt "$pkgdir"/usr/share/$pkgname/README.txt + mkdir -p "$pkgdir"/usr/share/$pkgname "$pkgdir"/usr/sbin + install "$srcdir"/README.txt "$pkgdir"/usr/share/$pkgname/README.txt || return 1 + install "$srcdir"/update-u-boot "$pkgdir"/usr/sbin || return 1 +} + +all() { + pkgdesc="u-boot for all boards (meta package)" + depends="$allboards" + + mkdir -p "$subpkgdir"/ } _split_boards() { cd "$builddir" pkgdesc="u-boot for $1" - depends="" + depends="u-boot" shift local board for board; do @@ -68,17 +77,18 @@ _split_boards() { mkdir -p "$subpkgdir"/usr/share/$pkgname/$board export BUILD_DIR="$builddir"/$board local ok=no - for image in MLO SPL u-boot.img u-boot-sunxi-with-spl.bin; do + for image in u-boot-sunxi-with-spl.bin -- MLO SPL u-boot.img -- u-boot.bin; do + if [ "$image" = "--" ]; then + [ "$ok" = yes ] && break + continue + fi if [ -e "$BUILD_DIR"/$image ]; then cp "$BUILD_DIR"/$image "$subpkgdir"/usr/share/$pkgname/$board \ || return 1 ok=yes fi done - if [ "$ok" = "no" ]; then - cp "$BUILD_DIR"/u-boot.bin "$subpkgdir"/usr/share/$pkgname/$board \ - || return 1 - fi + [ "$ok" = yes ] || return 1 done } @@ -89,8 +99,11 @@ for board_config in $board_configs; do done md5sums="425a3fa610a7d972e5092a0e92276c70 u-boot-2016.07.tar.bz2 -13684d0a2495da42144e1805fc5492d1 README.txt" +13684d0a2495da42144e1805fc5492d1 README.txt +c863032a8a2cd94b3ab9b837a640edfc update-u-boot" sha256sums="974fb7225c0af6a721307631f66b81e20dbda82a4d7cc32aba2a625727231253 u-boot-2016.07.tar.bz2 -80538ab8339bf84b8e3cfe8eb1cab9cb5d25bbecc6ba45824fb83e868df9160e README.txt" +80538ab8339bf84b8e3cfe8eb1cab9cb5d25bbecc6ba45824fb83e868df9160e README.txt +af8cef011c90dd44385a6105aee16f900fbf37c021841c927483e9d402aaab5c update-u-boot" sha512sums="fa76dbd7e654ff9e4b3166162be6c0a77ecf2eb2a952b4865df3c818ebcdca7e2bb75e5ba19bf0346000c3d185888552193bb74510b115426cfe444b78efd3ef u-boot-2016.07.tar.bz2 -f8c9bb6e84d6f0620c976ac7ad5dd7ec7ff9dfdd4b1d03d2bf6653e7beccf80bdf2debfc92fb1f696dba92fb40287d3c45897e0078951451d0835cb61a5f16d1 README.txt" +f8c9bb6e84d6f0620c976ac7ad5dd7ec7ff9dfdd4b1d03d2bf6653e7beccf80bdf2debfc92fb1f696dba92fb40287d3c45897e0078951451d0835cb61a5f16d1 README.txt +d57796ce018afa15e12521a90761ab1ae6411acf1fc0c1ce95f0d48630e0949568d8a7e577ba52d91c56918a9d414951c608aa49389ac7f8b50cb8aba5da9697 update-u-boot" diff --git a/main/u-boot/update-u-boot b/main/u-boot/update-u-boot new file mode 100755 index 0000000000..069d654755 --- /dev/null +++ b/main/u-boot/update-u-boot @@ -0,0 +1,115 @@ +#!/bin/sh + +verbose= +board= +device= +dryrun= +imagedir= + +get_defaults() { + if [ -z "$board" -a -e /sys/firmware/devicetree/base/compatible ]; then + case "$(cat /sys/firmware/devicetree/base/compatible 2>/dev/null)" in + wand,*) board=wand ;; + esac + fi + + if [ -z "$device" ]; then + case "$board" in + wand|cubie|cubie2) device=/dev/mmcblk0p0 ;; + esac + fi + + if [ -z "$imagedir" ]; then + imagedir="$(realpath $(dirname $0))" + [ -f "$imagedir/README.txt" ] || imagedir="/usr/share/u-boot" + fi +} + +die() { + echo "ERROR: $@" + exit 1 +} + +usage() { + get_defaults + + cat <<EOF +usage: $0 [-b|--board <board-type>] [-d|--device <device>] + +options: + + -b,--board <board> Specify the board type: wand, cubie, cubie2 + (current default: ${board:-none}) + + -d,--device <device> Specify the device where to install u-boot + (current default: ${device:-none}) + + -i,--imagedir <imagedir> Specify u-boot image directory + (current default: ${imagedir:-none}) + + -n,--dry-run Print commands but don't execute them + +EOF +} + +while [ $# -gt 0 ]; do + opt="$1" + shift + case "$opt" in + -b|--board) + case "$1" in + wand|wandboard) board="wand" ;; + cubie|cubieboard) board="cubie" ;; + *) usage; exit 1;; + esac + shift + ;; + -d|--device) + device="$1" + shift + ;; + -i|--imagedir) + imagedir="$1" + shift + ;; + -n|--dry-run) + dryrun="echo" + ;; + --) + break + ;; + -*) + usage + exit 1 + ;; + esac +done + +get_defaults +if [ -z "$board" -o -z "$device" -o -z "$imagedir" -o ! -e "$imagedir" ]; then + usage + exit 1 +fi + +if [ -z "$dryrun" ]; then + echo "Updating $board u-boot in $device in 3 seconds..." + sleep 3 +fi + +( +set -e +case "$board" in +wand) + [ -e "$imagedir/wandboard" ] || die "wandboard images not installed, apk add u-boot-wandboard" + $dryrun dd if=$imagedir/wandboard/SPL of=$device bs=1k seek=1 status=none + $dryrun dd if=$imagedir/wandboard/u-boot.img of=$device bs=1k seek=69 status=none + ;; +cubie|cubie2) + [ -e "$imagedir/Cubieboard${board#cubie}" ] || die "Cubieboard images not installed, apk add u-boot-cubieboard" + $dryrun dd if=$imagedir/Cubieboard${board#cubie}/u-boot-sunxi-with-spl.bin of=/dev/sda bs=1024 seek=8 status=none + ;; +esac +$dryrun sync +) || die "U-Boot installation in $device failed" + +[ -z "$dryrun" ] && echo "Completed successfully." |