Skip to content

Commit

Permalink
ubiupdatevol fails when target bank smaller (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
seud0nym committed Dec 13, 2023
1 parent 19bf87d commit 988eb36
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
53 changes: 45 additions & 8 deletions utilities/set-optimal-bank-plan
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,61 @@ else
echo -e "${GREEN}==> Passive = ${PASSIVE_VERSION}${NC}"
fi

manual_bank_planning() {
echo -e "${ORANGE}"
echo -e "########################################################"
echo -e "# You will need to manually set the optimal bank plan. #"
echo -e "# #"
echo -e "# 1. Ensure you have a rootable firmware in bank 1. #"
echo -e "# 2. Ensure you are running from bank 1: #"
echo -e "# a. Use ${NC}./show-bank-plan${ORANGE} to see active/booted bank #"
echo -e "# b. If necessary, swap to bank 1 using #"
echo -e "# ${NC}./reset-to-factory-defaults-with-root -s${ORANGE} #"
echo -e "# 3. Use ./safe-firmware-upgrade to load required #"
echo -e "# firmware into bank 2 #"
echo -e "# 4. Confirm bank layout with ${NC}./show-bank-plan${ORANGE} #"
echo -e "########################################################"
echo -e "${NC}"
}

echo -e "${ORANGE}Ensuring the banks match in size...${NC}"
if [ $BANKTABLE = Y ]; then
echo -e "${ORANGE}Ensuring the banks match in size...${NC}"
BANK_COUNT=$(grep -c bank_ /proc/mtd)
if [ $BANK_COUNT -ne 2 ]; then
echo -e "${RED}==> ABORTING: Unexpected bank count - Expected 2 but found ${BANK_COUNT}!${NC}"
exit 2
fi
BANK1_SIZE="$(grep bank_1 /proc/mtd | cut -d' ' -f2)"
BANK2_SIZE="$(grep bank_2 /proc/mtd | cut -d' ' -f2)"
if [ "$BANK1_SIZE" != "$BANK2_SIZE" ]; then
echo -e "${RED}==> ABORTING: Bank 1 and Bank 2 are different sizes??${NC}"
echo " - Bank 1 = $BANK1_SIZE"
echo " - Bank 2 = $BANK2_SIZE"
exit 2
else
echo -e "${GREEN}==> OKAY: Bank 1 = ${BANK1_SIZE} Bank 2 = ${BANK2_SIZE}${NC}"
else
BANK1_SIZE="$(grep rootfs1 /proc/mtd | cut -d' ' -f2)"
BANK2_SIZE="$(grep rootfs2 /proc/mtd | cut -d' ' -f2)"
fi
if [ "$BANK1_SIZE" != "$BANK2_SIZE" ]; then
echo -e "${RED}==> ABORTING: Bank 1 and Bank 2 are different sizes${NC}"
echo " - Bank 1 = $BANK1_SIZE"
echo " - Bank 2 = $BANK2_SIZE"
if [ $BANKTABLE = N ]; then
manual_bank_planning
fi
exit 2
else
echo -e "${GREEN}==> OKAY: Bank 1 = ${BANK1_SIZE} Bank 2 = ${BANK2_SIZE}${NC}"
if [ $BANKTABLE = N ]; then
BANK1_SIZE="$(grep bootfs1 /proc/mtd | cut -d' ' -f2)"
BANK2_SIZE="$(grep bootfs2 /proc/mtd | cut -d' ' -f2)"
if [ "$BANK1_SIZE" != "$BANK2_SIZE" ]; then
echo -e "${RED}==> ABORTING: Boot 1 and Boot 2 are different sizes${NC}"
echo " - Boot 1 = $BANK1_SIZE"
echo " - Boot 2 = $BANK2_SIZE"
manual_bank_planning
exit 2
else
echo -e "${GREEN}==> OKAY: Boot 1 = ${BANK1_SIZE} Boot 2 = ${BANK2_SIZE}${NC}"
fi
fi
fi
if [ $BANKTABLE = N ]; then
echo -e "${ORANGE}Checking /tmp space...${NC}"
rm -f /tmp/ubi*
sync
Expand Down
1 change: 0 additions & 1 deletion utilities/show-bank-plan
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ else
echo
echo "It is strongly recommended that you always boot from bank 2 on this device, and"
echo "keep a rootable firmware in bank 1 for updating the bank 2 firmware."
set_optimal_bank_plan
fi
fi
exit 1
Expand Down

0 comments on commit 988eb36

Please sign in to comment.