Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3718221pxb; Mon, 30 Aug 2021 09:03:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqvGUid2+P+IqKacFf+HR/VL9yBxpYoVycGsZL0paSb8W5GSJ7ZhBVese5tFXwlRotP9Gb X-Received: by 2002:a05:6402:27c6:: with SMTP id c6mr24971149ede.111.1630339389054; Mon, 30 Aug 2021 09:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630339389; cv=none; d=google.com; s=arc-20160816; b=VtxuHQPytLT9zQgJAHRboN8AlH4ugCw3VI5dyO/Gc2FRdqb6DCoK7oe6MGnYiuGzb2 9BddqpgZ4wBPNcY3zdHwfTDxCp8rejri+vDTQA1MG6C6xrwj1rNi/U1tUplPo5AzC4/+ PHZUxztzR68uLvJ7yigLG7/U4umnIPf9x7YeBV/sxayWaPgP+TTpLUAE9QvgD34rGPWQ b4DvGmu6Kx448xCT029y6pEKK7S9pcU+kmLrbk44sS5AvBorvb/Ntdc3qaAnJLXFoM9C +w3vHn80fSlVx9nSIP4Ond2/OrHRy1IstA61ux+5EPcOOXGNgSpxTR/9DqCM32FuxNQC 2HTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=EzLND7Bopp3YFFk8qiP7F6kcwfQFWTuokrIXZ++/vhE=; b=sGuGa1rct2tRNsXgwHyeOVxPF8ACEsqIavtP7Idre49Vbsf8M8YK1VRRnCLqclUIAj V94JFqE1Lf2aZo1j1kt2MLpc627D+fMFkF5PzatVdX+aNmIRAucY8rGMAsloQenqcqnz uB9RTVFcwqikZDwGPc+8eMZLqPwodDnnmDAxjsXuz0Dte2uclVlQVu3hyd/WgwSeTNd8 rGAeFQ5b6s/NaIgrZaz5SOufBqbrmU+WLAc/D9eBqavzfT6+Et1Sl/4cCMMbo9hxyLWH rWs8ZEYdviPwDScsgAZXDppKegWKtzMqS3Xe3hiAV4F9aFiAR0V2T6qpM/X+kLY4EAla BraQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="fWObb/2d"; 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 z1si6139364edl.531.2021.08.30.09.02.29; Mon, 30 Aug 2021 09:03:09 -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="fWObb/2d"; 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 S237809AbhH3P7g (ORCPT + 99 others); Mon, 30 Aug 2021 11:59:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237636AbhH3P7f (ORCPT ); Mon, 30 Aug 2021 11:59:35 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE072C061575; Mon, 30 Aug 2021 08:58:41 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id bt14so32227877ejb.3; Mon, 30 Aug 2021 08:58:41 -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; bh=EzLND7Bopp3YFFk8qiP7F6kcwfQFWTuokrIXZ++/vhE=; b=fWObb/2djR3cm5fTeSb9+LO040MhFz5L6dYeZV2JHwopgB9+uTVKX06+arqZaC/X/A CieSqOlJb1rXXSJrzxaNkQgh8u3zzv/A4aEBrh2o1JhmOaeb6vwugLWOQlJsYiJIw8qS tvHq6oG1/2ZJ274+HV+NShdq6LN2DQLgmxfNjjMaMFcYx//2fA862tSOQj5f/eZQ9DfX b1gkzvAZtFQ9xT5v8M/Au7rrlv1090n1d+lzlw4QyHtMacgZE0HLJkoZFCQ3WBimy/7R zt5JCF0eDOzbL0fjAB/CVVnoMQbx01IaCxBvsW0dA0TSgbbANhLMeSAQie1MFUoCqDbJ DMFg== 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; bh=EzLND7Bopp3YFFk8qiP7F6kcwfQFWTuokrIXZ++/vhE=; b=TbVCBOCpgBDWFh0mU8UsPtSHGWUaVqj44NxJVX2qls4gZbqXDFVTOZCTKqU19rEvL3 20nT3/QuDUsQdvcpNkZftjdLA/2UnDuYjOW2+mNyX057g6CRRWQhHrf/D3imDm+hiYfo dOBV7RZs13a4NrDFa504UvlnOvABKE5pTdhy8GHcfMjX5BvPtXzYqdXnQREPrkCma3pO ROprc/TUqKPO/Dtl3i0nNFgniLwKuAKQdooVvVd/Q75LeXVJJsOk2X1yP7LqNcTWml+b Uo32MCGrw8Rni0l8huK5hrpiIjeBxRtZYaIr98uo/873KvP/goUgr2ekcZpTtsYGrKtB nFog== X-Gm-Message-State: AOAM533SOJ+dgtfRZR+EXztBA7/yfQLaWu5VjaG5dAv7cL0LAGfbzi7a yk40jA9l6D6DjBbHR4WUZoei9VNQFDEKHPUepNs= X-Received: by 2002:a17:906:3e10:: with SMTP id k16mr26711718eji.116.1630339120139; Mon, 30 Aug 2021 08:58:40 -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: Pintu Agarwal Date: Mon, 30 Aug 2021 21:28:28 +0530 Message-ID: Subject: Re: MTD: How to get actual image size from MTD partition To: Ezequiel Garcia Cc: Richard Weinberger , Kernelnewbies , Greg KH , linux-kernel , linux-mtd , Sean Nyekjaer , linux-fsdevel , Phillip Lougher Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 22 Aug 2021 at 19:51, Ezequiel Garcia wrote: > 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 this: > > | 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. > Dear Ezequiel, Thank you so much for your reply. This is exactly what we are also doing :) In our system we have a mix of raw and ubi partitions. The ubi partitioning is done almost exactly the same way. Only for the rootfs (squashfs) I see we were using /mtd/block to mount the rootfs. Now, I understood we should change it to use /dev/ubiblock This might have several benefits, but one most important could be, using ubiblock can handle bad-blocks/wear-leveling automatically, whereas mtdblocks access the flash directly ? I found some references for these.. So, this seems good for my proposal. Another thing that is still open for us is: How do we calculate the exact image size from a raw mtd partition ? For example, support for one of the raw nand partitions, the size is defined as 15MB but we flash the actual image of size only 2.5MB. So, in the runtime how to determine the image size as ~2.5MB (at least roughly) ? Is it still possible ? Thanks, Pintu