diff --git a/board/common/overlay-initramfs/init b/board/common/overlay-initramfs/init index 0346014bfe..0316595994 100755 --- a/board/common/overlay-initramfs/init +++ b/board/common/overlay-initramfs/init @@ -41,6 +41,11 @@ trap on_exit EXIT msg "Waiting for sdcard" sleep 2 +if [ -x /prepare_initramfs ]; then + msg "Preparing initramfs" + /prepare_initramfs +fi + msg "Mounting pseudo filesystems" mount -t devtmpfs devtmpfs /dev mount -t proc proc /proc diff --git a/board/common/overlay/sbin/fwupdate b/board/common/overlay/sbin/fwupdate index f9bcd4e7de..ba1ce32651 100755 --- a/board/common/overlay/sbin/fwupdate +++ b/board/common/overlay/sbin/fwupdate @@ -230,7 +230,13 @@ function flash_boot() { wait $pid mount -o rw /boot - restore_boot_$board $FW_DIR/old_boot 2>/dev/null || true + + # the /usr/libexec/fw-restore-boot-cfg script, if present, takes the old (backup) boot dir as argument + # and should restore any /boot configuration that needs to be preserved across updates + # from the old boot dir to the current (new) /boot dir + if [ -x /usr/libexec/fw-restore-boot-cfg ]; then + /usr/libexec/fw-restore-boot-cfg $FW_DIR/old_boot 2>/dev/null || true + fi touch $FW_DIR/$BOOT_READY_FILE } @@ -257,19 +263,6 @@ function flash_cleanup() { mount /boot 2>/dev/null } -function restore_boot_raspberrypi() { - old_boot=$1 - cp $old_boot/config.txt /boot -} - -function restore_boot_raspberrypi2() { - restore_boot_raspberrypi -} - -function restore_boot_raspberrypi3() { - restore_boot_raspberrypi -} - #### flash reboot #### @@ -278,8 +271,13 @@ function flash_reboot() { board=$(cat $SYS_BOARD_FILE) + # the /usr/libexec/fw-prepare-boot script should be present and should + # make the necessary changes to the current boot configuration so that + # the firmware update initramfs will be used by the next boot mount -o remount,rw /boot - prepare_boot_$board + if [ -x /usr/libexec/fw-prepare-boot ]; then + /usr/libexec/fw-prepare-boot + fi sync busybox reboot & @@ -289,18 +287,6 @@ function flash_reboot() { exit 0 } -function prepare_boot_raspberrypi() { - echo "initramfs fwupdater.gz" >> /boot/config.txt -} - -function prepare_boot_raspberrypi2() { - prepare_boot_raspberrypi -} - -function prepare_boot_raspberrypi3() { - prepare_boot_raspberrypi -} - #### status #### diff --git a/board/odroidc1/boot.ini b/board/odroidc1/boot.ini index 857a09eb53..c886753268 100644 --- a/board/odroidc1/boot.ini +++ b/board/odroidc1/boot.ini @@ -51,6 +51,7 @@ setenv bootargs "console=ttyS0,115200n8 root=/dev/mmcblk0p2 rootwait ro no_conso # Booting fatload mmc 0:1 0x21000000 uImage +fatload mmc 0:1 0x22000000 uInitrd fatload mmc 0:1 0x21800000 meson8b_odroidc.dtb fdt addr 21800000 diff --git a/board/odroidc1/overlay-initramfs/prepare_initramfs b/board/odroidc1/overlay-initramfs/prepare_initramfs new file mode 100755 index 0000000000..1a0194ad6d --- /dev/null +++ b/board/odroidc1/overlay-initramfs/prepare_initramfs @@ -0,0 +1,7 @@ +#!/bin/sh + +# we don't have the codepage kernel modules compiled in, so we have to manually insert them +mkdir /system +mount /dev/mmcblk0p2 /system +/system/bin/busybox insmod /system/lib/modules/*/kernel/fs/nls/nls_cp437.ko + diff --git a/board/odroidc1/overlay-initramfs/remove_initramfs b/board/odroidc1/overlay-initramfs/remove_initramfs new file mode 100755 index 0000000000..ab6eeb2354 --- /dev/null +++ b/board/odroidc1/overlay-initramfs/remove_initramfs @@ -0,0 +1,4 @@ +#!/bin/sh + +sed -i 's/00 0x22000000 0x/00 - 0x/' /boot/boot.ini + diff --git a/board/odroidc1/postscript.sh b/board/odroidc1/postscript.sh index db05fded9e..aeac335477 100755 --- a/board/odroidc1/postscript.sh +++ b/board/odroidc1/postscript.sh @@ -8,6 +8,7 @@ cp $IMG_DIR/meson8b_odroidc.dtb $BOOT_DIR cp $BOARD_DIR/bl1.bin.hardkernel $IMG_DIR cp $BOARD_DIR/u-boot.bin $IMG_DIR cp $BOARD_DIR/boot.ini $BOOT_DIR +cp $BOARD_DIR/uInitrd $BOOT_DIR # fix some lib dirs if ! [ -L $TARGET/lib/arm-linux-gnueabihf ]; then diff --git a/board/odroidc1/uInitrd b/board/odroidc1/uInitrd new file mode 100644 index 0000000000..cef48975fa Binary files /dev/null and b/board/odroidc1/uInitrd differ diff --git a/board/odroidc1/usr/libexec/fw-prepare-boot b/board/odroidc1/usr/libexec/fw-prepare-boot new file mode 100755 index 0000000000..c506ae2891 --- /dev/null +++ b/board/odroidc1/usr/libexec/fw-prepare-boot @@ -0,0 +1,4 @@ +#!/bin/bash + +sed -i 's/00 - 0x/00 0x22000000 0x/' /boot/boot.ini + diff --git a/board/raspberrypi/fwupdater.gz b/board/raspberrypi/fwupdater.gz index 0f516d0d13..81e7fa1990 100644 Binary files a/board/raspberrypi/fwupdater.gz and b/board/raspberrypi/fwupdater.gz differ diff --git a/board/raspberrypi/overlay/usr/libexec/fw-prepare-boot b/board/raspberrypi/overlay/usr/libexec/fw-prepare-boot new file mode 100755 index 0000000000..e114525d86 --- /dev/null +++ b/board/raspberrypi/overlay/usr/libexec/fw-prepare-boot @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "initramfs fwupdater.gz" >> /boot/config.txt + diff --git a/board/raspberrypi/overlay/usr/libexec/fw-restore-boot-cfg b/board/raspberrypi/overlay/usr/libexec/fw-restore-boot-cfg new file mode 100755 index 0000000000..628189ebf6 --- /dev/null +++ b/board/raspberrypi/overlay/usr/libexec/fw-restore-boot-cfg @@ -0,0 +1,10 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "Usage: $0 " 1>&2 + exit -1 +fi + +old_boot=$1 +cp $old_boot/config.txt /boot + diff --git a/board/raspberrypi2/fwupdater.gz b/board/raspberrypi2/fwupdater.gz index 0f516d0d13..81e7fa1990 100644 Binary files a/board/raspberrypi2/fwupdater.gz and b/board/raspberrypi2/fwupdater.gz differ diff --git a/board/raspberrypi2/overlay/usr/libexec/fw-prepare-boot b/board/raspberrypi2/overlay/usr/libexec/fw-prepare-boot new file mode 100755 index 0000000000..e114525d86 --- /dev/null +++ b/board/raspberrypi2/overlay/usr/libexec/fw-prepare-boot @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "initramfs fwupdater.gz" >> /boot/config.txt + diff --git a/board/raspberrypi2/overlay/usr/libexec/fw-restore-boot-cfg b/board/raspberrypi2/overlay/usr/libexec/fw-restore-boot-cfg new file mode 100755 index 0000000000..628189ebf6 --- /dev/null +++ b/board/raspberrypi2/overlay/usr/libexec/fw-restore-boot-cfg @@ -0,0 +1,10 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "Usage: $0 " 1>&2 + exit -1 +fi + +old_boot=$1 +cp $old_boot/config.txt /boot + diff --git a/board/raspberrypi3/fwupdater.gz b/board/raspberrypi3/fwupdater.gz index 0f516d0d13..81e7fa1990 100644 Binary files a/board/raspberrypi3/fwupdater.gz and b/board/raspberrypi3/fwupdater.gz differ diff --git a/board/raspberrypi3/overlay/usr/libexec/fw-prepare-boot b/board/raspberrypi3/overlay/usr/libexec/fw-prepare-boot new file mode 100755 index 0000000000..e114525d86 --- /dev/null +++ b/board/raspberrypi3/overlay/usr/libexec/fw-prepare-boot @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "initramfs fwupdater.gz" >> /boot/config.txt + diff --git a/board/raspberrypi3/overlay/usr/libexec/fw-restore-boot-cfg b/board/raspberrypi3/overlay/usr/libexec/fw-restore-boot-cfg new file mode 100755 index 0000000000..628189ebf6 --- /dev/null +++ b/board/raspberrypi3/overlay/usr/libexec/fw-restore-boot-cfg @@ -0,0 +1,10 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "Usage: $0 " 1>&2 + exit -1 +fi + +old_boot=$1 +cp $old_boot/config.txt /boot + diff --git a/configs/odroidc1_initramfs_defconfig b/configs/odroidc1_initramfs_defconfig new file mode 100644 index 0000000000..86f8270ccf --- /dev/null +++ b/configs/odroidc1_initramfs_defconfig @@ -0,0 +1,26 @@ +BR2_arm=y +BR2_cortex_a5=y +BR2_ARM_ENABLE_NEON=y +BR2_ARM_ENABLE_VFP=y +BR2_ARM_FPU_NEON_VFPV4=y +BR2_DL_DIR="$(TOPDIR)/.download" +BR2_CCACHE=y +BR2_CCACHE_DIR="$(TOPDIR)/.buildroot-ccache-odroidc1-initramfs" +BR2_OPTIMIZE_2=y +BR2_TOOLCHAIN_EXTERNAL=y +BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y +BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y +BR2_TOOLCHAIN_EXTERNAL_URL="http://releases.linaro.org/14.09/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz" +BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="$(ARCH)-linux-gnueabihf" +BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y +BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_1=y +BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y +BR2_TOOLCHAIN_EXTERNAL_CXX=y +BR2_TARGET_OPTIMIZATION="-pipe" +BR2_ROOTFS_SKELETON_CUSTOM=y +BR2_ROOTFS_SKELETON_CUSTOM_PATH="board/common/skeleton-initramfs" +BR2_ROOTFS_OVERLAY="board/common/overlay-initramfs board/raspberrypi/overlay-initramfs" +BR2_PACKAGE_BUSYBOX_CONFIG="board/common/busybox_initramfs.config" +BR2_TARGET_ROOTFS_CPIO=y +BR2_TARGET_ROOTFS_CPIO_UIMAGE=y +# BR2_TARGET_ROOTFS_TAR is not set