]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
mediatek: comfast cf-wr632ax: add all-in-UBI layout 23981/head
authorAndrii Kuiukoff <andros.ua@gmail.com>
Tue, 23 Jun 2026 17:01:03 +0000 (20:01 +0300)
committerJonas Jelonek <jelonek.jonas@gmail.com>
Thu, 30 Jul 2026 19:42:33 +0000 (21:42 +0200)
This commit introduces OpenWrt U-Boot UBI layout support
for the COMFAST CF-WR632AX, enabling:
- Prolonged device lifetime by allocating most of the flash
  to UBI (which takes care of wear-leveling)
- Maximum available storage space for OpenWrt
- Fully-featured U-Boot
- Effective recovery mechanisms

OpenWrt U-Boot UBI flash instructions
-------------------------------------

A device running stock firmware should be upgraded to the
latest standard OpenWrt firmware
(https://firmware-selector.openwrt.org/?target=mediatek%2Ffilogic&id=comfast_cf-wr632ax).

Back up critical data
---------------------

Console:
1. While the device is running OpenWrt with stock MTD partitions:
   mtd dump BL2 > /tmp/BL2.bin
   mtd dump u-boot-env > /tmp/u-boot-env.bin
   mtd dump Factory > /tmp/Factory.bin
   mtd dump FIP > /tmp/FIP.bin
2. Copy the backup files to your PC via SCP.

LuCI Web-UI:
"System" -> "Backup / Flash Firmware" -> "Save mtdblock contents"
Save mtdblock:
   BL2
   u-boot-env
   Factory
   FIP
Make sure the files were successfully downloaded to your downloads directory,
especially the Factory file.

Using the installer image
-------------------------
To simplify the installation process, this method uses a fork
of Daniel Golle's (@dangowrt) UBI Installer
https://github.com/dangowrt/owrt-ubi-installer

1. Ensure your router is running the latest generic OpenWrt firmware.
   Upgrade it if necessary.
2. Obtain the installer image:
   Build the installer from source
   https://github.com/andros-ua/owrt-ubi-installer/tree/cf-wr632ax
   or download a prebuilt image from the
   https://github.com/andros-ua/owrt-ubi-installer/releases
3. Flash the openwrt*-ubi-initramfs-recovery-installer.itb
   image using sysupgrade.
4. Wait for installation: the green status LED will blink rapidly,
   indicating that the all-in-UBI installer is running.
5. Once the installation finishes,
   the status LED will turn solid amber for 5 seconds.
6. After the device reboots, perform a final sysupgrade using the
   openwrt*-ubi-squashfs-sysupgrade.itb image.

Return to stock MTD
-------------------
1. Flash openwrt*comfast_cf-wr632ax-initramfs-kernel.bin
   via sysupgrade
2. Copy files to /tmp on the device via SCP:
   BL2.bin
   u-boot-env.bin
   Factory.bin
   FIP.bin
   openwrt*-squashfs-sysupgrade.bin
3. Restore stock MTD partitions:
   apk add kmod-mtd-rw
   insmod mtd-rw i_want_a_brick=1
   mtd write /tmp/BL2.bin BL2
   mtd write /tmp/u-boot-env.bin u-boot-env
   mtd write /tmp/Factory.bin Factory
   mtd write /tmp/FIP.bin FIP
4. Install the system:
   sysupgrade /tmp/*sysupgrade.bin

BL2 and FIP Recovery
--------------------
Use mtk_uartboot to recover corrupted BL2 or FIP via UART:
https://github.com/981213/mtk_uartboot

Stock layout
----------------------------------------
| dev:    size   erasesize  name       |
| mtd0: 00100000 00020000 "BL2"        |
| mtd1: 00080000 00020000 "u-boot-env" |
| mtd2: 00200000 00020000 "Factory"    |
| mtd3: 00200000 00020000 "FIP"        |
| mtd4: 07000000 00020000 "ubi"        |
----------------------------------------

OpenWrt U-Boot UBI layout
----------------------------------
| dev:    size   erasesize  name |
| mtd0: 00100000 00020000 "bl2"  |
| mtd1: 07f00000 00020000 "ubi"  |
----------------------------------

Signed-off-by: Andrii Kuiukoff <andros.ua@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23981
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
package/boot/uboot-mediatek/Makefile
package/boot/uboot-mediatek/patches/448-add-comfast_cf-wr632ax-ubi.patch [new file with mode: 0644]
package/boot/uboot-tools/uboot-envtools/files/mediatek_filogic
target/linux/mediatek/dts/mt7981b-comfast-cf-wr632ax-common.dtsi
target/linux/mediatek/dts/mt7981b-comfast-cf-wr632ax-ubi.dts [new file with mode: 0644]
target/linux/mediatek/filogic/base-files/etc/board.d/02_network
target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
target/linux/mediatek/image/filogic.mk

index 2d17ef9b8598aa143b209de570087edc969e3ab2..b24826037ef7e6369222ee02add1040cf0d5ea03 100644 (file)
@@ -317,6 +317,18 @@ define U-Boot/mt7981_comfast_cf-wr632ax
   DEPENDS:=+trusted-firmware-a-mt7981-spim-nand-ddr3-1866
 endef
 
+define U-Boot/mt7981_comfast_cf-wr632ax-ubi
+  NAME:=COMFAST CF-WR632AX (UBI)
+  BUILD_SUBTARGET:=filogic
+  BUILD_DEVICES:=comfast_cf-wr632ax-ubi
+  UBOOT_CONFIG:=mt7981_comfast_cf-wr632ax-ubi
+  UBOOT_IMAGE:=u-boot.fip
+  BL2_BOOTDEV:=spim-nand-ubi
+  BL2_SOC:=mt7981
+  BL2_DDRTYPE:=ddr3-1866
+  DEPENDS:=+trusted-firmware-a-mt7981-spim-nand-ubi-ddr3-1866
+endef
+
 define U-Boot/mt7981_creatlentem_clt-r30b1-ubi
   NAME:=CreatLentem CLT-R30B1 (UBI)
   BUILD_SUBTARGET:=filogic
@@ -1295,6 +1307,7 @@ UBOOT_TARGETS := \
        mt7981_cmcc_rax3000m-nand-ddr3 \
        mt7981_cmcc_rax3000m-nand-ddr4 \
        mt7981_comfast_cf-wr632ax \
+       mt7981_comfast_cf-wr632ax-ubi \
        mt7981_creatlentem_clt-r30b1-ubi \
        mt7981_cudy_m3000-v1 \
        mt7981_cudy_m3000-v2-yt8821 \
diff --git a/package/boot/uboot-mediatek/patches/448-add-comfast_cf-wr632ax-ubi.patch b/package/boot/uboot-mediatek/patches/448-add-comfast_cf-wr632ax-ubi.patch
new file mode 100644 (file)
index 0000000..931b496
--- /dev/null
@@ -0,0 +1,309 @@
+--- /dev/null
++++ b/arch/arm/dts/mt7981-comfast-cf-wr632ax-ubi.dts
+@@ -0,0 +1,134 @@
++// SPDX-License-Identifier: GPL-2.0-or-later
++
++/dts-v1/;
++#include "mt7981.dtsi"
++#include <dt-bindings/gpio/gpio.h>
++#include <dt-bindings/input/linux-event-codes.h>
++
++/ {
++      model = "COMFAST CF-WR632AX (UBI)";
++      compatible = "comfast,cf-wr632ax-ubi", "mediatek,mt7981";
++
++      chosen {
++              stdout-path = &uart0;
++              tick-timer = &timer0;
++      };
++
++      memory@40000000 {
++              device_type = "memory";
++              reg = <0x40000000 0x20000000>;
++      };
++
++      gpio-keys {
++              compatible = "gpio-keys";
++
++              button-reset {
++                      label = "reset";
++                      linux,code = <KEY_RESTART>;
++                      gpios = <&pio 1 GPIO_ACTIVE_LOW>;
++              };
++      };
++
++      gpio-leds {
++              compatible = "gpio-leds";
++
++              led_status_blue: led-0 {
++                      label = "blue:status";
++                      gpios = <&pio 8 GPIO_ACTIVE_LOW>;
++              };
++
++              led_status_green: led-1 {
++                      label = "green:status";
++                      gpios = <&pio 35 GPIO_ACTIVE_LOW>;
++              };
++
++              led_status_red: led-2 {
++                      label = "red:status";
++                      gpios = <&pio 34 GPIO_ACTIVE_LOW>;
++                      default-state = "on";
++              };
++      };
++};
++
++&eth {
++      status = "okay";
++      mediatek,gmac-id = <1>;
++      phy-mode = "gmii";
++      phy-handle = <&phy0>;
++
++      mdio {
++              phy0: ethernet-phy@0 {
++                      compatible = "ethernet-phy-id03a2.9461";
++                      reg = <0x0>;
++                      phy-mode = "gmii";
++              };
++      };
++};
++
++&pio {
++      spi_flash_pins: spi0-pins-func-1 {
++              mux {
++                      function = "flash";
++                      groups = "spi0", "spi0_wp_hold";
++              };
++
++              conf-pu {
++                      pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
++                      drive-strength = <MTK_DRIVE_4mA>;
++                      bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
++              };
++
++              conf-pd {
++                      pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
++                      drive-strength = <MTK_DRIVE_4mA>;
++                      bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
++              };
++      };
++};
++
++&spi0 {
++      #address-cells = <1>;
++      #size-cells = <0>;
++      pinctrl-names = "default";
++      pinctrl-0 = <&spi_flash_pins>;
++      status = "okay";
++      must_tx;
++      enhance_timing;
++      dma_ext;
++      ipm_design;
++      support_quad;
++      tick_dly = <2>;
++      sample_sel = <0>;
++
++      spi_nand@0 {
++              compatible = "spi-nand";
++              reg = <0>;
++              spi-max-frequency = <52000000>;
++
++              partitions {
++                      compatible = "fixed-partitions";
++                      #address-cells = <1>;
++                      #size-cells = <1>;
++
++                      partition@0 {
++                              label = "bl2";
++                              reg = <0x0 0x100000>;
++                      };
++
++                      partition@100000 {
++                              label = "ubi";
++                              reg = <0x100000 0x7f00000>;
++                              compatible = "linux,ubi";
++                      };
++              };
++      };
++};
++
++&uart0 {
++      mediatek,force-highspeed;
++      status = "okay";
++};
++
++&watchdog {
++      status = "disabled";
++};
+--- /dev/null
++++ b/configs/mt7981_comfast_cf-wr632ax-ubi_defconfig
+@@ -0,0 +1,112 @@
++CONFIG_ARM=y
++CONFIG_ARM_SMCCC=y
++CONFIG_SYS_HAS_NONCACHED_MEMORY=y
++CONFIG_POSITION_INDEPENDENT=y
++CONFIG_ARCH_MEDIATEK=y
++CONFIG_TEXT_BASE=0x41e00000
++CONFIG_SYS_MALLOC_F_LEN=0x4000
++CONFIG_NR_DRAM_BANKS=1
++CONFIG_DEFAULT_DEVICE_TREE="mt7981-comfast-cf-wr632ax-ubi"
++CONFIG_OF_LIBFDT_OVERLAY=y
++CONFIG_TARGET_MT7981=y
++CONFIG_SYS_LOAD_ADDR=0x46000000
++CONFIG_PRE_CON_BUF_ADDR=0x4007EF00
++CONFIG_DEBUG_UART_BASE=0x11002000
++CONFIG_DEBUG_UART_CLOCK=40000000
++CONFIG_DEBUG_UART=y
++CONFIG_FIT=y
++CONFIG_BOOTDELAY=30
++CONFIG_AUTOBOOT_KEYED=y
++CONFIG_AUTOBOOT_MENU_SHOW=y
++CONFIG_USE_PREBOOT=y
++CONFIG_DEFAULT_FDT_FILE="mt7981-comfast-cf-wr632ax-ubi"
++CONFIG_LOGLEVEL=7
++CONFIG_PRE_CONSOLE_BUFFER=y
++CONFIG_LOG=y
++# CONFIG_BOARD_INIT is not set
++CONFIG_BOARD_LATE_INIT=y
++CONFIG_HUSH_PARSER=y
++CONFIG_SYS_PROMPT="MT7981> "
++CONFIG_CMD_CPU=y
++CONFIG_CMD_LICENSE=y
++CONFIG_CMD_BOOTMENU=y
++CONFIG_CMD_ASKENV=y
++CONFIG_CMD_ERASEENV=y
++CONFIG_CMD_ENV_FLAGS=y
++CONFIG_CMD_RNG=y
++CONFIG_CMD_STRINGS=y
++CONFIG_CMD_DM=y
++CONFIG_CMD_GPIO=y
++CONFIG_CMD_GPT=y
++CONFIG_CMD_MTD=y
++CONFIG_CMD_PART=y
++CONFIG_CMD_TFTPSRV=y
++CONFIG_CMD_RARP=y
++CONFIG_CMD_CDP=y
++CONFIG_CMD_SNTP=y
++CONFIG_CMD_LINK_LOCAL=y
++CONFIG_CMD_DHCP=y
++CONFIG_CMD_DNS=y
++CONFIG_CMD_PING=y
++CONFIG_CMD_PXE=y
++CONFIG_CMD_CACHE=y
++CONFIG_CMD_PSTORE=y
++CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000
++CONFIG_CMD_UUID=y
++CONFIG_CMD_HASH=y
++CONFIG_CMD_SMC=y
++CONFIG_CMD_UBI=y
++CONFIG_CMD_UBI_RENAME=y
++CONFIG_OF_EMBED=y
++CONFIG_ENV_OVERWRITE=y
++CONFIG_ENV_IS_IN_UBI=y
++CONFIG_ENV_REDUNDANT=y
++CONFIG_ENV_UBI_PART="ubi"
++CONFIG_ENV_UBI_VOLUME="ubootenv"
++CONFIG_ENV_UBI_VOLUME_REDUND="ubootenv2"
++CONFIG_ENV_RELOC_GD_ENV_ADDR=y
++CONFIG_ENV_USE_DEFAULT_ENV_TEXT_FILE=y
++CONFIG_ENV_DEFAULT_ENV_TEXT_FILE="defenvs/comfast_cf-wr632ax-ubi_env"
++CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
++CONFIG_VERSION_VARIABLE=y
++CONFIG_NETCONSOLE=y
++CONFIG_USE_IPADDR=y
++CONFIG_IPADDR="192.168.1.1"
++CONFIG_USE_SERVERIP=y
++CONFIG_SERVERIP="192.168.1.254"
++CONFIG_NET_RANDOM_ETHADDR=y
++CONFIG_REGMAP=y
++CONFIG_SYSCON=y
++CONFIG_BUTTON=y
++CONFIG_BUTTON_GPIO=y
++CONFIG_CLK=y
++CONFIG_GPIO_HOG=y
++CONFIG_LED=y
++CONFIG_LED_BLINK=y
++CONFIG_LED_GPIO=y
++# CONFIG_MMC is not set
++CONFIG_MTD=y
++CONFIG_DM_MTD=y
++CONFIG_MTD_SPI_NAND=y
++CONFIG_MTD_UBI_FASTMAP=y
++CONFIG_PHY_FIXED=y
++CONFIG_MEDIATEK_ETH=y
++CONFIG_PHY=y
++CONFIG_PINCTRL=y
++CONFIG_PINCONF=y
++CONFIG_PINCTRL_MT7981=y
++CONFIG_POWER_DOMAIN=y
++CONFIG_MTK_POWER_DOMAIN=y
++CONFIG_DM_REGULATOR=y
++CONFIG_DM_REGULATOR_FIXED=y
++CONFIG_DM_REGULATOR_GPIO=y
++CONFIG_RAM=y
++CONFIG_DM_RNG=y
++CONFIG_RNG_MTK_V2=y
++CONFIG_DM_SERIAL=y
++CONFIG_MTK_SERIAL=y
++CONFIG_SPI=y
++CONFIG_DM_SPI=y
++CONFIG_MTK_SPIM=y
++CONFIG_ZSTD=y
++CONFIG_HEXDUMP=y
+--- /dev/null
++++ b/defenvs/comfast_cf-wr632ax-ubi_env
+@@ -0,0 +1,54 @@
++ipaddr=192.168.1.1
++serverip=192.168.1.254
++loadaddr=0x46000000
++console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
++bootcmd=if pstore check ; then run boot_recovery ; else run boot_ubi ; fi
++bootconf=config-1
++bootdelay=0
++bootfile=openwrt-mediatek-filogic-comfast_cf-wr632ax-ubi-initramfs-recovery.itb
++bootfile_bl2=openwrt-mediatek-filogic-comfast_cf-wr632ax-ubi-preloader.bin
++bootfile_fip=openwrt-mediatek-filogic-comfast_cf-wr632ax-ubi-bl31-uboot.fip
++bootfile_upg=openwrt-mediatek-filogic-comfast_cf-wr632ax-ubi-squashfs-sysupgrade.itb
++bootled_pwr=red:status
++bootled_rec=green:status
++bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
++bootmenu_default=0
++bootmenu_delay=0
++bootmenu_title=      \e[0;34m( ( ( \e[1;39mOpenWrt\e[0;34m ) ) )
++bootmenu_0=Initialize environment.=run _firstboot
++bootmenu_0d=Run default boot command.=run boot_default
++bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
++bootmenu_2=Boot production system from NAND.=run boot_production ; run bootmenu_confirm_return
++bootmenu_3=Boot recovery system from NAND.=run boot_recovery ; run bootmenu_confirm_return
++bootmenu_4=Load production system via TFTP then write to NAND.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_production ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return
++bootmenu_5=Load recovery system via TFTP then write to NAND.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_recovery ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return
++bootmenu_6=\e[31mLoad BL31+U-Boot FIP via TFTP then write to NAND.\e[0m=run boot_tftp_write_fip ; run bootmenu_confirm_return
++bootmenu_7=\e[31mLoad BL2 preloader via TFTP then write to NAND.\e[0m=run boot_tftp_write_bl2 ; run bootmenu_confirm_return
++bootmenu_8=Reboot.=reset
++bootmenu_9=Reset all settings to factory defaults.=run reset_factory ; reset
++boot_first=if button reset ; then led $bootled_pwr off ; run boot_tftp_recovery ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu
++boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever
++boot_production=led $bootled_rec off ; run ubi_read_production && bootm $loadaddr#$bootconf ; led $bootled_pwr off
++boot_recovery=led $bootled_pwr off ; run ubi_read_recovery && bootm $loadaddr#$bootconf ; led $bootled_rec off
++boot_ubi=run boot_production ; run boot_recovery ; run boot_tftp_forever
++boot_tftp_forever=led $bootled_pwr off ; while true ; do run boot_tftp_recovery ; sleep 1 ; done
++boot_tftp_production=tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run ubi_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi
++boot_tftp_recovery=tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run ubi_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi
++boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
++boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run ubi_write_fip && run reset_factory
++boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run mtd_write_bl2
++preboot=led $bootled_pwr on ; led $bootled_rec on
++reset_factory=mw $loadaddr 0xff 0x1f000 ; ubi write $loadaddr ubootenv 0x1f000 ; ubi write $loadaddr ubootenv2 0x1f000 ; ubi remove rootfs_data
++mtd_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr
++ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x1f000 dynamic ; ubi check ubootenv2 || ubi create ubootenv2 0x1f000 dynamic
++ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi
++ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs
++ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery
++ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data
++ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip 0x200000 static ; ubi write $loadaddr fip 0x200000
++ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize
++ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize
++_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv
++_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; run boot_first
++_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
++_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title       \e[33m$ver\e[0m"
index 3571d0b75fb103e23a3bcd77e7fe5406a84cbf38..cb47d9d7846ccebecc901cf918416f3afb82bb00 100644 (file)
@@ -26,6 +26,7 @@ abt,asr3000|\
 acer,predator-w6x-ubootmod|\
 asus,zenwifi-bt8-ubootmod|\
 cmcc,a10-ubootmod|\
+comfast,cf-wr632ax-ubi|\
 comfast,cf-wr632ax-ubootmod|\
 creatlentem,clt-r30b1-ubi|\
 cudy,m3000-v1-ubootmod|\
index 7a926d90f628b1ac9cabab292fbda2062d7a0900..b6d5f43bd023a0580631a766cd88e13a1c029998 100644 (file)
                spi-tx-bus-width = <4>;
                spi-rx-bus-width = <4>;
 
-               partitions {
+               partitions: partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
                        #size-cells = <1>;
diff --git a/target/linux/mediatek/dts/mt7981b-comfast-cf-wr632ax-ubi.dts b/target/linux/mediatek/dts/mt7981b-comfast-cf-wr632ax-ubi.dts
new file mode 100644 (file)
index 0000000..d000a12
--- /dev/null
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "mt7981b-comfast-cf-wr632ax-common.dtsi"
+
+/ {
+       model = "COMFAST CF-WR632AX (UBI)";
+       compatible = "comfast,cf-wr632ax-ubi", "mediatek,mt7981";
+};
+
+&chosen {
+       bootargs = "root=/dev/fit0 rootwait";
+       rootdisk = <&ubi_rootdisk>;
+};
+
+/delete-node/ &partitions;
+
+&spi_nand {
+       partitions {
+               compatible = "fixed-partitions";
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               partition@0 {
+                       label = "bl2";
+                       reg = <0x0 0x100000>;
+                       read-only;
+               };
+
+               partition@100000 {
+                       label = "ubi";
+                       reg = <0x100000 0x7f00000>;
+                       compatible = "linux,ubi";
+
+                       volumes {
+                               ubi_factory: ubi-volume-factory {
+                                       volname = "factory";
+                               };
+
+                               ubi_rootdisk: ubi-volume-fit {
+                                       volname = "fit";
+                               };
+
+                               ubi-volume-ubootenv {
+                                       volname = "ubootenv";
+                                       nvmem-layout {
+                                               compatible = "u-boot,env-redundant-bool";
+                                       };
+                               };
+
+                               ubi-volume-ubootenv2 {
+                                       volname = "ubootenv2";
+                                       nvmem-layout {
+                                               compatible = "u-boot,env-redundant-bool";
+                                       };
+                               };
+                       };
+               };
+       };
+};
+
+&ubi_factory {
+       nvmem-layout {
+               compatible = "fixed-layout";
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               eeprom_factory_0: eeprom@0 {
+                       reg = <0x0 0x1000>;
+               };
+
+               macaddr_factory_4: macaddr@4 {
+                       reg = <0x4 0x6>;
+                       compatible = "mac-base";
+                       #nvmem-cell-cells = <1>;
+               };
+
+               macaddr_factory_8000: macaddr@8000 {
+                       compatible = "mac-base";
+                       reg = <0x8000 0x6>;
+                       #nvmem-cell-cells = <1>;
+               };
+
+               macaddr_factory_e000: macaddr@e000 {
+                       compatible = "mac-base";
+                       reg = <0xe000 0x6>;
+                       #nvmem-cell-cells = <1>;
+               };
+       };
+};
index 64dfb9a8aebe30bb7b5db25500ceff4705bb04dd..6f5f1e0a4dc6a01c9bdb77aa0a834c64fbca7cf6 100644 (file)
@@ -178,6 +178,7 @@ mediatek_setup_interfaces()
                ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" internet
                ;;
        comfast,cf-wr632ax|\
+       comfast,cf-wr632ax-ubi|\
        comfast,cf-wr632ax-ubootmod|\
        keenetic,kn-3911|\
        smartrg,sdg-8622|\
index 89c44cac7689f7ae9d4e758c5266a4cf07612508..ff98b766b0210ae480d6c07472ed4777f05a3911 100644 (file)
@@ -146,6 +146,7 @@ platform_do_upgrade() {
        bazis,ax3000wm|\
        cmcc,a10-ubootmod|\
        cmcc,rax3000m|\
+       comfast,cf-wr632ax-ubi|\
        comfast,cf-wr632ax-ubootmod|\
        creatlentem,clt-r30b1-ubi|\
        cudy,m3000-v1-ubootmod|\
@@ -391,6 +392,7 @@ platform_check_image() {
        bazis,ax3000wm|\
        cmcc,a10-ubootmod|\
        cmcc,rax3000m|\
+       comfast,cf-wr632ax-ubi|\
        comfast,cf-wr632ax-ubootmod|\
        creatlentem,clt-r30b1-ubi|\
        cudy,m3000-v1-ubootmod|\
index 134d9c967ba2f355358d9d9077a9248a55eb0e4b..aebd0d5c4776f2889ad31237dcec9a0916c89a61 100644 (file)
@@ -1028,9 +1028,25 @@ define Device/comfast_cf-wr632ax
 endef
 TARGET_DEVICES += comfast_cf-wr632ax
 
+define Device/comfast_cf-wr632ax-ubi
+  DEVICE_VARIANT := (UBI)
+  DEVICE_DTS := mt7981b-comfast-cf-wr632ax-ubi
+  ARTIFACT/preloader.bin := mt7981-bl2 spim-nand-ubi-ddr3-1866
+  ARTIFACT/bl31-uboot.fip := mt7981-bl31-uboot comfast_cf-wr632ax-ubi
+  $(call Device/comfast_cf-wr632ax-ubootmod-common)
+endef
+TARGET_DEVICES += comfast_cf-wr632ax-ubi
+
 define Device/comfast_cf-wr632ax-ubootmod
   DEVICE_VARIANT := (OpenWrt U-Boot layout)
   DEVICE_DTS := mt7981b-comfast-cf-wr632ax-ubootmod
+  ARTIFACT/preloader.bin := mt7981-bl2 spim-nand-ddr3-1866
+  ARTIFACT/bl31-uboot.fip := mt7981-bl31-uboot comfast_cf-wr632ax
+  $(call Device/comfast_cf-wr632ax-ubootmod-common)
+endef
+TARGET_DEVICES += comfast_cf-wr632ax-ubootmod
+
+define Device/comfast_cf-wr632ax-ubootmod-common
   UBOOTENV_IN_UBI := 1
   IMAGES := sysupgrade.itb
   KERNEL_INITRAMFS_SUFFIX := -recovery.itb
@@ -1040,11 +1056,8 @@ define Device/comfast_cf-wr632ax-ubootmod
   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 := mt7981-bl2 spim-nand-ddr3-1866
-  ARTIFACT/bl31-uboot.fip := mt7981-bl31-uboot comfast_cf-wr632ax
   $(call Device/comfast_cf-wr632ax-common)
 endef
-TARGET_DEVICES += comfast_cf-wr632ax-ubootmod
 
 define Device/comfast_cf-xr186
   DEVICE_VENDOR := COMFAST