mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
make ./iop ssh_upgrade work on sdk504
./iop ssh_upgrade will now install latest image on broadcom boards.
This commit is contained in:
parent
36ec134e33
commit
9d20839041
3 changed files with 89 additions and 51 deletions
|
|
@ -25,7 +25,7 @@ CONFIG_PACKAGE_map-topology=y
|
|||
CONFIG_PACKAGE_wfadatad=y
|
||||
CONFIG_PACKAGE_imonitor=m
|
||||
CONFIG_PACKAGE_inbd=y
|
||||
CONFIG_PACKAGE_iopupgrade=m
|
||||
CONFIG_PACKAGE_iopupgrade=y
|
||||
CONFIG_PACKAGE_ip-full=y
|
||||
CONFIG_PACKAGE_iperf3=y
|
||||
CONFIG_PACKAGE_ipset=y
|
||||
|
|
|
|||
|
|
@ -280,6 +280,14 @@ function ssh_upgrade {
|
|||
set_config_string CONFIG_TARGET_BOARD
|
||||
firmwares=$(cd bin/targets/$CONFIG_TARGET_BOARD/generic/; ls -t *[0-9].y[3])
|
||||
|
||||
# if target uses pkgtb
|
||||
if [ -z "$firmwares"]
|
||||
then
|
||||
# pkgtb files can not be streamed so copy over the file witch scp
|
||||
use_scp=1
|
||||
firmwares=$(cd bin/targets/$CONFIG_TARGET_BOARD/generic/; ls -t *[0-9].pkgtb)
|
||||
fi
|
||||
|
||||
for upd_fw_base in $firmwares
|
||||
do
|
||||
#echo "firmware $upd_fw"
|
||||
|
|
@ -313,7 +321,16 @@ function ssh_upgrade {
|
|||
[ $upd_forceboot -eq 1 ] && extra_args="$extra_args -b"
|
||||
|
||||
file_size_kb=`du -k "$upd_fw" | cut -f1`
|
||||
cat $upd_fw | pv -s ${file_size_kb}k | ssh root@$upd_host "iopu $extra_args"
|
||||
if [ "$use_scp" == "1" ]
|
||||
then
|
||||
echo "ken"
|
||||
echo "iopu $extra_arg -f /tmp/$upd_fw_base"
|
||||
echo "ken"
|
||||
scp $upd_fw root@$upd_host:/tmp/ &&
|
||||
ssh -o ConnectTimeout=60 root@$upd_host "iopu $extra_arg -f /tmp/$upd_fw_base"
|
||||
else
|
||||
cat $upd_fw | pv -s ${file_size_kb}k | ssh root@$upd_host "iopu $extra_args"
|
||||
fi
|
||||
else
|
||||
scp $upd_fw root@$upd_host:/tmp/ &&
|
||||
ssh -o ConnectTimeout=60 root@$upd_host "sysupgrade -v $3 /tmp/$upd_fw_base" &&
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ function usage {
|
|||
echo " -x Force install even if firmware is not for this board"
|
||||
echo " -b Force install of bootloader regardless of version installed"
|
||||
echo " -r Jump into chroot env of other system"
|
||||
echo " -f Firmware file to use"
|
||||
echo " -C \"command\" Execute command in chroot env of other system"
|
||||
}
|
||||
|
||||
|
|
@ -177,6 +178,64 @@ function newroot_exec {
|
|||
|
||||
}
|
||||
|
||||
function system_is_y_image {
|
||||
|
||||
# find out what rootfs volume is active.
|
||||
cur_vol=$(get_flashbank_current)
|
||||
upd_vol=$(get_flashbank_next)
|
||||
|
||||
# convert volume name "rootfs_$upd_vol" into ubi volume id
|
||||
upd_ubi_id=$(ubinfo -d 0 -N rootfs_$upd_vol | awk "/Volume ID:/ {print \$3}")
|
||||
log "installing Root Fileystem into UBI volume rootfs_$upd_vol"
|
||||
|
||||
# prepare to match dsl.
|
||||
function_call upd_conf_dsl
|
||||
|
||||
log "now starting writing data to flash with [ iopupgrade $cmdline -M "$cmdline_match" -u ubi0_$upd_ubi_id ]"
|
||||
run_cleanup=1 # When we start to actually write data there might be some
|
||||
# things that need cleanup if we get an error/crash
|
||||
if ! iopupgrade $cmdline -M "$cmdline_match" -u ubi0_$upd_ubi_id; then
|
||||
log "iopupgrade program Failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "Firmware programmed to flash."
|
||||
|
||||
# Force upgrade of boot loader
|
||||
[ $upd_forceboot -eq 1 ] && chroot_cmdline="$chroot_cmdline -b"
|
||||
|
||||
if [ $upd_keepconfig -eq 1 ]; then
|
||||
log "Transfering configuration to new system."
|
||||
chroot_cmdline="$chroot_cmdline -c"
|
||||
fi
|
||||
|
||||
mount_newroot
|
||||
if ! chroot /tmp/newroot_overlay /sbin/iopu_chroot $chroot_cmdline; then
|
||||
log "Configuration migration failed!"
|
||||
exit 1
|
||||
fi
|
||||
umount_newroot
|
||||
|
||||
log "New firmware fully installed."
|
||||
run_cleanup=0
|
||||
|
||||
|
||||
# Now make sure that we actually boot the new system on the next reboot
|
||||
upd_finnish
|
||||
|
||||
}
|
||||
|
||||
function system_is_FIT_image {
|
||||
|
||||
# prepare to match dsl.
|
||||
#function_call upd_conf_dsl
|
||||
|
||||
#here we write data
|
||||
bcm_flasher $firmware_file
|
||||
bcm_bootstate 1
|
||||
log "Firmware programmed to flash."
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
|
||||
# just one instance
|
||||
|
|
@ -194,7 +253,7 @@ trap ctrl_c INT
|
|||
trap timeout SIGALRM
|
||||
trap sig_pipe SIGPIPE
|
||||
|
||||
while getopts "nrxbhcC:" opt; do
|
||||
while getopts "nrxbhcC:f:" opt; do
|
||||
case $opt in
|
||||
n)
|
||||
upd_noreboot=1
|
||||
|
|
@ -216,6 +275,9 @@ while getopts "nrxbhcC:" opt; do
|
|||
newroot_exec "${OPTARG}"
|
||||
exit
|
||||
;;
|
||||
f)
|
||||
firmware_file="${OPTARG}"
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
exit 1
|
||||
|
|
@ -235,59 +297,18 @@ log "Firmware upgrade started"
|
|||
# Should board name be checked
|
||||
if [ $upd_forceimage -eq 0 ]
|
||||
then
|
||||
board=$(db get hw.board.iopVerBoard)
|
||||
board=$(db get hw.board.model_name)
|
||||
cmdline_match="board=$board"
|
||||
fi
|
||||
|
||||
# find out what rootfs volume is active.
|
||||
cur_vol=$(get_flashbank_current)
|
||||
upd_vol=$(get_flashbank_next)
|
||||
|
||||
# convert volume name "rootfs_$upd_vol" into ubi volume id
|
||||
upd_ubi_id=$(ubinfo -d 0 -N rootfs_$upd_vol | awk "/Volume ID:/ {print \$3}")
|
||||
log "installing Root Fileystem into UBI volume rootfs_$upd_vol"
|
||||
|
||||
# prepare to match dsl.
|
||||
function_call upd_conf_dsl
|
||||
|
||||
# prepare to update CFE if it exists
|
||||
function_call upd_conf_cfe
|
||||
|
||||
# prepare to update kernel if it is stored in MTD/JFFS2
|
||||
function_call upd_conf_kernel
|
||||
|
||||
log "now starting writing data to flash with [ iopupgrade $cmdline -M "$cmdline_match" -u ubi0_$upd_ubi_id ]"
|
||||
run_cleanup=1 # When we start to actually write data there might be some
|
||||
# things that need cleanup if we get an error/crash
|
||||
if ! iopupgrade $cmdline -M "$cmdline_match" -u ubi0_$upd_ubi_id; then
|
||||
log "iopupgrade program Failed"
|
||||
exit 1
|
||||
# BUG: should probably read a config file.
|
||||
if [ -f /proc/nvram/boardid ]
|
||||
then
|
||||
system_is_FIT_image
|
||||
else
|
||||
system_is_y_image
|
||||
fi
|
||||
|
||||
log "Firmware programmed to flash."
|
||||
|
||||
# Force upgrade of boot loader
|
||||
[ $upd_forceboot -eq 1 ] && chroot_cmdline="$chroot_cmdline -b"
|
||||
|
||||
if [ $upd_keepconfig -eq 1 ]; then
|
||||
log "Transfering configuration to new system."
|
||||
chroot_cmdline="$chroot_cmdline -c"
|
||||
fi
|
||||
|
||||
mount_newroot
|
||||
if ! chroot /tmp/newroot_overlay /sbin/iopu_chroot $chroot_cmdline; then
|
||||
log "Configuration migration failed!"
|
||||
exit 1
|
||||
fi
|
||||
umount_newroot
|
||||
|
||||
log "New firmware fully installed."
|
||||
run_cleanup=0
|
||||
|
||||
|
||||
# Now make sure that we actually boot the new system on the next reboot
|
||||
upd_finnish
|
||||
|
||||
# spawn the reboot to a subshell to allow the main program to quit before reset
|
||||
# to avoid any hanged network connection like ssh
|
||||
if [ $upd_noreboot -eq 0 ]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue