From acdc497fdf4465bab6a8af9fe2fa5cb1f994e632 Mon Sep 17 00:00:00 2001
From: Bartlomiej Grzeskowiak <bartlomiej.grzeskowiak@iopsys.eu>
Date: Tue, 19 Oct 2021 12:17:45 +0200
Subject: [PATCH] iopsys-econet: Add mtdparts to kernel cmdline

Prepare for new flash layout handling that should be done on uboot env
level. Not hardcoded in kernel.

Signed-off-by: Bartlomiej Grzeskowiak <bartlomiej.grzeskowiak@iopsys.eu>
---
 iopsys-econet/en7562/mi.conf              | 6 ++++--
 iopsys-econet/image/Makefile              | 1 -
 iopsys-econet/image/ubinize.cfg           | 7 +++++++
 iopsys-econet/image/ubinize_container.cfg | 7 -------
 4 files changed, 11 insertions(+), 10 deletions(-)
 delete mode 100644 iopsys-econet/image/ubinize_container.cfg

diff --git a/iopsys-econet/en7562/mi.conf b/iopsys-econet/en7562/mi.conf
index f7bb7a8e4..d02865b72 100755
--- a/iopsys-econet/en7562/mi.conf
+++ b/iopsys-econet/en7562/mi.conf
@@ -99,8 +99,10 @@ stderr=serial
 active_image=1
 board_id=arcee
 rootfstype=squashfs
+mtdparts_squashfs=mtdparts=ECO-NAND:0x100000(u-boot),0x500000(boot1),0x500000(boot2),0x4600000(rootfs1),0x4600000(rootfs2),0xa00000(overlay1),0xa00000(overlay2),0x100000(jffs_test),0x3280000(ubi_container),0x180000(art)
+mtdparts_ubifs=mtdparts=ECO-NAND:0x100000(u-boot),0x500000(boot1),0x500000(boot2),0xd380000(ubi),0x180000(art)
 bootcmd=run iop_set_mtdblock_${rootfstype}\; setenv bootargs ${iop_gen_bootargs} ${iop_sys_bootargs}\; run iop_read_kernel\; bootm
 iop_read_kernel=if test "${active_image}" = 1\; then flash read 0x100000 0x500000\; else flash read 0x600000 0x500000\; fi
 iop_gen_bootargs=console=ttyS0,115200n8 earlycon init=/sbin/init
-iop_set_mtdblock_ubifs=setenv iop_sys_bootargs ubi.mtd=ubi root=ubi0:rootfs${active_image} rootfstype=${rootfstype}
-iop_set_mtdblock_squashfs=if test "${active_image}" = 1\; then setenv iop_sys_bootargs root=/dev/mtdblock3 ro rootfstype=${rootfstype}\; else setenv iop_sys_bootargs root=/dev/mtdblock4 ro rootfstype=${rootfstype}\; fi
+iop_set_mtdblock_ubifs=setenv iop_sys_bootargs ubi.mtd=ubi mtdparts=${mtdparts_ubifs} root=ubi0:rootfs${active_image} rootfstype=ubifs
+iop_set_mtdblock_squashfs=if test "${active_image}" = 1\; then setenv iop_sys_bootargs mtdparts=${mtdparts_squashfs} root=/dev/mtdblock3 ro rootfstype=squashfs\; else setenv iop_sys_bootargs mtdparts=${mtdparts_squashfs} root=/dev/mtdblock4 ro rootfstype=squashfs\; fi
diff --git a/iopsys-econet/image/Makefile b/iopsys-econet/image/Makefile
index 63a7e4359..080a38ea7 100755
--- a/iopsys-econet/image/Makefile
+++ b/iopsys-econet/image/Makefile
@@ -121,7 +121,6 @@ define Image/Build/GenerateUbifsFIT
 	$(STAGING_DIR_HOST)/bin/mkimage -f $(PLATFORM_DIR)/$(SUBTARGET)/boot.its $(BIN_DIR)/EN7562$(IOPSYS_VERSION_SUFFIX).itb
 	ln -sf $(BIN_DIR)/EN7562$(IOPSYS_VERSION_SUFFIX).itb $(BIN_DIR)/last.itb
 	ubinize $(UBINIZE_OPTS) -o $(BIN_DIR)/ubi_root.bin ubinize.cfg
-	ubinize $(UBINIZE_OPTS) -o $(BIN_DIR)/ubi_container.bin ubinize_container.cfg
 endef
 
 define Image/Build/ubifs
diff --git a/iopsys-econet/image/ubinize.cfg b/iopsys-econet/image/ubinize.cfg
index 9d78ec423..b5c9ec406 100644
--- a/iopsys-econet/image/ubinize.cfg
+++ b/iopsys-econet/image/ubinize.cfg
@@ -27,4 +27,11 @@ vol_id=3
 vol_size=25MiB
 vol_type=dynamic
 vol_name=overlay2
+
+[container]
+mode=ubi
+vol_id=4
+vol_size=40MiB
+vol_type=dynamic
+vol_name=container
 vol_flags=autoresize
diff --git a/iopsys-econet/image/ubinize_container.cfg b/iopsys-econet/image/ubinize_container.cfg
deleted file mode 100644
index e1dd34693..000000000
--- a/iopsys-econet/image/ubinize_container.cfg
+++ /dev/null
@@ -1,7 +0,0 @@
-[container]
-mode=ubi
-vol_id=0
-vol_size=40MiB
-vol_type=dynamic
-vol_name=container
-vol_flags=autoresize
-- 
GitLab