Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2230236/?format=api
{ "id": 2230236, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2230236/?format=api", "web_url": "http://patchwork.ozlabs.org/project/swupdate/patch/20260429140130.615536-2-dario.binacchi@amarulasolutions.com/", "project": { "id": 58, "url": "http://patchwork.ozlabs.org/api/1.1/projects/58/?format=api", "name": "swupdate development", "link_name": "swupdate", "list_id": "swupdate.googlegroups.com", "list_email": "swupdate@googlegroups.com", "web_url": "https://github.com/sbabic/swupdate", "scm_url": "git://github.com/sbabic/swupdate", "webscm_url": "" }, "msgid": "<20260429140130.615536-2-dario.binacchi@amarulasolutions.com>", "date": "2026-04-29T14:01:30", "name": "[1/1] handler: add \"fwumdata\" handler", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "e244919d3da953aaabbe00d4d57b97274354c349", "submitter": { "id": 83038, "url": "http://patchwork.ozlabs.org/api/1.1/people/83038/?format=api", "name": "Dario Binacchi", "email": "dario.binacchi@amarulasolutions.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/swupdate/patch/20260429140130.615536-2-dario.binacchi@amarulasolutions.com/mbox/", "series": [ { "id": 502071, "url": "http://patchwork.ozlabs.org/api/1.1/series/502071/?format=api", "web_url": "http://patchwork.ozlabs.org/project/swupdate/list/?series=502071", "date": "2026-04-29T14:01:29", "name": "Add support for fwumdata handler", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/502071/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2230236/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2230236/checks/", "tags": {}, "headers": { "Return-Path": "<swupdate+bncBCQ4XFG47UFRBSE6ZDHQMGQEOUFUNMQ@googlegroups.com>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=googlegroups.com header.i=@googlegroups.com\n header.a=rsa-sha256 header.s=20251104 header.b=fsYveplr;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com\n (client-ip=2a00:1450:4864:20::53d; helo=mail-ed1-x53d.google.com;\n envelope-from=swupdate+bncbcq4xfg47ufrbse6zdhqmgqeoufunmq@googlegroups.com;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from mail-ed1-x53d.google.com (mail-ed1-x53d.google.com\n [IPv6:2a00:1450:4864:20::53d])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g5Jrd05vjz1yK5\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 00:01:51 +1000 (AEST)", "by mail-ed1-x53d.google.com with SMTP id\n 4fb4d7f45d1cf-66bb7305ae7sf10817982a12.2\n for <incoming@patchwork.ozlabs.org>;\n Wed, 29 Apr 2026 07:01:51 -0700 (PDT)", "by 2002:aa7:da99:0:b0:672:f72:23ae with SMTP id\n 4fb4d7f45d1cf-67271825199ls9989827a12.1.-pod-prod-03-eu;\n Wed, 29 Apr 2026 07:01:42 -0700 (PDT)", "from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com.\n [2a00:1450:4864:20::32f])\n by gmr-mx.google.com with ESMTPS id\n 4fb4d7f45d1cf-67b22122f04si43227a12.4.2026.04.29.07.01.42\n for <swupdate@googlegroups.com>\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Wed, 29 Apr 2026 07:01:42 -0700 (PDT)", "by mail-wm1-x32f.google.com with SMTP id\n 5b1f17b1804b1-488a9033b2cso132255755e9.2\n for <swupdate@googlegroups.com>; Wed, 29 Apr 2026 07:01:42 -0700 (PDT)", "from dario-ThinkPad-P14s-Gen-5.homenet.telecomitalia.it\n (host-82-56-22-134.retail.telecomitalia.it. [82.56.22.134])\n by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-48a7c5c7631sm53190915e9.13.2026.04.29.07.01.38\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 29 Apr 2026 07:01:38 -0700 (PDT)" ], "ARC-Seal": [ "i=2; a=rsa-sha256; t=1777471308; cv=pass;\n d=google.com; s=arc-20240605;\n b=L0b07baCepnl38vde7hD+0pMViu49fYFmGG2GqWjYHU995U7D4Xn1OFWATG7jI1gAf\n aPy1pOiXrCTeqtN8tZwN025JNnO+VnURSwdeFO1l1vdDibEV8K2HciNnq22bevem63dD\n 0PCHYSRN93IDYMgzqnzotTNcnfU2/cI3cgXCOgVuEnhiesQJn+bhjDT8sZaX1zaDDulU\n MGPIqN7SOMq3iw0PDjgpYahKSh73kPTuvsp3MerFbrft7Vf4miioDlXuPfK9O13T6aLx\n mpw2alLarM0Jt1AK2rE2rrkldOODCZjogRP9e2pWSVugtE1+pAk+NVEFW3cOLsgQaMeI\n psXw==", "i=1; a=rsa-sha256; t=1777471302; cv=none;\n d=google.com; s=arc-20240605;\n b=TyfLmleV0MInvrGIsKyHzpckiYcDftQqgJ+S3wYbwOVS8/j26iFj9iCnzh89A8of2u\n q4CAnBjse15cDUpQNixkhscLYFuBBod+r78M9bvTad9mzYBuAQ1KNWBw9AWC8QAvCAgk\n LWYbhlOacEsEqjbeirXMjx9Bp/JWKcZKV0MStcNHj+4cj7qJNVsix4nbKjihHyRXhTVj\n hrZcDLbprmKyvBF+7P/83GiFPb4i5Kq9wmxoWWKIATOxMon18ICB5fCnjM1e+BfEl16T\n VhscoGWXCh07ZvARx2U8np62VJo6M0ri0LnTLrZupWv9Mj0Uk4tdXOSvda/bENe5ORg8\n Fv4g==" ], "ARC-Message-Signature": [ "i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n s=arc-20240605;\n h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post\n :list-id:mailing-list:precedence:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:sender:dkim-signature;\n bh=VKFW+aHlwtQm8RYn9FJCJEUYYHwPHLS/tYN3Lpa/gFM=;\n fh=y1txT+/ILURK5ysIBQYGk3xPWMgR3tw+VfWi/42yE1U=;\n b=SHoeS2yKk7mznmkgFG16fqWhC9fF1/vIdK/lc4j7/VGKnJgoFGW8dUC4ISUY2RuDdd\n lWbKv+soFelb4L2Ufa3T8XjQBuGotgIcVB4DT8dLQnk2mh5mmlDsWbJj6zZSv7zonp2+\n Ne+IKtPU9MrzsG6f2bRf5DaqDeW36u9WAxRKA7HgiFog+axydJJiBt2kBQyPln69DhW4\n eAmiG/wxUZha8aBCoV6gAE6rHE2NmArsiREb/wfwUF9olR9jF7+TM2hs7aWKQEYScbKy\n Kwu9uJymgGQE+kPCCsYW5k8qU7xmdY4p0CmflCethqzDSbeA0FVkDRm3+H1ZILHdOF8m\n NZxA==;\n darn=patchwork.ozlabs.org", "i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n s=arc-20240605;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:dkim-signature;\n bh=nrGs4Vp9VVfTAec6ofwPGOsc3bnWbDFNe1MDtOtYVIo=;\n fh=PVQ6qK/apE8apMCQLUsBZ5FgEk1zvaf7+lv3UFNLduQ=;\n b=VJUOek/+o3DMsWLM9AW2LRtYIW9jGFeIL6c8GvgHgcbdvC4+yZZDZBx452WE0H7Vsr\n mPD9qjOWUrHXLRt1JJuGsOs7q0ZtSwFEVqHOZccUKRT5laiISCFa3Tpyrq6Ds0BRj0iJ\n GjTol0c0mjoYeJskaLJe6hMvrYguNL9dS1lUUWdQfMFSe/VCpY+Ed6SBIYUqe6upNoUF\n z7cu3th5inOOgFcoruIIOHKp2wkQcLT8dRb5OFVgbT6RgVZM/qEkhKxPa1F2Tsf00WIp\n fYYh4Eoo8DB6gqSSbDJwrAzAYhAgu8o45w0/x7LHemEuIruwM63ycwMIX38aDiy9W08g\n hoyg==;\n dara=google.com" ], "ARC-Authentication-Results": [ "i=2; gmr-mx.google.com;\n dkim=pass header.i=@amarulasolutions.com header.s=google\n header.b=Bw0LYn1I;\n spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com\n designates 2a00:1450:4864:20::32f as permitted sender)\n smtp.mailfrom=dario.binacchi@amarulasolutions.com;\n dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;\n dara=pass header.i=@googlegroups.com", "i=1; gmr-mx.google.com;\n dkim=pass header.i=@amarulasolutions.com header.s=google\n header.b=Bw0LYn1I;\n spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com\n designates 2a00:1450:4864:20::32f as permitted sender)\n smtp.mailfrom=dario.binacchi@amarulasolutions.com;\n dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;\n dara=pass header.i=@googlegroups.com" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=googlegroups.com; s=20251104; t=1777471308; x=1778076108;\n darn=patchwork.ozlabs.org;\n h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post\n :list-id:mailing-list:precedence:x-original-authentication-results\n :x-original-sender:mime-version:references:in-reply-to:message-id\n :date:subject:cc:to:from:sender:from:to:cc:subject:date:message-id\n :reply-to;\n bh=VKFW+aHlwtQm8RYn9FJCJEUYYHwPHLS/tYN3Lpa/gFM=;\n b=fsYveplrIICHamoy8G1Un7U3x3AcRMUXs2j7Htj9N7HhpNNwZyLkQmUfCa/lXsnTbk\n 7ZlHVea0/VOjloZ3CK7vKIZuMRvD+S/jOa+zFkQrzLT8ZxmkEg77r2TKKAacraSSFtv9\n fvgEEPexuVAxrx84y2RO3UEnLsfqTV0SdaFeP9MSrVMEfuPOSy/9rGfmZJXiJgirBN3g\n xwdGmKElAm0Otp212q35kYyNO7UAI2SQHiRoLXKOOWa75zUDgWWKO5K5hJaM+Td3/HCO\n q7zKDCR2Pko7jKiQ7paT75+wFMR/qXxO+pJi/pK3YM2JJ5muYo4BODrl3sYkALU9G1sY\n tHhA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777471308; x=1778076108;\n h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post\n :x-spam-checked-in-group:list-id:mailing-list:precedence\n :x-original-authentication-results:x-original-sender:mime-version\n :references:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg\n :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date\n :message-id:reply-to;\n bh=VKFW+aHlwtQm8RYn9FJCJEUYYHwPHLS/tYN3Lpa/gFM=;\n b=Y6IiDp7t6rGyJiLhzs/EZWcRIjsJloaTmPSd0s0zPDwFzBPlfvdGC53f3DQ9HhZHjz\n UBrqzM8QDz1o//k5Vh8SnwVzbzoaKGoL9tLO2zDwtWKhimV98cedOybl9GECRa7V8zeD\n +bMALZpkgpgsWQthwfwRglgcltDVluSEW9Hs/jEve07+4W4gYF4RlN25PCtqG7bFafod\n GnhdgscpXaDgS34taA3Vb5cXUqQ8pFOd2VoJbPXgAfDapojBQMDC1Arf2yjF0oLO7szA\n ZAvl9mNdiZoW+FTcizH+doyUpAqbtv6OR13tGi/FNIQgj3KCrU5pqNhb19G4V+RWHQCU\n eGNA==", "Sender": "swupdate@googlegroups.com", "X-Forwarded-Encrypted": "i=2;\n AFNElJ+AyHLYZrXWaLTqzpl31YKfqu+cXNp7N3G8wdjvOS5mQ5BifpJtJBNf4/hDhb3v+Y9kMOVWnvV8fw==@patchwork.ozlabs.org", "X-Gm-Message-State": "AOJu0YzxY3CkHb+OTHU2NaEAbAAcyQZmTdQ3LF9dbHUMxJ4N3sx5caT4\n\t9tqQPnONv6HsBIBbOrsFws01Gls/57MK25rd+goZXfU1L2c08Aossciv", "X-Received": [ "by 2002:a05:6402:26c7:b0:674:1f5e:1b3f with SMTP id\n 4fb4d7f45d1cf-679bafe0e53mr4272689a12.0.1777471307156;\n Wed, 29 Apr 2026 07:01:47 -0700 (PDT)", "by 2002:a05:6402:5216:b0:677:1ce0:c087 with SMTP id\n 4fb4d7f45d1cf-679bb08bb89mr4012355a12.15.1777471302177;\n Wed, 29 Apr 2026 07:01:42 -0700 (PDT)", "by 2002:a05:600c:3b15:b0:489:1f04:96c3 with SMTP id\n 5b1f17b1804b1-48a77ae53famr132004095e9.2.1777471299725;\n Wed, 29 Apr 2026 07:01:39 -0700 (PDT)" ], "X-BeenThere": "swupdate@googlegroups.com;\n h=\"AUV6zMPJQ7vv12VEqpr2ZsoooIXnVXjPiuD+8Mi/aGHFps1qtA==\"", "Received-SPF": "pass (google.com: domain of dario.binacchi@amarulasolutions.com\n designates 2a00:1450:4864:20::32f as permitted sender)\n client-ip=2a00:1450:4864:20::32f;", "X-Gm-Gg": "AeBDietWxDqtGgZIoBtAN97mNuG/VqyYzn/lVMMnS6y/6+EnIMHgbEd2CsMvxFigZSk\n\t6O2njB/hfDZhJ8jD+GLHF1UV0TVJhkVvW992fSVWDiqin47H9X4H2eFAQUvxKRb1ermcD2QBNCu\n\tOXCwOCkMlzqYqkYA7CZxRg1y/FN+BjqMbtvCgjp22H9j+RZK1cgAcrZD8q0X+x0wpylGN39x86a\n\twY1xHtyNpKjDHywUto5H9YNp+15qdZjulgVJGY5hdQzx2P+e27OJSOM/d8p31+UdZHOcSU5wigd\n\tKrHpIrtPV1hc8j4DWJTG2N2SX6ePMIyWOcL0JZIrZ9WXsdLLnuOamPYqy/38kI2BdGiqi7Br5vs\n\tSpOUBGte6anF8Pqqp7/Bf2jVts7XsGfjwbiGi4nn00Il6ijiqBL0XbqMa5atd+aY5j1L2VPlPyY\n\t5GG9boWZS4dP9pXQlsX676VuGtOIx314kimB1VmN5p4AgTYPg8cDMFXm0835SWPTM5y2Gp6wdxV\n\t9WS14p/iihV+CmjHw5ALk+jhqbqLT2mKvhr5CVr+L0KWKP60bx6qtHV9oFFlUsLXr5KjTO9V7Hz\n\tF1+CUH78Q48y7X9CgKXHj2AkKcmRKHY+G+o=", "From": "Dario Binacchi <dario.binacchi@amarulasolutions.com>", "To": "swupdate@googlegroups.com", "Cc": "linux-amarula@amarulasolutions.com,\n\tDario Binacchi <dario.binacchi@amarulasolutions.com>", "Subject": "[swupdate] [PATCH 1/1] handler: add \"fwumdata\" handler", "Date": "Wed, 29 Apr 2026 16:01:30 +0200", "Message-ID": "<20260429140130.615536-2-dario.binacchi@amarulasolutions.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260429140130.615536-1-dario.binacchi@amarulasolutions.com>", "References": "<20260429140130.615536-1-dario.binacchi@amarulasolutions.com>", "MIME-Version": "1.0", "X-Original-Sender": "dario.binacchi@amarulasolutions.com", "X-Original-Authentication-Results": "gmr-mx.google.com; dkim=pass\n header.i=@amarulasolutions.com header.s=google header.b=Bw0LYn1I;\n spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com\n designates 2a00:1450:4864:20::32f as permitted sender)\n smtp.mailfrom=dario.binacchi@amarulasolutions.com;\n dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;\n dara=pass header.i=@googlegroups.com", "Content-Type": "text/plain; charset=\"UTF-8\"", "Precedence": "list", "Mailing-list": "list swupdate@googlegroups.com;\n contact swupdate+owners@googlegroups.com", "List-ID": "<swupdate.googlegroups.com>", "X-Spam-Checked-In-Group": "swupdate@googlegroups.com", "X-Google-Group-Id": "605343134186", "List-Post": "<https://groups.google.com/group/swupdate/post>,\n <mailto:swupdate@googlegroups.com>", "List-Help": "<https://groups.google.com/support/>,\n <mailto:swupdate+help@googlegroups.com>", "List-Archive": "<https://groups.google.com/group/swupdate", "List-Subscribe": "<https://groups.google.com/group/swupdate/subscribe>,\n <mailto:swupdate+subscribe@googlegroups.com>", "List-Unsubscribe": "\n <mailto:googlegroups-manage+605343134186+unsubscribe@googlegroups.com>,\n <https://groups.google.com/group/swupdate/subscribe>" }, "content": "Add a handler to manage the boot selection process according to\nthe Firmware Update (FWU) metadata specification using the\nlibfwumdata library.\n\nThe handler is a script handler that updates the active_index\nand marks the selected bank as valid during the post-install phase.\n\nExample in sw-description:\n\n scripts: (\n {\n type = \"fwumdata\";\n properties: {\n active = \"1\";\n }\n }\n );\n\nSigned-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>\n---\n Kconfig | 4 ++\n Makefile.deps | 4 ++\n Makefile.flags | 3 +\n bootloader/Kconfig | 7 ++\n configs/all_handlers_defconfig | 1 +\n doc/source/handlers.rst | 37 ++++++++++\n handlers/Kconfig | 17 +++++\n handlers/Makefile | 1 +\n handlers/fwumdata_handler.c | 125 +++++++++++++++++++++++++++++++++\n 9 files changed, 199 insertions(+)\n create mode 100644 handlers/fwumdata_handler.c", "diff": "diff --git a/Kconfig b/Kconfig\nindex 2cf68eb890b0..fcb60f900b3f 100644\n--- a/Kconfig\n+++ b/Kconfig\n@@ -129,6 +129,10 @@ config HAVE_ZCK\n \tbool\n \toption env=\"HAVE_ZCK\"\n \n+config HAVE_LIBFWUMDATA\n+\tbool\n+\toption env=\"HAVE_LIBFWUMDATA\"\n+\n menu \"SWUpdate Settings\"\n \n menu \"General Configuration\"\ndiff --git a/Makefile.deps b/Makefile.deps\nindex c759f6876dea..313d5af6230c 100644\n--- a/Makefile.deps\n+++ b/Makefile.deps\n@@ -121,3 +121,7 @@ endif\n ifeq ($(HAVE_ZCK),)\n export HAVE_ZCK = y\n endif\n+\n+ifeq ($(HAVE_LIBFWUMDATA),)\n+export HAVE_LIBFWUMDATA = y\n+endif\ndiff --git a/Makefile.flags b/Makefile.flags\nindex 40dd3b66856e..76b87e67fe67 100644\n--- a/Makefile.flags\n+++ b/Makefile.flags\n@@ -233,6 +233,9 @@ ifeq ($(CONFIG_UCFWHANDLER),y)\n LDLIBS += gpiod\n endif\n \n+ifeq ($(CONFIG_FWUMDATA_HANDLER),y)\n+LDLIBS += fwumdata\n+endif\n \n ifeq ($(CONFIG_BOOTLOADER_STATIC_LINKED),y)\n ifeq ($(CONFIG_BOOTLOADER_EBG),y)\ndiff --git a/bootloader/Kconfig b/bootloader/Kconfig\nindex edc02d99b2d1..36f856507356 100644\n--- a/bootloader/Kconfig\n+++ b/bootloader/Kconfig\n@@ -158,3 +158,10 @@ config UPDATE_STATE_BOOTLOADER\n \thelp\n \t Store update information in Bootloader's environment.\n \n+config FWUMDATA_CONFIG_FILE\n+\tstring \"FWU Metadata Configuration file\"\n+\tdepends on HAVE_LIBFWUMDATA\n+\tdefault \"/etc/fwumdata.config\"\n+\thelp\n+\t It tells where the FWU metadata are saved.\n+\ndiff --git a/configs/all_handlers_defconfig b/configs/all_handlers_defconfig\nindex 16cd9b6b98f1..63299bd223ae 100644\n--- a/configs/all_handlers_defconfig\n+++ b/configs/all_handlers_defconfig\n@@ -20,6 +20,7 @@ CONFIG_DISKPART=y\n CONFIG_DISKPART_FORMAT=y\n CONFIG_DISKFORMAT_HANDLER=y\n CONFIG_FAT_FILESYSTEM=y\n+CONFIG_FWUMDATA_HANDLER=y\n CONFIG_EXT_FILESYSTEM=y\n CONFIG_LUASCRIPTHANDLER=y\n CONFIG_RAW=y\ndiff --git a/doc/source/handlers.rst b/doc/source/handlers.rst\nindex 6742c10a58c3..cbfb146f099c 100644\n--- a/doc/source/handlers.rst\n+++ b/doc/source/handlers.rst\n@@ -1710,3 +1710,40 @@ Examples:\n \t\t\tname = \"helloworld\";\n \t\t};\n \t});\n+\n+FWU Metadata Handler\n+--------------------\n+\n+This is a script handler used to manage the boot selection process according to\n+the Firmware Update (FWU) metadata specification.\n+\n+The handler implements a post-install script that updates the metadata to switch\n+the active bank and marks it as valid, ensuring the system boots from the new\n+bank at the next reset. The ``active`` property defines which bank must be\n+selected.\n+\n+Example selecting boot bank 1 (bank A in A/B schema):\n+\n+::\n+\n+\tscripts: (\n+\t\t{\n+\t\t\ttype = \"fwumdata\";\n+\t\t\tproperties: {\n+\t\t\t\tactive = \"1\";\n+\t\t\t}\n+\t\t}\n+\t);\n+\n+Example selecting boot bank 2 (bank B in A/B schema):\n+\n+::\n+\n+\tscripts: (\n+\t\t{\n+\t\t\ttype = \"fwumdata\";\n+\t\t\tproperties: {\n+\t\t\t\tactive = \"2\";\n+\t\t\t}\n+\t\t}\n+\t);\ndiff --git a/handlers/Kconfig b/handlers/Kconfig\nindex 152bc08074a1..b7d9e51a20c9 100644\n--- a/handlers/Kconfig\n+++ b/handlers/Kconfig\n@@ -151,6 +151,23 @@ config EMMC_HANDLER\n \t with a dual-copy concept. This guarantees that the upgrade\n \t is power-cut safe.\n \n+config FWUMDATA_HANDLER\n+\tbool \"FWU metadata update\"\n+\tdepends on HAVE_LIBFWUMDATA\n+\tdefault n\n+\thelp\n+\t This handler allows to manage the boot selection process using\n+\t firmware update (FWU) metadata via libfwumdata.\n+\n+\t Selecting the new boot bank automatically triggers the handler to\n+\t set the current bank for rollback and mark the selected boot-up\n+\t bank as 'valid'.\n+\n+\t This ensures the system is ready to boot from the updated\n+\t partition while maintaining a safe path to revert to the previous\n+\t working state if the new firmware fails to reach the 'accepted'\n+\t state\n+\n config RAW\n \tbool \"raw\"\n \tdefault n\ndiff --git a/handlers/Makefile b/handlers/Makefile\nindex 8490172a10a3..45fcb525e461 100644\n--- a/handlers/Makefile\n+++ b/handlers/Makefile\n@@ -30,3 +30,4 @@ obj-$(CONFIG_SWUFORWARDER_HANDLER) += swuforward_handler.o swuforward-ws.o\n obj-$(CONFIG_UBIVOL)\t+= ubivol_handler.o\n obj-$(CONFIG_UCFWHANDLER)\t+= ucfw_handler.o\n obj-$(CONFIG_DOCKER)\t+= docker_handler.o\n+obj-$(CONFIG_FWUMDATA_HANDLER)\t+= fwumdata_handler.o\ndiff --git a/handlers/fwumdata_handler.c b/handlers/fwumdata_handler.c\nnew file mode 100644\nindex 000000000000..1331fe64aa74\n--- /dev/null\n+++ b/handlers/fwumdata_handler.c\n@@ -0,0 +1,125 @@\n+#include <stdio.h>\n+#include <unistd.h>\n+#include <fcntl.h>\n+#include <stdlib.h>\n+#include <stdbool.h>\n+#include <errno.h>\n+#include <linux/version.h>\n+#include <sys/ioctl.h>\n+#include <stddef.h>\n+\n+#include \"swupdate_image.h\"\n+#include \"handler.h\"\n+#include \"util.h\"\n+\n+#include <libfwumdata.h>\n+\n+static int _fwumdata_set(uint32_t active_index, uint32_t previous_index,\n+\t\t\t uint8_t bank_state)\n+{\n+\tint mdd;\n+\tint ret;\n+\n+\tmdd = fwumdata_init();\n+\tif (mdd < 0) {\n+\t\tERROR(\"Cannot initialize libfwumdata\\n\");\n+\t\treturn mdd;\n+\t}\n+\n+\tret = fwumdata_read_config(mdd, CONFIG_FWUMDATA_CONFIG_FILE);\n+\tif (ret) {\n+\t\tERROR(\"Cannot read %s\\n\", CONFIG_FWUMDATA_CONFIG_FILE);\n+\t\tgoto exit;\n+\t}\n+\n+\tret = fwumdata_open(mdd, 0);\n+\tif (ret) {\n+\t\tERROR(\"Cannot open %s\\n\", CONFIG_FWUMDATA_CONFIG_FILE);\n+\t\tgoto exit;\n+\t}\n+\n+\tret = fwumdata_set_active_index(mdd, active_index);\n+\tif (ret) {\n+\t\tERROR(\"Cannot set active index\\n\");\n+\t\tgoto close;\n+\t}\n+\n+\tfwumdata_set_previous_index(mdd, previous_index);\n+\tif (ret) {\n+\t\tERROR(\"Cannot set previous index\\n\");\n+\t\tgoto close;\n+\t}\n+\n+\tret = fwumdata_set_bank_state(mdd, active_index, bank_state);\n+\tif (ret) {\n+\t\tERROR(\"Cannot set bank state\\n\");\n+\t\tgoto close;\n+\t}\n+\n+ ret = fwumdata_store(mdd);\n+ if (ret) {\n+\t\tERROR(\"Cannot store fwu metadata\\n\");\n+\t\tgoto close;\n+\t}\n+\n+\tDEBUG(\"fwumdata: active: %d, previous: %d, state: 0x%x\",\n+\t active_index, previous_index, bank_state);\n+\n+close:\n+\tfwumdata_close(mdd);\n+exit:\n+\tfwumdata_exit(mdd);\n+\treturn ret;\n+}\n+\n+static int fwumdata_set(struct img_type *img, void *data)\n+{\n+\tstruct script_handler_data *script_data;\n+\tchar *value;\n+\tint active_index = -1;\n+\tint previous_index;\n+\n+\n+\tif (!data)\n+\t\treturn -EINVAL;\n+\n+\tscript_data = data;\n+\n+\t/*\n+\t * Call only in case of postinstall\n+\t */\n+\tif (script_data->scriptfn != POSTINSTALL)\n+\t\treturn 0;\n+\n+\tvalue = dict_get_value(&img->properties, \"active\");\n+\tif (!value) {\n+\t\tERROR(\"active: cannot find in sw-description\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tactive_index = ustrtoull(value, NULL, 10);\n+\tif (errno) {\n+\t\tERROR(\"active %s: ustrotull failed\", value);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tactive_index--;\n+\tif (active_index == 0) {\n+\t\tprevious_index = 1;\n+\t} else if (active_index == 1) {\n+\t\tprevious_index = 0;\n+\t} else {\n+\t\tERROR(\"active %s: invalid value\", value);\n+\t\treturn -EINVAL;\n+\n+\t}\n+\n+\treturn _fwumdata_set(active_index, previous_index, FWUMDATA_BANK_VALID);\n+}\n+\n+__attribute__((constructor))\n+void fwumdata_handler(void)\n+{\n+\tregister_handler(\"fwumdata\", fwumdata_set,\n+\t\t\t SCRIPT_HANDLER | NO_DATA_HANDLER, NULL);\n+}\n", "prefixes": [ "1/1" ] }