diff --git a/iopupgrade/Makefile b/iopupgrade/Makefile new file mode 100644 index 000000000..9c5e52dbb --- /dev/null +++ b/iopupgrade/Makefile @@ -0,0 +1,55 @@ +# +# Copyright (C) 2006-2010 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=iopupgrade +PKG_VERSION:=1.0.0 +PKG_RELEASE:=1 + +PKG_SOURCE_VERSION:=bf64143758a0dacbf161310a857d3284c3308c75 +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/iopupgrade + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)-$(PKG_SOURCE_VERSION).tar.gz +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) + +# support parallel build +PKG_BUILD_PARALLEL:=1 + +#re create configure scripts if not present. +PKG_FIXUP:=autoreconf + +# run install target when cross compiling. basically, make install DESTDIR=$(PKG_INSTALL_DIR) +# this way we don't need to pick out the resulting files from the build dir. +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/iopupgrade + CATEGORY:=Utilities + TITLE:=Iopsys system upgrade utility + URL:= +# DEPENDS:= +endef + +define Package/iopupgrade/description + Application handling peripheral +endef + +define Package/iopupgrade/install +# $(CP) ./files/* $(1)/ + $(INSTALL_DIR) $(1)/etc/ + $(INSTALL_DIR) $(1)/etc/init.d/ + $(INSTALL_DIR) $(1)/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/iopupgrade $(1)/sbin/ +endef + +$(eval $(call BuildPackage,iopupgrade)) + diff --git a/iopupgrade/files/sbin/iopu b/iopupgrade/files/sbin/iopu new file mode 100755 index 000000000..1f3868131 --- /dev/null +++ b/iopupgrade/files/sbin/iopu @@ -0,0 +1,89 @@ +#!/bin/sh + +source /lib/upgrade/iopsys.sh + +bcm_get_chip_id() { + local chip_id=$(brcm_fw_tool -k info) + case $chip_id in + 6313?) echo 63138 ;; + *) echo $chip_id ;; + esac +} + +bcm_find_mtd() { + local part=$(awk -F: "/\"$1\"/ { print \$1 }" /proc/mtd) + echo ${part##mtd} +} + +#find out board name +board=$(db get hw.board.iopVerBoard) + +# find out what rootfs volume is active. +cur_vol=$(get_flashbank_current) +upd_vol=$(get_flashbank_next) + +# broadcom cfe +cfe_mtd_0=$(bcm_find_mtd "nvram") +cfe_mtd_1=$(bcm_find_mtd "cfe_extend") +cfe_ver=$(db get hw.board.cfeIopsysVersion) + + # Binary patch next CFE with current nvram0(?) +case $(bcm_get_chip_id) in + 63138) + cfe_skip=$((65536+1408)) + ;; + *) + cfe_skip=1408 + ;; +esac + +# broadcom kernel +kernel_cur_mtd=$(bcm_find_mtd "kernel_$cur_vol") +kernel_upd_mtd=$(bcm_find_mtd "kernel_$upd_vol") + + # Get sequence number of current kernel +kernel_seqn=$(brcm_fw_tool -s -1 update /dev/mtd$kernel_cur_mtd | sed -re "s/^0+//") + +#./iopupgrade -b $board -c $cfe_mtd_0,$cfe_mtd_1 -N $cfe_skip -k $kernel_upd_mtd -s $kernel_seqn -u ubi0_$upd_vol +true +if [ $? -ne 0 ]; then + echo "upgrade failed" + exit 1 +fi + + + +mkdir -p /tmp/newroot +mkdir -p /tmp/newroot_overlay + +mount -t ubifs ubi0:rootfs_$upd_vol /tmp/newroot + +mount -o noatime,lowerdir=/tmp/newroot,upperdir=/tmp/newroot/overlay,workdir=/tmp/newroot/lib/overlay.tmp -t overlay "overlayfs:/tmp/newroot/overlay" /tmp/newroot_overlay +mount --bind /tmp/newroot/ /tmp/newroot_overlay/rom + +mount --bind /dev /tmp/newroot_overlay/dev +mount --bind /proc /tmp/newroot_overlay/proc +mount --bind /sys /tmp/newroot_overlay/sys +mount -t tmpfs -o noatime,mode=0755 root /tmp/newroot_overlay/tmp + +mkdir -p /tmp/newroot_overlay/tmp/oldroot +mount --bind / /tmp/newroot_overlay/tmp/oldroot + + +chroot /tmp/newroot_overlay /bin/sh + +echo "result was $?" + +# cleanup +umount /tmp/newroot_overlay/tmp/oldroot +umount /tmp/newroot_overlay/tmp +umount /tmp/newroot_overlay/sys +umount /tmp/newroot_overlay/proc +umount /tmp/newroot_overlay/dev +umount /tmp/newroot_overlay/rom +umount /tmp/newroot_overlay +umount /tmp/newroot + + + +