--- /dev/null
+# SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause
+
+rootfs_create() {
+ local blocks
+
+ blocks=$(cat /sys/class/ubi/ubi0/avail_eraseblocks)
+ [ -z "$blocks" ] && {
+ echo "Failed to read amount of available erase blocks" >&2
+ return
+ }
+
+ # Delete after getting available blocks: Make sure enough space is
+ # left to recreate these volumes.
+ ubirmvol /dev/ubi0 -N kernel_backup
+ ubirmvol /dev/ubi0 -N rootfs_backup
+
+ # Use 90% of remaining flash size for "rootfs_data"
+ ubimkvol /dev/ubi0 -n 20 -N rootfs_data --lebs $((blocks / 100 * 90))
+ mknod -m 0600 /dev/ubi0_20 c 250 21
+}
+
+rootfs_prepare() {
+ case $(board_name) in
+ netgear,wax220)
+ if ! ubinfo /dev/ubi0 -N rootfs_data &>/dev/null; then
+ echo "Creating \"rootfs_data\" UBI volume"
+ rootfs_create
+ fi
+ ;;
+ *)
+ ;;
+ esac
+}
+
+boot_hook_add preinit_main rootfs_prepare
TARGET_DEVICES += h3c_magic-nx30-pro
define Device/netgear_wax220
- DEVICE_VENDOR := Netgear
+ DEVICE_VENDOR := NETGEAR
DEVICE_MODEL := WAX220
DEVICE_DTS := mt7986b-netgear-wax220
DEVICE_DTS_DIR := ../dts
+ NETGEAR_ENC_MODEL := WAX220
+ NETGEAR_ENC_REGION := US
DEVICE_PACKAGES := kmod-mt7986-firmware mt7986-wo-firmware
- IMAGES := sysupgrade.bin
- KERNEL_IN_UBI := 1
- 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
+ KERNEL_INITRAMFS_SUFFIX := -recovery.itb
+ IMAGE_SIZE := 32768k
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+ IMAGES += factory.img
+ # Padding to 10M seems to be required by OEM web interface
+ IMAGE/factory.img := sysupgrade-tar | \
+ pad-to 10M | check-size | netgear-encrypted-factory
endef
TARGET_DEVICES += netgear_wax220