openwrt/target/linux/ramips/mt7621/base-files/lib/upgrade/buffalo.sh

113 lines
3.3 KiB
Bash
Raw Normal View History

ramips: add support for Buffalo WSR-2533DHPLS Buffalo WSR-2533DHPLS is a 2.4/5 GHz band 11ac router, based on MediaTek MT7621A. Very similar to Buffalo WSR-2533DHPL, but with NAND, different GPIO and TRX partitions. Specification: - SoC : MediaTek MT7621AT - RAM : DDR3 256 MiB (Samsung K4B2G1646F-BYMA) - Flash : RAW-NAND 128 MiB (Winbond W29N01HV or KIOXIA TC58BVG0S3HTAI0) - WLAN : 2.4/5 GHz (2x MediaTek MT7615N) - Ethernet : 10/100/1000 Mbps - Switch : MediaTek MT7530 (SoC) 4 ports - LED/keys : 8x/6x (2x buttons, 1x slide-switch) - UART : through-hole on PCB (J4) - arrangement : 3.3V, GND, TX, RX from triangle-mark - settings : 115200n8 - Power : 12VDC 1.5A Flash instruction using factory.bin image: 1. boot WSR-2533DHPLS normally with "Router" mode 2. access to the WebI ("http://192.168.11.1/") on the device and open firmware update page ("管理" -> "ファームウェア更新") 3. select the OpenWrt factory.bin image and click update ("更新実行") button Attention: do not use "factory-uboot.bin" image 4. Wait ~120 seconds to complete flashing Flash instruction using initramfs image: 1. prepare the TFTP server with the initramfs image renamed to "linux.trx-recovery" and IP address "192.168.11.2" 2. press the "AOSS" button while powering on the WSR-2533DHPLS 3. after 10 seconds, release the "AOSS" button, WSR-2533DHPLS downloads the initramfs image and boot with it automatically 4. on the initramfs image, download the factory-uboot.bin image to the device and perform sysupgrade with it and "-F" option 5. wait ~120 seconds to complete flashing Notes: - The embedded addresses in eeprom data in Factory partition have Buffalo's OUI, but they don't match with the actual addresses assigned to wlan devices. So fixup addresses by the user-space script. root@localhost:/# hexdump -C /dev/mtdblock3 | grep "^0000[08]000\s" 00000000 15 76 a0 00 88 57 ee bc 01 a8 15 76 c3 14 00 80 |.v...W.....v....| 00008000 15 76 a0 00 88 57 ee bc 01 f8 15 76 c3 14 00 80 |.v...W.....v....| See "MAC addresses" below for actual addresses. - There are 2x factory*.bin images for different purposes. - factory.bin : for flashing on OEM WebUI - factory-uboot.bin: for flashing on OEM bootloader or initramfs image factory-uboot.bin is useful for recoverying the device, or refreshing when the kernel partition is expanded in the future. sysupgrade on this device accepts factory-uboot.bin with option "-F", but on that situation, user configurations won't be kept, so it's not for normal use. MAC addresses: LAN : 90:96:F3:xx:xx:30 (board_data, "mac" (text)) WAN : 90:96:F3:xx:xx:30 (board_data, "mac" (text)) 2.4 GHz: 90:96:F3:xx:xx:31 5 GHz : 90:96:F3:xx:xx:38 [original work] Signed-off-by: Audun-Marius Gangstø <audun@gangsto.org> [convert to ubi, fix/improve DT, add sysupgrade support] Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2024-03-30 06:33:58 +00:00
# The mtd partitions "firmware" and "Kernel2" on NAND flash are os-image
# partitions. These partitions are called as "Image1/Image2" in U-Boot
# on WSR-2533DHPLx devices, and they are checked conditions when booting.
# "Image1" is always used for booting.
#
# == U-Boot Behaviors ==
#
# - "Image1"/"Image2" images are good, images are different or
# "Image2" image is broken
# -> copy os-image to "Image2" from "Image1"
#
# - "Image1" image is broken
# -> copy os-image to "Image1" from "Image2"
#
# - "Image1"/"Image2" images are broken
# -> fall to U-Boot command line
# TRX magic numbers of each model
case "$(board_name)" in
ramips: add support for Buffalo WSR-2533DHPL2 Buffalo WSR-2533DHPL2 is a 2.4/5 GHz band 11ac (Wi-Fi 5) router, based on MediaTek MT7621A. Specification: - SoC : MediaTek MT7621AT - RAM : DDR3 128 MiB (Winbond W631GG6MB12J) - Flash : RAW-NAND 128 MiB (Winbond W29N01HVSINF) - WLAN : 2.4/5 GHz (2x MediaTek MT7615N) - Ethernet : 10/100/1000 Mbps x4 - Switch : MediaTek MT7530 (SoC) - LED/keys : 8x/6x (2x buttons, 1x slide-switch) - UART : through-hole on PCB (J4) - arrangement : 3.3V, GND, TX, RX from triangle-mark - settings : 57600n8 - Power : 12VDC 1.5A Flash instruction using factory.bin image: 1. boot WSR-2533DHPL2 normally with "Router" mode 2. access to the WebI ("http://192.168.11.1/") on the device and open firmware update page ("管理" -> "ファームウェア更新") 3. select the OpenWrt factory.bin image and click update ("更新実行") button Attention: do not use "factory-uboot.bin" image 4. Wait ~120 seconds to complete flashing Flash instruction using initramfs image: 1. prepare the TFTP server with the initramfs image renamed to "linux.trx-recovery" and IP address "192.168.11.2" 2. press the "AOSS" button while powering on the WSR-2533DHPL2 3. after 10 seconds, release the "AOSS" button, WSR-2533DHPL2 downloads the initramfs image and boot with it automatically 4. on the initramfs image, download the factory-uboot.bin image to the device and perform sysupgrade with it and "-F" option 5. wait ~120 seconds to complete flashing Notes: - There are 2x factory*.bin images for different purposes. - factory.bin : for flashing on OEM WebUI - factory-uboot.bin: for flashing on OEM bootloader or initramfs image factory-uboot.bin is useful for recoverying the device, or refreshing when the kernel partition is expanded in the future. sysupgrade on this device accepts factory-uboot.bin with option "-F", but on that situation, user configurations won't be kept, so it's not for normal use. MAC addresses: LAN : 18:EC:E7:xx:xx:E0 (board_data, "mac" (text)) WAN : 18:EC:E7:xx:xx:E0 (board_data, "mac" (text)) 2.4 GHz: 18:EC:E7:xx:xx:E1 (Factory, 0x4 (hex)) 5 GHz : 18:EC:E7:xx:xx:E4 (Factory, 0x8004 (hex)) Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2024-03-30 06:33:58 +00:00
buffalo,wsr-2533dhpl2)
BUFFALO_TRX_MAGIC="50484c32" # "PHL2"
;;
ramips: add support for Buffalo WSR-2533DHPLS Buffalo WSR-2533DHPLS is a 2.4/5 GHz band 11ac router, based on MediaTek MT7621A. Very similar to Buffalo WSR-2533DHPL, but with NAND, different GPIO and TRX partitions. Specification: - SoC : MediaTek MT7621AT - RAM : DDR3 256 MiB (Samsung K4B2G1646F-BYMA) - Flash : RAW-NAND 128 MiB (Winbond W29N01HV or KIOXIA TC58BVG0S3HTAI0) - WLAN : 2.4/5 GHz (2x MediaTek MT7615N) - Ethernet : 10/100/1000 Mbps - Switch : MediaTek MT7530 (SoC) 4 ports - LED/keys : 8x/6x (2x buttons, 1x slide-switch) - UART : through-hole on PCB (J4) - arrangement : 3.3V, GND, TX, RX from triangle-mark - settings : 115200n8 - Power : 12VDC 1.5A Flash instruction using factory.bin image: 1. boot WSR-2533DHPLS normally with "Router" mode 2. access to the WebI ("http://192.168.11.1/") on the device and open firmware update page ("管理" -> "ファームウェア更新") 3. select the OpenWrt factory.bin image and click update ("更新実行") button Attention: do not use "factory-uboot.bin" image 4. Wait ~120 seconds to complete flashing Flash instruction using initramfs image: 1. prepare the TFTP server with the initramfs image renamed to "linux.trx-recovery" and IP address "192.168.11.2" 2. press the "AOSS" button while powering on the WSR-2533DHPLS 3. after 10 seconds, release the "AOSS" button, WSR-2533DHPLS downloads the initramfs image and boot with it automatically 4. on the initramfs image, download the factory-uboot.bin image to the device and perform sysupgrade with it and "-F" option 5. wait ~120 seconds to complete flashing Notes: - The embedded addresses in eeprom data in Factory partition have Buffalo's OUI, but they don't match with the actual addresses assigned to wlan devices. So fixup addresses by the user-space script. root@localhost:/# hexdump -C /dev/mtdblock3 | grep "^0000[08]000\s" 00000000 15 76 a0 00 88 57 ee bc 01 a8 15 76 c3 14 00 80 |.v...W.....v....| 00008000 15 76 a0 00 88 57 ee bc 01 f8 15 76 c3 14 00 80 |.v...W.....v....| See "MAC addresses" below for actual addresses. - There are 2x factory*.bin images for different purposes. - factory.bin : for flashing on OEM WebUI - factory-uboot.bin: for flashing on OEM bootloader or initramfs image factory-uboot.bin is useful for recoverying the device, or refreshing when the kernel partition is expanded in the future. sysupgrade on this device accepts factory-uboot.bin with option "-F", but on that situation, user configurations won't be kept, so it's not for normal use. MAC addresses: LAN : 90:96:F3:xx:xx:30 (board_data, "mac" (text)) WAN : 90:96:F3:xx:xx:30 (board_data, "mac" (text)) 2.4 GHz: 90:96:F3:xx:xx:31 5 GHz : 90:96:F3:xx:xx:38 [original work] Signed-off-by: Audun-Marius Gangstø <audun@gangsto.org> [convert to ubi, fix/improve DT, add sysupgrade support] Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
2024-03-30 06:33:58 +00:00
buffalo,wsr-2533dhpls)
BUFFALO_TRX_MAGIC="44484c53" # "DHLS"
;;
esac
buffalo_check_image() {
local board="$1"
local boardname="$(echo $board | tr ',' '_')"
local magic="$2"
local fw_image="$3"
# return error state if TRX + UBI formatted image specified
# to notify about configurations
if [ "$magic" = "$BUFFALO_TRX_MAGIC" ]; then
echo "Your configurations won't be saved if factory-uboot.bin image specified."
echo "But if you want to upgrade, please execute sysupgrade with \"-F\" option."
return 1
fi
# check if valid tar file specifed
if ! tar tf "$fw_image" &>/dev/null; then
echo "Specified file is not a tar archive: $fw_image"
return 1
fi
local control_len=$( (tar xf $fw_image sysupgrade-$boardname/CONTROL -O | wc -c) 2> /dev/null)
# check if valid sysupgrade tar archive
if [ "$control_len" = "0" ]; then
echo "Invalid sysupgrade file: $fw_image"
return 1
fi
local kern_part_len=$(grep "\"linux\"" /proc/mtd | sed "s/mtd[0-9]*:[ \t]*\([^ \t]*\).*/\1/")
[ -z "$kern_part_len" ] && {
echo "Unable to get \"linux\" partition size"
return 1
}
kern_part_len=$((0x$kern_part_len))
# this also checks if the sysupgrade image is for correct models
local kern_bin_len=$( (tar xf $fw_image sysupgrade-${boardname}/kernel -O | wc -c) 2> /dev/null)
if [ -z "$kern_bin_len" ]; then
echo "Failed to get new kernel size, is valid sysupgrade image specified for the device?"
return 1
fi
# kernel binary has a trx header (len: 28 (0x1c))
kern_bin_len=$((kern_bin_len - 28))
if [ "$kern_bin_len" != "$kern_part_len" ]; then
echo -n "The length of new kernel is invalid for current "
echo "\"linux\" partition, please use factory-uboot.bin image."
echo "\"linux\" partition: $kern_part_len, new kernel: $kern_bin_len"
return 1
fi
}
# for TRX + UBI formatted image
buffalo_upgrade_ubinized() {
sync
echo 3 > /proc/sys/vm/drop_caches
local mtdnum="$( find_mtd_index "ubi" )"
# if no "ubi", don't return error for the purpose of recovery
# ex: recovery after accidental erasing "firmware" partition
if [ ! "$mtdnum" ]; then
echo "cannot find ubi mtd partition \"ubi\", skip detachment"
else
ubidetach -m "$mtdnum"
fi
# erase all data in "firmware"
mtd erase "${PART_NAME}"
# write TRX + UBI formatted image to "firmware"
get_image "$1" | mtd $MTD_ARGS write - "${PART_NAME:-firmware}"
if [ $? -ne 0 ]; then
echo "Failed to write the specified image."
exit 1
fi
}
buffalo_do_upgrade() {
if [ "$(get_magic_long "$1")" = "$BUFFALO_TRX_MAGIC" ]; then
buffalo_upgrade_ubinized "$1"
else
CI_KERNPART="firmware"
nand_do_upgrade "$1"
fi
}