From patchwork Fri Nov 13 17:17:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 4872 Delivered-To: michael@amarulasolutions.com Received: by 2002:a05:7301:4187:b0:36a:3487:1c26 with SMTP id ph7csp545346dyb; Fri, 13 Nov 2026 09:17:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErGCj3GDOa3Jbs/Pysh9T8yTxmKUgD+OOQbWhpXhs+g6hzqUqGZa3ZP7GM7FDGYcrJZ0exENLGEE@amarulasolutions.com X-Received: by 2002:a05:600c:8b11:b0:4a3:59c9:a756 with SMTP id 5b1f17b1804b1-4bb55a6a53emr70502765e9.6.1794590266314; Fri, 13 Nov 2026 09:17:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794590266; cv=none; d=google.com; s=arc-20260327; b=e8UzN9Iv8ASKKNQVS4RcizNWlQDwgkyVQMlSvw66VJnLvp1axeb2JeP6Vw+twmQHYA go602NuPqTc2DzgJ/X/FWVxgirJE3mpM5flKw686c1C7eRG5R6zPQx78azk+DZ9PTuZA G2VkoiNn/isIoP7jI72V3FpmboFrwMCAINxfK5oJJ/W/GvJ6pFtfNzrC/spiI1lpt9+L DG7VohLUTWVZSSrNGJKw+AwCk5Pxbv4TVAoxlFsWRIT55xs5w3VlIy+VivhbL1hhRM6C De7rndtQ9U6QfgtQqoP056giaVzgMc53trnrm31+LQm2K/MKOXaRNIvTaygQ7EX7looS NYXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=R5dYLuG+ASH3CiDAET/FUHUUAv0oF9dg3VK0aCh9XE4=; fh=9FWlbaCr0bn/VRuogu17VdrGZzLBZ9vKIeRWck3YYxA=; b=ik8dvZaeHyPLQ8f15EAADSdUum47G484HI9Ua4XelqAPnEoJvpaaOwQ4e5NoH5OKAS bwSrs4RYO/IcuBOr+29Gfc6vPQ80MwiMH1piVmHaqZg4t5KXDaYs1PGHW5bmIsA31k6S Y/CCjS/kMKpPrlilw/3u75jnQ6E3I5UF5O5vpuKVyMCE+cRSnXdDBVXF5uqow+4f7KHN 5cW2bKLFSmpaoYKtIBbU1GtsdTAWqILctZ5h8j5YZXUB2Ix+ltra8dk2z5iZkzI7x57L Qe4SjF5LRvyAMHmKMyoYmPw38zb/iW4spd6ucSv3UcoCT4MxIm3+as/GrNKNA2+AheLl rVOw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Yu0ssxY4; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=neutral header.i=@amarulasolutions.com Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id ffacd0b85a97d-49c60da2730sor785621f8f.14.2026.11.13.09.17.46 for (Google Transport Security); Fri, 13 Nov 2026 09:17:46 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Yu0ssxY4; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=neutral header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1794590266; x=1795195066; darn=amarulasolutions.com; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=R5dYLuG+ASH3CiDAET/FUHUUAv0oF9dg3VK0aCh9XE4=; b=Yu0ssxY4MTq/zhCLrFNxBXSYPFkfpv7t5BjclE3mcUlKzmkP2sKaLQG/xAb81KPvZU Vmu7fwrwJYD9moq+q5mJJ+dH1eQhkP6AqOmiJqrdaYdqyKwWnyo3dLI9WmBc4JvmOtMC 53nRs+HF38U3y1TkFPnKkumuA5iyvyBRBLo3Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794590266; x=1795195066; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=R5dYLuG+ASH3CiDAET/FUHUUAv0oF9dg3VK0aCh9XE4=; b=f7o4G2+Yx5NcGyEYmqzTHWcK1pa53wfR4UCymLy62Tz52XcjQ0SmEHPxSJ3OO2JQt3 0+OVIFU9f2gHLxgah5I0QiOdJxIaFh7W6kLAWQnwgWsbHAub/rawbz4m0Ust7WtLmhV1 MEnzUUXEv3zshtuEdzX1yNmo3OLMyoXssHrHCXqmIjdy+f5Wc318xNd+7N6JSujN8hQ0 qLjRSq/s/GovhFB1bWYKOJfAvdL7i1FHmDyFJVVHfRIIccJPGdMtORwnAh54uTG024Cd E2dsQOS5vCzd6y5SQ7EcJ7OjGE2qgDPzNfHm7mLieUYvqFzCLnA+ZUuhgPB40ZhZHC4L pjrQ== X-Forwarded-Encrypted: i=1; AL+hErFKy6LzcEj5SsFWID333w05zpXx9fuk+QWLNtQdZmtfmIDccf5pJEXCZ2xBWiZIyRPBNs1uPAWH@amarulasolutions.com X-Gm-Message-State: APuU4Z8+G1FLs+HLc49knoiWsqNRbz7o7DmMHfEsx9OR0I/6m0kqdUcJ CUVhsk0nbrtDAFfvSYHaMNi7a+dNg4UPOSj4M7GPfiSv59OBJxpB32lnpQVacwDJ/IPrTC4K0Yp GHSyoSc8= X-Gm-Gg: AYBFou1vaAIfhvXskvnloAZR0+rWMB9nngoHT2BDnUBWlJe1ImrWMKncyNAH0AQ/vpt Knt3ShbNDWtsi9zkm11XU5Ep4D2+ViMFGBScUTkb04E8KoXiCfCkpUKxzOLhdRArz3G9dvzF5k4 AXSjwwIuaWdwktbNGZ4fVJvWLnwJo2SO2hpNBR0ay7cPQW3PdSXAAQp+/pqX2MZZVdrG3GBNd9H fm1N7Q6Twyv6RHnxMBe21BgkFrtB6dWdTNErItE84iEAeuoBkfjFZStpsFuj4yq/g4cNKSySD9K 5/nR3yIkVLwAUnJFjKx4eZc1NYNjA8g+I44POb4RsZw8lQiFWGSGNdG7aNnnpJU5nZ4y9x7+JJE Lx8ffwFrLwZxZdy83K57jE9GTihybIYGwpc6RZCV3v7ElAWGCnisNPNqyFi5VPq4bgCpeaE+G3+ k6CCFigvKnZKTY+fGaVwcahZYnbfjThYB+l9kFg6W9BK1QJlhGLAB3Vfwc3pvaGpb1BkxLjZ0U8 zmArc91nzyJWtel9yafAfMSvTt9/HtjK9NWTcvdiTivii5Uhb0kHUlaLSvpYIOwu2J3ZUBRmS/5 JEu4FLX8pgH6Y7iy5xZH8lphVVS5fBUcNySjJ+u3h+matafTTiQHIxPUroXEqf2ejuWHEnJRGVt ez7w79MkmNqqV5bGPrYIFT3fOoMjWQteV98bI0iyBrswWsBgoMOJHby/5B5y64voJZoS+O+6A+2 C6BRa93von9Xb8/2GfbYxQK5xPf5LNoK1n8+GJS37VDJtLbRU= X-Received: by 2002:a05:600c:4e43:b0:4a1:e00b:a10b with SMTP id 5b1f17b1804b1-4bb55a6a937mr67421385e9.7.1794590265723; Fri, 13 Nov 2026 09:17:45 -0800 (PST) Return-Path: Received: from dario-ThinkPad-P14s-Gen-5.homenet.telecomitalia.it (host-79-14-29-58.business.telecomitalia.it. [79.14.29.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb55ac0e1esm68545935e9.3.2026.11.13.09.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2026 09:17:45 -0800 (PST) From: Dario Binacchi To: swupdate@googlegroups.com Cc: stefano.babic@swupdate.org, linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi Subject: [libubootenv][PATCH v2 0/8] Add the FWU metadata storage format Date: Fri, 13 Nov 2026 18:17:29 +0100 Message-ID: <20261113171737.470894-1-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 This series lets libubootenv access the Arm FWU metadata through a namespace, as discussed in [1]. An update agent can then switch the boot bank with the existing API and tools, together with the U-Boot environment. - Patch 1 is a fix: filewrite() ignores the result of fsync(). - Patch 2 moves loading and storing behind callbacks selected by the format of the namespace. No functional change. - Patch 3 adds an optional callback to validate a value before it is set. No functional change. - Patch 4 adds the "fwu-mdata" format, versions 1 and 2. Only active_index, previous_active_index and bank_state are exposed. - Patch 5 documents it. - Patches 6-8 add unit tests based on cmocka, as in SWUpdate, for both versions of the metadata. The SWUpdate side follows in a separate series. v1 was tested on the STM32MP257F-EV1 with TF-A and U-Boot, FWU metadata version 2 with two banks: update of either bank from SWUpdate, acceptance at boot, rollback by TF-A after failed trial boots. v2 was tested on the same board, updating both banks from SWUpdate, and on the host with the new unit tests. Changes in v2: - Clear the accepted flags of the images when a bank leaves the accepted state in version 2 too - Convert the fields of the metadata, which are little endian - Check the values when they are set, through a new callback (patch 3) - Document the requirement for MTD and that version 1 does not support "invalid" - Add unit tests (patches 6-8) [1] https://groups.google.com/g/swupdate/c/kYr2Hy-f3us Link to v1: https://groups.google.com/g/swupdate/c/_nJSCCjWETU Dario Binacchi (8): uboot_env: report fsync errors when writing to a file uboot_env: access the storage through callbacks uboot_env: add a callback to validate a value before it is set add FWU metadata storage format docs: fw_env_config.md: document the FWU metadata format tests: add unit test infrastructure based on cmocka fwu_mdata: move the metadata structures to a private header tests: add unit tests for the FWU metadata format .gitlab-ci.yml | 4 +- CMakeLists.txt | 7 + docs/fw_env_config.md | 65 ++++ src/CMakeLists.txt | 2 + src/extended_config.c | 59 ++++ src/fw_printenv.c | 7 +- src/fwu_mdata.c | 723 +++++++++++++++++++++++++++++++++++++++++ src/fwu_mdata.h | 60 ++++ src/uboot_env.c | 68 +++- src/uboot_private.h | 41 ++- tests/CMakeLists.txt | 19 ++ tests/test_fwu_mdata.c | 637 +++++++++++++++++++++++++++++++++++ 12 files changed, 1679 insertions(+), 13 deletions(-) create mode 100644 src/fwu_mdata.c create mode 100644 src/fwu_mdata.h create mode 100644 tests/CMakeLists.txt create mode 100644 tests/test_fwu_mdata.c --- 2.43.0