2022-07-06 12:06:30 +00:00
|
|
|
DTS_DIR := $(DTS_DIR)/mediatek
|
|
|
|
|
|
|
|
KERNEL_LOADADDR := 0x44000000
|
|
|
|
|
|
|
|
define Image/Prepare
|
|
|
|
# For UBI we want only one extra block
|
|
|
|
rm -f $(KDIR)/ubi_mark
|
|
|
|
echo -ne '\xde\xad\xc0\xde' > $(KDIR)/ubi_mark
|
|
|
|
endef
|
|
|
|
|
2022-07-13 03:30:32 +00:00
|
|
|
define Build/bl2
|
|
|
|
cat $(STAGING_DIR_IMAGE)/mt7986-$1-bl2.img >> $@
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/bl31-uboot
|
|
|
|
cat $(STAGING_DIR_IMAGE)/mt7986_$1-u-boot.fip >> $@
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/mt7986-gpt
|
|
|
|
cp $@ $@.tmp 2>/dev/null || true
|
|
|
|
ptgen -g -o $@.tmp -a 1 -l 1024 \
|
|
|
|
$(if $(findstring sdmmc,$1), \
|
|
|
|
-H \
|
|
|
|
-t 0x83 -N bl2 -r -p 4079k@17k \
|
|
|
|
) \
|
|
|
|
-t 0x83 -N ubootenv -r -p 512k@4M \
|
|
|
|
-t 0x83 -N factory -r -p 2M@4608k \
|
|
|
|
-t 0xef -N fip -r -p 4M@6656k \
|
|
|
|
-N recovery -r -p 32M@12M \
|
|
|
|
$(if $(findstring sdmmc,$1), \
|
|
|
|
-N install -r -p 20M@44M \
|
|
|
|
-t 0x2e -N production -p $(CONFIG_TARGET_ROOTFS_PARTSIZE)M@64M \
|
|
|
|
) \
|
|
|
|
$(if $(findstring emmc,$1), \
|
|
|
|
-t 0x2e -N production -p $(CONFIG_TARGET_ROOTFS_PARTSIZE)M@64M \
|
|
|
|
)
|
|
|
|
cat $@.tmp >> $@
|
|
|
|
rm $@.tmp
|
|
|
|
endef
|
|
|
|
|
2023-01-26 16:39:43 +00:00
|
|
|
define Device/asus_tuf-ax4200
|
|
|
|
DEVICE_VENDOR := ASUS
|
|
|
|
DEVICE_MODEL := TUF-AX4200
|
|
|
|
DEVICE_DTS := mt7986a-asus-tuf-ax4200
|
|
|
|
DEVICE_DTS_DIR := ../dts
|
|
|
|
DEVICE_DTS_LOADADDR := 0x47000000
|
|
|
|
DEVICE_PACKAGES := kmod-usb3
|
|
|
|
IMAGES := sysupgrade.bin
|
|
|
|
KERNEL_LOADADDR := 0x48000000
|
|
|
|
KERNEL = kernel-bin | lzma | \
|
|
|
|
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
|
|
|
|
KERNEL_INITRAMFS := kernel-bin | lzma | \
|
|
|
|
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
|
|
|
|
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
|
|
|
|
endef
|
|
|
|
TARGET_DEVICES += asus_tuf-ax4200
|
|
|
|
|
|
|
|
|
2022-07-13 03:30:32 +00:00
|
|
|
define Device/bananapi_bpi-r3
|
|
|
|
DEVICE_VENDOR := Bananapi
|
|
|
|
DEVICE_MODEL := BPi-R3
|
|
|
|
DEVICE_DTS := mt7986a-bananapi-bpi-r3
|
|
|
|
DEVICE_DTS_CONFIG := config-mt7986a-bananapi-bpi-r3
|
|
|
|
DEVICE_DTS_OVERLAY:= mt7986a-bananapi-bpi-r3-nor mt7986a-bananapi-bpi-r3-emmc-nor mt7986a-bananapi-bpi-r3-emmc-snand mt7986a-bananapi-bpi-r3-snand
|
|
|
|
DEVICE_DTS_DIR := ../dts
|
2023-03-10 20:05:18 +00:00
|
|
|
DEVICE_PACKAGES := kmod-hwmon-pwmfan kmod-i2c-gpio kmod-mt7986-firmware kmod-sfp kmod-usb3 e2fsprogs f2fsck mkf2fs mt7986-wo-firmware
|
2022-07-13 03:30:32 +00:00
|
|
|
IMAGES := sysupgrade.itb
|
|
|
|
KERNEL_INITRAMFS_SUFFIX := -recovery.itb
|
|
|
|
ARTIFACTS := \
|
|
|
|
emmc-preloader.bin emmc-bl31-uboot.fip \
|
|
|
|
nor-preloader.bin nor-bl31-uboot.fip \
|
|
|
|
sdcard.img.gz \
|
|
|
|
snand-preloader.bin snand-bl31-uboot.fip
|
|
|
|
ARTIFACT/emmc-preloader.bin := bl2 emmc-ddr4
|
|
|
|
ARTIFACT/emmc-bl31-uboot.fip := bl31-uboot bananapi_bpi-r3-emmc
|
|
|
|
ARTIFACT/nor-preloader.bin := bl2 nor-ddr4
|
|
|
|
ARTIFACT/nor-bl31-uboot.fip := bl31-uboot bananapi_bpi-r3-nor
|
|
|
|
ARTIFACT/snand-preloader.bin := bl2 spim-nand-ddr4
|
|
|
|
ARTIFACT/snand-bl31-uboot.fip := bl31-uboot bananapi_bpi-r3-snand
|
|
|
|
ARTIFACT/sdcard.img.gz := mt7986-gpt sdmmc |\
|
|
|
|
pad-to 17k | bl2 sdmmc-ddr4 |\
|
|
|
|
pad-to 6656k | bl31-uboot bananapi_bpi-r3-sdmmc |\
|
2022-09-08 01:34:28 +00:00
|
|
|
$(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),\
|
|
|
|
pad-to 12M | append-image-stage initramfs-recovery.itb | check-size 44m |\
|
|
|
|
) \
|
2022-07-13 03:30:32 +00:00
|
|
|
pad-to 44M | bl2 spim-nand-ddr4 |\
|
|
|
|
pad-to 45M | bl31-uboot bananapi_bpi-r3-snand |\
|
|
|
|
pad-to 49M | bl2 nor-ddr4 |\
|
|
|
|
pad-to 50M | bl31-uboot bananapi_bpi-r3-nor |\
|
|
|
|
pad-to 51M | bl2 emmc-ddr4 |\
|
|
|
|
pad-to 52M | bl31-uboot bananapi_bpi-r3-emmc |\
|
|
|
|
pad-to 56M | mt7986-gpt emmc |\
|
2022-09-08 01:34:28 +00:00
|
|
|
$(if $(CONFIG_TARGET_ROOTFS_SQUASHFS),\
|
|
|
|
pad-to 64M | append-image squashfs-sysupgrade.itb | check-size | gzip \
|
|
|
|
)
|
|
|
|
IMAGE_SIZE := $$(shell expr 64 + $$(CONFIG_TARGET_ROOTFS_PARTSIZE))m
|
2022-07-13 03:30:32 +00:00
|
|
|
KERNEL := kernel-bin | gzip
|
|
|
|
KERNEL_INITRAMFS := kernel-bin | lzma | \
|
|
|
|
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
|
|
|
|
IMAGE/sysupgrade.itb := append-kernel | fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-static-with-rootfs | pad-rootfs | append-metadata
|
|
|
|
DTC_FLAGS += -@ --space 32768
|
|
|
|
endef
|
|
|
|
TARGET_DEVICES += bananapi_bpi-r3
|
|
|
|
|
2022-10-29 21:03:08 +00:00
|
|
|
define Device/mediatek_mt7986a-rfb-nand
|
2022-07-06 12:06:30 +00:00
|
|
|
DEVICE_VENDOR := MediaTek
|
2022-10-29 21:03:08 +00:00
|
|
|
DEVICE_MODEL := MT7986 rfba AP (NAND)
|
|
|
|
DEVICE_DTS := mt7986a-rfb-spim-nand
|
2022-07-06 12:06:30 +00:00
|
|
|
DEVICE_DTS_DIR := $(DTS_DIR)/
|
2023-03-10 20:05:18 +00:00
|
|
|
DEVICE_PACKAGES := kmod-mt7986-firmware mt7986-wo-firmware
|
2022-07-06 12:06:30 +00:00
|
|
|
KERNEL_LOADADDR := 0x48000000
|
2022-10-29 21:03:08 +00:00
|
|
|
SUPPORTED_DEVICES := mediatek,mt7986a-rfb-snand
|
2022-07-06 12:06:30 +00:00
|
|
|
UBINIZE_OPTS := -E 5
|
|
|
|
BLOCKSIZE := 128k
|
|
|
|
PAGESIZE := 2048
|
|
|
|
IMAGE_SIZE := 65536k
|
|
|
|
KERNEL_IN_UBI := 1
|
|
|
|
IMAGES += factory.bin
|
|
|
|
IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE)
|
|
|
|
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
|
|
|
|
KERNEL = kernel-bin | lzma | \
|
2022-10-29 21:03:08 +00:00
|
|
|
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
|
2022-07-06 12:06:30 +00:00
|
|
|
KERNEL_INITRAMFS = kernel-bin | lzma | \
|
2022-10-29 21:03:08 +00:00
|
|
|
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd
|
2022-07-06 12:06:30 +00:00
|
|
|
DTC_FLAGS += -@ --space 32768
|
|
|
|
endef
|
2022-10-29 21:03:08 +00:00
|
|
|
TARGET_DEVICES += mediatek_mt7986a-rfb-nand
|
2022-07-06 12:06:30 +00:00
|
|
|
|
|
|
|
define Device/mediatek_mt7986b-rfb
|
|
|
|
DEVICE_VENDOR := MediaTek
|
|
|
|
DEVICE_MODEL := MTK7986 rfbb AP
|
|
|
|
DEVICE_DTS := mt7986b-rfb
|
|
|
|
DEVICE_DTS_DIR := $(DTS_DIR)/
|
2023-03-10 20:05:18 +00:00
|
|
|
DEVICE_PACKAGES := kmod-mt7986-firmware mt7986-wo-firmware
|
2022-07-06 12:06:30 +00:00
|
|
|
KERNEL_LOADADDR := 0x48000000
|
|
|
|
SUPPORTED_DEVICES := mediatek,mt7986b-rfb
|
|
|
|
UBINIZE_OPTS := -E 5
|
|
|
|
BLOCKSIZE := 128k
|
|
|
|
PAGESIZE := 2048
|
|
|
|
IMAGE_SIZE := 65536k
|
|
|
|
KERNEL_IN_UBI := 1
|
|
|
|
IMAGES += factory.bin
|
|
|
|
IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE)
|
|
|
|
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
|
|
|
|
endef
|
|
|
|
TARGET_DEVICES += mediatek_mt7986b-rfb
|
mediatek: add Xiaomi Redmi Router AX6000 support
Hardware specification:
SoC: MediaTek MT7986A 4x A53
Flash: ESMT F50L1G41LB 128 MB
RAM: K4A4G165WF-BCWE 512 MB
Ethernet: 4x 10/100/1000 Mbps
WiFi1: MT7976GN 2.4GHz ax 4x4
WiFi2: MT7976AN 5GHz ax 4x4
Button: Mesh, Reset
Flash instructions:
1. Gain ssh and serial port access, see the link below:
https://openwrt.org/toh/xiaomi/redmi_ax6000#installation
2. Use ssh or serial port to log in to the router, and
execute the following command:
nvram set boot_wait=on
nvram set flag_boot_rootfs=0
nvram set flag_boot_success=1
nvram set flag_last_success=1
nvram set flag_try_sys1_failed=8
nvram set flag_try_sys2_failed=8
nvram commit
3. Set a static ip on the ethernet interface of your computer
(e.g. default: ip 192.168.31.100, gateway 192.168.31.1)
4. Download the initramfs image, rename it to initramfs.bin,
and host it with the tftp server.
5. Interrupt U-Boot and run these commands:
setenv mtdparts nmbm0:1024k(bl2),256k(Nvram),256k(Bdata),2048k(factory),2048k(fip),256k(crash),256k(crash_log),112640k(ubi)
saveenv
tftpboot initramfs.bin
bootm
6. After openwrt boots up, use scp or luci web
to upload sysupgrade.bin to upgrade.
Revert to stock firmware:
Restore mtdparts back to default, then use the
vendor's recovery tool (Windows only).
Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
2022-09-18 15:16:18 +00:00
|
|
|
|
mediatek: add alternative stock layout for Xiaomi Redmi Router AX6000
In this implementation, the flash partition layout is adjusted to avoid
modifying the uboot environment of mtdparts. This ensures that the 30M
ubi_kernel partition remains aligned with the stock ubi partition, and
the kernel volume is placed in it. This allows the stock uboot to boot
from it without changing the mtdparts, which is useful for reverting back
to the stock firmware using Xiaomi Firmware Tools. In actual testing,
modifying mtdparts has been found to break Xiaomi Firmware Tools.
1. use ARTIFACTS to generate initramfs-factory.ubi for easy installation.
2. The NAND flash layout is changed to allow for reverting back to the
stock firmware.
3. Before performing sysupgrade, do some cleanup in platform_pre_upgrade
to ensure a clean installation of OpenWRT.
4. Setup the uboot env to ensure that the system always boot, which can
be helpful for users who may forget to do this before sysupgrade in
the initramfs.
New flash instructions:
1. Gain ssh access. Please refer to:
https://openwrt.org/toh/xiaomi/redmi_ax6000#installation)
2. Check which system current u-boot is loading from:
COMMAND: `cat /proc/cmdline`
sample OUTPUT: `console=ttyS0,115200n1 loglevel=8 firmware=1 uart_en=1`
if firmware=1, current system is ubi1
if firmware=0, current system is ubi0
3. Setup nvram and write the firmware:
If the current system is ubi1, please set it up so that the next time
it will boot from ubi, and write the firmware to ubi:
```
nvram set boot_wait=on
nvram set uart_en=1
nvram set flag_boot_rootfs=0
nvram set flag_last_success=0
nvram set flag_boot_success=1
nvram set flag_try_sys1_failed=0
nvram set flag_try_sys2_failed=0
nvram commit
ubiformat /dev/mtd8 -y -f /tmp/initramfs-factory.ubi
```
If the current system is ubi, please set it up so that the next time
it will boot from ubi1, and write the firmware to ubi1:
```
nvram set boot_wait=on
nvram set uart_en=1
nvram set flag_boot_rootfs=1
nvram set flag_last_success=1
nvram set flag_boot_success=1
nvram set flag_try_sys1_failed=0
nvram set flag_try_sys2_failed=0
nvram commit
ubiformat /dev/mtd9 -y -f /tmp/initramfs-factory.ubi
```
4. After rebooting, the system should now boot into the openwrt initramfs.
Flash the squashfs-sysupgrade.bin via using ssh or luci.
```
sysupgrade -n /tmp/squashfs-sysupgrade.bin
```
Done.
For existing users of the Redmi AX6000 running OpenWrt, here are the steps to
switch to this new layout:
1. Flash initramfs-factory.ubi
```
mtd -r -e ubi write /tmp/initramfs-factory.ubi ubi
```
2. After rebooting, the system will boot into the new openwrt-initramfs.
Log in and perform a sysupgrade to complete the process.
```
sysupgrade -n /tmp/squashfs-sysupgrade.bin
```
Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
2022-09-13 05:46:20 +00:00
|
|
|
define Device/xiaomi_redmi-router-ax6000-stock
|
|
|
|
DEVICE_VENDOR := Xiaomi
|
|
|
|
DEVICE_MODEL := Redmi Router AX6000 (stock layout)
|
|
|
|
DEVICE_DTS := mt7986a-xiaomi-redmi-router-ax6000-stock
|
|
|
|
DEVICE_DTS_DIR := ../dts
|
2023-03-10 20:05:18 +00:00
|
|
|
DEVICE_PACKAGES := kmod-leds-ws2812b kmod-mt7986-firmware mt7986-wo-firmware
|
mediatek: add alternative stock layout for Xiaomi Redmi Router AX6000
In this implementation, the flash partition layout is adjusted to avoid
modifying the uboot environment of mtdparts. This ensures that the 30M
ubi_kernel partition remains aligned with the stock ubi partition, and
the kernel volume is placed in it. This allows the stock uboot to boot
from it without changing the mtdparts, which is useful for reverting back
to the stock firmware using Xiaomi Firmware Tools. In actual testing,
modifying mtdparts has been found to break Xiaomi Firmware Tools.
1. use ARTIFACTS to generate initramfs-factory.ubi for easy installation.
2. The NAND flash layout is changed to allow for reverting back to the
stock firmware.
3. Before performing sysupgrade, do some cleanup in platform_pre_upgrade
to ensure a clean installation of OpenWRT.
4. Setup the uboot env to ensure that the system always boot, which can
be helpful for users who may forget to do this before sysupgrade in
the initramfs.
New flash instructions:
1. Gain ssh access. Please refer to:
https://openwrt.org/toh/xiaomi/redmi_ax6000#installation)
2. Check which system current u-boot is loading from:
COMMAND: `cat /proc/cmdline`
sample OUTPUT: `console=ttyS0,115200n1 loglevel=8 firmware=1 uart_en=1`
if firmware=1, current system is ubi1
if firmware=0, current system is ubi0
3. Setup nvram and write the firmware:
If the current system is ubi1, please set it up so that the next time
it will boot from ubi, and write the firmware to ubi:
```
nvram set boot_wait=on
nvram set uart_en=1
nvram set flag_boot_rootfs=0
nvram set flag_last_success=0
nvram set flag_boot_success=1
nvram set flag_try_sys1_failed=0
nvram set flag_try_sys2_failed=0
nvram commit
ubiformat /dev/mtd8 -y -f /tmp/initramfs-factory.ubi
```
If the current system is ubi, please set it up so that the next time
it will boot from ubi1, and write the firmware to ubi1:
```
nvram set boot_wait=on
nvram set uart_en=1
nvram set flag_boot_rootfs=1
nvram set flag_last_success=1
nvram set flag_boot_success=1
nvram set flag_try_sys1_failed=0
nvram set flag_try_sys2_failed=0
nvram commit
ubiformat /dev/mtd9 -y -f /tmp/initramfs-factory.ubi
```
4. After rebooting, the system should now boot into the openwrt initramfs.
Flash the squashfs-sysupgrade.bin via using ssh or luci.
```
sysupgrade -n /tmp/squashfs-sysupgrade.bin
```
Done.
For existing users of the Redmi AX6000 running OpenWrt, here are the steps to
switch to this new layout:
1. Flash initramfs-factory.ubi
```
mtd -r -e ubi write /tmp/initramfs-factory.ubi ubi
```
2. After rebooting, the system will boot into the new openwrt-initramfs.
Log in and perform a sysupgrade to complete the process.
```
sysupgrade -n /tmp/squashfs-sysupgrade.bin
```
Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
2022-09-13 05:46:20 +00:00
|
|
|
KERNEL_LOADADDR := 0x48000000
|
|
|
|
UBINIZE_OPTS := -E 5
|
|
|
|
BLOCKSIZE := 128k
|
|
|
|
PAGESIZE := 2048
|
|
|
|
ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
|
|
|
|
ARTIFACTS := initramfs-factory.ubi
|
|
|
|
ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-kernel.bin | ubinize-kernel
|
|
|
|
endif
|
|
|
|
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
|
|
|
|
endef
|
|
|
|
TARGET_DEVICES += xiaomi_redmi-router-ax6000-stock
|
2022-12-22 02:40:26 +00:00
|
|
|
|
|
|
|
define Device/xiaomi_redmi-router-ax6000-ubootmod
|
|
|
|
DEVICE_VENDOR := Xiaomi
|
|
|
|
DEVICE_MODEL := Redmi Router AX6000 (OpenWrt U-Boot layout)
|
|
|
|
DEVICE_DTS := mt7986a-xiaomi-redmi-router-ax6000-ubootmod
|
|
|
|
DEVICE_DTS_DIR := ../dts
|
2023-03-10 20:05:18 +00:00
|
|
|
DEVICE_PACKAGES := kmod-leds-ws2812b kmod-mt7986-firmware mt7986-wo-firmware
|
2022-12-22 02:40:26 +00:00
|
|
|
KERNEL_INITRAMFS_SUFFIX := -recovery.itb
|
|
|
|
IMAGES := sysupgrade.itb
|
|
|
|
KERNEL_LOADADDR := 0x48000000
|
|
|
|
UBINIZE_OPTS := -E 5
|
|
|
|
BLOCKSIZE := 128k
|
|
|
|
PAGESIZE := 2048
|
|
|
|
KERNEL_IN_UBI := 1
|
|
|
|
UBOOTENV_IN_UBI := 1
|
|
|
|
KERNEL := kernel-bin | gzip
|
|
|
|
KERNEL_INITRAMFS := kernel-bin | lzma | \
|
|
|
|
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
|
|
|
|
IMAGE/sysupgrade.itb := append-kernel | \
|
|
|
|
fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-static-with-rootfs | append-metadata
|
|
|
|
ARTIFACTS := preloader.bin bl31-uboot.fip
|
|
|
|
ARTIFACT/preloader.bin := bl2 spim-nand-ddr4
|
|
|
|
ARTIFACT/bl31-uboot.fip := bl31-uboot xiaomi_redmi-router-ax6000
|
|
|
|
ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
|
|
|
|
ARTIFACTS += initramfs-factory.ubi
|
|
|
|
ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-recovery.itb | ubinize-kernel
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
TARGET_DEVICES += xiaomi_redmi-router-ax6000-ubootmod
|