| Message ID | 20261108133615.2483762-1-dario.binacchi@amarulasolutions.com |
|---|---|
| Headers |
Delivered-To: michael@amarulasolutions.com
Received: by 2002:a05:7300:aca6:b0:36a:3487:1c26 with SMTP id
cr38csp1709533dyb;
Sun, 8 Nov 2026 05:36:23 -0800 (PST)
X-Forwarded-Encrypted: i=2;
AL+hErHuyTBxO4K5jQSfJIHWMFccPHKNxX9Kx5+6snb3s2oRSo5qE8/IrjA6l7+1r4fedjf9S9JswmA6@amarulasolutions.com
X-Received: by 2002:a05:6000:2311:b0:48a:fbcf:6f43 with SMTP id
ffacd0b85a97d-4958c9653d7mr3344880f8f.54.1794144983546;
Sun, 08 Nov 2026 05:36:23 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1794144983; cv=none;
d=google.com; s=arc-20260327;
b=bE4jEiUwIb+HoWYUlQMVgQOnB+qGdZ3eOs4wx3q3nwHj8i4IJw+X05V+OXSWwojd3+
MnZA3caVdkLDCPckkhCw3tSNWV4QrAoVxfMq/o0QWs6se1GLXoMYx3UkD2ASiA50Osi8
WBqvcLgBnc2B9qhAkDwRd5bzMZ3HVChWTP/KSpsQAUYk9bOf0DtP5U3JGPrPG0MwqVnQ
+/Me8kF+uMdVz9L3WzMmWZsTcSUH4KIBQr7AObVIbDxAG6e6Q3ZdsIsvCgfrqMPxBH/6
khcA4EeXV0MW/Gn4BBBje9EcpwFQA7EqzruqtyMyW0fMwZWyS6OjwkzeH0mE480xiPi7
Vt2g==
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=EDra2r55peISFrzrwBUnwMg4UayNa8lQoI9xUlTj9mg=;
fh=ZewkZCsr156awSwoChal9in0LDPBDa91UngiAWvTHbo=;
b=mmmWDVf1Za/2llVbARIhFBRBuZ0xAbvq5NjVJZk13WFefAS0ElOi4tgPQOYRfVc+Il
bOtLazCOEcZu84YlECKC8nZqb5PvKe9xZq/glBojH7uDohLyfHmTIWngvjolHFtUPUT9
07cvWa7nO4m/1RgOgq9T5rSgTDFc9ne2E0AJCe/KeUe8vQdXNfcrjVIx5QnDMPj8WN7e
YxRtrlruQWYBVIJNqanGOBLlkALgI9usSTiNg5qY1ZFPHFBFEJSRa93jVQ9cNNKWWXoY
kyytlQ4bDSFQFhWbgGDk6jc44cjwZYE1JJ/dog5oTGHfgd8h29GEFe/jTF6Th3sq62pA
FnDQ==;
dara=google.com
ARC-Authentication-Results: i=1; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b=mTtG8fW5;
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: <dario.binacchi@amarulasolutions.com>
Received: from mail-sor-f41.google.com (mail-sor-f41.google.com.
[209.85.220.41])
by mx.google.com with SMTPS id
ffacd0b85a97d-4959708f727sor197680f8f.7.2026.11.08.05.36.23
for <michael@amarulasolutions.com>
(Google Transport Security);
Sun, 08 Nov 2026 05:36:23 -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=mTtG8fW5;
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=1794144983; x=1794749783;
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=EDra2r55peISFrzrwBUnwMg4UayNa8lQoI9xUlTj9mg=;
b=mTtG8fW5qZZWvcqPitjvrcFhqVLmjSosfzDJObLc6VZ+TLZgWt8cAMG4gFXxAmoJtR
xa+Bi7deNsRipxwwqPPCmLNxODtqRQ0imwH42X7AkSHxfHlnjhHiXg+lg4kJh7xU3QZa
7yuy2/DJrQ4L1hCRtkL6hUhHmtr+5A9xwWHzc=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794144983; x=1794749783;
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=EDra2r55peISFrzrwBUnwMg4UayNa8lQoI9xUlTj9mg=;
b=XC0NdaLtKcsnHjy6we3cKK9jMaHPQe2cyMUrh8qgjacTa7nvGWJkCChY58F14VWPE5
QeueJfIrcPesMC2nPMxZE4M5POWU5CdVWiy7Egz+gSUDMRFZnOIfd4lWFjdpu4zsezID
5/937dN3bkxZk9Kcpe6OybSqKTW9OtCozWJdOPQPorkH+ptKTvaNRSnPdgEwxb0sBW1H
8dh4aNc/Jej4t+HePTqyxgxJtjrMKWaAm3F/aZ4L7WubNqK5wq9+woJwi+evd67F7ezR
r++UEcYkQ4/buBL4WkzJMhlfyQoB7uwB3ZkZgpHDU4QOzblrp1ygh1YwY+G8eYdGG3eo
9bTA==
X-Forwarded-Encrypted: i=1;
AL+hErFsFcBUcE9sKKEcDRykOkEvYIbD4PJsPRLmdG9pi7WtFtIlCKfXbMyvX1OJ8p7QykDYSIC95I0E@amarulasolutions.com
X-Gm-Message-State: APuU4Z/Nqr+bX5UAxTD1jUXPkMc/s535QWEtf6e2otdyzhsR7W9BCjpF
4I4fupW4J/jFwAwm44yloJvYRYBsOhge27vFBeA4pLofm1YuIUVhj0V50phMzW3aUNbPmA==
X-Gm-Gg: AYBFou0fhlLOTQq29oCfapAlnbFiOqXCZiAQygha66yF6aq+ShKKIipcFZHg142Stxy
tUCCPTrEpPyJMWESCeHJ4JxGH+CiRdxsTu2Yixt4bZ73WGO8+Pkx7+JNCdi0+ymy3z7Q+wkS6CF
UG+oPuwFAuKYgA7oJQpC7BhzowgW4R08FJEcBo1w4tmpmBmxwZINKJ6nLXr4Cf1eYcr3CxgZ9Al
RfHEOdlYe4taV3su+l0Il3TbGW7K34CdUdaBV90ESH5u1ZYvxYP0E6qmAV3h+rRZ42pS13pjWz1
amwgl8Y+efEkDRjLmyFlucyn7iEFUKMhSh7Oj9DwuO4nIUnFo4zZOPUdSiLDdslGWI8PCL536rw
nz1HSyfuZZu/Df45xaGQ6r/SMblXUyF33APWjprY+ywsboJM/lIiiLiUpjXWTXLky3mmygLR53T
fxlGPsK5fWLfmcg5qn+kdNv3AQ2Wd72ot2KNQmD5+eEveAh4WbMvKuKT/JPdyfx3e9p9YohYU7N
IfNcogboWT/vbvgo1RsL3Au94b93cjbQftw9/w7Q8iDc0FH4NmUR41foMHXQEw7YPeF3OGYUPEV
0uoMprjK1QcqSWq0Qk8D0qfVR9pPHsdjLXu7GfVAF9mMxHGD5jdB+vqr/Nfx84lmZSGfEEtA6+0
ij0SXiMrtYV0f/PAPcvDjuDK66wBwFYWyC2wcp00k+2OYRa+L/nNFM025G83GjOG8Qx6V6WhVpc
sRUFvkrqhj+lpCKmcp3ZzvPTATQA==
X-Received: by 2002:a05:600c:34c9:b0:4a1:fa33:441a with SMTP id
5b1f17b1804b1-4b94d7631ccmr28560945e9.2.1794144982894;
Sun, 08 Nov 2026 05:36:22 -0800 (PST)
Return-Path: <dario.binacchi@amarulasolutions.com>
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-4b76cb76697sm92901945e9.0.2026.11.08.05.36.20
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Sun, 08 Nov 2026 05:36:22 -0800 (PST)
From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
To: swupdate@googlegroups.com
Cc: stefano.babic@swupdate.org,
linux-amarula@amarulasolutions.com,
michael@amarulasolutions.com,
Dario Binacchi <dario.binacchi@amarulasolutions.com>
Subject: [libubootenv][RFC PATCH 0/4] Add the FWU metadata storage format
Date: Sun, 8 Nov 2026 14:36:11 +0100
Message-ID: <20261108133615.2483762-1-dario.binacchi@amarulasolutions.com>
X-Mailer: git-send-email 2.43.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
|
| Series |
Add the FWU metadata storage format
|
|
Message
Dario Binacchi
Nov. 8, 2026, 1:36 p.m. UTC
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 the "fwu-mdata" format, versions 1 and 2. Only active_index, previous_active_index and bank<N>_state are exposed. - Patch 4 documents it. The SWUpdate side follows in a separate patch. 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. Both versions, corrupted copies and invalid values were also tested on the host. [1] https://groups.google.com/g/swupdate/c/kYr2Hy-f3us Dario Binacchi (4): uboot_env: report fsync errors when writing to a file uboot_env: access the storage through callbacks add FWU metadata storage format docs: fw_env_config.md: document the FWU metadata format docs/fw_env_config.md | 61 ++++ src/CMakeLists.txt | 1 + src/extended_config.c | 59 ++++ src/fw_printenv.c | 7 +- src/fwu_mdata.c | 709 ++++++++++++++++++++++++++++++++++++++++++ src/uboot_env.c | 60 +++- src/uboot_private.h | 38 ++- 7 files changed, 923 insertions(+), 12 deletions(-) create mode 100644 src/fwu_mdata.c -- 2.43.0
Comments
Hi Dario, On 11/8/26 14:36, Dario Binacchi wrote: > 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 the "fwu-mdata" format, versions 1 and 2. Only > active_index, previous_active_index and bank<N>_state are exposed. > - Patch 4 documents it. > > The SWUpdate side follows in a separate patch. > > 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. Both > versions, corrupted copies and invalid values were also tested on the > host. > > [1] https://groups.google.com/g/swupdate/c/kYr2Hy-f3us > > Dario Binacchi (4): > uboot_env: report fsync errors when writing to a file > uboot_env: access the storage through callbacks > add FWU metadata storage format > docs: fw_env_config.md: document the FWU metadata format > > docs/fw_env_config.md | 61 ++++ > src/CMakeLists.txt | 1 + > src/extended_config.c | 59 ++++ > src/fw_printenv.c | 7 +- > src/fwu_mdata.c | 709 ++++++++++++++++++++++++++++++++++++++++++ > src/uboot_env.c | 60 +++- > src/uboot_private.h | 38 ++- > 7 files changed, 923 insertions(+), 12 deletions(-) > create mode 100644 src/fwu_mdata.c > thanks for the series, this is the direction we discussed: the FWU metadata is a storage format of a namespace, and the update agent and the tools keep the same interface. I tested it on the host with version 2 metadata in two files (2 banks, 2 images) and fw_printenv / fw_setenv -m: the switch of the active bank, a corrupted first copy (the second one is used, and both are repaired on the next store), an invalid state, an index out of range, adding and removing a variable. All work as described, and the CRC is correct in both copies. Patch 1/4 and 2/4 are fine for me. Some (minor) points for patch 3/4: 1. Accepted flags of the images in version 2 > + accept = state == FWU_MDATA_BANK_ACCEPTED; > + /* Version 1 has no bank state and uses the acceptance of the images */ > + if (info->version == 1 || accept) { In version 2, setting a bank to "valid" or "invalid" changes only bank_state, and the images of the bank keep their accepted flag. After the usual switch on a device where both banks were accepted: fw_setenv -m fwu previous_active_index 0 active_index 1 bank1_state valid bank 1 is "valid", but all its images are still marked as accepted. U-Boot takes the trial state from bank_state in version 2, so the boot works, but the metadata is inconsistent: U-Boot clears the flag of an image when it updates it (fwu_clear_accept_image()), and requires all flags set before it moves a bank to accepted. Please clear the flags when a bank leaves the accepted state in version 2 too, as for version 1. 2. Byte order The fields are read and written in host byte order, while the metadata is little endian. Please use le32toh() / htole32() (and the 16-bit variants for the descriptor), so that the code is correct on a big-endian host as well. 3. Copies on MTD The store writes copy 0 and then copy 1. On an MTD device, if both copies are in the same erase block, erasing for the second write also removes the first one, and a power cut leaves no valid copy. This is known, it is the same for environment, but maybe it is better to doocument it (I let to you to decide). 4. Validation when the value is set An invalid state or an index out of range is detected only by store, so fw_setenv reports "Error storing the env". It is correct, but rejecting the value in libuboot_set_env() gives a clearer error and lets an application check a value before the store. Not a blocker. 5. Tests Please add tests in tests/ for both versions: loading, switching, corrupted and invalid copies, and the fixed list of variables. They are easy to do on the host with metadata created by the test itself. For patch 4/4: please mention that "invalid" is not supported with version 1 (it returns -ENOTSUP), and the requirement for MTD of point 3. Best regards, Stefano Babic -- _______________________________________________________________________ Nabla Software Engineering GmbH Hirschstr. 111A | 86156 Augsburg | Tel: +49 821 45592596 Geschäftsführer : Stefano Babic | HRB 40522 Augsburg E-Mail: sbabic@nabladev.com