distroboot: Fix ubifs
Fix multiple issues in ubifs distroboot code:
U-Boot supports attaching only one MTD device as UBI at the time. So
always call 'ubifsmount ubi0:${bootubivol}' for mounting UBI volume
${bootubivol}. Usage of 'ubi${devnum}' is incorrect as 'ubi part'
command attach MTD device always as UBI device ubi0.
Set distroboot ${bootfstype} variable to ubifs in ubifs_boot command.
Distroboot scripts require ${bootfstype} variable to be properly set and it
is already set for all other boot types.
Set distroboot ${distro_bootpart} variable to ${bootubivol} value. UBI
device does not have partitions, but has volumes. Distroboot scripts
require something to be set in ${distro_bootpart} variable, so set it to
the UBI volume which is currently mounted by ubifs.
Set distroboot ${devnum} variable to fixed string "ubi0". ubifs code
differs from the other partition code that it requires "ubi" prefix before
number.
Explicitly unmount ubifs volume after loading all data from it. This allows
to detach UBI device from MTD device.
Move definition of MTD device with UBI and UBI volume with ubifs filesystem
from global env variables ${bootubipart} and ${bootubivol} into the
distroboot "func" macro, defined in board include config files. UBIFS
distroboot macros then set ${bootubipart} and ${bootubivol} local variables
for compatibility with existing distroboot scripts.
This last change allows to define more UBIFS target devices and make it
clear what is boot MTD/UBI device.
All board include config files are adjusted to use this new scheme of
specifying boot MTD/UBI device.
Signed-off-by: Pali Rohár <pali@kernel.org>
Acked-by: Frieder Schrempf <frieder.schrempf@kontron.de>
diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index c5502388..c6e9c49 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -70,18 +70,23 @@
#ifdef CONFIG_CMD_UBIFS
#define BOOTENV_SHARED_UBIFS \
"ubifs_boot=" \
- "env exists bootubipart || " \
- "env set bootubipart UBI; " \
- "env exists bootubivol || " \
- "env set bootubivol boot; " \
"if ubi part ${bootubipart} && " \
- "ubifsmount ubi${devnum}:${bootubivol}; " \
+ "ubifsmount ubi0:${bootubivol}; " \
"then " \
"devtype=ubi; " \
+ "devnum=ubi0; " \
+ "bootfstype=ubifs; " \
+ "distro_bootpart=${bootubivol}; " \
"run scan_dev_for_boot; " \
+ "ubifsumount; " \
"fi\0"
-#define BOOTENV_DEV_UBIFS BOOTENV_DEV_BLKDEV
-#define BOOTENV_DEV_NAME_UBIFS BOOTENV_DEV_NAME_BLKDEV
+#define BOOTENV_DEV_UBIFS(devtypeu, devtypel, instance, bootubipart, bootubivol) \
+ "bootcmd_ubifs" #instance "=" \
+ "bootubipart=" #bootubipart "; " \
+ "bootubivol=" #bootubivol "; " \
+ "run ubifs_boot\0"
+#define BOOTENV_DEV_NAME_UBIFS(devtypeu, devtypel, instance, bootubipart, bootubivol) \
+ #devtypel #instance " "
#else
#define BOOTENV_SHARED_UBIFS
#define BOOTENV_DEV_UBIFS \
@@ -411,13 +416,13 @@
BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE
#endif
-#define BOOTENV_DEV_NAME(devtypeu, devtypel, instance) \
- BOOTENV_DEV_NAME_##devtypeu(devtypeu, devtypel, instance)
+#define BOOTENV_DEV_NAME(devtypeu, devtypel, instance, ...) \
+ BOOTENV_DEV_NAME_##devtypeu(devtypeu, devtypel, instance, ## __VA_ARGS__)
#define BOOTENV_BOOT_TARGETS \
"boot_targets=" BOOT_TARGET_DEVICES(BOOTENV_DEV_NAME) "\0"
-#define BOOTENV_DEV(devtypeu, devtypel, instance) \
- BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance)
+#define BOOTENV_DEV(devtypeu, devtypel, instance, ...) \
+ BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance, ## __VA_ARGS__)
#define BOOTENV \
BOOTENV_SHARED_HOST \
BOOTENV_SHARED_MMC \