diff options
author | John Klug <john.klug@multitech.com> | 2021-11-16 12:35:22 -0600 |
---|---|---|
committer | Andrii Pientsov <andrii.pientsov@globallogic.com> | 2021-11-19 10:56:24 +0200 |
commit | 196fbbe077968016ad5d4507d99b3ed4c9f82850 (patch) | |
tree | 400187dbe7902bdce812cd068427b81680c7adb8 /recipes-core/initscripts | |
parent | 964253932585c2fcee6266a69db7f8921ed28dd5 (diff) | |
download | meta-mlinux-196fbbe077968016ad5d4507d99b3ed4c9f82850.tar.gz meta-mlinux-196fbbe077968016ad5d4507d99b3ed4c9f82850.tar.bz2 meta-mlinux-196fbbe077968016ad5d4507d99b3ed4c9f82850.zip |
New umountfs for factory flash upgrade from mLinux
Diffstat (limited to 'recipes-core/initscripts')
-rw-r--r-- | recipes-core/initscripts/initscripts-1.0/umountfs | 61 | ||||
-rw-r--r-- | recipes-core/initscripts/initscripts_1.0.bbappend | 2 |
2 files changed, 53 insertions, 10 deletions
diff --git a/recipes-core/initscripts/initscripts-1.0/umountfs b/recipes-core/initscripts/initscripts-1.0/umountfs index c3d217e..d3ac460 100644 --- a/recipes-core/initscripts/initscripts-1.0/umountfs +++ b/recipes-core/initscripts/initscripts-1.0/umountfs @@ -43,6 +43,19 @@ umount_all() { mount -o remount,ro / } +get_file_size() { + local file_size=0 + local regex='[^[:space:]]+[[:space:]]+[^[:space:]]+[[:space:]]+([^[:space:]]+)' + local upgrade_file="$1" + local file="$2" + if [[ $(tar -tvf ${upgrade_file} ${file}) =~ ${regex} ]] ; then + file_size=${BASH_REMATCH[1]} + echo "${file_size}" + else + echo "0" + fi +} + blink_leds() { led_dir=/sys/class/leds # blink all programmable LEDs except status @@ -295,9 +308,9 @@ flash_upgrade() { fi if ! cp ${reboot_cmd} ${flash_dir}/upgrade-reboot ; then - echo "Aborting upgrade. Failed \"cp ${reboot_cmd} ${flash_dir}/upgrade-reboot\"" - err_leds - return 1 + echo "Aborting upgrade. Failed \"cp ${reboot_cmd} ${flash_dir}/upgrade-reboot\"" + err_leds + return 1 fi if ! cp ${nandwrite_cmd} ${flash_dir}/nandwrite.static ; then echo "Aborting upgrade. Failed \"cp ${nandwrite_cmd} ${flash_dir}/nandwrite.static\"" @@ -336,18 +349,37 @@ flash_upgrade() { local dev=${devs[i]} if tar -t -f ${upgrade_file} | grep -F -q "${file}"; then if [ "${file}" == "${bootstrap_file}" ] || [ "${file}" == "${uboot_file}" ]; then - local file_size=$(tar -xO -f ${upgrade_file} ${file} | wc -c) + file_size=$(get_file_size "${upgrade_file}" "${file}") if dd if=${dev} bs=${file_size} count=1 | md5sum -c ${file}.md5; then echo "Found ${file} in upgrade but it is the same as current. Continuing..." continue fi - fi + elif ((factory_up == 1)) ; then # Not AT91Bootstrap or U-Boot. + file_size=$(get_file_size "${upgrade_file}" "${file}") + if [ "${file}" == "${kernel_file}" ]; then + if dd if=${dev} bs=${file_size} count=1 | md5sum -c ${file}.md5; then + echo "Found ${file} in upgrade but it is the same as current. Continuing..." + continue + fi # Matching md5sum + fi # kernel_file case + fi # factory upgrade echo "Flashing ${dev} with ${file}..." flash_erase ${extraopt} -j ${dev} 0 0 tar -xO -f ${upgrade_file} ${file} | ${flash_dir}/nandwrite.static ${extraopt} -p ${dev} - fi - done + if ((factory_up == 1)) ; then + if dd if=${dev} bs=${file_size} count=1 | md5sum -c ${file}.md5; then + echo "SUCCESS: File ${file} was written successfully" + else + cat ${file}.md5 + echo ${file_size} + echo dd if=${dev} bs=${file_size} count=1 | md5sum + dd if=${dev} bs=${file_size} count=1 | md5sum + echo "ERROR: File ${file} is bad" + fi + fi # factory upgrade + fi # Found a file in the upgrade package + done # Loop through the files in an upgrade package else if [ -f ${uboot_solo_file} ]; then echo "Flashing ${uboot_mtd} (u-boot) with ${uboot_solo_file}..." @@ -384,9 +416,14 @@ flash_upgrade() { flash_erase ${extraopt} ${ubootenv1_mtd} 0 0 flash_erase ${extraopt} ${ubootenv2_mtd} 0 0 fi - echo "Rebooting..." - ${flash_dir}/upgrade-reboot + if ((factory_up == 1)) ; then + echo "Finished upgrade. Halting." + while : ; do : ; done # Wait forever + else + echo "Rebooting..." + ${flash_dir}/upgrade-reboot + fi # Should not get here normally echo "upgrade-reboot failed" @@ -404,6 +441,12 @@ if [[ -f ${wipe_fname} ]] ; then fi fi if [[ -f ${upgrade_fname} ]] ; then + if [[ $(cat ${upgrade_fname}) == "1" ]] ; then + factory_up=1 + extraopt="-q" + else + factory_up=0 + fi owner=$(stat -c%u "${upgrade_fname}") if ((${#owner} > 0)) && ((owner == 0)) ; then flash_upgrade /var/volatile diff --git a/recipes-core/initscripts/initscripts_1.0.bbappend b/recipes-core/initscripts/initscripts_1.0.bbappend index bec5d5a..f4edd90 100644 --- a/recipes-core/initscripts/initscripts_1.0.bbappend +++ b/recipes-core/initscripts/initscripts_1.0.bbappend @@ -3,4 +3,4 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:" # flash on reboot/umountfs needs regular umount (not busybox) RDEPENDS_${PN} += "util-linux-umount util-linux-mount bash" -PR .= ".48" +PR .= ".49" |