diff --git a/board/bananapim1/uInitrd b/board/bananapim1/uInitrd index d84507ef47..191d4b5f3c 100644 Binary files a/board/bananapim1/uInitrd and b/board/bananapim1/uInitrd differ diff --git a/board/common/overlay-initramfs/init b/board/common/overlay-initramfs/init index 5869745d88..301697a9e7 100755 --- a/board/common/overlay-initramfs/init +++ b/board/common/overlay-initramfs/init @@ -1,18 +1,20 @@ #!/bin/sh PATH=/bin:/sbin:/usr/bin:/usr/sbin -DISK_TIMEOUT="10" +DISK_TIMEOUT=10 msg() { echo " * $1" } +sh + msg "Mounting pseudo filesystems" mount -t devtmpfs devtmpfs /dev mount -t proc proc /proc ROOT_DEV=$(cat /proc/cmdline | grep -oE 'root=[/a-z0-9]+' | cut -d '=' -f 2) -if echo ${ROOT_DEV: -2} | grep -E 'p[0-9]' &>/dev/null; then # e.g. /dev/mmcblk0p2 +if echo ${ROOT_DEV:-2} | grep -E 'p[0-9]' &>/dev/null; then # e.g. /dev/mmcblk0p2 DISK_DEV=${ROOT_DEV:0:$((${#ROOT_DEV}-2))} BOOT_DEV=${DISK_DEV}p1 DATA_DEV=${DISK_DEV}p3 @@ -28,10 +30,10 @@ while true; do if [ ${count} -ge ${DISK_TIMEOUT} ]; then break fi - if [ -b ${ROOT_DEV} ]; then + if [[ -b ${ROOT_DEV} ]]; then break fi - count=$((${count} + 1)) + count=$((count + 1)) sleep 1 done @@ -41,15 +43,12 @@ msg "Root device is ${ROOT_DEV}" msg "Data device is ${DATA_DEV}" FW_DIR=/data/.fwupdate -FW_FILE=firmware.img.gz -FW_FILE_EXTR=firmware.img +FW_FILE=${FW_DIR}/firmware.img.gz +FW_FILE_EXTR=${FW_DIR}/firmware.img -LEGACY_FW_DIR=/data/.firmware_update -LEGACY_FW_FILE_EXTR=firmware +ROOT_INFO_FILE=${FW_DIR}/root_info -ROOT_INFO_FILE=root_info - -on_exit() { +cleanup_on_exit() { msg "Switching to normal boot" /remove_initramfs @@ -66,7 +65,7 @@ on_exit() { echo 'b' > /proc/sysrq-trigger } -trap on_exit EXIT +trap cleanup_on_exit EXIT if [ -x /prepare_initramfs ]; then msg "Preparing initramfs" @@ -79,35 +78,39 @@ mount ${BOOT_DEV} /boot msg "Mounting data partition" mount ${DATA_DEV} /data -if ! [ -r ${FW_DIR}/${FW_FILE_EXTR} ]; then - if [ -r ${LEGACY_FW_DIR}/${LEGACY_FW_FILE_EXTR} ]; then - msg "Detected legacy firmware path" - mkdir -p ${FW_DIR} - mv ${LEGACY_FW_DIR}/${LEGACY_FW_FILE_EXTR} ${FW_DIR}/${FW_FILE_EXTR} - - msg "Computing root partition info" - root_start=$(fdisk -l ${FW_DIR}/${FW_FILE_EXTR} | grep ${FW_FILE_EXTR}2 | tr -s ' ' | cut -d ' ' -f 4) - root_start=$((${root_start} / 2048)) - root_size=$(fdisk -l ${FW_DIR}/${FW_FILE_EXTR} | grep ${FW_FILE_EXTR}2 | tr -s ' ' | cut -d ' ' -f 6) - root_size=$((${root_size} / 2048)) - - echo ${root_start} ${root_size} > ${FW_DIR}/${ROOT_INFO_FILE} - else - msg "No firmware found, aborting" - exit 1 - fi +if ! [[ -r ${FW_FILE_EXTR} ]]; then + msg "No firmware found, aborting" + exit 1 fi -if ! [ -r ${FW_DIR}/${ROOT_INFO_FILE} ]; then +if ! [[ -r ${ROOT_INFO_FILE} ]]; then msg "No root partition info, aborting" exit 1 fi msg "Copying root image" -root_start=$(cat ${FW_DIR}/${ROOT_INFO_FILE} | cut -d ' ' -f 1) -root_size=$(cat ${FW_DIR}/${ROOT_INFO_FILE} | cut -d ' ' -f 2) +root_info=$(cat ${ROOT_INFO_FILE}) +count=0 -dd if=${FW_DIR}/${FW_FILE_EXTR} skip=${root_start} of=${ROOT_DEV} bs=1048576 count=${root_size} || exit 1 +for i in ${root_info}; do count=$((count + 1)); done + +if [[ ${count} == 3 ]]; then + root_start=$(echo ${root_info} | cut -d ' ' -f 1) + root_size=$(echo ${root_info} | cut -d ' ' -f 3) + root_start=$((root_start / 2048)) + root_size=$((root_size / 2048)) + +elif [[ ${count} == 2 ]]; then + # compatibility with old info file format + root_start=$(echo ${root_info} | cut -d ' ' -f 1) + root_size=$(echo ${root_info} | cut -d ' ' -f 2) + +else + msg "Unrecognized root partition info file format" + exit 1 +fi + +dd if=${FW_FILE_EXTR} skip=${root_start} of=${ROOT_DEV} bs=1048576 count=${root_size} || exit 1 msg "Cleaning up" rm -rf ${FW_DIR} diff --git a/board/common/overlay/etc/init.d/S72postgresql b/board/common/overlay/etc/init.d/S72postgresql index b6b61b82ce..b081d457ad 100755 --- a/board/common/overlay/etc/init.d/S72postgresql +++ b/board/common/overlay/etc/init.d/S72postgresql @@ -35,7 +35,7 @@ start() { run_pg_ctl initdb -s -D ${DB_DIR} &>> ${LOG} test $? == 0 && msg_done || msg_fail - echo "include_if_exists = '/data/etc/postgresql.conf'" >> ${DB_DIR}/postgresql.conf + echo "include_if_exists = '${CONF}'" >> ${DB_DIR}/postgresql.conf fi msg_begin "Starting postgresql" diff --git a/board/common/overlay/etc/modprobe.d/boot-modprobe.conf b/board/common/overlay/etc/modprobe.d/boot-modprobe.conf new file mode 120000 index 0000000000..581315cf7e --- /dev/null +++ b/board/common/overlay/etc/modprobe.d/boot-modprobe.conf @@ -0,0 +1 @@ +/boot/etc/modprobe.conf \ No newline at end of file diff --git a/board/common/overlay/etc/modprobe.d/user-modprobe.conf b/board/common/overlay/etc/modprobe.d/data-modprobe.conf similarity index 100% rename from board/common/overlay/etc/modprobe.d/user-modprobe.conf rename to board/common/overlay/etc/modprobe.d/data-modprobe.conf diff --git a/board/common/overlay/sbin/fwupdate b/board/common/overlay/sbin/fwupdate index d9097227eb..ad79d1998a 100755 --- a/board/common/overlay/sbin/fwupdate +++ b/board/common/overlay/sbin/fwupdate @@ -5,8 +5,8 @@ function exit_usage() { echo "Usage: fwupdate versions [-j] (lists available versions, optionally outputting json)" - echo " fwupdate current (shows the current version" - echo " fwupdate download (downloads a firmware version)" + echo " fwupdate current (shows the current version)" + echo " fwupdate download (downloads a firmware OS image)" echo " fwupdate extract (extracts the downloaded firmware archive)" echo " fwupdate flashboot (flashes the boot partition from extracted image)" echo " fwupdate flashreboot (prepares for reboot + root partititon flash)" @@ -26,7 +26,7 @@ function exit_usage() { exit 1 } -if [ -z "$1" ]; then +if [[ -z "$1" ]]; then exit_usage fi @@ -40,32 +40,60 @@ SYS_VERSION_FILE=/etc/version SYS_BOARD_FILE=/etc/board OS_CONF_FILE=/etc/init.d/os_conf -MIN_FREE_DISK=$((500*1024)) # 500 MB -VER_FILE=version -ROOT_INFO_FILE=root_info -BOOT_READY_FILE=boot_flash_ready - +MIN_FREE_DISK=500 # MB FW_DIR=/data/.fwupdate -FW_FILE_GZ=firmware.img.gz -FW_FILE_XZ=firmware.img.xz -FW_FILE_EXTR=firmware.img -CURL_LOG_FILE=curl.log -CURL_PID_FILE=curl.pid +FW_FILE_GZ=${FW_DIR}/firmware.img.gz +FW_FILE_XZ=${FW_DIR}/firmware.img.xz +FW_FILE_EXTR=${FW_DIR}/firmware.img -GUNZIP_LOG_FILE=gunzip.log -GUNZIP_PID_FILE=gunzip.pid +VER_FILE=${FW_DIR}/version -XZCAT_LOG_FILE=xzcat.log -XZCAT_PID_FILE=xzcat.pid +BOOT_INFO_FILE=${FW_DIR}/boot_info +ROOT_INFO_FILE=${FW_DIR}/root_info +BOOT_READY_FILE=${FW_DIR}/boot_flash_ready -DD_LOG_FILE=dd.log -DD_PID_FILE=dd.pid +TMP_BOOT_DIR=/tmp/fwupdate_boot +TMP_ROOT_DIR=/tmp/fwupdate_root + +CURL_LOG_FILE=${FW_DIR}/curl.log +CURL_PID_FILE=${FW_DIR}/curl.pid + +GUNZIP_LOG_FILE=${FW_DIR}/gunzip.log +GUNZIP_PID_FILE=${FW_DIR}/gunzip.pid + +XZCAT_LOG_FILE=${FW_DIR}/xzcat.log +XZCAT_PID_FILE=${FW_DIR}/xzcat.pid + +DD_LOG_FILE=${FW_DIR}/dd.log +DD_PID_FILE=${FW_DIR}/dd.pid + +BOOT_LOOP="/dev/loop3" +ROOT_LOOP="/dev/loop4" source ${OS_CONF_FILE} source ${SYS_VERSION_FILE} +#### cleanup on exit #### + +function cleanup_on_exit() { + set +e + + if [[ -f /sbin/reboot.bak ]]; then + rm -f /sbin/reboot + mv /sbin/reboot.bak /sbin/reboot + fi + + umount ${TMP_BOOT_DIR} 2>/dev/null + umount ${TMP_ROOT_DIR} 2>/dev/null + losetup -d ${BOOT_LOOP} 2>/dev/null + losetup -d ${ROOT_LOOP} 2>/dev/null + + mount -T /etc/fstab.disk -o ro /boot 2>/dev/null +} + + #### disk & partition devices #### BOOT_DEV=$(mount | grep /boot | cut -d ' ' -f 1) @@ -81,6 +109,84 @@ else exit 1 fi +function reallocate_boot_part() { + current_boot_info=$(fdisk --bytes -l -o device,start,end,size ${DISK_DEV} | grep "${BOOT_DEV}") + current_boot_info=(${current_boot_info}) + + current_root_info=$(fdisk --bytes -l -o device,start,end,size ${DISK_DEV} | grep "${ROOT_DEV}") + current_root_info=(${current_root_info}) + + boot_info=($(cat ${BOOT_INFO_FILE})) + + if [[ ${current_boot_info[1]} == ${boot_info[0]} ]] && + [[ ${current_boot_info[2]} == ${boot_info[1]} ]]; then + + return # all good + fi + + echo "reallocating boot partition..." + + # check overlapping with root partition + if [[ ${boot_info[1]} -ge ${current_root_info[1]} ]]; then + echo "cannot reallocate boot partition: will overlap with root" + return 1 + fi + + fdisk -w auto ${DISK_DEV} >/dev/null </dev/null < ${FW_DIR}/${VER_FILE} + echo ${version} > ${VER_FILE} return fi fi - + board=$(cat ${SYS_BOARD_FILE}) url=$1 version=$1 @@ -158,51 +264,51 @@ function do_download() { version="custom" fi - if [ -z "${url}" ]; then + if [[ -z "${url}" ]]; then echo "no such version" 1>&2 exit 1 fi free_disk=$(df /data | tail -n 1 | tr -s ' ' | cut -d ' ' -f 4) - if [ "${free_disk}" -lt ${MIN_FREE_DISK} ]; then + if [[ "${free_disk}" -lt $((MIN_FREE_DISK * 1024)) ]]; then echo "not enough disk space" 1>&2 exit 1 fi - outfile=${FW_DIR}/${FW_FILE_GZ} + outfile=${FW_FILE_GZ} format=$(echo ${url} | sed -rn 's/.*\.img\.([a-z]+)$/\1/ p') - if [ "${format}" == "xz" ]; then - outfile=${FW_DIR}/${FW_FILE_XZ} + if [[ "${format}" == "xz" ]]; then + outfile=${FW_FILE_XZ} fi - echo ${version} > ${FW_DIR}/${VER_FILE} + echo ${version} > ${VER_FILE} curl_opts="-S -f -L" - if [ -n "${OS_FIRMWARE_USERNAME}" ]; then + if [[ -n "${OS_FIRMWARE_USERNAME}" ]]; then curl_opts+=" --user ${OS_FIRMWARE_USERNAME}:${OS_FIRMWARE_PASSWORD}" fi - curl ${curl_opts} -o ${outfile} "${url}" &> ${FW_DIR}/${CURL_LOG_FILE} & + curl ${curl_opts} -o ${outfile} "${url}" &> ${CURL_LOG_FILE} & pid=$! - echo ${pid} > ${FW_DIR}/${CURL_PID_FILE} + echo ${pid} > ${CURL_PID_FILE} wait ${pid} - if [ "$?" != 0 ]; then - cat ${FW_DIR}/${CURL_LOG_FILE} + if [[ "$?" != 0 ]]; then + cat ${CURL_LOG_FILE} exit 1 fi } function download_status() { - if [ -f ${FW_DIR}/${CURL_PID_FILE} ]; then - pid=$(cat ${FW_DIR}/${CURL_PID_FILE}) + if [[ -f ${CURL_PID_FILE} ]]; then + pid=$(cat ${CURL_PID_FILE}) if kill -0 ${pid} &>/dev/null; then echo "running" return fi fi - if [ -f ${FW_DIR}/${FW_FILE_GZ} -o -f ${FW_DIR}/${FW_FILE_XZ} ]; then + if [[ -f ${FW_FILE_GZ} || -f ${FW_FILE_XZ} ]]; then echo "done" fi } @@ -213,14 +319,17 @@ function download_status() { function run_pre_upgrade() { which losetup &>/dev/null || return 0 - root_start=$(cat ${FW_DIR}/${ROOT_INFO_FILE} | cut -d ' ' -f 1) - tmp_mnt="/tmp/fwupdate_root" - loop="/dev/loop4" - pre_upgrade="${tmp_mnt}/usr/share/pre-upgrade/*" + boot_info=($(cat ${BOOT_INFO_FILE})) + root_info=($(cat ${ROOT_INFO_FILE})) + pre_upgrade="${TMP_ROOT_DIR}/usr/share/pre-upgrade/*" + + mkdir -p ${TMP_BOOT_DIR} + mkdir -p ${TMP_ROOT_DIR} + losetup -o $((boot_info[0] * 512)) ${BOOT_LOOP} ${FW_FILE_EXTR} + losetup -o $((root_info[0] * 512)) ${ROOT_LOOP} ${FW_FILE_EXTR} + mount ${BOOT_LOOP} ${TMP_BOOT_DIR} + mount ${ROOT_LOOP} ${TMP_ROOT_DIR} - mkdir -p ${tmp_mnt} - losetup -o $((root_start * 1024 * 1024)) ${loop} ${FW_DIR}/${FW_FILE_EXTR} - mount ${loop} ${tmp_mnt} if [[ -d ${pre_upgrade} ]]; then for script in ${pre_upgrade}/*.sh; do echo "running pre-upgrade script $(basename ${script})" @@ -234,37 +343,41 @@ function run_pre_upgrade() { done fi - umount ${tmp_mnt} - losetup -d ${loop} + umount ${TMP_BOOT_DIR} + umount ${TMP_ROOT_DIR} + losetup -d ${BOOT_LOOP} + losetup -d ${ROOT_LOOP} } function do_extract() { - echo "extracting..." - - rm -f ${FW_DIR}/${FW_FILE_EXTR} - rm -f ${FW_DIR}/${BOOT_READY_FILE} - - if ! [ -f ${FW_DIR}/${FW_FILE_GZ} -o -f ${FW_DIR}/${FW_FILE_XZ} ]; then + if ! [[ -f ${FW_FILE_GZ} || -f ${FW_FILE_XZ} ]]; then echo "firmware file not downloaded" 1>&2 exit 1 fi + + rm -f ${FW_FILE_EXTR} + rm -f ${BOOT_READY_FILE} + + echo "extracting..." + + trap cleanup_on_exit EXIT format="gz" - if [ -f ${FW_DIR}/${FW_FILE_XZ} ]; then + if [[ -f ${FW_FILE_XZ} ]]; then format="xz" fi - rm -f ${FW_DIR}/${FW_FILE_EXTR} - rm -f ${FW_DIR}/${GUNZIP_PID_FILE} ${FW_DIR}/${XZCAT_PID_FILE} + rm -f ${FW_FILE_EXTR} + rm -f ${GUNZIP_PID_FILE} ${XZCAT_PID_FILE} - if [ "${format}" == "xz" ]; then - DECOMPRESS_LOG_FILE=${FW_DIR}/${XZCAT_LOG_FILE} - DECOMPRESS_PID_FILE=${FW_DIR}/${XZCAT_PID_FILE} - xzcat ${FW_DIR}/${FW_FILE_XZ} > ${FW_DIR}/${FW_FILE_EXTR} 2>${FW_DIR}/${XZCAT_LOG_FILE} & - elif [ "${format}" == "gz" ]; then - DECOMPRESS_LOG_FILE=${FW_DIR}/${GUNZIP_LOG_FILE} - DECOMPRESS_PID_FILE=${FW_DIR}/${GUNZIP_PID_FILE} - gunzip -k -c ${FW_DIR}/${FW_FILE_GZ} > ${FW_DIR}/${FW_FILE_EXTR} 2>${FW_DIR}/${GUNZIP_LOG_FILE} & + if [[ "${format}" == "xz" ]]; then + DECOMPRESS_LOG_FILE=${XZCAT_LOG_FILE} + DECOMPRESS_PID_FILE=${XZCAT_PID_FILE} + xzcat ${FW_FILE_XZ} > ${FW_FILE_EXTR} 2>${XZCAT_LOG_FILE} & + elif [[ "${format}" == "gz" ]]; then + DECOMPRESS_LOG_FILE=${GUNZIP_LOG_FILE} + DECOMPRESS_PID_FILE=${GUNZIP_PID_FILE} + gunzip -k -c ${FW_FILE_GZ} > ${FW_FILE_EXTR} 2>${GUNZIP_LOG_FILE} & else echo "firmware compression format ${format} not supported" 1>&2 exit 1 @@ -274,32 +387,47 @@ function do_extract() { echo ${pid} > ${DECOMPRESS_PID_FILE} wait ${pid} - if [ "$?" != 0 ]; then + if [[ "$?" != 0 ]]; then cat ${DECOMPRESS_LOG_FILE} exit 1 fi # TODO verify hash + boot_info=$(fdisk --bytes -l -o device,start,end,size ${FW_FILE_EXTR} | grep "${FW_FILE_EXTR}1") + boot_info=(${boot_info}) + boot_start=${boot_info[1]} + boot_end=${boot_info[2]} + boot_size=$((boot_info[3] / 512)) + + root_info=$(fdisk --bytes -l -o device,start,end,size ${FW_FILE_EXTR} | grep "${FW_FILE_EXTR}2") + root_info=(${root_info}) + root_start=${root_info[1]} + root_end=${root_info[2]} + root_size=$((root_info[3] / 512)) + + echo ${boot_start} ${boot_end} ${boot_size} > ${BOOT_INFO_FILE} + echo ${root_start} ${root_end} ${root_size} > ${ROOT_INFO_FILE} + run_pre_upgrade } function extract_status() { - if [ -f ${FW_DIR}/${XZCAT_PID_FILE} ]; then - pid=$(cat ${FW_DIR}/${XZCAT_PID_FILE}) + if [[ -f ${XZCAT_PID_FILE} ]]; then + pid=$(cat ${XZCAT_PID_FILE}) if kill -0 ${pid} &>/dev/null; then echo "running" return fi - elif [ -f ${FW_DIR}/${GUNZIP_PID_FILE} ]; then - pid=$(cat ${FW_DIR}/${GUNZIP_PID_FILE}) + elif [[ -f ${GUNZIP_PID_FILE} ]]; then + pid=$(cat ${GUNZIP_PID_FILE}) if kill -0 ${pid} &>/dev/null; then echo "running" return fi fi - if [ -f ${FW_DIR}/${FW_FILE_EXTR} ]; then + if [[ -f ${FW_FILE_EXTR} && -f ${ROOT_INFO_FILE} ]]; then echo "done" fi } @@ -307,76 +435,34 @@ function extract_status() { #### flash boot #### -function reallocate_boot_part() { - boot_info=$(fdisk --bytes -l -o device,start,end,size ${DISK_DEV} | grep "${BOOT_DEV}") - boot_info=(${boot_info}) - - root_info=$(fdisk --bytes -l -o device,start,end,size ${DISK_DEV} | grep "${ROOT_DEV}") - root_info=(${root_info}) - - fw_boot_info=$(fdisk --bytes -l -o device,start,end,size ${FW_DIR}/${FW_FILE_EXTR} | grep "${FW_FILE_EXTR}1") - fw_boot_info=(${fw_boot_info}) - - if [[ ${boot_info[1]} == ${fw_boot_info[1]} ]] && - [[ ${boot_info[2]} == ${fw_boot_info[2]} ]]; then - - return # all good - fi - - echo "reallocating boot partition..." - - # check overlapping with root partition - if [[ ${fw_boot_info[2]} -ge ${root_info[1]} ]]; then - echo "cannot reallocate boot partition: will overlap with root" +function do_flash_boot() { + if [[ ! -f ${FW_FILE_EXTR} ]]; then + echo "extracted firmware not present" return 1 fi - fdisk -w auto ${DISK_DEV} >/dev/null < ${FW_DIR}/${ROOT_INFO_FILE} - reallocate_boot_part - dd if=${FW_DIR}/${FW_FILE_EXTR} skip=${boot_start} of=${BOOT_DEV} bs=1048576 count=${boot_size} &>${FW_DIR}/${DD_LOG_FILE} & + dd if=${FW_FILE_EXTR} skip=$((boot_info[0] / 2048)) of=${BOOT_DEV} bs=1048576 count=$((boot_info[2] / 2048)) &>${DD_LOG_FILE} & pid=$! - echo ${pid} > ${FW_DIR}/${DD_PID_FILE} + echo ${pid} > ${DD_PID_FILE} wait ${pid} mount -T /etc/fstab.disk -o rw /boot @@ -384,92 +470,48 @@ function do_flash_boot() { # 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 + 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} + touch ${BOOT_READY_FILE} } function flash_boot_status() { - if [ -f ${FW_DIR}/${DD_PID_FILE} ]; then - pid=$(cat ${FW_DIR}/${DD_PID_FILE}) + if [[ -f ${DD_PID_FILE} ]]; then + pid=$(cat ${DD_PID_FILE}) if kill -0 ${pid} &>/dev/null; then echo "running" return fi fi - if [ -f ${FW_DIR}/${BOOT_READY_FILE} ]; then + if [[ -f ${BOOT_READY_FILE} ]]; then echo "done" fi } -function flash_cleanup() { - if [ -f /sbin/reboot.bak ]; then - rm -f /sbin/reboot - mv /sbin/reboot.bak /sbin/reboot - fi - - mount /boot 2>/dev/null -} - #### flash reboot #### -function reallocate_root_part() { - root_info=$(fdisk --bytes -l -o device,start,end,size ${DISK_DEV} | grep "${ROOT_DEV}") - root_info=(${root_info}) - - data_info=$(fdisk --bytes -l -o device,start,end,size ${DISK_DEV} | grep "${DATA_DEV}") - data_info=(${data_info}) - - fw_root_info=$(fdisk --bytes -l -o device,start,end,size ${FW_DIR}/${FW_FILE_EXTR} | grep "${FW_FILE_EXTR}2") - fw_root_info=(${fw_root_info}) - - if [[ ${root_info[1]} == ${fw_root_info[1]} ]] && - [[ ${root_info[2]} == ${fw_root_info[2]} ]]; then - - return # all good - fi - - echo "reallocating root partition..." - - # check overlapping with data partition - if [[ ${fw_root_info[2]} -ge ${data_info[1]} ]]; then - echo "cannot reallocate root partition: will overlap with data" - return 1 - fi - - fdisk -w auto ${DISK_DEV} >/dev/null <> /boot/config.txt -echo "initramfs fwupdater.gz" >> /boot/config.txt +echo "initramfs initrd.gz" >> /boot/config.txt diff --git a/board/raspberrypi2/fwupdater.gz b/board/raspberrypi2/fwupdater.gz index 5cc053dcd8..78f3ccf01e 100644 Binary files a/board/raspberrypi2/fwupdater.gz and b/board/raspberrypi2/fwupdater.gz differ diff --git a/board/raspberrypi2/initrd.gz b/board/raspberrypi2/initrd.gz new file mode 100644 index 0000000000..78f3ccf01e Binary files /dev/null and b/board/raspberrypi2/initrd.gz differ diff --git a/board/raspberrypi2/overlay/usr/libexec/fw-prepare-boot b/board/raspberrypi2/overlay/usr/libexec/fw-prepare-boot index e930649d1c..e372abdb87 100755 --- a/board/raspberrypi2/overlay/usr/libexec/fw-prepare-boot +++ b/board/raspberrypi2/overlay/usr/libexec/fw-prepare-boot @@ -1,5 +1,5 @@ #!/bin/bash echo >> /boot/config.txt -echo "initramfs fwupdater.gz" >> /boot/config.txt +echo "initramfs initrd.gz" >> /boot/config.txt diff --git a/board/raspberrypi3/fwupdater.gz b/board/raspberrypi3/fwupdater.gz index ac47e69edf..36ddbb3b57 100644 Binary files a/board/raspberrypi3/fwupdater.gz and b/board/raspberrypi3/fwupdater.gz differ diff --git a/board/raspberrypi3/initrd.gz b/board/raspberrypi3/initrd.gz new file mode 100644 index 0000000000..36ddbb3b57 Binary files /dev/null and b/board/raspberrypi3/initrd.gz differ diff --git a/board/raspberrypi3/overlay/usr/libexec/fw-prepare-boot b/board/raspberrypi3/overlay/usr/libexec/fw-prepare-boot index e930649d1c..e372abdb87 100755 --- a/board/raspberrypi3/overlay/usr/libexec/fw-prepare-boot +++ b/board/raspberrypi3/overlay/usr/libexec/fw-prepare-boot @@ -1,5 +1,5 @@ #!/bin/bash echo >> /boot/config.txt -echo "initramfs fwupdater.gz" >> /boot/config.txt +echo "initramfs initrd.gz" >> /boot/config.txt diff --git a/board/tinkerboard/initrd.gz b/board/tinkerboard/initrd.gz index 1c7648c8a5..a8b440bdae 100644 Binary files a/board/tinkerboard/initrd.gz and b/board/tinkerboard/initrd.gz differ diff --git a/configs/raspberrypi2_initramfs_defconfig b/configs/raspberrypi2_initramfs_defconfig index 4bb8992d15..5f6512aed9 100644 --- a/configs/raspberrypi2_initramfs_defconfig +++ b/configs/raspberrypi2_initramfs_defconfig @@ -1,14 +1,10 @@ BR2_arm=y -BR2_arm1176jzf_s=y +BR2_cortex_a7=y +BR2_ARM_FPU_NEON_VFPV4=y BR2_CCACHE=y -BR2_CCACHE_DIR="$(TOPDIR)/.buildroot-ccache-raspberrypi-initramfs" +BR2_CCACHE_DIR="$(TOPDIR)/.buildroot-ccache-raspberrypi2-initramfs" BR2_OPTIMIZE_2=y -BR2_STATIC_LIBS=y -BR2_KERNEL_HEADERS_4_4=y -# BR2_UCLIBC_INSTALL_UTILS is not set -BR2_BINUTILS_VERSION_2_31_X=y -BR2_GCC_VERSION_5_X=y -BR2_TOOLCHAIN_BUILDROOT_CXX=y +BR2_TOOLCHAIN_EXTERNAL=y BR2_TARGET_OPTIMIZATION="-pipe" BR2_TARGET_GENERIC_HOSTNAME="" BR2_TARGET_GENERIC_ISSUE="" diff --git a/configs/raspberrypi3_initramfs_defconfig b/configs/raspberrypi3_initramfs_defconfig index 4bb8992d15..7f50bf393e 100644 --- a/configs/raspberrypi3_initramfs_defconfig +++ b/configs/raspberrypi3_initramfs_defconfig @@ -1,14 +1,10 @@ BR2_arm=y -BR2_arm1176jzf_s=y +BR2_cortex_a7=y +BR2_ARM_FPU_NEON_VFPV4=y BR2_CCACHE=y -BR2_CCACHE_DIR="$(TOPDIR)/.buildroot-ccache-raspberrypi-initramfs" +BR2_CCACHE_DIR="$(TOPDIR)/.buildroot-ccache-raspberrypi3-initramfs" BR2_OPTIMIZE_2=y -BR2_STATIC_LIBS=y -BR2_KERNEL_HEADERS_4_4=y -# BR2_UCLIBC_INSTALL_UTILS is not set -BR2_BINUTILS_VERSION_2_31_X=y -BR2_GCC_VERSION_5_X=y -BR2_TOOLCHAIN_BUILDROOT_CXX=y +BR2_TOOLCHAIN_EXTERNAL=y BR2_TARGET_OPTIMIZATION="-pipe" BR2_TARGET_GENERIC_HOSTNAME="" BR2_TARGET_GENERIC_ISSUE=""