]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
mediatek: creatlentem clt-r30b1: add all-in-UBI layout 20666/head
authorAndrii Kuiukoff <andros.ua@gmail.com>
Wed, 29 Oct 2025 20:05:19 +0000 (22:05 +0200)
committerJonas Jelonek <jelonek.jonas@gmail.com>
Wed, 17 Jun 2026 07:09:25 +0000 (09:09 +0200)
This commit introduces OpenWrt U-Boot all-in-ubi layout support
for the CreatLentem CLT-R30B1, enabling:
- Fully-featured U-Boot
- Effective recovery mechanisms
- Prolonged device lifetime by allocating most of the flash
  to UBI (which takes care of wear-leveling)
- Maximum available storage space for OpenWrt
- Unified firmware across different device variants

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

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/clt-r30b1
   or download a prebuilt image from the
   https://github.com/andros-ua/owrt-ubi-installer/releases
3. Flash the openwrt*creatlentem_clt-r30b1-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 white (lime) for 5 seconds.
6. After the device reboots, perform a final sysupgrade using the
   openwrt*creatlentem_clt-r30b1-ubi-squashfs-sysupgrade.itb image.

Return to stock layout
----------------------
1. Flash openwrt*creatlentem_clt-r30b1(-112m)-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*creatlentem_clt-r30b1(-112m)-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

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/20666
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
package/boot/uboot-mediatek/Makefile
package/boot/uboot-mediatek/patches/473-add-creatlentem_clt-r30b1-ubi.patch [new file with mode: 0644]
package/boot/uboot-tools/uboot-envtools/files/mediatek_filogic
target/linux/mediatek/dts/mt7981b-creatlentem-clt-r30b1-112m.dts
target/linux/mediatek/dts/mt7981b-creatlentem-clt-r30b1-common.dtsi
target/linux/mediatek/dts/mt7981b-creatlentem-clt-r30b1-ubi.dts [new file with mode: 0644]
target/linux/mediatek/dts/mt7981b-creatlentem-clt-r30b1.dts
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 f9a37bc775752c5e5b374ecb55258c58f818c2c6..eb0a29ecc901ea2c1a4e12d092357efa842e2668 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_creatlentem_clt-r30b1-ubi
+  NAME:=CreatLentem CLT-R30B1 (UBI)
+  BUILD_SUBTARGET:=filogic
+  BUILD_DEVICES:=creatlentem_clt-r30b1-ubi
+  UBOOT_CONFIG:=mt7981_creatlentem_clt-r30b1-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_cudy_tr3000-v1
   NAME:=Cudy TR3000 v1
   BUILD_SUBTARGET:=filogic
@@ -1247,6 +1259,7 @@ UBOOT_TARGETS := \
        mt7981_cmcc_rax3000m-nand-ddr3 \
        mt7981_cmcc_rax3000m-nand-ddr4 \
        mt7981_comfast_cf-wr632ax \
+       mt7981_creatlentem_clt-r30b1-ubi \
        mt7981_cudy_tr3000-v1 \
        mt7981_cudy_wbr3000uax-v1 \
        mt7981_cudy_wr3000e-v1 \
diff --git a/package/boot/uboot-mediatek/patches/473-add-creatlentem_clt-r30b1-ubi.patch b/package/boot/uboot-mediatek/patches/473-add-creatlentem_clt-r30b1-ubi.patch
new file mode 100644 (file)
index 0000000..ba5a203
--- /dev/null
@@ -0,0 +1,315 @@
+--- /dev/null
++++ b/configs/mt7981_creatlentem_clt-r30b1-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-creatlentem-clt-r30b1-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-creatlentem-clt-r30b1-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/creatlentem_clt-r30b1-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/creatlentem_clt-r30b1-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-creatlentem_clt-r30b1-ubi-initramfs-recovery.itb
++bootfile_bl2=openwrt-mediatek-filogic-creatlentem_clt-r30b1-ubi-preloader.bin
++bootfile_fip=openwrt-mediatek-filogic-creatlentem_clt-r30b1-ubi-bl31-uboot.fip
++bootfile_upg=openwrt-mediatek-filogic-creatlentem_clt-r30b1-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"
+--- /dev/null
++++ b/arch/arm/dts/mt7981-creatlentem-clt-r30b1-ubi.dts
+@@ -0,0 +1,140 @@
++// 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 = "CreatLentem CLT-R30B1 (UBI)";
++      compatible = "creatlentem,clt-r30b1-ubi", "mediatek,mt7981";
++
++      chosen {
++              stdout-path = &uart0;
++              tick-timer = &timer0;
++      };
++
++      memory@40000000 {
++              device_type = "memory";
++              reg = <0x40000000 0x10000000>;
++      };
++
++      gpio-keys {
++              compatible = "gpio-keys";
++
++              button-reset {
++                      label = "reset";
++                      linux,code = <KEY_RESTART>;
++                      gpios = <&pio 1 GPIO_ACTIVE_LOW>;
++              };
++
++              button-wps {
++                      label = "wps";
++                      linux,code = <KEY_WPS_BUTTON>;
++                      gpios = <&pio 0 GPIO_ACTIVE_LOW>;
++              };
++      };
++
++      gpio-leds {
++              compatible = "gpio-leds";
++
++              led_status_green: led-0 {
++                      label = "green:status";
++                      gpios = <&pio 11 GPIO_ACTIVE_LOW>;
++              };
++
++              led_status_red: led-1 {
++                      label = "red:status";
++                      gpios = <&pio 12 GPIO_ACTIVE_LOW>;
++                      default-state = "on";
++              };
++      };
++};
++
++&eth {
++      status = "okay";
++      mediatek,gmac-id = <0>;
++      phy-mode = "2500base-x";
++      mediatek,switch = "mt7531";
++      reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>;
++
++      fixed-link {
++              speed = <2500>;
++              full-duplex;
++      };
++};
++
++&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>;
++              };
++      };
++
++      line_8-hog {
++              gpio-hog;
++              gpios = <8 GPIO_ACTIVE_HIGH>;
++              output-low;
++              line-name = "LEDs power";
++      };
++};
++
++&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";
++};
index 6caeca6dd9c3ab7548a12f0d6fb4c037ecc08f73..21646b100a557fce7380e971bdbbc8af054911e4 100644 (file)
@@ -27,6 +27,7 @@ acer,predator-w6x-ubootmod|\
 asus,zenwifi-bt8-ubootmod|\
 cmcc,a10-ubootmod|\
 comfast,cf-wr632ax-ubootmod|\
+creatlentem,clt-r30b1-ubi|\
 cudy,tr3000-v1-ubootmod|\
 cudy,wbr3000uax-v1-ubootmod|\
 cudy,wr3000e-v1-ubootmod|\
index 36351565ebb83366d350a4084e6cfdce4a58bb36..c987c76fad45b46796c609f0a789c71b9d7303fb 100644 (file)
@@ -7,9 +7,12 @@
        compatible = "creatlentem,clt-r30b1-112m", "mediatek,mt7981";
 };
 
-&partitions {
-       partition@580000 {
-               label = "ubi";
-               reg = <0x0580000 0x7000000>;
-       };
+&spi_nand {
+       mediatek,nmbm;
+       mediatek,bmt-max-ratio = <1>;
+       mediatek,bmt-max-reserved-blocks = <64>;
+};
+
+&ubi {
+       reg = <0x0580000 0x7000000>;
 };
index 6958c174a0748d29b641931df7d1443ab41e3867..ff55eb3f9f0227879595e6a657aca02ef2d7f170 100644 (file)
@@ -17,7 +17,7 @@
                serial0 = &uart0;
        };
 
-       chosen {
+       chosen: chosen {
                stdout-path = "serial0:115200n8";
        };
 
        pinctrl-0 = <&spi0_flash_pins>;
        status = "okay";
 
-       spi_nand@0 {
+       spi_nand: spi-nand@0 {
                compatible = "spi-nand";
                reg = <0>;
 
                spi-cal-addrlen = <5>;
                spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>;
 
-               mediatek,nmbm;
-               mediatek,bmt-max-ratio = <1>;
-               mediatek,bmt-max-reserved-blocks = <64>;
-
                partitions: partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
                                reg = <0x380000 0x200000>;
                                read-only;
                        };
+
+                       ubi: partition@580000 {
+                               label = "ubi";
+                       };
                };
        };
 };
diff --git a/target/linux/mediatek/dts/mt7981b-creatlentem-clt-r30b1-ubi.dts b/target/linux/mediatek/dts/mt7981b-creatlentem-clt-r30b1-ubi.dts
new file mode 100644 (file)
index 0000000..b4cd51e
--- /dev/null
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "mt7981b-creatlentem-clt-r30b1-common.dtsi"
+
+/ {
+       model = "CreatLentem CLT-R30B1 (UBI)";
+       compatible = "creatlentem,clt-r30b1-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_24: macaddr@24 {
+                       compatible = "mac-base";
+                       reg = <0x24 0x6>;
+                       #nvmem-cell-cells = <1>;
+               };
+
+               macaddr_factory_2a: macaddr@2a {
+                       compatible = "mac-base";
+                       reg = <0x2a 0x6>;
+                       #nvmem-cell-cells = <1>;
+               };
+       };
+};
index 941d0c34353fb65fe523106b60e8641a3bd6b429..9b38fd8cc26a1fa8a8cc6ae1fff55059a40ed34c 100644 (file)
@@ -8,13 +8,18 @@
 };
 
 &partitions {
-       partition@580000 {
-               label = "ubi";
-               reg = <0x0580000 0x4000000>;
-       };
        partition@4580000 {
                label = "data";
                reg = <0x4580000 0x2000000>;
        };
+};
+
+&spi_nand {
+       mediatek,nmbm;
+       mediatek,bmt-max-ratio = <1>;
+       mediatek,bmt-max-reserved-blocks = <64>;
+};
 
+&ubi {
+       reg = <0x0580000 0x4000000>;
 };
index 8fcbcce3d38f89000d4d7413207f2ed2635eb613..36d79b80d7c2fa168f22e110fea0fd7874b6e7d4 100644 (file)
@@ -56,6 +56,7 @@ mediatek_setup_interfaces()
        confiabits,mt7981|\
        creatlentem,clt-r30b1|\
        creatlentem,clt-r30b1-112m|\
+       creatlentem,clt-r30b1-ubi|\
        cudy,wr3000-v1|\
        globitel,bt-r320|\
        huasifei,wh3000r-nand|\
index 80fbfb24c84755ec715d831703aa3093bd3bdaa6..bc6d8271747e370b08050b8d8433eb0175118182 100644 (file)
@@ -147,6 +147,7 @@ platform_do_upgrade() {
        cmcc,a10-ubootmod|\
        cmcc,rax3000m|\
        comfast,cf-wr632ax-ubootmod|\
+       creatlentem,clt-r30b1-ubi|\
        cudy,tr3000-v1-ubootmod|\
        cudy,wbr3000uax-v1-ubootmod|\
        cudy,wr3000e-v1-ubootmod|\
@@ -360,6 +361,7 @@ platform_check_image() {
        cmcc,a10-ubootmod|\
        cmcc,rax3000m|\
        comfast,cf-wr632ax-ubootmod|\
+       creatlentem,clt-r30b1-ubi|\
        cudy,tr3000-v1-ubootmod|\
        cudy,wbr3000uax-v1-ubootmod|\
        cudy,wr3000e-v1-ubootmod|\
index bda388ee3bf2588aff4fe98e8297d4d4ce0593cd..eb660ddc14242f0c2d84fb445743f8ad55b5a18c 100644 (file)
@@ -1079,7 +1079,6 @@ define Device/creatlentem_clt-r30b1-common
   BLOCKSIZE := 128k
   PAGESIZE := 2048
   KERNEL_IN_UBI := 1
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
 endef
 
 define Device/creatlentem_clt-r30b1-112m
@@ -1090,6 +1089,7 @@ define Device/creatlentem_clt-r30b1-112m
   DEVICE_DTS := mt7981b-creatlentem-clt-r30b1-112m
   SUPPORTED_DEVICES += clt,r30b1 clt,r30b1-112m
   IMAGE_SIZE := 114688k
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   $(call Device/creatlentem_clt-r30b1-common)
 endef
 TARGET_DEVICES += creatlentem_clt-r30b1-112m
@@ -1098,10 +1098,32 @@ define Device/creatlentem_clt-r30b1
   DEVICE_DTS := mt7981b-creatlentem-clt-r30b1
   SUPPORTED_DEVICES += mediatek,mt7981-spim-snand-rfb
   IMAGE_SIZE := 65536k
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   $(call Device/creatlentem_clt-r30b1-common)
 endef
 TARGET_DEVICES += creatlentem_clt-r30b1
 
+define Device/creatlentem_clt-r30b1-ubi
+  DEVICE_VARIANT := (UBI)
+  DEVICE_ALT0_VARIANT := (UBI)
+  DEVICE_ALT1_VARIANT := (UBI)
+  DEVICE_ALT2_VARIANT := (UBI)
+  DEVICE_DTS := mt7981b-creatlentem-clt-r30b1-ubi
+  UBOOTENV_IN_UBI := 1
+  IMAGES := sysupgrade.itb
+  KERNEL_INITRAMFS_SUFFIX := -recovery.itb
+  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 := mt7981-bl2 spim-nand-ubi-ddr3-1866
+  ARTIFACT/bl31-uboot.fip := mt7981-bl31-uboot creatlentem_clt-r30b1-ubi
+  $(call Device/creatlentem_clt-r30b1-common)
+endef
+TARGET_DEVICES += creatlentem_clt-r30b1-ubi
+
 define Device/cudy_ap3000outdoor-v1
   DEVICE_VENDOR := Cudy
   DEVICE_MODEL := AP3000 Outdoor