From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 63039C433FE for ; Fri, 14 Oct 2022 07:10:29 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2FB5484EA8; Fri, 14 Oct 2022 09:10:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="luX7GF2E"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 363AF84EA8; Fri, 14 Oct 2022 09:10:25 +0200 (CEST) Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 94BDB81F4E for ; Fri, 14 Oct 2022 09:10:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ej1-x631.google.com with SMTP id ot12so8609048ejb.1 for ; Fri, 14 Oct 2022 00:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=f4SLJNJYkeSVqyXlJaUKsO1rXQ/gGJc7iqz+GKHpl9Q=; b=luX7GF2EJSo3xgCIs6u4VFV/68OZsL1sw7izj9l/4iJ1+dc5ZL4Y8BH0ah50qoJFN+ jTNJLjsGxNkzKuzaerc0UDqXrozAf7AiRRLT9lLmBepnSH2zcEkLDi7h1GYcumFuEaIK a6/5sJK5ILvBiTaPD1ibK3D86ITM6DVzu+5qh4ZOplYYsMMntKyzQ9ajgEMf32TIzKnK ZkJh71053Sftm29NZQWnufTPxYiKY98w3PpcyFZgi6po07HtsSZkddNKlu5Dl7RFnvIW GFWOIx9faaMVYHHVCgbcul7w5uINhtfhOPRQKZkCHR3mbTkI/nfKjjsLss2OImz65Ddn R0OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=f4SLJNJYkeSVqyXlJaUKsO1rXQ/gGJc7iqz+GKHpl9Q=; b=VubOHrVxoylFw14YWKuio3bHDB00tt1TR5Cqg22CTfW/8/ACT6nK9PZXXAY88WtLh5 YpT1IZTFYP+Tqh+Cwi7xmfToJHqCYXBfGShnQaCf76Pv8UwWu8lscGErOEXF0NzykGB+ gEwWgD1epB2CXYpWbl20Jl4l39TsX6KnaCO9ndIBZaLHHOXZ9Y2fZrIZ5cOPy8EZScT+ vM1i7lHnXmPdFTFnri7GMFyGdqb89Y75vWASAXlqTdBuzZULf+xw2oEfoON9TnOtNxx2 VEN4bPx+Ti9Xm2AMGMS2Ntpc1jz325MR3Tgou0IyOMxcquhTd+TT3rOyib4zEdHIT8Fx uc8Q== X-Gm-Message-State: ACrzQf1z6VrzKjrH1cxCmLpP7rpne7LBPvLwKQFptYUgeGK6YdEhqBEj 8UEHBvbAHOppcujqNLx91wcozA== X-Google-Smtp-Source: AMsMyM55zFkBCOCnsCqISAGnA4qHD3X1e23xN2CMKHuvucfQpwrbhFoANzrjjQZfnrHQxHHslhhVjw== X-Received: by 2002:a17:906:b08d:b0:782:d526:3e36 with SMTP id x13-20020a170906b08d00b00782d5263e36mr2550706ejy.358.1665731422239; Fri, 14 Oct 2022 00:10:22 -0700 (PDT) Received: from hera (ppp046103015185.access.hol.gr. [46.103.15.185]) by smtp.gmail.com with ESMTPSA id s11-20020a50d48b000000b00458947539desm1251654edi.78.2022.10.14.00.10.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 00:10:21 -0700 (PDT) Date: Fri, 14 Oct 2022 10:10:19 +0300 From: Ilias Apalodimas To: jassisinghbrar@gmail.com Cc: u-boot@lists.denx.de, xypron.glpk@gmx.de, takahiro.akashi@linaro.org, sjg@chromium.org, trini@konsulko.com, etienne.carriere@linaro.org, monstr@monstr.eu, Sughosh Ganu , Jassi Brar Subject: Re: [PATCHv2 2/5] FWU: mtd: Add helper functions for accessing FWU metadata Message-ID: References: <20221002235046.344149-1-jassisinghbrar@gmail.com> <20221002235145.344304-1-jassisinghbrar@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221002235145.344304-1-jassisinghbrar@gmail.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Hi Sughosh, Jassi On Sun, Oct 02, 2022 at 06:51:45PM -0500, jassisinghbrar@gmail.com wrote: > From: Sughosh Ganu > > Add helper functions needed for accessing the FWU metadata which > contains information on the updatable images. > > Signed-off-by: Sughosh Ganu > Signed-off-by: Jassi Brar > --- > include/fwu.h | 27 ++++++ > lib/fwu_updates/Makefile | 1 + > lib/fwu_updates/fwu_mtd.c | 178 ++++++++++++++++++++++++++++++++++++++ > 3 files changed, 206 insertions(+) > create mode 100644 lib/fwu_updates/fwu_mtd.c > > diff --git a/include/fwu.h b/include/fwu.h > index b5c59dc161..48c83f7618 100644 > --- a/include/fwu.h > +++ b/include/fwu.h > @@ -8,6 +8,7 @@ > > #include > #include > +#include > > #include > > @@ -296,4 +297,30 @@ u8 fwu_update_checks_pass(void); > */ > int fwu_trial_state_ctr_start(void); > > +/** [..] > +#include > + > +int fwu_mtd_get_alt_num(efi_guid_t *image_id, u8 *alt_num, > + const char *mtd_dev) > +{ > + int i, nalt; > + int ret = -1; > + struct mtd_info *mtd; > + struct dfu_entity *dfu; > + ofnode node, parts_node; > + fdt_addr_t offset, size; > + char uuidbuf[UUID_STR_LEN + 1]; > + > + mtd_probe_devices(); > + mtd = get_mtd_device_nm(mtd_dev); > + > + /* Find partition node under given MTD device. */ > + parts_node = ofnode_by_compatible(mtd_get_ofnode(mtd), > + "fixed-partitions"); > + > + uuid_bin_to_str(image_id->b, uuidbuf, UUID_STR_FORMAT_STD); > + node = ofnode_by_prop_value(parts_node, "uuid", uuidbuf, > + sizeof(uuidbuf)); > + if (!ofnode_valid(node)) { > + log_warning("Warning: Failed to find partition by image UUID\n"); > + return -ENOENT; > + } > + > + offset = ofnode_get_addr_size_index_notrans(node, 0, &size); > + if (offset == FDT_ADDR_T_NONE || !size) > + return -ENOENT; > + > + dfu_init_env_entities(NULL, NULL); > + > + nalt = 0; > + list_for_each_entry(dfu, &dfu_list, list) > + nalt++; Sughosh we need to update this and follow similar logic to the GPT patches, where nalt goes away and this is converted to a while (true) loop > + > + if (!nalt) { > + log_warning("No entities in dfu_alt_info\n"); > + dfu_free_entities(); > + return -ENOENT; > + } > + > + for (i = 0; i < nalt; i++) { > + dfu = dfu_get_entity(i); > + > + /* Only MTD RAW access */ > + if (!dfu || dfu->dev_type != DFU_DEV_MTD || > + dfu->layout != DFU_RAW_ADDR || > + dfu->data.mtd.start != offset || > + dfu->data.mtd.size != size) > + continue; This needs to be rebased as well and that code needs to be added in that new function you created > + > + *alt_num = dfu->alt; > + ret = 0; > + break; > + } > + > + dfu_free_entities(); > + > + return ret; > +} > + > +static int gen_image_alt_info(char *buf, size_t len, int sidx, > + struct fwu_image_entry *img, struct mtd_info *mtd) > +{ > + int i; > + const char *suuid; [...] Thanks /Ilias