diff --git a/board/common/overlay-initramfs/init b/board/common/overlay-initramfs/init index 382f85c886..f504443afa 100755 --- a/board/common/overlay-initramfs/init +++ b/board/common/overlay-initramfs/init @@ -60,7 +60,7 @@ fi msg "Copying root image" root_start=$(cat $FW_DIR/$ROOT_INFO_FILE | cut -d ' ' -f 1) -root_size=$(cat $FW_DIR/$ROOT_INFOO_FILE | cut -d ' ' -f 2) +root_size=$(cat $FW_DIR/$ROOT_INFO_FILE | cut -d ' ' -f 2) dd if=$FW_DIR/$FW_FILE_EXTR skip=$root_start of=$ROOT_DEV bs=1048576 count=$root_size || exit 1 diff --git a/board/common/overlay/sbin/fwupdate b/board/common/overlay/sbin/fwupdate index 63b489b573..66c8df6170 100755 --- a/board/common/overlay/sbin/fwupdate +++ b/board/common/overlay/sbin/fwupdate @@ -4,20 +4,13 @@ #### usage #### function exit_usage() { - echo "Usage: fwupdate versions" - echo " - lists available versions" - echo " fwupdate current" - echo " - shows the current version" - echo " fwupdate download " - echo " - downloads a firmware version" - echo " fwupdate extract" - echo " - extracts the downloaded firmware archive" - echo " fwupdate flashboot" - echo " - flashes the extracted boot partition" - echo " fwupdate flashreboot" - echo " - prepares for reboot + root partititon flash" - echo " fwupdate status" - echo " - shows the current firmware updating status (see below)" + echo "Usage: fwupdate versions (lists available versions)" + echo " fwupdate current (shows the current version" + echo " fwupdate download (downloads a firmware version)" + 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)" + echo " fwupdate status (shows the current firmware updating status; see below)" echo "" echo "Statuses:" echo " idle" @@ -47,6 +40,7 @@ BOOT_DEV=/dev/mmcblk0p1 MIN_FREE_DISK=$((500*1024)) # 500 MB VER_FILE=version ROOT_INFO_FILE=root_info +BOOT_READY_FILE=boot_flash_ready FW_DIR=/data/.fwupdate FW_FILE=firmware.img.gz @@ -106,6 +100,10 @@ function show_current() { function do_download() { echo "downloading..." + rm -f $FW_DIR/$FW_FILE + rm -f $FW_DIR/$FW_FILE_EXTR + rm -f $FW_DIR/$BOOT_READY_FILE + source $OS_CONF board=$(cat $SYS_BOARD_FILE) url=$1 @@ -164,6 +162,9 @@ function download_status() { 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 ]; then echo "firmware file not downloaded" 1>&2 @@ -185,6 +186,7 @@ function extract_status() { pid=$(cat $FW_DIR/$GUNZIP_PID_FILE) if kill -0 $pid &>/dev/null; then echo "running" + return fi fi @@ -198,6 +200,8 @@ function extract_status() { function flash_boot() { echo "flashing boot..." + + rm -f $FW_DIR/$BOOT_READY_FILE set +e board=$(cat $SYS_BOARD_FILE) @@ -212,15 +216,15 @@ function flash_boot() { boot_info=$(fdisk --bytes -l -o device,start,end,size $FW_DIR/$FW_FILE_EXTR | grep "${FW_FILE_EXTR}1") boot_info=($boot_info) - boot_start=$((${boot_info[1]} * 512)) # in bytes + boot_start=$((${boot_info[1]} / 2048)) # in MB boot_size=$((${boot_info[3]} / 1048576)) # in MB root_info=$(fdisk --bytes -l -o device,start,end,size $FW_DIR/$FW_FILE_EXTR | grep "${FW_FILE_EXTR}2") root_info=($root_info) - root_start=$((${root_info[1]} * 512)) # in bytes + root_start=$((${root_info[1]} / 2048)) # in MB root_size=$((${root_info[3]} / 1048576)) # in MB - echo $root_start $root_size > $FW_DIR/$ROOT_INFO + echo $root_start $root_size > $FW_DIR/$ROOT_INFO_FILE dd if=$FW_DIR/$FW_FILE_EXTR skip=$boot_start of=$BOOT_DEV bs=1048576 count=$boot_size &>$FW_DIR/$DD_LOG_FILE & pid=$! @@ -229,7 +233,7 @@ function flash_boot() { mount -o rw /boot restore_boot_$board $FW_DIR/old_boot 2>/dev/null || true - touch $FW_DIR/boot_flash_ready + touch $FW_DIR/$BOOT_READY_FILE } function flash_boot_status() { @@ -241,7 +245,7 @@ function flash_boot_status() { fi fi - if [ -f $FW_DIR/boot_flash_ready ]; then + if [ -f $FW_DIR/$BOOT_READY_FILE ]; then echo "done" fi } diff --git a/board/common/overlay/usr/libexec/list-versions-bitbucket b/board/common/overlay/usr/libexec/list-versions-bitbucket index e2944530b3..e54c188a84 100755 --- a/board/common/overlay/usr/libexec/list-versions-bitbucket +++ b/board/common/overlay/usr/libexec/list-versions-bitbucket @@ -7,7 +7,7 @@ fi opts="-s -S -f" test -n "$FW_USERNAME" && opts+=" --user $FW_USERNAME:$FW_PASSWORD" -url=https://api.bitbucket.org/2.0/repositories/$1/downloads?pagelen=100 +url="https://api.bitbucket.org/2.0/repositories/$1/downloads?pagelen=100&_=$(date +%s)" jq_expr='.values[] | [{a: .name | split("-"), url: .links.self.href}] | map((.a[2] | rtrimstr(".img.gz") | rtrimstr(".img")), "false", .a[1], .url) | join("|")' curl $opts $url | jq --raw-output "$jq_expr" diff --git a/board/raspberrypi/fwupdater.gz b/board/raspberrypi/fwupdater.gz index d7a3017498..f6b4df253f 100644 Binary files a/board/raspberrypi/fwupdater.gz and b/board/raspberrypi/fwupdater.gz differ diff --git a/board/raspberrypi2/fwupdater.gz b/board/raspberrypi2/fwupdater.gz index d7a3017498..f6b4df253f 100644 Binary files a/board/raspberrypi2/fwupdater.gz and b/board/raspberrypi2/fwupdater.gz differ diff --git a/board/raspberrypi3/fwupdater.gz b/board/raspberrypi3/fwupdater.gz index d7a3017498..f6b4df253f 100644 Binary files a/board/raspberrypi3/fwupdater.gz and b/board/raspberrypi3/fwupdater.gz differ