Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp446797pxv; Thu, 22 Jul 2021 04:16:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb0mFhxYPsR4J0JsVqJ80wZwKGDa3SoUTVNnM/hDcl7pnm9PcKzno0zEKxx37LrlwDTnpZ X-Received: by 2002:a17:906:24c3:: with SMTP id f3mr42591819ejb.145.1626952564405; Thu, 22 Jul 2021 04:16:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626952564; cv=none; d=google.com; s=arc-20160816; b=upY1GDruqZUB75/GxE3gScVQJ5zpfyq26ZQ3AWHu50jg5a/jQ97LhCg1IR0bjz3hS8 zaY/32cRaRR5Fu5EA4Qc6cwaSQjSCe/zeqGvGM9dNHK3TOUeRLgEyb9w1ILItbSH30mD YWIFdenvA1xFSnONTBWqF+yApeon4SBybzZnkPG3GAi+hTIZTVMOP22QJx1C4Deeq1SV Jk3j1YQsa1i9FqaqopcWxhPURvc+k9Gs4jxqWnJiFlVyarxxB9sEeSjSNZcglSQbNbMu 8FFSydVl0b8MUS/68i7dApUAYn0j3Y3TSy3Gx2ZWVGlPXCevP1WWoqVy9wr7xSczXVLR I8/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=bB4VtmJFxxMk/xBdcOQ1aAgpkQfyBX7MX2ec1/1+iic=; b=Nk12oiZIORyEqjKuaEfm1zymgEx53C2jX0HN35M8Ic85mNBR43Ge3vNhuHTYnJtPgW EBI5yHlKvamP+XzTmfzwoP3OcxHvgomLa3Rq+UX26Cg7lEatXZxCTH15UqTGNyreSp5f JY53c9PadU8jYq7mfWR7utS+MECEr1jqzhptbtcWjJzKWhNMVx+A3sVM/4k5A3R7zhLb iPFF2IH4tLv+sSh86JaJH5WP6brEVFe51TX46Fjsyik0nhcbbDtQ5KQvdN0mDAx8/BAX guiHNU4/nBiG5N/kdw/AelMFmtkcGqj5VD/O66aiueJpuU0RxsyxqXLkfC5J0GSOmlsf oZLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="kS8N55z/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si31080847ejv.442.2021.07.22.04.15.40; Thu, 22 Jul 2021 04:16:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="kS8N55z/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231579AbhGVKaF (ORCPT + 99 others); Thu, 22 Jul 2021 06:30:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231450AbhGVKaF (ORCPT ); Thu, 22 Jul 2021 06:30:05 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 396FEC061575; Thu, 22 Jul 2021 04:10:39 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id ee25so6283320edb.5; Thu, 22 Jul 2021 04:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=bB4VtmJFxxMk/xBdcOQ1aAgpkQfyBX7MX2ec1/1+iic=; b=kS8N55z/Mvvyqlvp1E5NKwCjT4j99fk1wbSreQcjnCFZZsU7Bh5VqyE1wmM9X18znC TMJnNpDiSyrcNnMiYG6Kggc97uaIFNHZlxaQIqMp2bHz4UUgGi7YGg9G18IEDxlH+ACC wMhw7fE6DLlLZob+k8ZvVGvbTCyVUv5vErhRggVkfD9adlzkHza1sZUkUOFCuD0omtlr hJT/jtngpCE+rIMfgocltP39U68xb+xt0KpHmHMbH8JLUQH/yNYRUqWStTVXeAhx/lvZ ZmYS8iGhs9Df5x4d+InHU6Hxqgmqc9WgkjnFkCNXmtpznjNP2/eYi5l0mEIm+YgSUzrt YkZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=bB4VtmJFxxMk/xBdcOQ1aAgpkQfyBX7MX2ec1/1+iic=; b=mpnV11yxLolOigXJZeYdPUd+6rgsSJ14fBGd2XtDW5kh3zX0/QWcNybvfnXMgc8a4m Kf9twkGaU+cVXf8CGrIVaKBBdfTWYoVvMVAYkaUU0TNM7Qgm85F0Vb/OtXGL5lO0dENc Hh4u3AMrMso+sQgdC9UsseEApHZsiImfcXeTVOEVh7eJvJ9ypdLZYpWPdbc/lCngYY3r qccJhNizoU5u0QnH0S6HPELViT7JoNUo4CpaY+NBo1GqjRhMVTRzRLplZphC4Xq3VIdx dRiAcIgWmY8etNOWVdNFbD4J0Vx0kONreft8AloKduyWu+4nDicYNHovKd1tvRtl6qnq NZqA== X-Gm-Message-State: AOAM530hnjhQ8cVtl8ihhzQ2GdOsBIVAsTzsmdxbvO2E7iIGytTARCBb NgZ4xV/HB70/Ln6lIGbuiD4rIOKAOMV5sAHz68k= X-Received: by 2002:a05:6402:19a:: with SMTP id r26mr52960170edv.230.1626952237710; Thu, 22 Jul 2021 04:10:37 -0700 (PDT) MIME-Version: 1.0 References: <568938486.33366.1626452816917.JavaMail.zimbra@nod.at> <1458549943.44607.1626686894648.JavaMail.zimbra@nod.at> <1556211076.48404.1626763215205.JavaMail.zimbra@nod.at> <2132615832.4458.1626900868118.JavaMail.zimbra@nod.at> In-Reply-To: <2132615832.4458.1626900868118.JavaMail.zimbra@nod.at> From: Pintu Agarwal Date: Thu, 22 Jul 2021 16:40:26 +0530 Message-ID: Subject: Re: MTD: How to get actual image size from MTD partition To: Richard Weinberger Cc: Greg KH , linux-kernel , linux-mtd , linux-fsdevel , Phillip Lougher , Sean Nyekjaer , Kernelnewbies Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 22 Jul 2021 at 02:24, Richard Weinberger wrote: > > ----- Urspr=C3=BCngliche Mail ----- > >> But let me advertise ubiblock a second time. > > Sorry, I could not understand about the ubiblock request. Is it > > possible to elaborate little more ? > > We are already using squashfs on top of our UBI volumes (including > > rootfs mounting). > > This is the kernel command line we pass: > > rootfstype=3Dsquashfs root=3D/dev/mtdblock44 ubi.mtd=3D40,0,30 > > And CONFIG_MTD_UBI_BLOCK=3Dy is already enabled in our kernel. > > Do we need to do something different for ubiblock ? > > From that command line I understand that you are *not* using squashfs on = top of UBI. > You use mtdblock. ubiblock is a mechanism to turn an UBI volume into a re= ad-only > block device. > See: http://www.linux-mtd.infradead.org/doc/ubi.html#L_ubiblock > Okay, you mean to say, we should use this ? ubi.mtd=3D5 ubi.block=3D0,0 root=3D/dev/ubiblock0_0 Instead of this: root=3D/dev/mtdblock44 ubi.mtd=3D40,0,30 Okay I will discuss this internally and check.. > >> If you place your squashfs on a UBI static volume, UBI knows the exact= length > >> and you can checksum it > >> more easily. > > Yes, we use squashfs on UBI volumes, but our volume type is still dynam= ic. > > Also, you said, UBI knows the exact length, you mean the whole image le= ngth ? > > How can we get this length at runtime ? > > You need a static volume for that. If you update a static volume the leng= th is > known by UBI. > Thank you so much for your reply! Sorry, I could not get this part. How static volume can give image len ? You mean there is some interface available in kernel to get actual image le= n ? > > Also, how can we get the checksum of the entire UBI volume content > > (ignoring the erased/empty/bad block content) ? > > Just read from the volume. /dev/ubiX_Y. > I think this also will give the entire volume size, but we still don't know= how many pages have real data ? For example: Suppose, my raw partition/volume is of size 10MB But my actual data inside it is of size ~3MB (may be split across?) Then, how can we get the actual size of the data content ? You mean to say: /dev/ubiX_Y should contain only data blocks ? > > Or, you mean to say, the whole checksum logic is in-built inside the > > UBI layer and users don't need to worry about the integrity at all ? >