openwrt/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh

198 lines
5.2 KiB
Bash
Raw Normal View History

REQUIRE_IMAGE_METADATA=1
RAMFS_COPY_BIN='blockdev'
# Full system upgrade including preloader for MediaTek SoCs on eMMC or SD
mtk_mmc_full_upgrade() {
local diskdev partdev diff oldrecovery
if grep -q root=/dev/mmcblk0p2 /proc/cmdline; then
oldrecovery=1
else
oldrecovery=2
fi
export_bootdevice && export_partdevice diskdev 0 || {
echo "Unable to determine upgrade device"
return 1
}
#Keep the persistent random mac address (if it exists)
mkdir -p /tmp/recovery
export_partdevice recoverydev $oldrecovery
if mount -o rw,noatime "/dev/$recoverydev" -tvfat /tmp/recovery; then
[ -f "/tmp/recovery/mac_addr" ] && cp /tmp/recovery/mac_addr /tmp/
umount /tmp/recovery
fi
sync
if [ "$SAVE_PARTITIONS" = "1" ]; then
get_partitions "/dev/$diskdev" bootdisk
#extract the boot sector from the image
get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b
get_partitions /tmp/image.bs image
#compare tables
diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
else
diff=1
fi
if [ -n "$diff" ]; then
get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync
# Separate removal and addition is necessary; otherwise, partition 1
# will be missing if it overlaps with the old partition 2
partx -d - "/dev/$diskdev"
partx -a - "/dev/$diskdev"
else
# iterate over each partition from the image and write it to the boot disk
while read part start size; do
part="$(($part - 2))"
if export_partdevice partdev $part; then
echo "Writing image to /dev/$partdev..."
get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
else
echo "Unable to find partition $part device, skipped."
fi
done < /tmp/partmap.image
#copy partition uuid
echo "Writing new UUID to /dev/$diskdev..."
get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
fi
export_partdevice recoverydev 2
if mount -o rw,noatime "/dev/$recoverydev" -t vfat /tmp/recovery; then
[ -f "/tmp/mac_addr" ] && cp /tmp/mac_addr /tmp/recovery
if [ "$diskdev" = "mmcblk0" -a -r /tmp/recovery/eMMCboot.bin ]; then
echo 0 > /sys/block/mmcblk0boot0/force_ro
dd if=/tmp/recovery/eMMCboot.bin of=/dev/mmcblk0boot0 conv=fsync
sync
echo 1 > /sys/block/mmcblk0boot0/force_ro
fi
sync
umount /tmp/recovery
fi
}
platform_do_upgrade() {
local board=$(board_name)
case "$board" in
bananapi,bpi-r2)
export_bootdevice
export_partdevice rootdev 0
export_partdevice fitpart 3
[ "$fitpart" ] || return 1
dd if=/dev/zero of=/dev/$fitpart bs=4096 count=1 2>/dev/null
blockdev --rereadpt /dev/$rootdev
get_image "$1" | dd of=/dev/$fitpart
blockdev --rereadpt /dev/$rootdev
local datapart=$(get_partition_by_name $rootdev "rootfs_data")
[ "$datapart" ] || return 0
dd if=/dev/zero of=/dev/$datapart bs=4096 count=1 2>/dev/null
echo $datapart > /tmp/sysupgrade.datapart
;;
unielec,u7623-02-emmc-512m)
local magic="$(get_magic_long "$1")"
if [ "$magic" = "53444d4d" ]; then
mtk_mmc_full_upgrade "$1"
else # Old partial image starting with uImage
# Keep the persistent random mac address (if it exists)
recoverydev=mmcblk0p1
mkdir -p /tmp/recovery
mount -o rw,noatime /dev/$recoverydev /tmp/recovery
[ -f "/tmp/recovery/mac_addr" ] && \
mv -f /tmp/recovery/mac_addr /tmp/
umount /tmp/recovery
mediatek: Add support for the UniElec U7623-02 This commit adds support for the MT7623A-based UniElec U7623-02 router, with eMMC storage and 512MB RAM. The router can be delivered with NAND Flash and more memory, but I only have access to the one configuration. The DTS is structured in such a way that adding support for more/different storage/memory should be straight forward. The device has the following specifications: * MT7623A (quad-core, 1.3 GHz) * 512MB RAM (DDR3) * 8GB storage (eMMC 4.5) * 2x normal miniPCIe slots * 1x miniPCIe slot that is connected via an internal USB OTG port * 5x 1Gbps Ethernet (MT7530 switch) * 1x UART header * 1x USB 3.0 port * 1x SATA 3.0 * 1x 40P*0.5mm FPC for MIPI LCD * 1x SIM slot * 12x LEDs (2 GPIO controlled) * 1x reset button * 1x DC jack for main power (12V) The following has been tested and is working: * Ethernet switch * miniPCIe slots (tested with Wi-Fi cards) * USB 3.0 port * sysupgrade * reset button Not working: * The miniPCIe connected via USB OTG. For the port to work, some MUSB glue must be added. I am currently in the process of porting the glue from the vendor SDK. Not tested: * SATA 3.0 * MIPI LCD Installation: The board ships with u-boot, and the first installation needs to be done via the bootloader using tftp. Step number one is to update the MBR of the eMMC, as the one that ships with the device is broken. Since the device can ship with different storage sizes, I will not provide the exact steps for creating a valid MBR. However, I have made some assumptions about the disk layout - there must be one 8MB recovery partition (FAT32) and a partition for the rootfs (Linux). The board loads the kernel from block 0xA00 (2560) and I have reserved 32MB for the kernel (65536 blocks). I have aligned the partitions on the erase block size (4096 byte), so the recovery partition must start on block 69632 and end on 86016 (16385 sectors). The rootfs is assumed to start on sector 90112. In order to install the mbr, you run the following commands from the u-boot command line: * tftpboot ${loadaddr} <name of mbr file> * mmc device 0 * mmc write ${loadaddr} 0x00 1 Run the following commands to install + boot OpenWRT: * tftpboot ${loadaddr} openwrt-mediatek-mt7623-7623a-unielec-u7623-02-emmc-512m-squashfs-sysupgrade-emmc.bin.gz * run boot_wr_img * run boot_rd_img * bootm Recovery: In order to recover the router, you need to follow the installation steps above (no need to replace MBR). Notes: * F2FS is used as the overlay filesystem. * The device does not ship with any valid MAC address, so a random address has to be generated. As a work-around, I write the initial random MAC to a file on the recovery partition. The MAC of the WAN interface is set to the MAC-address contained in this file on each boot, and the address of the LAN-interfaces are WAN + 1. The MAC file is kept across sysupgrade/firstboot. My approach is slightly different than what the stock image does. The first fives bytes of the MAC addresses in the stock image are static, and then the last byte is random. I believe it is better to create fully random MAC addresses. * In order to support the miniPCIe-slots, I needed to add missing pcie-nodes to mt7623.dtsi. The nodes are just c&p from the upstream dtsi. * One of the USB3.0 phys (u3phy2) on the board can be used as either USB or PCI, and one of the wifi-cards is connected to this phy. In order to support switching the phy from USB to PCI, I needed to patch the phy-driver. The patch is based on a rejected (at least last time I checked) PCI-driver submitted to the linux-mediatek mailing list. * The eMMC is configured to boot from the user area, and according to the data sheet of the eMMC this value can't be changed. * I tried to structure the MBR more nicely and use for example a FAT32-parition for the kernel, so that we don't need to write/read from some offset. The bootloader does not support reading from FAT32-paritions. While the command (fatload) is there, it just throws an error when I try to use it. * I will submit and hope to get the DTS for the device accepted upstream. If and when that happens, I will update the patches accordingly. Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
2018-06-20 01:17:40 +02:00
# 1310720 is the offset in bytes from the start of eMMC and to
# the location of the kernel (2560 512 byte sectors)
get_image "$1" | dd of=/dev/mmcblk0 bs=1310720 seek=1 conv=fsync
mediatek: Add support for the UniElec U7623-02 This commit adds support for the MT7623A-based UniElec U7623-02 router, with eMMC storage and 512MB RAM. The router can be delivered with NAND Flash and more memory, but I only have access to the one configuration. The DTS is structured in such a way that adding support for more/different storage/memory should be straight forward. The device has the following specifications: * MT7623A (quad-core, 1.3 GHz) * 512MB RAM (DDR3) * 8GB storage (eMMC 4.5) * 2x normal miniPCIe slots * 1x miniPCIe slot that is connected via an internal USB OTG port * 5x 1Gbps Ethernet (MT7530 switch) * 1x UART header * 1x USB 3.0 port * 1x SATA 3.0 * 1x 40P*0.5mm FPC for MIPI LCD * 1x SIM slot * 12x LEDs (2 GPIO controlled) * 1x reset button * 1x DC jack for main power (12V) The following has been tested and is working: * Ethernet switch * miniPCIe slots (tested with Wi-Fi cards) * USB 3.0 port * sysupgrade * reset button Not working: * The miniPCIe connected via USB OTG. For the port to work, some MUSB glue must be added. I am currently in the process of porting the glue from the vendor SDK. Not tested: * SATA 3.0 * MIPI LCD Installation: The board ships with u-boot, and the first installation needs to be done via the bootloader using tftp. Step number one is to update the MBR of the eMMC, as the one that ships with the device is broken. Since the device can ship with different storage sizes, I will not provide the exact steps for creating a valid MBR. However, I have made some assumptions about the disk layout - there must be one 8MB recovery partition (FAT32) and a partition for the rootfs (Linux). The board loads the kernel from block 0xA00 (2560) and I have reserved 32MB for the kernel (65536 blocks). I have aligned the partitions on the erase block size (4096 byte), so the recovery partition must start on block 69632 and end on 86016 (16385 sectors). The rootfs is assumed to start on sector 90112. In order to install the mbr, you run the following commands from the u-boot command line: * tftpboot ${loadaddr} <name of mbr file> * mmc device 0 * mmc write ${loadaddr} 0x00 1 Run the following commands to install + boot OpenWRT: * tftpboot ${loadaddr} openwrt-mediatek-mt7623-7623a-unielec-u7623-02-emmc-512m-squashfs-sysupgrade-emmc.bin.gz * run boot_wr_img * run boot_rd_img * bootm Recovery: In order to recover the router, you need to follow the installation steps above (no need to replace MBR). Notes: * F2FS is used as the overlay filesystem. * The device does not ship with any valid MAC address, so a random address has to be generated. As a work-around, I write the initial random MAC to a file on the recovery partition. The MAC of the WAN interface is set to the MAC-address contained in this file on each boot, and the address of the LAN-interfaces are WAN + 1. The MAC file is kept across sysupgrade/firstboot. My approach is slightly different than what the stock image does. The first fives bytes of the MAC addresses in the stock image are static, and then the last byte is random. I believe it is better to create fully random MAC addresses. * In order to support the miniPCIe-slots, I needed to add missing pcie-nodes to mt7623.dtsi. The nodes are just c&p from the upstream dtsi. * One of the USB3.0 phys (u3phy2) on the board can be used as either USB or PCI, and one of the wifi-cards is connected to this phy. In order to support switching the phy from USB to PCI, I needed to patch the phy-driver. The patch is based on a rejected (at least last time I checked) PCI-driver submitted to the linux-mediatek mailing list. * The eMMC is configured to boot from the user area, and according to the data sheet of the eMMC this value can't be changed. * I tried to structure the MBR more nicely and use for example a FAT32-parition for the kernel, so that we don't need to write/read from some offset. The bootloader does not support reading from FAT32-paritions. While the command (fatload) is there, it just throws an error when I try to use it. * I will submit and hope to get the DTS for the device accepted upstream. If and when that happens, I will update the patches accordingly. Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
2018-06-20 01:17:40 +02:00
mount -o rw,noatime /dev/$recoverydev /tmp/recovery
[ -f "/tmp/mac_addr" ] && mv -f /tmp/mac_addr /tmp/recovery
sync
umount /tmp/recovery
fi
mediatek: Add support for the UniElec U7623-02 This commit adds support for the MT7623A-based UniElec U7623-02 router, with eMMC storage and 512MB RAM. The router can be delivered with NAND Flash and more memory, but I only have access to the one configuration. The DTS is structured in such a way that adding support for more/different storage/memory should be straight forward. The device has the following specifications: * MT7623A (quad-core, 1.3 GHz) * 512MB RAM (DDR3) * 8GB storage (eMMC 4.5) * 2x normal miniPCIe slots * 1x miniPCIe slot that is connected via an internal USB OTG port * 5x 1Gbps Ethernet (MT7530 switch) * 1x UART header * 1x USB 3.0 port * 1x SATA 3.0 * 1x 40P*0.5mm FPC for MIPI LCD * 1x SIM slot * 12x LEDs (2 GPIO controlled) * 1x reset button * 1x DC jack for main power (12V) The following has been tested and is working: * Ethernet switch * miniPCIe slots (tested with Wi-Fi cards) * USB 3.0 port * sysupgrade * reset button Not working: * The miniPCIe connected via USB OTG. For the port to work, some MUSB glue must be added. I am currently in the process of porting the glue from the vendor SDK. Not tested: * SATA 3.0 * MIPI LCD Installation: The board ships with u-boot, and the first installation needs to be done via the bootloader using tftp. Step number one is to update the MBR of the eMMC, as the one that ships with the device is broken. Since the device can ship with different storage sizes, I will not provide the exact steps for creating a valid MBR. However, I have made some assumptions about the disk layout - there must be one 8MB recovery partition (FAT32) and a partition for the rootfs (Linux). The board loads the kernel from block 0xA00 (2560) and I have reserved 32MB for the kernel (65536 blocks). I have aligned the partitions on the erase block size (4096 byte), so the recovery partition must start on block 69632 and end on 86016 (16385 sectors). The rootfs is assumed to start on sector 90112. In order to install the mbr, you run the following commands from the u-boot command line: * tftpboot ${loadaddr} <name of mbr file> * mmc device 0 * mmc write ${loadaddr} 0x00 1 Run the following commands to install + boot OpenWRT: * tftpboot ${loadaddr} openwrt-mediatek-mt7623-7623a-unielec-u7623-02-emmc-512m-squashfs-sysupgrade-emmc.bin.gz * run boot_wr_img * run boot_rd_img * bootm Recovery: In order to recover the router, you need to follow the installation steps above (no need to replace MBR). Notes: * F2FS is used as the overlay filesystem. * The device does not ship with any valid MAC address, so a random address has to be generated. As a work-around, I write the initial random MAC to a file on the recovery partition. The MAC of the WAN interface is set to the MAC-address contained in this file on each boot, and the address of the LAN-interfaces are WAN + 1. The MAC file is kept across sysupgrade/firstboot. My approach is slightly different than what the stock image does. The first fives bytes of the MAC addresses in the stock image are static, and then the last byte is random. I believe it is better to create fully random MAC addresses. * In order to support the miniPCIe-slots, I needed to add missing pcie-nodes to mt7623.dtsi. The nodes are just c&p from the upstream dtsi. * One of the USB3.0 phys (u3phy2) on the board can be used as either USB or PCI, and one of the wifi-cards is connected to this phy. In order to support switching the phy from USB to PCI, I needed to patch the phy-driver. The patch is based on a rejected (at least last time I checked) PCI-driver submitted to the linux-mediatek mailing list. * The eMMC is configured to boot from the user area, and according to the data sheet of the eMMC this value can't be changed. * I tried to structure the MBR more nicely and use for example a FAT32-parition for the kernel, so that we don't need to write/read from some offset. The bootloader does not support reading from FAT32-paritions. While the command (fatload) is there, it just throws an error when I try to use it. * I will submit and hope to get the DTS for the device accepted upstream. If and when that happens, I will update the patches accordingly. Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
2018-06-20 01:17:40 +02:00
;;
*)
default_do_upgrade "$1"
mediatek: Add support for the UniElec U7623-02 This commit adds support for the MT7623A-based UniElec U7623-02 router, with eMMC storage and 512MB RAM. The router can be delivered with NAND Flash and more memory, but I only have access to the one configuration. The DTS is structured in such a way that adding support for more/different storage/memory should be straight forward. The device has the following specifications: * MT7623A (quad-core, 1.3 GHz) * 512MB RAM (DDR3) * 8GB storage (eMMC 4.5) * 2x normal miniPCIe slots * 1x miniPCIe slot that is connected via an internal USB OTG port * 5x 1Gbps Ethernet (MT7530 switch) * 1x UART header * 1x USB 3.0 port * 1x SATA 3.0 * 1x 40P*0.5mm FPC for MIPI LCD * 1x SIM slot * 12x LEDs (2 GPIO controlled) * 1x reset button * 1x DC jack for main power (12V) The following has been tested and is working: * Ethernet switch * miniPCIe slots (tested with Wi-Fi cards) * USB 3.0 port * sysupgrade * reset button Not working: * The miniPCIe connected via USB OTG. For the port to work, some MUSB glue must be added. I am currently in the process of porting the glue from the vendor SDK. Not tested: * SATA 3.0 * MIPI LCD Installation: The board ships with u-boot, and the first installation needs to be done via the bootloader using tftp. Step number one is to update the MBR of the eMMC, as the one that ships with the device is broken. Since the device can ship with different storage sizes, I will not provide the exact steps for creating a valid MBR. However, I have made some assumptions about the disk layout - there must be one 8MB recovery partition (FAT32) and a partition for the rootfs (Linux). The board loads the kernel from block 0xA00 (2560) and I have reserved 32MB for the kernel (65536 blocks). I have aligned the partitions on the erase block size (4096 byte), so the recovery partition must start on block 69632 and end on 86016 (16385 sectors). The rootfs is assumed to start on sector 90112. In order to install the mbr, you run the following commands from the u-boot command line: * tftpboot ${loadaddr} <name of mbr file> * mmc device 0 * mmc write ${loadaddr} 0x00 1 Run the following commands to install + boot OpenWRT: * tftpboot ${loadaddr} openwrt-mediatek-mt7623-7623a-unielec-u7623-02-emmc-512m-squashfs-sysupgrade-emmc.bin.gz * run boot_wr_img * run boot_rd_img * bootm Recovery: In order to recover the router, you need to follow the installation steps above (no need to replace MBR). Notes: * F2FS is used as the overlay filesystem. * The device does not ship with any valid MAC address, so a random address has to be generated. As a work-around, I write the initial random MAC to a file on the recovery partition. The MAC of the WAN interface is set to the MAC-address contained in this file on each boot, and the address of the LAN-interfaces are WAN + 1. The MAC file is kept across sysupgrade/firstboot. My approach is slightly different than what the stock image does. The first fives bytes of the MAC addresses in the stock image are static, and then the last byte is random. I believe it is better to create fully random MAC addresses. * In order to support the miniPCIe-slots, I needed to add missing pcie-nodes to mt7623.dtsi. The nodes are just c&p from the upstream dtsi. * One of the USB3.0 phys (u3phy2) on the board can be used as either USB or PCI, and one of the wifi-cards is connected to this phy. In order to support switching the phy from USB to PCI, I needed to patch the phy-driver. The patch is based on a rejected (at least last time I checked) PCI-driver submitted to the linux-mediatek mailing list. * The eMMC is configured to boot from the user area, and according to the data sheet of the eMMC this value can't be changed. * I tried to structure the MBR more nicely and use for example a FAT32-parition for the kernel, so that we don't need to write/read from some offset. The bootloader does not support reading from FAT32-paritions. While the command (fatload) is there, it just throws an error when I try to use it. * I will submit and hope to get the DTS for the device accepted upstream. If and when that happens, I will update the patches accordingly. Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
2018-06-20 01:17:40 +02:00
;;
esac
}
PART_NAME=firmware
platform_check_image() {
local board=$(board_name)
local magic="$(get_magic_long "$1")"
local diskdev partdev diff
[ "$#" -gt 1 ] && return 1
case "$board" in
bananapi,bpi-r2)
[ "$magic" != "d00dfeed" ] && {
echo "Invalid image type."
return 1
}
;;
unielec,u7623-02-emmc-512m)
# Can always upgrade to the new-style full image
[ "$magic" = "53444d4d" ] && return 0
# Legacy uImage directly at 0xA00 on the eMMC.
[ "$magic" != "27051956" ] && {
echo "Invalid image type."
return 1
}
rootpart=$(cat /proc/cmdline)
rootpart="${rootpart##*root=}"
rootpart="${rootpart%% *}"
[ "$rootpart" != "/dev/mmcblk0p2" ] && {
echo "Cannot downgrade to legacy image."
return 1
}
return 0
;;
*)
echo "Sysupgrade is not supported on your board yet."
return 1
;;
esac
return 0
mediatek: Add support for the UniElec U7623-02 This commit adds support for the MT7623A-based UniElec U7623-02 router, with eMMC storage and 512MB RAM. The router can be delivered with NAND Flash and more memory, but I only have access to the one configuration. The DTS is structured in such a way that adding support for more/different storage/memory should be straight forward. The device has the following specifications: * MT7623A (quad-core, 1.3 GHz) * 512MB RAM (DDR3) * 8GB storage (eMMC 4.5) * 2x normal miniPCIe slots * 1x miniPCIe slot that is connected via an internal USB OTG port * 5x 1Gbps Ethernet (MT7530 switch) * 1x UART header * 1x USB 3.0 port * 1x SATA 3.0 * 1x 40P*0.5mm FPC for MIPI LCD * 1x SIM slot * 12x LEDs (2 GPIO controlled) * 1x reset button * 1x DC jack for main power (12V) The following has been tested and is working: * Ethernet switch * miniPCIe slots (tested with Wi-Fi cards) * USB 3.0 port * sysupgrade * reset button Not working: * The miniPCIe connected via USB OTG. For the port to work, some MUSB glue must be added. I am currently in the process of porting the glue from the vendor SDK. Not tested: * SATA 3.0 * MIPI LCD Installation: The board ships with u-boot, and the first installation needs to be done via the bootloader using tftp. Step number one is to update the MBR of the eMMC, as the one that ships with the device is broken. Since the device can ship with different storage sizes, I will not provide the exact steps for creating a valid MBR. However, I have made some assumptions about the disk layout - there must be one 8MB recovery partition (FAT32) and a partition for the rootfs (Linux). The board loads the kernel from block 0xA00 (2560) and I have reserved 32MB for the kernel (65536 blocks). I have aligned the partitions on the erase block size (4096 byte), so the recovery partition must start on block 69632 and end on 86016 (16385 sectors). The rootfs is assumed to start on sector 90112. In order to install the mbr, you run the following commands from the u-boot command line: * tftpboot ${loadaddr} <name of mbr file> * mmc device 0 * mmc write ${loadaddr} 0x00 1 Run the following commands to install + boot OpenWRT: * tftpboot ${loadaddr} openwrt-mediatek-mt7623-7623a-unielec-u7623-02-emmc-512m-squashfs-sysupgrade-emmc.bin.gz * run boot_wr_img * run boot_rd_img * bootm Recovery: In order to recover the router, you need to follow the installation steps above (no need to replace MBR). Notes: * F2FS is used as the overlay filesystem. * The device does not ship with any valid MAC address, so a random address has to be generated. As a work-around, I write the initial random MAC to a file on the recovery partition. The MAC of the WAN interface is set to the MAC-address contained in this file on each boot, and the address of the LAN-interfaces are WAN + 1. The MAC file is kept across sysupgrade/firstboot. My approach is slightly different than what the stock image does. The first fives bytes of the MAC addresses in the stock image are static, and then the last byte is random. I believe it is better to create fully random MAC addresses. * In order to support the miniPCIe-slots, I needed to add missing pcie-nodes to mt7623.dtsi. The nodes are just c&p from the upstream dtsi. * One of the USB3.0 phys (u3phy2) on the board can be used as either USB or PCI, and one of the wifi-cards is connected to this phy. In order to support switching the phy from USB to PCI, I needed to patch the phy-driver. The patch is based on a rejected (at least last time I checked) PCI-driver submitted to the linux-mediatek mailing list. * The eMMC is configured to boot from the user area, and according to the data sheet of the eMMC this value can't be changed. * I tried to structure the MBR more nicely and use for example a FAT32-parition for the kernel, so that we don't need to write/read from some offset. The bootloader does not support reading from FAT32-paritions. While the command (fatload) is there, it just throws an error when I try to use it. * I will submit and hope to get the DTS for the device accepted upstream. If and when that happens, I will update the patches accordingly. Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
2018-06-20 01:17:40 +02:00
}
platform_copy_config_mmc() {
[ -e "$UPGRADE_BACKUP" ] || return
local datapart=$(cat /tmp/sysupgrade.datapart)
[ "$datapart" ] || echo "no rootfs_data partition, cannot keep configuration." >&2
dd if="$UPGRADE_BACKUP" of=/dev/$datapart
sync
}
mediatek: Add support for the UniElec U7623-02 This commit adds support for the MT7623A-based UniElec U7623-02 router, with eMMC storage and 512MB RAM. The router can be delivered with NAND Flash and more memory, but I only have access to the one configuration. The DTS is structured in such a way that adding support for more/different storage/memory should be straight forward. The device has the following specifications: * MT7623A (quad-core, 1.3 GHz) * 512MB RAM (DDR3) * 8GB storage (eMMC 4.5) * 2x normal miniPCIe slots * 1x miniPCIe slot that is connected via an internal USB OTG port * 5x 1Gbps Ethernet (MT7530 switch) * 1x UART header * 1x USB 3.0 port * 1x SATA 3.0 * 1x 40P*0.5mm FPC for MIPI LCD * 1x SIM slot * 12x LEDs (2 GPIO controlled) * 1x reset button * 1x DC jack for main power (12V) The following has been tested and is working: * Ethernet switch * miniPCIe slots (tested with Wi-Fi cards) * USB 3.0 port * sysupgrade * reset button Not working: * The miniPCIe connected via USB OTG. For the port to work, some MUSB glue must be added. I am currently in the process of porting the glue from the vendor SDK. Not tested: * SATA 3.0 * MIPI LCD Installation: The board ships with u-boot, and the first installation needs to be done via the bootloader using tftp. Step number one is to update the MBR of the eMMC, as the one that ships with the device is broken. Since the device can ship with different storage sizes, I will not provide the exact steps for creating a valid MBR. However, I have made some assumptions about the disk layout - there must be one 8MB recovery partition (FAT32) and a partition for the rootfs (Linux). The board loads the kernel from block 0xA00 (2560) and I have reserved 32MB for the kernel (65536 blocks). I have aligned the partitions on the erase block size (4096 byte), so the recovery partition must start on block 69632 and end on 86016 (16385 sectors). The rootfs is assumed to start on sector 90112. In order to install the mbr, you run the following commands from the u-boot command line: * tftpboot ${loadaddr} <name of mbr file> * mmc device 0 * mmc write ${loadaddr} 0x00 1 Run the following commands to install + boot OpenWRT: * tftpboot ${loadaddr} openwrt-mediatek-mt7623-7623a-unielec-u7623-02-emmc-512m-squashfs-sysupgrade-emmc.bin.gz * run boot_wr_img * run boot_rd_img * bootm Recovery: In order to recover the router, you need to follow the installation steps above (no need to replace MBR). Notes: * F2FS is used as the overlay filesystem. * The device does not ship with any valid MAC address, so a random address has to be generated. As a work-around, I write the initial random MAC to a file on the recovery partition. The MAC of the WAN interface is set to the MAC-address contained in this file on each boot, and the address of the LAN-interfaces are WAN + 1. The MAC file is kept across sysupgrade/firstboot. My approach is slightly different than what the stock image does. The first fives bytes of the MAC addresses in the stock image are static, and then the last byte is random. I believe it is better to create fully random MAC addresses. * In order to support the miniPCIe-slots, I needed to add missing pcie-nodes to mt7623.dtsi. The nodes are just c&p from the upstream dtsi. * One of the USB3.0 phys (u3phy2) on the board can be used as either USB or PCI, and one of the wifi-cards is connected to this phy. In order to support switching the phy from USB to PCI, I needed to patch the phy-driver. The patch is based on a rejected (at least last time I checked) PCI-driver submitted to the linux-mediatek mailing list. * The eMMC is configured to boot from the user area, and according to the data sheet of the eMMC this value can't be changed. * I tried to structure the MBR more nicely and use for example a FAT32-parition for the kernel, so that we don't need to write/read from some offset. The bootloader does not support reading from FAT32-paritions. While the command (fatload) is there, it just throws an error when I try to use it. * I will submit and hope to get the DTS for the device accepted upstream. If and when that happens, I will update the patches accordingly. Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
2018-06-20 01:17:40 +02:00
platform_copy_config() {
case "$(board_name)" in
bananapi,bpi-r2)
platform_copy_config_mmc
;;
unielec,u7623-02-emmc-512m)
# platform_do_upgrade() will have set $recoverydev
if [ -n "$recoverydev" ]; then
mkdir -p /tmp/recovery
mount -o rw,noatime "/dev/$recoverydev" -t vfat /tmp/recovery
cp -af "$UPGRADE_BACKUP" "/tmp/recovery/$BACKUP_FILE"
sync
umount /tmp/recovery
fi
mediatek: Add support for the UniElec U7623-02 This commit adds support for the MT7623A-based UniElec U7623-02 router, with eMMC storage and 512MB RAM. The router can be delivered with NAND Flash and more memory, but I only have access to the one configuration. The DTS is structured in such a way that adding support for more/different storage/memory should be straight forward. The device has the following specifications: * MT7623A (quad-core, 1.3 GHz) * 512MB RAM (DDR3) * 8GB storage (eMMC 4.5) * 2x normal miniPCIe slots * 1x miniPCIe slot that is connected via an internal USB OTG port * 5x 1Gbps Ethernet (MT7530 switch) * 1x UART header * 1x USB 3.0 port * 1x SATA 3.0 * 1x 40P*0.5mm FPC for MIPI LCD * 1x SIM slot * 12x LEDs (2 GPIO controlled) * 1x reset button * 1x DC jack for main power (12V) The following has been tested and is working: * Ethernet switch * miniPCIe slots (tested with Wi-Fi cards) * USB 3.0 port * sysupgrade * reset button Not working: * The miniPCIe connected via USB OTG. For the port to work, some MUSB glue must be added. I am currently in the process of porting the glue from the vendor SDK. Not tested: * SATA 3.0 * MIPI LCD Installation: The board ships with u-boot, and the first installation needs to be done via the bootloader using tftp. Step number one is to update the MBR of the eMMC, as the one that ships with the device is broken. Since the device can ship with different storage sizes, I will not provide the exact steps for creating a valid MBR. However, I have made some assumptions about the disk layout - there must be one 8MB recovery partition (FAT32) and a partition for the rootfs (Linux). The board loads the kernel from block 0xA00 (2560) and I have reserved 32MB for the kernel (65536 blocks). I have aligned the partitions on the erase block size (4096 byte), so the recovery partition must start on block 69632 and end on 86016 (16385 sectors). The rootfs is assumed to start on sector 90112. In order to install the mbr, you run the following commands from the u-boot command line: * tftpboot ${loadaddr} <name of mbr file> * mmc device 0 * mmc write ${loadaddr} 0x00 1 Run the following commands to install + boot OpenWRT: * tftpboot ${loadaddr} openwrt-mediatek-mt7623-7623a-unielec-u7623-02-emmc-512m-squashfs-sysupgrade-emmc.bin.gz * run boot_wr_img * run boot_rd_img * bootm Recovery: In order to recover the router, you need to follow the installation steps above (no need to replace MBR). Notes: * F2FS is used as the overlay filesystem. * The device does not ship with any valid MAC address, so a random address has to be generated. As a work-around, I write the initial random MAC to a file on the recovery partition. The MAC of the WAN interface is set to the MAC-address contained in this file on each boot, and the address of the LAN-interfaces are WAN + 1. The MAC file is kept across sysupgrade/firstboot. My approach is slightly different than what the stock image does. The first fives bytes of the MAC addresses in the stock image are static, and then the last byte is random. I believe it is better to create fully random MAC addresses. * In order to support the miniPCIe-slots, I needed to add missing pcie-nodes to mt7623.dtsi. The nodes are just c&p from the upstream dtsi. * One of the USB3.0 phys (u3phy2) on the board can be used as either USB or PCI, and one of the wifi-cards is connected to this phy. In order to support switching the phy from USB to PCI, I needed to patch the phy-driver. The patch is based on a rejected (at least last time I checked) PCI-driver submitted to the linux-mediatek mailing list. * The eMMC is configured to boot from the user area, and according to the data sheet of the eMMC this value can't be changed. * I tried to structure the MBR more nicely and use for example a FAT32-parition for the kernel, so that we don't need to write/read from some offset. The bootloader does not support reading from FAT32-paritions. While the command (fatload) is there, it just throws an error when I try to use it. * I will submit and hope to get the DTS for the device accepted upstream. If and when that happens, I will update the patches accordingly. Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
2018-06-20 01:17:40 +02:00
;;
esac
}