openwrt/target/linux
Enrico Mioso f2a40e1117
mediatek: filogic: add support for GatoNetworks GDSP
The GatoNetworks GDSP is a re-branded version of the R5000 5G Industrial
router from Yinghua Technologies.
The re-branded device comes with OpenWrt preinstalled, and an OpenWrt-based
U-Boot bootloader version. While the flash layout has been kept compatible
with the OpenWrt version found on the stock device (see [5]), the image format
changed, making a bootloader upgrade necessary.

Specifications:
SoC: Mediatek MT7981BA
RAM: 256MB
Flash: SPI-NOR 32 MiB (Winbond W25Q256)
WLAN: MT7976CN DBDC AX Wi-Fi
Switch: MT7531AE (4x LAN Gigabit ports, 1x WAN Gigabit port)
5G: Quectel RM520N modem
Watchdog: an external WDT connected to GPIO 6 is present and always running;
          the built-in Mediatek watchdog is also present and effective, but
          not used at the moment.

This porting has been tested only with 1x 5G modems installed (the device
supports up to two).

Installation:
Installation is possible via sysupgrade both in the stock device and
re-branded version. However, in the former case, updating the bootloader is
required.

OpenWrt-based U-Boot Bootloader installation
--------------------------------------------
The firmware flashed in the re-branded device at manifacturing time will
flash an OpenWrt-based U-Boot bootloader with some extra recovery features
(see [1]) at first boot.
To update the bootloader, you need to install the mtd-rw module and
insmod it:

insmod mtd-rw i_want_a_brick=1

Then update relevant flash partitions:

mtd erase u-boot-env
mtd erase BL2
mtd erase FIP
mtd write openwrt-mediatek-filogic-gatonetworks_gdsp-preloader.bin BL2
mtd write openwrt-mediatek-filogic-gatonetworks_gdsp-bl31-uboot.fip FIP

And reboot, making sure all previous commands ran succesfully.
If something goes wrong, you can recover your device via the mtk_uartboot
tool.
In my testing, it was possible to start the process even without (un)-plugging
the device, may be handy for remote recovery.

Installation from stock device and firmware
-------------------------------------------
To install vanilla OpenWrt in the stock device (R5000 5G Industrial router
from Yinghua Technologies) running the stock vendor firmware, you will need
to update your bootloader as described in previous section. Remember to use
-F (force upgrade) and -n (not keeping settings).

U-Boot Recovery
---------------
This procedure has been tested only with the OpenWrt-based U-boot bootloader.
Assign your system static IP address 192.168.1.1 and start a TFTP server. The
device will look for an initramfs image named
openwrt-mediatek-filogic-gatonetworks_gdsp-initramfs-kernel.bin
(so you may use openwrt/bin/targets/mediatek/filogic as root dir for your
TFTP server).
Power on the device while keeping the reset button pressed, until you see
a TFTP request from 192.168.1.10. Your environment will be restored to it's
default state.

MAC addresses assignment
------------------------
MAC addresses are assigned slightly differently than in stock firmware. In
particular, the 5 GHz Wi-Fi uses 2.4 GHZ MAC + 1, rather than reusing it with
LA bit set as done in stock firmware. This MAC address is allocated to the
device, so it can be used.
The 2.4 GHz Wi-Fi MAC address is the label MAC. LAN MAC is used to set the
special U-Boot environment ethaddr variable.

device					MAC address		U-Boot env variable		factory partition offset
2.4 GHz Wi-Fi		:84						wifi_mac							0x4
5.8 GHz Wi-Fi		:85						not present						not present
WAN							:86						wan_mac								0x24
LAN							:87						lan_mac								0x2A

Notes
-----
[1]: the OpenWrt-based U-Boot bootloader you will find installed in the
re-branded device is configured to request for the initramfs image via
TFTP for $gdsp_tftp_tries times before trying normal boot from NOR flash.
Setting this U-Boot environment variable to 0x0 will disable the feature,
which is not implemented in this patch.
[2]: the exposed UART port is connected to ttyS1; the ttyS0 console port is
not exposed.
[3]: the provided bootloader environment has no provision for operating on
BL2 and the FIP partitions. This is an intentional choice to make it
(slightly) more difficult to brick the device.
[4]: it seems GPIO 6 is used both for the "SYS" LED and external WDT.
[5] BL2 expects to find FIP payload at a fixed offset, so some constraints
apply.

Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
(cherry picked from commit b43194e041)
Link: https://github.com/openwrt/openwrt/pull/17097
Signed-off-by: Petr Štetiar <ynezz@true.cz>
2024-11-28 18:47:13 +00:00
..
airoha kernel: bump 6.6 to 6.6.61 2024-11-24 22:46:21 +01:00
apm821xx apm821xx: move CONFIG_GENERIC_PHY up 2024-10-24 00:25:28 +02:00
archs38 kernel: activate *_FS_SECURITY and *_FS_ACL_ATTR options for all big flash targets 2024-09-06 22:46:59 +02:00
armsr armsr: don't limit kmods to armsr armv8 subtarget 2024-10-29 00:07:55 +01:00
at91 at91: drop 6.1 support 2024-09-20 18:42:56 +01:00
ath79 treewide: remove THIS_MODULE assignment 2024-11-28 18:46:45 +00:00
bcm27xx kernel: bump 6.6 to 6.6.63 2024-11-24 22:46:21 +01:00
bcm47xx treewide: remove THIS_MODULE assignment 2024-11-28 18:46:45 +00:00
bcm53xx kernel: bump 6.6 to 6.6.59 2024-11-09 17:35:58 +01:00
bcm4908 bcm4908: drop 6.1 support 2024-08-30 11:39:44 +02:00
bmips bmips: fix kernel panic caused by missing CBR address 2024-10-01 19:15:45 +02:00
d1 kernel: Reorder config files 2024-10-22 21:13:26 +02:00
gemini kernel: bump 6.6 to 6.6.57 2024-10-19 16:21:32 +02:00
generic treewide: remove THIS_MODULE assignment 2024-11-28 18:46:45 +00:00
imx kernel: Reorder config files 2024-10-22 21:13:26 +02:00
ipq40xx treewide: remove THIS_MODULE assignment 2024-11-28 18:46:45 +00:00
ipq806x treewide: remove THIS_MODULE assignment 2024-11-28 18:46:45 +00:00
ixp4xx ixp4xx: Add back support for D-Link DSM G600 A 2024-05-25 09:17:19 +02:00
kirkwood kirkwood: dns320l: export mcu_power GPIO 2024-10-28 09:24:32 +01:00
lantiq lantiq: use devm for mutex_init 2024-11-28 18:46:49 +00:00
layerscape layerscape: drop fmc and fmc-eth-config package 2024-10-29 00:07:55 +01:00
loongarch64 kernel: activate *_FS_SECURITY and *_FS_ACL_ATTR options for all big flash targets 2024-09-06 22:46:59 +02:00
malta kernel: activate *_FS_SECURITY and *_FS_ACL_ATTR options for all big flash targets 2024-09-06 22:46:59 +02:00
mediatek mediatek: filogic: add support for GatoNetworks GDSP 2024-11-28 18:47:13 +00:00
mpc85xx mpc85xx: move CONFIG_MTD_SPLIT_FIRMWARE up 2024-10-24 00:30:11 +02:00
mvebu mvebu: cortexa9: drop removal of firewall4 package 2024-10-30 14:17:33 +01:00
mxs mxs: drop removal of firewall4 package 2024-10-30 14:17:33 +01:00
octeon octeon: set Linux 6.6 as the default kernel 2024-09-09 18:24:34 +02:00
omap omap: remove 6.1 support 2024-09-16 00:19:49 +02:00
pistachio pistachio: drop files for Linux 6.1 2024-09-20 18:57:33 +01:00
qoriq kernel: move CONFIG_DRM_OFDRM to generic 2024-10-22 00:50:55 +02:00
qualcommax qualcommax: ipq60xx: add NSS reserved memory 2024-11-28 18:47:01 +00:00
ramips ramips: mt7621: fix typo 2024-11-28 18:46:53 +00:00
realtek realtek: rtl83xx: use devm for mutex_init 2024-11-28 18:46:55 +00:00
rockchip kernel: bump 6.6 to 6.6.61 2024-11-24 22:46:21 +01:00
sifiveu kernel: Reorder config files 2024-10-22 21:13:26 +02:00
siflower treewide: remove THIS_MODULE assignment 2024-11-28 18:46:45 +00:00
starfive kernel: bump 6.6 to 6.6.61 2024-11-24 22:46:21 +01:00
sunxi kernel: bump 6.6 to 6.6.61 2024-11-24 22:46:21 +01:00
tegra tegra: promote kernel 6.6 as default 2024-07-13 14:29:16 +02:00
uml uml: fix glibc-static check with GCC14 2024-06-22 22:06:06 +02:00
x86 kernel: Reorder config files 2024-10-22 21:13:26 +02:00
zynq zynq: drop 6.1 support 2024-08-03 11:36:59 +02:00
Makefile linux: add dtb makefile target to targets list 2024-02-08 23:04:55 +01:00