forked from lede-project/source
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lantiq: BTHOMEHUB5A - create install image
Signed-off-by: Mathias Kresin <dev@kresin.me>
- Loading branch information
Showing
15 changed files
with
3,081 additions
and
16 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
******************************************************************************* | ||
* Guide for installing LEDE onto a BT Home Hub 5 Type A/Plusnet Hub One * | ||
******************************************************************************* | ||
|
||
You need an USB flash drive with at least 512MB free capacity, formatted as | ||
FAT32 or exFAT, attached to the Hub. The attached flash drive will be | ||
accessible at /tmp/mounts/<directory>. | ||
|
||
To install LEDE, the USB flash drive must have a copy of the file: | ||
lede-lantiq-xrx200-BTHOMEHUBV5A-squashfs-sysupgrade.bin | ||
|
||
To restore the stock Firmware, the USB flash drive must have a have a copy | ||
of the nanddump backup file (hh5a.nanddump) containing the stock Firmware. | ||
|
||
LIST OF COMMANDS | ||
|
||
To create a backup of the installed firmware (Take care to not overwrite | ||
any previously made backup): | ||
nanddump --file /tmp/mounts/<directory>/hh5a.nanddump /dev/mtd4 | ||
|
||
To install LEDE: | ||
prepare | ||
|
||
To restore stock firmware: | ||
restore | ||
|
||
TO UPGRADE FROM OpenWrt OR LEDE PRIOR TO XXX: | ||
|
||
Restore the stock firmware and do a fresh install of LEDE. | ||
|
||
If you don't have a backup of the stock firmware from your Hub, use the | ||
experimental 'migrate' script. It is offered with no guarantee of success. | ||
You are strongly advised to restore the stock firmware. | ||
|
||
Please scroll back to view ALL of the above instructions. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
#!/bin/sh | ||
# Copyright (C) 2016 Mathias Kresin <dev@kresin.me> | ||
|
||
. /lib/functions.sh | ||
|
||
# use the u-boot and u-boot env from bt for plusnet hub one as well | ||
UBOOT_FILE="/data/uboot.bin" | ||
UBOOT_ENV_FILE="/data/uboot-env_bt_patched.bin" | ||
|
||
# check for required binaries | ||
BINARIES="flash_erase hexdump nanddump nandwrite ubiattach ubidetach" | ||
for BINARY in ${BINARIES}; do | ||
[ ! -x $(which ${BINARY}) ] && { | ||
echo "${BINARY} not found - are you running the install image?" >&2 | ||
exit 1 | ||
} | ||
done | ||
|
||
# make sure expected partitions exist and are writable | ||
PART_NAME="u-boot" | ||
UBOOT_PART_INDEX=$(find_mtd_index "${PART_NAME}") | ||
[ -z "${UBOOT_PART_INDEX}" ] && { | ||
echo "${PART_NAME} partition not found - something is wrong!" >&2 | ||
exit 1 | ||
} | ||
|
||
[ $(cat /sys/class/block/mtdblock${UBOOT_PART_INDEX}/ro) -eq 1 ] && { | ||
echo "${PART_NAME} partition not writable - are you running the install image?" >&2 | ||
exit 1 | ||
} | ||
|
||
PART_NAME="uboot-env" | ||
UBOOT_ENV_PART_INDEX=$(find_mtd_index "${PART_NAME}") | ||
[ -z "${UBOOT_ENV_PART_INDEX}" ] && { | ||
echo "${PART_NAME} partition not found - something is wrong!" >&2 | ||
exit 1 | ||
} | ||
|
||
[ $(cat /sys/class/block/mtdblock${UBOOT_ENV_PART_INDEX}/ro) -eq 1 ] && { | ||
echo "${PART_NAME} partition not writable - are you running the install image?" >&2 | ||
exit 1 | ||
} | ||
|
||
PART_NAME="unused" | ||
UNUSED_PART_INDEX=$(find_mtd_index "${PART_NAME}") | ||
[ -z "${UNUSED_PART_INDEX}" ] && { | ||
echo "${PART_NAME} partition not found - something is wrong!" >&2 | ||
exit 1 | ||
} | ||
|
||
[ $(cat /sys/class/block/mtdblock${UNUSED_PART_INDEX}/ro) -eq 1 ] && { | ||
echo "${PART_NAME} partition not writable - are you running the install image?" >&2 | ||
exit 1 | ||
} | ||
|
||
PART_NAME="ubi" | ||
UBI_PART_INDEX=$(find_mtd_index "${PART_NAME}") | ||
[ -z "${UBI_PART_INDEX}" ] && { | ||
echo "${PART_NAME} partition not found - something is wrong!" >&2 | ||
exit 1 | ||
} | ||
|
||
[ $(cat /sys/class/block/mtdblock${UBI_PART_INDEX}/ro) -eq 1 ] && { | ||
echo "${PART_NAME} partition not writable - something is wrong!" >&2 | ||
exit 1 | ||
} | ||
|
||
# make sure required files exist | ||
[ ! -s "${UBOOT_FILE}" ] && { | ||
echo "U-Boot file ${UBOOT_FILE} not found - are you running the install image?" >&2 | ||
exit 1 | ||
} | ||
|
||
[ ! -s "${UBOOT_ENV_FILE}" ] && { | ||
echo "U-Boot Enviroment file ${UBOOT_ENV_FILE} not found - are you running the install image?" >&2 | ||
exit 1 | ||
} | ||
|
||
# make sure the required bits are present on the flash | ||
[ "$(nanddump -q -s 0x81000 /dev/mtd${UBOOT_PART_INDEX} | hexdump -v -n 2 -e '1/1 "%02x"')" != "a55a" ] && { | ||
echo "Caldata not found on flash. Sorry, there is nothing we can do for you!" >&2 | ||
exit 1 | ||
} | ||
|
||
echo "This script should be only used as a LAST RESORT to migrate to the new LEDE" | ||
echo "partition layout if you have no backup, or you cannot restore the stock firmware" | ||
echo "for any other reason." | ||
echo "" | ||
echo "DISCLAIMER: Use this script at your own risk. Very limited testing has been" | ||
echo " completed for this script. It is offered with no guarantee of" | ||
echo " success." | ||
echo "" | ||
echo "You are strongly advised to use the 'restore' and 'prepare' scripts to" | ||
echo "restore the stock firmware, and then to install LEDE." | ||
echo "" | ||
echo "" | ||
echo "WARNING: DO NOT CONTINUE unless you have saved a backup of the current running" | ||
echo " firmware to your COMPUTER or other storage device!" | ||
echo "" | ||
echo "" | ||
echo "Please enter YESIHAVEABACKUP to continue:" | ||
|
||
read CONFIRMATION | ||
|
||
[ "${CONFIRMATION}" != "YESIHAVEABACKUP" ] && exit 0 | ||
|
||
set -o pipefail | ||
|
||
echo "" | ||
echo "STARTING migration..." | ||
|
||
echo "DETACHING ubi partition..." | ||
# hide any error messages to not confuse users in case the ubi volume isn't at | ||
# the expected position or doesn't exist at all | ||
ubidetach -m "${UBI_PART_INDEX}" 2>/dev/null | ||
|
||
echo "" | ||
echo "FORMATING ubi partition" | ||
ubiformat "/dev/mtd${UBI_PART_INDEX}" -y | ||
|
||
NAND_UBI_DEV_ID=0 | ||
echo "" | ||
echo "ATTACHING ubi partition to ubi dev number ${NAND_UBI_DEV_ID} using" | ||
echo "19 reserved blocks for bad block handling" | ||
ubiattach -m "${UBI_PART_INDEX}" -d "${NAND_UBI_DEV_ID}" --max-beb-per1024=19 | ||
|
||
UBI_VOL_NAME="caldata" | ||
echo "" | ||
echo "COPYING caldata to ${UBI_VOL_NAME} ubi volume" | ||
UBI_VOL_SIZE=129024 | ||
UBI_VOL_ID=3 | ||
ubimkvol /dev/ubi"${NAND_UBI_DEV_ID}" -n "${UBI_VOL_ID}" -N "${UBI_VOL_NAME}" -s "${UBI_VOL_SIZE}" | ||
nanddump -s 0x80000 -l 0x20000 "/dev/mtd${UBOOT_PART_INDEX}" | \ | ||
ubiupdatevol /dev/ubi"${NAND_UBI_DEV_ID}"_"${UBI_VOL_ID}" -s "${UBI_VOL_SIZE}" - | ||
|
||
echo "" | ||
echo "RESTORING u-boot partition from ${UBOOT_FILE}" | ||
flash_erase "/dev/mtd${UBOOT_PART_INDEX}" 0 0 | ||
nandwrite -m "/dev/mtd${UBOOT_PART_INDEX}" "${UBOOT_FILE}" | ||
|
||
echo "" | ||
echo "RESTORING u-boot env partition from ${UBOOT_ENV_FILE} (unlocked u-boot console and update bootcmd)" | ||
flash_erase "/dev/mtd${UBOOT_ENV_PART_INDEX}" 0 0 | ||
nandwrite -m "/dev/mtd${UBOOT_ENV_PART_INDEX}" "${UBOOT_ENV_FILE}" | ||
|
||
echo "" | ||
echo "FORMATING unused partition" | ||
flash_erase "/dev/mtd${UNUSED_PART_INDEX}" 0 0 | ||
|
||
echo "" | ||
echo "Migration finished!" | ||
echo "" | ||
echo "" | ||
echo "To install LEDE, run:" | ||
echo "" | ||
echo " sysupgrade /tmp/mounts/<directory>/lede-lantiq-xrx200-BTHOMEHUBV5A-squashfs-sysupgrade.bin" | ||
echo "" | ||
echo "Sysupgrade will automatically restart your device when it has finished." | ||
echo "If the UART prompt appears, power-cycle your device!" | ||
echo "The hub should now boot up using LEDE." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
#!/bin/sh | ||
# Copyright (C) 2016 Mathias Kresin <dev@kresin.me> | ||
|
||
. /lib/functions.sh | ||
|
||
# bt homehub 5a and plusnet hub one are using different AES256 keys for the env | ||
UBOOT_ENV_BT_FILE="/data/uboot-env_bt_patched.bin" | ||
UBOOT_ENV_PN_FILE="/data/uboot-env_pn_patched.bin" | ||
|
||
# check for required binaries | ||
BINARIES="flash_erase nandwrite ubirmvol" | ||
for BINARY in ${BINARIES}; do | ||
[ ! -x $(which ${BINARY}) ] && { | ||
echo "${BINARY} not found - are you running the install image?" >&2 | ||
exit 1 | ||
} | ||
done | ||
|
||
# make sure expected partitions exist and are writable | ||
PART_NAME="ubi" | ||
UBI_PART_INDEX=$(find_mtd_index "${PART_NAME}") | ||
[ -z "${UBI_PART_INDEX}" ] && { | ||
echo "${PART_NAME} partition not found - something is wrong!" >&2 | ||
exit 1 | ||
} | ||
|
||
[ $(cat /sys/class/block/mtdblock${UBI_PART_INDEX}/ro) -eq 1 ] && { | ||
echo "${PART_NAME} partition not writable - something is wrong!" >&2 | ||
exit 1 | ||
} | ||
|
||
PART_NAME="uboot-env" | ||
UBOOT_ENV_PART_INDEX=$(find_mtd_index "${PART_NAME}") | ||
[ -z "${UBOOT_ENV_PART_INDEX}" ] && { | ||
echo "${PART_NAME} partition not found - something is wrong!" >&2 | ||
exit 1 | ||
} | ||
|
||
[ $(cat /sys/class/block/mtdblock${UBOOT_ENV_PART_INDEX}/ro) -eq 1 ] && { | ||
echo "${PART_NAME} partition not writable - are you running the install image?" >&2 | ||
exit 1 | ||
} | ||
|
||
# make sure required files exist | ||
[ ! -s "${UBOOT_ENV_BT_FILE}" ] && { | ||
echo "U-Boot Enviroment file ${UBOOT_ENV_BT_FILE} not found - are you running the install image?" >&2 | ||
exit 1 | ||
} | ||
|
||
[ ! -s "${UBOOT_ENV_PN_FILE}" ] && { | ||
echo "U-Boot Enviroment file ${UBOOT_ENV_PN_FILE} not found - are you running the install image?" >&2 | ||
exit 1 | ||
} | ||
|
||
echo "" | ||
echo "This script will erase parts of the Nand flash memory on this Hub, and then" | ||
echo "prepare it for running Sysupgrade." | ||
echo "" | ||
echo "" | ||
echo "WARNING: DO NOT CONTINUE unless you have saved a backup of the original firmware" | ||
echo " to your COMPUTER or other storage device!" | ||
echo "" | ||
echo "" | ||
echo "DO NOT POWER OFF THE DEVICE DURING THIS PROCEDURE." | ||
echo "" | ||
echo "" | ||
echo "Please enter YESIHAVEABACKUP to continue:" | ||
|
||
read CONFIRMATION | ||
|
||
[ "${CONFIRMATION}" != "YESIHAVEABACKUP" ] && exit 0 | ||
|
||
set -o pipefail | ||
|
||
echo "" | ||
echo "Starting installation..." | ||
|
||
# TODO: Add AES256 support to the u-boot env tools and try all known AES256 keys. | ||
echo "" | ||
echo "Please select you device:" | ||
echo "" | ||
echo "a) BT Home Hub 5 Type A" | ||
echo "b) Plusnet Hub One" | ||
echo "" | ||
read DEVICETYPE | ||
|
||
case $DEVICETYPE in | ||
"a") | ||
UBOOT_ENV_FILE=$UBOOT_ENV_BT_FILE | ||
;; | ||
"b") | ||
UBOOT_ENV_FILE=$UBOOT_ENV_PN_FILE | ||
;; | ||
*) | ||
echo "invalid option" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# TODO: Use the AES256 enabled u-boot env tools to remove the silent flag and | ||
# to set the correct bootcmd commands, instead of replacing the whole | ||
# u-boot env. | ||
# setenv bootcmd ubi part UBI\; ubi read \$(loadaddr) kernel\; bootm \$(loadaddr) | ||
# setenv silent | ||
# saveenv | ||
echo "" | ||
echo "WRITING custom uboot-env to unlock u-boot console and update bootcmd..." | ||
flash_erase "/dev/mtd${UBOOT_ENV_PART_INDEX}" 0 0 | ||
nandwrite "/dev/mtd${UBOOT_ENV_PART_INDEX}" "${UBOOT_ENV_FILE}" | ||
|
||
echo "" | ||
echo "REMOVING ubi volume OpenRG..." | ||
ubirmvol /dev/ubi0 --name=OpenRG | ||
|
||
echo "" | ||
echo "REMOVING ubi volume FFS..." | ||
ubirmvol /dev/ubi0 --name=FFS | ||
|
||
echo "" | ||
echo "" | ||
echo "Preparation completed!" | ||
echo "" | ||
echo "Your attached USB media is mounted as a subdirectory at /tmp/mounts/" | ||
echo "" | ||
echo "To install LEDE, run:" | ||
echo "" | ||
echo " sysupgrade /tmp/mounts/<directory>/lede-lantiq-xrx200-BTHOMEHUBV5A-squashfs-sysupgrade.bin" | ||
echo "" | ||
echo "Sysupgrade will automatically restart your device when it has finished." | ||
echo "If the UART prompt appears, power-cycle your device!" | ||
echo "The hub should now boot up using LEDE." |
Oops, something went wrong.