Deploy squashfs on ubiblock partitions

Hi every one,

We want to use mender for our OTA service. I gone through the references, yocto mender layer and build-root but none of them are close to my requirement

my requirement is similar to discussion in the link

I made modifications in flash layout to fit the mender dual rootfs + kernel on raw ubi volume.
kernel arguments are modified to mount the squashfs( rootfs) stored in /dev/ubiblock0_3, the setup works fine mender recognize the active/inactive partition then one and tries to flash the the mender artifact,it come out with open permission failure message.further in our linux 4.4 kernel driver ‘driver/mnt/ubi/block.c’ driver only read-only support.investigating further on internet I found there are patches available for older version but I did’t see and thing equivalent for newer kernel.

Kindly guide on how I can solve this.

Hi @Ratheendran,

Welcome to Mender Hub and glad that you are are choosing Mender for your OTA needs.

Could you please share the content of /proc/cmdline? It could be that your MTD parts are marked as RO which could such an error that you have.

Also please share any log/output in clear text instead of pictures. Much easier to view/search

Appreciate your prompt response.

cat /proc/cmdline
ubi.mtd=UBI,2048 ubi.block=0,ROOTFS1 root=/dev/ubiblock0_3 ro rootfstype=squashfs init=/linuxrc rootwait=10 $(mtdparts)

cat /proc/mtd( here kernel and rootfs are ubi volume)
ev: size erasesize name
mtd4: 00080000 00020000 “UBOOT0”
mtd5: 00080000 00020000 “UBOOT1”
mtd6: 00040000 00020000 “ENV”
mtd7: 07c00000 00020000 “UBI”
mtd8: 00516000 0001f000 “KERNEL0”
mtd9: 00516000 0001f000 “KERNEL1”
mtd10: 0101b000 0001f000 “ROOTFS0”
mtd11: 0101b000 0001f000 “ROOTFS1”

What is the content of this?

Thanks
mtdparts=nand0:768k@1280k(IPL0),384k(IPL_CUST0),384k(IPL_CUST1),512k(UBOOT0),512k(UBOOT1),256k(ENV0),124m(UBI)

mtdparts=nand0:768k@1280k(IPL0),384k(IPL_CUST0),384k(IPL_CUST1),512k(UBOOT0),512k(UBOOT1),256k(ENV0),124m(UBI)

But this does not match the content of /proc/mtd? Do you have multiple NAND devices?

this is one flash, Partition info is correct, I am access env partition /dev/mtd6 from user space.
dev: size erasesize name
mtd0: 00140000 00020000 “UNKNOWN”
mtd1: 000c0000 00020000 “IPL0”
mtd2: 00060000 00020000 “IPL_CUST0”
mtd3: 00060000 00020000 “IPL_CUST1”
mtd4: 00080000 00020000 “UBOOT0”
mtd5: 00080000 00020000 “UBOOT1”
mtd6: 00040000 00020000 “ENV”
mtd7: 07c00000 00020000 “UBI”
mtd8: 00516000 0001f000 “KERNEL0”
mtd9: 00516000 0001f000 “KERNEL1”
mtd10: 0101b000 0001f000 “ROOTFS0”
mtd11: 0101b000 0001f000 “ROOTFS1”

Thanks @mirzak for the support, any idea on what’s going wrong with my mender integration ,also I need clarity on how mender is going to write to /dev/ubiblock0_2 , the lowlevel driver(/driver/mnt/ubi/block.c) support allows only read operation. please correct me if there is any misunderstanding.

The Mender client will do the equivalent to what ubiupdatevol does, you could try with this tool first.

If ubiupdatevol does not work then you might have some non-standard modifications in you Linux kernel that disallows this and in which case I do not know if I can provide any additional guidance.

Thanks @mirzak for you time, really appreciate this.

I think mender integration on my board still have gaps.

My observations

This works on my board,
ubiupdatevol /dev/ubi0_2

Then I created a block device
ubiblock -c /dev/ubi0_2
block ubiblock0_2: created from ubi0:2(ROOTFS0)

This is not working on my board.
ubiupdatevol /dev/ubiblock0_2
libubi: error!: “/dev/ubiblock0_2” is not a character device
ubiupdatevol: error!: error while probing “/dev/ubiblock0_2”
error 22 (Invalid argument)

I have yocto mender build for nor-vexpress-qemu for reference, mender works fine on this syste.

further I created test programme which is equivalent to ‘ubiupdatevol’.
this neither works on my board nor on vexpress-qemu

int main()
{
char buf[] = “0123456789012345678901234567890123456789012345678901234567890123456789”;
int fd = open("/dev/ubi0_2",O_RDWR);
int image_size=sizeof(buf);
ioctl(fd, UBI_IOCVOLUP, &image_size);
if(write(fd, buf, image_size)<0)
perror("");
close(fd);
}

ubiupdatevol /dev/ubiblock0_2
libubi: error!: “/dev/ubiblock0_2” is not a character device
ubiupdatevol: error!: error while probing “/dev/ubiblock0_2”
error 22 (Invalid argument)

I apologize I missed/skipped some information you posted earlier, but UBI blocks are as you pointed out RO so you can not point the Mender client to /dev/ubiblock0_2 devices, it has to be e.g /dev/ubi0_2. /dev/ubi0_2 represents an UBI volume while /dev/ubiblock0_2 is a raw visual representation of the NAND area.

I pointed this out in the other thread,

For this reason I would suggest for you to use UBI volumes in “raw mode” where you store your squashfs images. This will work out of the box pretty much.

Also from the other thread,

Apologies, I mixed up the terminology. What I am referring to is static UBI volumes, from the UBI docs,

Making the same mistake again.

Thanks for support, this channel is helping my mender integration effort.

The discussion on fit image in other threads caught my interest, I created a setup on which uboot loads the kernel and squashfs rootfs using FIT image.I believe, this case kernel will mount the rootfs as ramdisk.This approach requires ram space equivalent to rootfs size blocked,which other wise would have been available for application.

Can you please comment on a better way of using the fit images or different approach.

@mirzak
I tried mender on uboot fit images and ramdisk, o/p on console is as below, how to get the right partition ?.

Mender running on partition: /dev/root module=main

etc/mender # mender -debug -install /tmp/release-1.mender
WARN[0000] Could not connect to syslog daemon: Unix syslog delivery error. (use -no-syslog to disable completely) module=main
DEBU[0000] Reading Mender configuration from file /var/lib/mender/mender.conf module=config
INFO[0000] Loaded configuration file: /var/lib/mender/mender.conf module=config
DEBU[0000] Reading Mender configuration from file /etc/mender/mender.conf module=config
INFO[0000] Loaded configuration file: /etc/mender/mender.conf module=config
WARN[0000] No server URL(s) specified in mender configuration. module=config
WARN[0000] Server entry 1 has no associated server URL. module=config
DEBU[0000] Merged configuration = &main.menderConfig{menderConfigFromFile:main.menderConfigFromFile{ClientProtocol:“”, ArtifactVerifyKey:“”, HttpsClient:struct { Certificate string; Key string; SkipVerify bool }{Certificate:“”, Key:“”, SkipVerify:false}, RootfsPartA:“ubi0_2”, RootfsPartB:“ubi0_3”, DeviceTypeFile:“/var/lib/mender/device_type”, UpdatePollIntervalSeconds:0, InventoryPollIntervalSeconds:0, RetryPollIntervalSeconds:0, StateScriptTimeoutSeconds:0, StateScriptRetryTimeoutSeconds:0, StateScriptRetryIntervalSeconds:0, ModuleTimeoutSeconds:0, ServerCertificate:“”, ServerURL:“”, UpdateLogPath:“”, TenantToken:“”, Servers:client.MenderServer{client.MenderServer{ServerURL:“”}}}, ModulesPath:“/usr/share/mender/modules/v3”, ModulesWorkPath:“/var/lib/mender/modules/v3”, ArtifactInfoFile:“/etc/mender/artifact_info”, ArtifactScriptsPath:“/var/lib/mender/scripts”, RootfsScriptsPath:“/etc/mender/scripts”} module=config
WARN[0000] Could not resolve path link: ubi0_2 Attempting to continue module=partitions
WARN[0000] Could not resolve path link: ubi0_3 Attempting to continue module=partitions
DEBU[0000] Have U-Boot variable: mender_check_saveenv_canary=0 module=bootenv
DEBU[0000] List of U-Boot variables:map[mender_check_saveenv_canary:0] module=bootenv
DEBU[0000] Have U-Boot variable: mender_boot_part=3 module=bootenv
DEBU[0000] List of U-Boot variables:map[mender_boot_part:3] module=bootenv
DEBU[0000] Setting active partition from mount candidate: /dev/root module=partitions
INFO[0000] Mender running on partition: /dev/root module=main
DEBU[0000] I/O read error for entry mender-agent.pem: open /var/lib/mender/mender-agent.pem: no such file or directory module=dirstore
DEBU[0000] private key does not exist module=keystore
DEBU[0000] ModuleTimeoutSeconds not set. Defaulting to 14400 seconds module=modules
DEBU[0000] Starting device update. module=standalone
INFO[0000] Start updating from local image file: [/tmp/release-1.mender] module=standalone
DEBU[0000] Fetching update from file results: [&{0x85ef00}], 14299136, module=standalone
Installing Artifact of size 14299136…
DEBU[0000] Read data from device manifest file: device_type=emdev module=device
DEBU[0000] Current manifest data: emdev module=device
DEBU[0000] statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds module=executor
INFO[0000] no public key was provided for authenticating the artifact module=installer
INFO[0000] Update Module path “/usr/share/mender/modules/v3” could not be opened (open /usr/share/mender/modules/v3: no such file or directory). Update modules will not be available module=modules
DEBU[0000] checking if device [emdev] is on compatible device list: [emdev]
module=installer
DEBU[0000] installer: successfully read artifact [name: release-1; version: 3; compatible devices: [emdev]] module=installer
.DEBU[0000] Trying to install update of size: 14290944 module=dual_rootfs_device
DEBU[0000] Active partition: /dev/root module=partitions
ERRO[0000] Download failed: Payload: can not install Payload: rootfs.squashfs: Active root partition matches neither RootfsPartA nor RootfsPartB. module=standalone
DEBU[0000] statescript: timeout for executing scripts is not defined; using default of 1h0m0s seconds module=executor
ERRO[0000] Payload: can not install Payload: rootfs.squashfs: Active root partition matches neither RootfsPartA nor RootfsPartB. module=main