#!/bin/sh # raspi-boot.SlackBuild # Boot firmware for Raspberry Pi # # Copyright 2012 David Spencer, Baildon, West Yorkshire, U.K. # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #------------------------------------------------------------------------------ # # Before you run this SlackBuild you must get a tarball of the firmware # from the raspberrypi's github repository: # a script is here to help that (if you haven't already run it through # the get_needed_files.sh in the main folder) # # sh get_firmware.sh # sh get_userland.sh (not needed ATM) # #------------------------------------------------------------------------------ PRGNAM=raspi-boot VERSION=${VERSION:-$(date '+%Y%m%d')} BUILD=${BUILD:-1} TAG=${TAG:-} ARCH=arm CWD=$(pwd) TMP=${TMP:-/tmp} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} set -e rm -rf $PKG mkdir -p $PKG GITREV=${GITREV:-$(echo raspberrypi-firmware-*.tar.gz | sed -e "s|raspberrypi-firmware-||" -e "s|\.tar\.gz||")} echo "Uncompressing the firmware silently to avoid spamming the console too much." echo "It can take a while..." echo "tar xf raspberrypi-firmware-$GITREV.tar.gz" tar xf raspberrypi-firmware-$GITREV.tar.gz mv raspberrypi-firmware-$GITREV firmware cd $CWD/firmware/boot chown -R root:root * ../opt ../documentation chmod 644 * mkdir -p $PKG/boot cp -a \ bootcode.bin fixup*.dat start*.elf LICENCE.broadcom COPYING.linux \ $PKG/boot zcat $CWD/README.initrd.gz > $PKG/boot/README.initrd zcat $CWD/README.boot.gz > $PKG/boot/README # The default memory allocation for the OS and GPU is set here # (or by pasing it as an environment variable). # GPUMEM preferred values are 16 or 64 or 128. # The operating system will get the rest of memory, i.e. 256-$GPUMEM Mb. # We use the 16Mb version by default (upstream has 64Mb by default, but this # seems pointless until accelerated video works). # You can also edit this later in /boot/config.txt. GPUMEM=${GPUMEM:-16} # There is now a documented 'safe mode', so we'll include upstream's prebuilt # 'emergency kernel' with its built-in busybox. # To boot it, add a jumper on pins 5 and 6 of P1. cp -a \ kernel_emergency.img \ $PKG/boot/ # Install config.txt as .new even though it's not in /etc sed "s|@GPUMEM@|$GPUMEM|" $CWD/config.txt > $PKG/boot/config.txt.new # Install the proprietary parts in $PKG/opt cp -a ../opt $PKG/opt mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION cp -a \ LICENCE.broadcom COPYING.linux ../documentation/ilcomponents \ $PKG/usr/doc/$PRGNAM-$VERSION/ mv $PKG/opt/vc/LICENCE $PKG/usr/doc/$PRGNAM-$VERSION/LICENCE.vc # Add version stamp into /boot and /usr/doc echo "Package: $PRGNAM-$VERSION-$ARCH-$BUILD$TAG" \ > $PKG/boot/version-$PRGNAM.txt echo "Build date: $(date -u '+%F %T')" \ >> $PKG/boot/version-$PRGNAM.txt echo "Git revision: $GITREV" \ >> $PKG/boot/version-$PRGNAM.txt cp \ $PKG/boot/version-$PRGNAM.txt \ $PKG/usr/doc/$PRGNAM-$VERSION/version.txt ## Install the userland libs cd $CWD GITREV=$(echo raspberrypi-userland-*.tar.gz | sed -e "s|raspberrypi-userland-||" -e "s|\.tar\.gz||") mkdir -p $TMP/$PRGNAM cd $TMP/$PRGNAM tar xf $CWD/raspberrypi-userland-$GITREV.tar.gz chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ -exec chmod 755 {} \; -o \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; mkdir -p raspberrypi-userland-$GITREV/build/arm-linux/release cd raspberrypi-userland-$GITREV/build/arm-linux/release # The build try to crosscompile for hardfloat by default, but we don't need it sed -e "s|arm-linux-gnueabihf-||" \ -e "s|\ -mfloat-abi=hard| -O2 -march=armv6zk -mfpu=vfp -mfloat-abi=hard|" \ ../../../makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake > \ ../../../makefiles/cmake/toolchains/armv6hl-slackware-linux-gnueabi.cmake cmake -DCMAKE_TOOLCHAIN_FILE=../../../makefiles/cmake/toolchains/armv6hl-slackware-linux-gnueabi.cmake \ -DCMAKE_INSTALL_PREFIX=/opt/vc -DCMAKE_BUILD_TYPE=Release ../../.. make make install DESTDIR=$PKG mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc cat $CWD/doinst.sh > $PKG/install/doinst.sh cd $PKG /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}