Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1152659pxb; Sun, 22 Aug 2021 07:30:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYo6LW/MNmK98LsuRoNk7MULPLS1JCCbo/JdJJ1b6FJxHb4GtzpJyGtYwxD7QpxdSzEPfs X-Received: by 2002:aa7:ccda:: with SMTP id y26mr2262473edt.245.1629642657110; Sun, 22 Aug 2021 07:30:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629642657; cv=none; d=google.com; s=arc-20160816; b=pk4tD4UGYpNpj07hPry587L2mxILho1BwW+jC3t1r6mfNB/U/pUXAvUo+o/8FhU8cj 9vEfCxyaoRY2Fjv2g97lSz1Rrya0LJ5uIHb7rmz6l3psAxtWTIieUT6Pn7GOXhy1IyzQ PnHPaDCtOpK4BoE0Y7syQgSm01k4bc9wfP/+84kwL3BaNSnHOY9vzc27I1cvOGG/kdjx whaJz1Q957aA7BCHGUC60q/tQMasyW5+aGlXeARflew1XA3dbX9QiTxX+DAj3v9luFW1 cBXyEK4A8+qmncFr8TwjlpcHdja8KeRJTpoGXVSnds1dbIHvJMWAXsGdnOZ/pp0ODsHq O15Q== 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=J4ZN/SXLkaHtgaR5XMNgO5PtUr/lZWOqM0+2vN5G3FE=; b=b8UPD6ZAuLJj7E3jqFyIfQSq2/bCCdxYytYbHceSO3MY6gCj9g9xOABn2WmGWGdMdK gYSWgbT0a45x8RNaGksiP6o1IF4Ns9JuNyKuDYkjQ+SFA3HWwfYYEP37UERCxzTLnxA6 cCjTF1G5C+jNohdZa4xOBwrNQPgn/MWAgixjiZOonCYCDjFWhOx/XUSbJne7JAkiwjGT 8ILswQT5yWpWRSX1DK2nTERoldauRmjfbZBazaOxaTAgplQQsO/ly6/X9Mqa4KCOyDWj M4mT81cuhvK78NjSn/2cNe+5uITGIk9AkqP4htALh8SC57E1jVHgQ9+l5jqX8pNpMb77 kKQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vanguardiasur-com-ar.20150623.gappssmtp.com header.s=20150623 header.b=DKAzZ8Q4; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bf22si11818029edb.311.2021.08.22.07.30.21; Sun, 22 Aug 2021 07:30:57 -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=@vanguardiasur-com-ar.20150623.gappssmtp.com header.s=20150623 header.b=DKAzZ8Q4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232920AbhHVOWH (ORCPT + 99 others); Sun, 22 Aug 2021 10:22:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232471AbhHVOWG (ORCPT ); Sun, 22 Aug 2021 10:22:06 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6580EC061756 for ; Sun, 22 Aug 2021 07:21:25 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id v2so21886065edq.10 for ; Sun, 22 Aug 2021 07:21:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=J4ZN/SXLkaHtgaR5XMNgO5PtUr/lZWOqM0+2vN5G3FE=; b=DKAzZ8Q4mXjXOBqaMdNNISaFGKc9lQXjGeecFK1OFEAGNv2u4kbda/p/vKDS42UX6h KCXnwavPMs6+8oSSt9oJoXkxaP9Q5UkTSr7FiLunnGQmvE+ZnSd68uG/V5VaRYLxKilv sgqkfYGdvvmKvjugUd17wtvv/GWx3EW+MjQU7pkg9mto22HFkW814EuquaKH3vCu+wZO s0wasYNMAQAX6EvNlLuWjb7KZQ2WpdC1Pz0wN8qQ+3SGgtMlZRJSTD9So4RWGK/AIZ+v 7xm5ED3BN1nuzyFckLpNfhulcdYXepu3YnnuqDVFjagvD+9mH0T6TEdLq/6Cd8op2Ng7 +qmg== 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=J4ZN/SXLkaHtgaR5XMNgO5PtUr/lZWOqM0+2vN5G3FE=; b=eDUCk/jSagwhVEx8RxncNILfRxSOWOjStBoj4z+MazLGru/Q5aojbh1Fo4RoRdjDpd FL7eRA4h2MS4HooTt/p2RYpWa/4E0AQsDr/sEXiHaPsargjeBoxfUe32f7IDvJ7wQUsl 4yVSi7Up/zQYgm4+lKczzNdyo5dA6HI11u+ITYPebFiT2AimilGbRWAoPg/SROLrg0Vp 3U7LP9pVJmOGV74dLWLgxFQ3FC3tendL9tS3J48rRIlCJKE+ajYOT0FSEPGomdwLsCM+ aLm8ngWJt03F2dr+aulnhQTyTmTeZqUz44wpenzg8PfE7e/8auo74QM7RprrYnhyQf0Q pj6w== X-Gm-Message-State: AOAM533PlHcGGUmmhRFJ/8sRt6uX+LKn3bDPT/awPV1B9LeptwEJijZl d1MTB2iuxRFJrtoB4NVFIIcrFyLqz/888Soe6Rt3Eg== X-Received: by 2002:aa7:dcd1:: with SMTP id w17mr31920855edu.322.1629642083843; Sun, 22 Aug 2021 07:21:23 -0700 (PDT) MIME-Version: 1.0 References: <1556211076.48404.1626763215205.JavaMail.zimbra@nod.at> <2132615832.4458.1626900868118.JavaMail.zimbra@nod.at> <1668790824.35266.1627559144878.JavaMail.zimbra@nod.at> In-Reply-To: From: Ezequiel Garcia Date: Sun, 22 Aug 2021 11:21:12 -0300 Message-ID: Subject: Re: MTD: How to get actual image size from MTD partition To: Pintu Agarwal Cc: Richard Weinberger , Kernelnewbies , Greg KH , linux-kernel , linux-mtd , Sean Nyekjaer , linux-fsdevel , Phillip Lougher Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pintu, On Fri, 20 Aug 2021 at 15:25, Pintu Agarwal wrote: > > On Thu, 29 Jul 2021 at 22:41, Pintu Agarwal wrote: > > > > On Thu, 29 Jul 2021 at 17:33, Ezequiel Garcia > > wrote: > > > > > > On Thu, 29 Jul 2021 at 08:45, Richard Weinberger wro= te: > > > > > > > > Ezequiel, > > > > > > > > ----- Urspr=C3=BCngliche Mail ----- > > > > > [snip] > > > > > > > > > > Ouch, so surprised that after all these years someone is doing sq= uashfs/mtdblock > > > > > instead of using ubiblock :-) > > > > > > > > > > Can we patch either Kconfig or add some warn_once on mtdblock > > > > > usage, suggesting to use ubiblock instead? > > > > > > > > a hint in Kconfig makes IMHO sense. Do you want to send a patch? > > > > A warning is too much since on some tiny embedded system with NOR f= lash mtdblock is still > > > > a good choice. > > > > ubiblock is mostly useful for NAND flash. > > > > > > > > > I remember there was still some use case(s) for mtdblock but I ca= n't remember > > > > > now what was it, perhaps we should document the expectations? > > > > > (Is that for JFFS2 to mount?) > > > > > > > > a long time ago mount didn't accept character devices, so you had t= o pass mtdblockX to mount > > > > JFFS2. > > > > This limitation is gone. > > > > > > Hi, > > Just a further follow-up on this discussion. > Whether to use /dev/mtdblock or /dev/ubiblock for rootfs (squashfs) > mounting during boot. > > As suggested here: > Instead of using this in kernel command line: > [ 0.000000] Kernel command line: ... rootfstype=3Dsquashfs > root=3D/dev/mtdblock44 ubi.mtd=3D40,0,30 ... > > I used this: > [ 0.000000] Kernel command line: ... rootfstype=3Dsquashfs > ubi.mtd=3D40,0,30 ubi.block=3D0,0 root=3D/dev/ubiblock0_0 ... > > The device is booting fine with ubiblock as well. > But, per say, I could not find any visible difference. > I just observed a slight improvement in boot time, but I need to > double-check on this, with few more reboot cycles. > That's a very good thing, it means we offered you a smooth transition :-) > Apart from this what are the other visible benefits of using ubiblock > which can be explained to be management or internal team ? > I could not find any documentation explaining the difference, except this= one: > http://www.linux-mtd.infradead.org/doc/ubi.html#L_ubiblock > I'm not a flash expert here. In any case, you are expected to do your own research (just like we all did), design your own setup matching your use-case, design tests based on your workload and access patterns, etc= . There are presentations on YouTube which discuss UBI, UBIFS and NAND-based designs on Linux, as well as white papers discussing NAND flashes challenges. Having said that... When you use UBI block, you are accessing the flash via the UBI layer. This is IMO the best way to design your system, since UBI addresses wear leveling and bad blocks, and offers atomic updates. In other words, IMO it's best to expose the NAND through UBI for both read-only and read-write access, using a single UBI device, and then creating UBI volumes as needed. This will allow UBI to spread wear leveling across the whole device, which is expected to increase the flash lifetime. For instance, just as some silly example, you could have something like thi= s: | RootFS SquashFS | | UBI block | UBIFS User R-W area ------------------------------------------------------------------------ Kernel A | Kernel B | RootFS A | RootFS B | User ------------------------------------------------------------------------ UBIX ------------------------------------------------------------------------ /dev/mtdX This setup allows safe kernel and rootfs upgrading. The RootFS is read-only via SquashFS and there's a read-write user area. UBI is supporting all the volumes, handling bad blocks and wear leveling. > Can someone also point me to the respective driver code in case of > using /dev/mtdblock and /dev/ubiblock ? > Apart from theory I also want to check the impact at the code level.. > You can find all the UBI code in drivers/mtd/ubi of course. The differences between mtdblock and ubiblock are huge: one goes directly to the flash, and the other uses UBI. Good luck! Ezequiel