openwrt/target/linux
Daniel Golle 0235186182 mediatek: add alternative UBI NAND layout for Linksys E8450
The vendor flash layout of the Linksys E8450 is problematic as it uses
the SPI-NAND chip without any wear-leveling while at the same time
wasting a lot of space for padding.
Use an all-UBI layout instead, storing the kernel+dtb+squashfs in
uImage.FIT standard format in UBI volume 'fit', the read-write
overlay in UBI volume 'rootfs_data' as well as reduntant U-Boot
environments 'ubootenv' and 'ubootenv2', and a 'recovery'
kernel+dtb+initramfs uImage.FIT for dual-boot.

** WARNING **
THIS PROCEDURE CAN EASILY BRICK YOUR DEVICE PERMANENTLY IF NOT CARRIED
OUT VERY CAREFULLY AND EXACTLY AS DESCRIBED!

Step 0

 * Configure your PC to have the static IPv4 address 192.168.1.254/24
 * Provide bin/targets/mediatek/mt7622 via TFTP

Now continue EITHER with step 1A or 1B, depending on your preference
(and on having serial console wired up or not).

Step 1A (Using the vendor web interface (or non-UBI OpenWrt install))

In order to update to the new bootloader and UBI-based firmware,
use the web browser of your choice to open the routers web-interface
accessible on http://192.168.1.1

 * Navigate to
   'Configuration' -> 'Administration' -> 'Firmware Upgrade'

 * Upload the file
    openwrt-mediatek-mt7622-linksys_e8450-ubi-initramfs-recovery.itb
   and proceed with the upgrade.

 * Once OpenWrt comes up, use SCP to upload the new bootloader files to
   /tmp on the router:
    *-mt7622-linksys_e8450-ubi-preloader.bin
    *-mt7622-linksys_e8450-ubi-bl31-uboot.fip

 * Connect via SSH as you will now need to replace the bootloader in
   the Flash.

    ssh root@192.168.1.1
    (the usual warnings)

 * First of all, backup all the flash now:

    for mtd in /dev/mtdblock*; do
     dd if=$mtd of=/tmp/$(basename $mtd);
    done

 * Then use SCP to copy /tmp/mtdblock* from the router and keep them
   safe. You will need them should you ever want to return to the
   factory firmware!

 * Now flow the uploaded files:
    mtd -e /dev/mtd0 write /tmp/*linksys_e8450-ubi-preloader.bin /dev/mtd0
    mtd -e /dev/mtd1 write /tmp/*linksys_e8450-ubi-bl31-uboot.fip /dev/mtd1

   If and only if both writes look like the completed successfully
   reboot the router. Now continue with step 2.

Step 1B (Using the vendor bootloader serial console)

 * Use the serial to backup all /dev/mtd* devices before using the
   stock firmware (you got root shell when connected to serial).

 * Then reboot and select 'U-Boot Console' in the boot menu.

 * Copy the following lines, one by one:

tftpboot 0x40080000 openwrt-mediatek-mt7622-linksys_e8450-ubi-preloader.bin
tftpboot 0x40100000 openwrt-mediatek-mt7622-linksys_e8450-ubi-bl31-uboot.fip
nand erase 0x0 0x180000
nand write 0x40080000 0x0 0x180000
reset

Now continue with step 2

Step 2

Once the new bootchain comes up, the loader will initialize UBI and the
ubootenv volumes. It will then of course fail to find any bootable
volume and hence resort to load kernel via TFTP from server
192.168.1.254 while giving itself the address 192.168.1.1

The requested file is called
openwrt-mediatek-mt7622-linksys_e8450-ubi-initramfs-recovery.itb
and your TFTP server should provide exactly that :)
It will be written to UBI as recovery image and booted.
You can then continue and flash the production OS image, either
by using sysupgrade in the booted initramfs recovery OS, or by using
the bootloader menu and TFTP.

That's it. Go ahead and mess around with a bootchain built almost
completely from source (only DRAM calibration blobs are fitted in bl2,
and the irreplacable on-chip ROM loader remains, of course).
And enjoy U-Boot built with many great features out-of-the-box.

You can access the bootloader environment from within OpenWrt using the
'fw_printenv' and 'fw_setenv' commands. Don't be afraid, once you got
the new bootchain installed the device should be fairly unbrickable
(holding reset button before and during power-on resets things and
allows reflashing recovery image via TFTP)

Special thanks to @dvn0 (Devan Carpenter) for providing amazingly fast
infra for test-builds, allowing for `make clean ; make -j$(nproc)` in
less than two minutes :)

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-02-28 01:23:48 +00:00
..
apm821xx kernel: bump 5.4 to 5.4.97 2021-02-11 16:08:28 +01:00
arc770 target: use SPDX license identifiers on scripts 2021-02-10 15:47:23 +01:00
archs38 target: use SPDX license identifiers on scripts 2021-02-10 15:47:23 +01:00
armvirt target: use SPDX license identifiers on Makefiles 2021-02-10 15:47:18 +01:00
at91 at91: use SPDX license identifiers on DTS files 2021-02-10 15:47:23 +01:00
ath25 treewide: rename IMAGE_PREFIX/IMAGE_NAME to DEVICE_IMG_* 2021-02-25 18:11:06 +01:00
ath79 ath79: fix USB power on TP-Link TL-WR810N v1 2021-02-26 13:57:02 +01:00
bcm27xx bcm27xx: remove urngd package 2021-02-20 19:55:14 +01:00
bcm47xx treewide: rename IMAGE_PREFIX/IMAGE_NAME to DEVICE_IMG_* 2021-02-25 18:11:06 +01:00
bcm53xx bcm53xx: backport more upstream dts stuff from kernel 5.11 2021-02-25 21:17:38 +01:00
bcm63xx treewide: rename IMAGE_PREFIX/IMAGE_NAME to DEVICE_IMG_* 2021-02-25 18:11:06 +01:00
bcm4908 treewide: rename IMAGE_PREFIX/IMAGE_NAME to DEVICE_IMG_* 2021-02-25 18:11:06 +01:00
bmips bmips: dts: fix syscon-reboot nodes 2021-02-25 20:40:02 +01:00
gemini target: use SPDX license identifiers on Makefiles 2021-02-10 15:47:18 +01:00
generic kernel: add support for enabling fit firmware partition parser via cmdline 2021-02-28 00:46:11 +00:00
imx6 treewide: rename IMAGE_PREFIX/IMAGE_NAME to DEVICE_IMG_* 2021-02-25 18:11:06 +01:00
ipq40xx treewide: remove redundant KERNEL_PREFIX definitions 2021-02-23 00:26:40 +01:00
ipq806x treewide: remove redundant KERNEL_PREFIX definitions 2021-02-23 00:26:40 +01:00
ipq807x config: limit CONFIG_PERF_EVENTS to top-level generic configs 2021-01-25 14:37:41 +01:00
kirkwood kirkwood: set testing kernel version to 5.10 2021-02-24 02:53:53 +01:00
lantiq lantiq: fritz7320: enable USB power supply 2021-02-18 08:43:08 +01:00
layerscape kernel: bump 5.4 to 5.4.101 2021-02-27 16:51:52 +01:00
malta target: use SPDX license identifiers on Makefiles 2021-02-10 15:47:18 +01:00
mediatek mediatek: add alternative UBI NAND layout for Linksys E8450 2021-02-28 01:23:48 +00:00
mpc85xx mpc85xx: remove fdt.bin image 2021-02-26 15:35:41 +01:00
mvebu mvebu: add LED support for GL.iNet GL-MV1000 2021-02-26 13:57:50 +01:00
mxs target: use SPDX license identifiers on scripts 2021-02-10 15:47:23 +01:00
octeon target: use SPDX license identifiers on Makefiles 2021-02-10 15:47:18 +01:00
octeontx target: use SPDX license identifiers on Makefiles 2021-02-10 15:47:18 +01:00
omap target: use SPDX license identifiers on scripts 2021-02-10 15:47:23 +01:00
oxnas kernel: move some new symbols available on 5.10 to generic 2021-02-27 16:49:02 +01:00
pistachio target: use SPDX license identifiers on scripts 2021-02-10 15:47:23 +01:00
ramips ramips: add support for ZTE MF283+ 2021-02-26 13:57:54 +01:00
realtek realtek: add support for Netgear GS108T v3 2021-02-12 08:52:41 +01:00
rockchip kernel: move some new symbols available on 5.10 to generic 2021-02-27 16:49:02 +01:00
sunxi target: use SPDX license identifiers on scripts 2021-02-10 15:47:23 +01:00
tegra target: use SPDX license identifiers on Makefiles 2021-02-10 15:47:18 +01:00
uml target: use SPDX license identifiers on Makefiles 2021-02-10 15:47:18 +01:00
x86 x86: add led driver for PC Engines APU1 2021-02-20 00:29:18 -10:00
zynq zynq: Enable CONFIG_KERNEL_MODE_NEON 2021-02-26 20:41:00 +01:00
Makefile target: use SPDX license identifiers on Makefiles 2021-02-10 15:47:18 +01:00