Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2732607pxv; Sun, 27 Jun 2021 07:10:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh1GLXadLT9+sLa03JfIhsvTUmEHQWWpaidOgvnvK9sZGTyDNXxF9I5mE+jla5nRu/3Fjr X-Received: by 2002:a05:6402:354b:: with SMTP id f11mr27288454edd.387.1624803029596; Sun, 27 Jun 2021 07:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624803029; cv=none; d=google.com; s=arc-20160816; b=l2e1MQ3UYVGlF6QMgpdNiQr14hMIe55s1q1FOaD4ejnWzbClJEON79n9QOWwxpOGP/ NwDE6nPN9+pM4qpRapHkGOnr4GH24HBWkI+F+QoASm6vxv6cIelW5qmvmNtYF3iAwxXZ y/89ZvS10GkD5fbpMLgBhO+vs1N6H+BFV4e0pRn4prsi4GnNiOR7MnbWzSm2IrdOQ8ZU WjE82+svwcdtwqJ3yiIMBuwQi5UJ5Dj13MeZlUhpU/FYmbZcS9evpDyXx4AVb1Xsmh6G hjyU2VGF8gyL/rA9y5g/uxjbXZFxO4DAs5zkDgURAQbc10J6WzLDVwF4t1kMXW6yXDbh bNRw== 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=BWGO+itUm6tMgujfJIGgElCIQmjPwoC/qMTdg68ZcXc=; b=tvG9Ee/JS936mIBUoYaRNJbFlHiuV79CpgOCJeE1WsE1hRRUX8nTNFc4/wh3TyJ4GE NFaXfeZmyi6Pwl0Mgs3d6uMLoRnNpTYY9h5cPQWJCjkOHSOAJiD+cuvNPOqpvRNYbEXr YJ3P5kTZUancXzn4iFKwtx27Qwl2t8XN2O4zmP2WkrD+65EjHBY38eNOIzbxFyhTcTxr fUfWpO98FVI7bNkk1vnCyrqu+TDGZoBIDS1t0OQT6QvV4+ITT35iegcr0OtnVeyzsvLO CJXRhNDNEipSnikkwuzRqdQayXnWPiea4NcJcFA1dJAIYT9T4ofiDXSJtNQ3OKJ5HniS x0+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jSx1jWRN; 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 by10si11252935ejc.77.2021.06.27.07.10.03; Sun, 27 Jun 2021 07:10:29 -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=jSx1jWRN; 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 S230505AbhF0Nv5 (ORCPT + 99 others); Sun, 27 Jun 2021 09:51:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229927AbhF0Nvz (ORCPT ); Sun, 27 Jun 2021 09:51:55 -0400 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04480C061574; Sun, 27 Jun 2021 06:49:30 -0700 (PDT) Received: by mail-il1-x12f.google.com with SMTP id b5so14699326ilc.12; Sun, 27 Jun 2021 06:49:30 -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=BWGO+itUm6tMgujfJIGgElCIQmjPwoC/qMTdg68ZcXc=; b=jSx1jWRNMlAT68tgB7bCsuZqgDYgfiNEwJ1mD2Za+4v4gYkEgHIsfr7NLcl/pPu17E sMc7eWOadn89rncqJblRCe2nilMIVe9+Lr0KL+CbAUtDY2ukpo7/iwZ9MCTOworuIwiH STBBr6guaR+2aQXcvf7lerOIhVDZWCDmuWp6R4Jv4BwYxFgPZTyv53kg0xQ8/VfTwaJp JHRC80ddtc2TbByE27FVpuS/MB4VoLb+XNQQ0kvnqfs1ibZToIoi5tPVhQKdn3uswlkQ SW+TyonxdygwCu6jods4Mn3ql5Ei8/OiH53q17/MtCKvNkPl+64lanBnagGZjHi4lnWg AD5g== 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=BWGO+itUm6tMgujfJIGgElCIQmjPwoC/qMTdg68ZcXc=; b=hq9056m9lXtDmEVWZZACpz9+Fd5UlTq5ZnFCiWgh962ImJtv4mrkazt5trkebXVWyz uIOqXUYMsh1JXAptviJN5wwNYONKUKbPQ9qJSE2abk/o2xogSEu0Bv0DJLGTGjdjAMOb rQPwnHnf8sTp6A7bRhnsvX3qW/Eoz9PEr8pRZD19EEt/VrljwNRKD/nA4YFM9JUpWEtN tacI0+TDp+Nn3Z2zyv10CLsHbsQk6LzooX4QWswH48I7K6Jkzcl86xZkif8QpH1Ywj/6 X58Hdhzv0so010IaN5rUuiVTWpBphfV4tA3dz0cRWNm4VIZlHXaOvrSr8k2bKIjpoB/X YTGA== X-Gm-Message-State: AOAM531lT869KKvSBSsVJ2SB54URP0OdLtnYQiQqEgEjI9Qn6KYC8Em8 iWn5l6uIn4dqNtKjgArGbU7QhWaF2mUuag7GBqQ= X-Received: by 2002:a92:d4c5:: with SMTP id o5mr8968854ilm.306.1624801770256; Sun, 27 Jun 2021 06:49:30 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Pintu Agarwal Date: Sun, 27 Jun 2021 19:19:18 +0530 Message-ID: Subject: Re: Query: UBIFS: How to detect empty volumes To: Richard Weinberger Cc: open list , linux-mtd , Richard Weinberger , linux-fsdevel , Phillip Lougher , Sean Nyekjaer , Kernelnewbies Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 27 Jun 2021 at 14:12, Richard Weinberger wrote: > > On Thu, Jun 24, 2021 at 6:09 PM Pintu Agarwal wrote: > > I have one basic query related to UBIFS volumes on a system with NAND partition. > > There is no such thing as a UBIFS volume. Do you mean UBI volumes? > Yes I mean the ubi volumes which are created using the ubinize config file. > > In short, how to detect a particular empty volume inside a system > > partition while flashing the partition image? > > What do you mean by system partition? A MTD partition? By this I mean the entire UBI partition that contains the magic header "UBI#" > > > Suppose I have one big system partition that consists of 4-5 ubi > > volumes inside it with varying sizes. > > Lets say: > > -- System Partition (ubi image) > > - rootfs volume (ro, squashfs) > > - data volume (rw, ubifs) > > - firmware volume (ro, ubifs) > > - some-other volume (ro, squashfs) > > So by system partition you mean the MTD partition that hosts UBI itself? > Yes the entire UBI partition that contains UBI volumes > > Consider that all these could be flashed together as part of > > system.ubi image in a single shot from the bootloader. > > Now, suppose, one of the volume image (say firmware) is missing or > > remains empty (as you know we can have empty volumes). > > > > So, during system image flashing, we wanted to detect if one of the > > volume (firmware) is empty. > > Since this is an important volume, so we wanted to detect if this > > volume is empty/missing we will abort flashing the system partition. > > As there is no point in booting the system without this partition. > > > > So, I am exploring options, how can this be detected ? > > Read from the volume after flashing. If you get only 0xFF bytes it is empty. > I mean, without flashing the image, is it possible to determine/guess from the image content/header that a volume in the image is empty. If it is empty then do not allow to flash the image. > > I mean is there any kind of magic number or header information which > > we can read to detect a particular empty volume ? > > Can we get any information from just "system.ubi" image to indicate > > about the volume information ? > > You'll need to perform a proper UBI scan on all blocks. > If for the sad volume no LEBs have been found it is empty. > hmm, this seems reasonable. We have something called "ubi_scan_partition" that scans for bad blocks, during "ubi_open". And we also have ubi_find_volume that checks for vtbl record in an incoming image. Let me check about the LEB option here. > > Also it could be possible that 2 or more volumes are empty, but we are > > only concerned about one particular volume (firmware), so how to > > detect particular volume ? > > I don't understand the use case. Is your image creation process so error prone > that you can't be sure whether critical parts got included or not? > Actually our UBI creation process contains multiple volumes, in which one volume contains firmware image, that comes from another subsystem. So, it requires copying that firmware image manually before building the etire yocto image. But, it might be possible that some developer may miss/skip this firmware copying part, thus the resulting image may end up is having an empty firmware volume. However, this firmware volume is an important volume, without which the modem may not boot up.