summaryrefslogtreecommitdiff
path: root/lib/fwu_updates
AgeCommit message (Collapse)Author
9 daysglobal: Audit Kconfig usage of PARTITION_TYPE_GUIDTom Rini
It is not functionally possible to use the code enabled by PARTITION_TYPE_GUID without having EFI_PARTITION be enabled as well. Not all users of the former had ensured that the latter was enabled however, so audit all current users and then as appropriate select or imply EFI_PARTITION as needed. Signed-off-by: Tom Rini <[email protected]>
2026-02-11fwu: Mark failed bank as invalid during rollbackKory Maincent
When boot_idx differs from active_idx at boot time, it indicates a rollback scenario where the firmware update failed and the system reverted to the previous working bank. In this case, mark the failed bank (active_idx) as invalid to prevent future boot attempts from that bank. Signed-off-by: Kory Maincent <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2026-02-11fwu: Pass bank state enum to fwu_state_machine_updates()Kory Maincent
Change fwu_state_machine_updates() to accept an enum fwu_bank_states parameter instead of a boolean. This makes the function interface more explicit and prepares for adding FWU_BANK_INVALID support to handle boot failures on the active bank. Convert the FWU_BANK_* defines to an enum and update all call sites accordingly. Signed-off-by: Kory Maincent <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2025-10-09FWU: Add platform hook support for fwu metataPadmarao Begari
FWU metadata information is unavailable for platform-specific operations since FWU initialization has not yet occurred. The initialization function is invoked as part of the main loop event. To address this, the FWU platform hook function is introduced during FWU initialization, allowing metadata processing with platform-specific operations. Signed-off-by: Padmarao Begari <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michal Simek <[email protected]>
2025-06-02include/mtd.h: Cleanup usageTom Rini
There are only a few things found in <mtd.h> today. Go through and audit the C files which include <mtd.h> and remove it when not required. Then, add it to the files which had either missed it or had an indirect inclusion of it. Signed-off-by: Tom Rini <[email protected]>
2024-09-19fwu: do not allow capsule processing on exceeding Trial Counter thresholdSughosh Ganu
When in Trial State, the platform keeps a count of the number of times it has booted in the Trial State. Once the threshold of the maximum allowed count exceeds, the platform reverts to boot from a different bank on subsequent boot, thus coming out of the Trial State. It is expected that all the updated images would be accepted or rejected while the platform is in Trial State. Put in checks so that it is not possible to apply an empty capsule once the max Trial Count exceeds. Signed-off-by: Sughosh Ganu <[email protected]> Tested-by: Michal Simek <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2024-09-19fwu: add dependency checks for selecting FWU metadata versionSughosh Ganu
The FWU code supports both versions of the FWU metadata, i.e. v1 and v2. A platform can then select one of the two versions through a config symbol. Put a dependency in the FWU metadata version selection config symbol to ensure that both versions of the metadata cannot be enabled. Signed-off-by: Sughosh Ganu <[email protected]> Reviewed-by: Michal Simek <[email protected]> Tested-by: Michal Simek <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2024-09-19fwu: check all images for transitioning out of Trial StateSughosh Ganu
The platform transitions out of Trial State into the Regular State only when all the images in the update bank have been accepted. Check for this condition before transitioning out of Trial State. Signed-off-by: Sughosh Ganu <[email protected]> Tested-by: Michal Simek <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2024-09-19fwu: v1: do a version check for the metadataSughosh Ganu
Do a sanity check that the version of the FWU metadata that has been read aligns with the version enabled in the image. This allows to indicate an early failure as part of the FWU module initialisation. Signed-off-by: Sughosh Ganu <[email protected]> Tested-by: Michal Simek <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2024-09-19fwu: v2: try reading both copies of metadataSughosh Ganu
In the version 2 of the FWU metadata, the metadata is broken into two parts, a top-level structure, which provides information on the total size of the structure among other things. Try reading the primary partition first, and if that fails, try reading the secondary partition. This will help in the scenario where the primary metadata partition has been corrupted, but the secondary partition is intact. Signed-off-by: Sughosh Ganu <[email protected]> Tested-by: Michal Simek <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]>
2024-09-12include: export uuid.hCaleb Connolly
Move this header to include/u-boot/ so that it can be used by external tools. Reviewed-by: Ilias Apalodimas <[email protected]> Signed-off-by: Caleb Connolly <[email protected]>
2024-08-30list: use list_count_nodes() to count list entriesSughosh Ganu
Use the API function list_count_nodes() to count the number of list entries. Signed-off-by: Sughosh Ganu <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2024-07-15lib: Remove duplicate newlinesMarek Vasut
Drop all duplicate newlines. No functional change. Signed-off-by: Marek Vasut <[email protected]>
2024-05-24Merge patch series "FWU: Add support for FWU metadata version 2"Tom Rini
Sughosh Ganu <[email protected]> says: The following patch series adds support for version 2 of the FWU metadata. The version 2 metadata structure is defined in the latest revision of the FWU specification [1]. The earlier versions of these patches were migrating to a version 2 only support in U-Boot, similar to TF-A. However, based on feedback from ST [2], this series has been updated to support both versions. A platform would still be needed to enable one of the two versions of metadata through a config symbol. TF-A has code which reads the FWU metadata and boots the platform from the active partition. TF-A has decided to migrate the FWU code to a version 2 only support. These changes have been merged in upstream TF-A. These changes have been tested on the ST DK2 board, which uses the GPT based partitioning scheme. Both V1 and V2 metadata versions have been tested on the DK2 board. These changes need to be tested on platforms with MTD partitioned storage devices.
2024-05-24fwu: mtd: obtain image information from version agnostic structureSughosh Ganu
Make changes to the functions used for generating the DFU's alt variable so that the FWU image information is obtained from the common version agnostic structure instead of reading the metadata. While here, also update the name of the field used for storing the image GUID in the FWU metadata. Signed-off-by: Sughosh Ganu <[email protected]> Tested-by: Michal Simek <[email protected]>
2024-05-24fwu: mtd: get MTD partition specific info from driverSughosh Ganu
Information about FWU images on MTD partitions is now stored with the corresponding driver instead of a global variable. Get this information from the driver. Signed-off-by: Sughosh Ganu <[email protected]> Tested-by: Michal Simek <[email protected]>
2024-05-24fwu: mtd: remove unused argument from function callSughosh Ganu
The third argument passed to the function gen_image_alt_info() is not used and is superfluous. Remove this unused argument from the function call. Fixes: 4898679e190 (FWU: Add FWU metadata access driver for MTD storage regions) Signed-off-by: Sughosh Ganu <[email protected]> Tested-by: Michal Simek <[email protected]>
2024-05-24fwu: add config symbols for enabling FWU metadata versionsSughosh Ganu
Support has been added for version 2 of the FWU metadata structure. Add config symbols to enable either of the two versions. Signed-off-by: Sughosh Ganu <[email protected]> Tested-by: Michal Simek <[email protected]>
2024-05-24fwu: make changes to access version agnostic structure fieldsSughosh Ganu
With addition of support for version 2 of the FWU metadata structure, the metadata information is collected into a version agnostic structure. Make changes to the FWU functions so that the information that was earlier obtained by reading the metadata structure is now obtained through this version agnostic structure. Signed-off-by: Sughosh Ganu <[email protected]> Tested-by: Michal Simek <[email protected]>
2024-05-24fwu: metadata: add functions for handling version specific metadata fieldsSughosh Ganu
Support is being added in U-Boot for version 2 of the FWU metadata. Support for this version is to co-exist with version 1 support. To achieve this, a common, version agnostic structure has been added to keep information provided by the FWU metadata structure. Add API's to handle the version specific FWU metadata fields. The version agnostic structure gets initialized at boot by reading the FWU metadata. Updates to the FWU metadata result in the API's getting called to populate the version specific fields of the strucure, before the metadata gets written to the storage media. Signed-off-by: Sughosh Ganu <[email protected]> Tested-by: Michal Simek <[email protected]>
2024-05-22include: Move snprintf to stdio.hRaymond Mao
Move snprintf to stdio.h since it is needed by exteranl libraries. Signed-off-by: Raymond Mao <[email protected]> Reviewed-by: Tom Rini <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2024-01-13fwu: fix fwu_get_image_index interfaceMasahisa Kojima
The capsule update uses the DFU framework for updating storage. fwu_get_image_index() currently returns the image_index calculated by (dfu_alt_num + 1), but this is different from the image_index in UEFI terminology. Since capsule update implementation calls dfu_write_by_alt function, it is better that FWU returns the dfu_alt_num. Signed-off-by: Masahisa Kojima <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2023-09-19FWU: Avoid showing an unselectable menu optionSimon Glass
Use a menuconfig to avoid showing a menu which cannot be selected in many cases. Signed-off-by: Simon Glass <[email protected]> Acked-by: Sughosh Ganu <[email protected]> Reviewed-by: Tom Rini <[email protected]> Acked-by: Ilias Apalodimas <[email protected]>
2023-08-31event: Convert existing spy records to simpleSimon Glass
Very few of the existing event-spy records use the arguments they are passed. Update them to use a simple spy instead, to simplify the code. Where an adaptor function is currently used, remove it where possible. Signed-off-by: Simon Glass <[email protected]>
2023-08-30fwu: Initialize global fwu library state during CI testMarek Vasut
The current CI test worked by sheer luck, the g_dev global pointer in the fwu library was never initialized and the test equally well failed on sandbox64. Trigger the main loop in sandbox tests too to initialize that global state, and move the sandbox specific exit from fwu_boottime_checks after g_dev is initialized. Signed-off-by: Marek Vasut <[email protected]> Acked-by: Sughosh Ganu <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-07-25fwu: Show number of attempts in Trial StateMichal Simek
It is not visible anywhere in Trial State if this is the first, second, etc attempt that's why show a message to be aware about status. Signed-off-by: Michal Simek <[email protected]> Acked-by: Jassi Brar <[email protected]>
2023-07-25fwu: mtd: Fix dfu_alt_info generation for 2 images per bankMichal Simek
Code rewrites the last char of size with adding &. It is visible from dfu_alt_info print before this patch: Make dfu_alt_info: 'mtd nor0=bank0 raw 2320000 80000;bank1 raw 27a0000 8000&mtd nor0=bank0 raw 23a0000 4000000;bank1 raw 2820000 4000000' And after it: Make dfu_alt_info: 'mtd nor0=bank0 raw 2320000 80000;bank1 raw 27a0000 80000&mtd nor0=bank0 raw 23a0000 4000000;bank1 raw 2820000 4000000' Size for bank0 and bank1 must be the same because it is the same image. Signed-off-by: Michal Simek <[email protected]> Acked-by: Jassi Brar <[email protected]>
2023-07-25fwu: Allow code to properly decode trial stateMichal Simek
Current code after capsule update (mtd write) is not changing active_index in mdata to previous_active_index. On the reboot this is shown but showing message "Boot idx 1 is not matching active idx 0, changing active_idx" which is changing active_idx and writing mdata to flash. But when this message is visible it is not checking which state that images are. If they have acceptance bit setup to yes everything is fine and valid images are booted (doesn't mean the latest one). But if acceptance bit is no and images are in trial state in_trial variable is never setup. Which means that from new flashed image stable image can be rewritten because in_trial is not setup properly. Signed-off-by: Michal Simek <[email protected]> Acked-by: Jassi Brar <[email protected]>
2023-06-12Merge tag v2023.07-rc4 into nextTom Rini
Signed-off-by: Tom Rini <[email protected]>
2023-06-09fwu: provide default fwu_plat_get_bootidxJassi Brar
Just like fwu_plat_get_update_index, provide a default/weak implementation of fwu_plat_get_bootidx. So that most platforms wouldn't have to re-implement the likely case. Signed-off-by: Jassi Brar <[email protected]>
2023-06-09FWU: Add FWU metadata access driver for MTD storage regionsMasami Hiramatsu
In the FWU Multi Bank Update feature, the information about the updatable images is stored as part of the metadata, on a separate region. Add a driver for reading from and writing to the metadata when the updatable images and the metadata are stored on a raw MTD region. The code is divided into core under drivers/fwu-mdata/ and some helper functions clubbed together under lib/fwu_updates/ Signed-off-by: Masami Hiramatsu <[email protected]> Signed-off-by: Jassi Brar <[email protected]>
2023-06-09fwu: rename fwu_get_verified_mdata to fwu_get_mdataJassi Brar
fwu_get_mdata() sounds more appropriate than fwu_get_verified_mdata() Signed-off-by: Jassi Brar <[email protected]> Reviewed-by: Etienne Carriere <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Tested-by: Sughosh Ganu <[email protected]>
2023-06-09fwu: meta-data: switch to management by common codeJassi Brar
The common code can now read, verify and fix meta-data copies while exposing one consistent structure to users. Only the .read_mdata() and .write_mdata() callbacks of fwu_mdata_ops are needed. Get rid of .get_mdata() .update_mdata() .get_mdata_part_num() .read_mdata_partition() and .write_mdata_partition() and also the corresponding wrapper functions. Signed-off-by: Jassi Brar <[email protected]> Reviewed-by: Etienne Carriere <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Tested-by: Sughosh Ganu <[email protected]>
2023-06-09fwu: move meta-data management in coreJassi Brar
Instead of each i/f having to implement their own meta-data verification and storage, move the logic in common code. This simplifies the i/f code much simpler and compact. Signed-off-by: Jassi Brar <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Tested-by: Sughosh Ganu <[email protected]>
2023-06-08efi_loader: add the number of image entries in efi_capsule_update_infoMasahisa Kojima
The number of image array entries global variable is required to support EFI capsule update. This information is exposed as a num_image_type_guids variable, but this information should be included in the efi_capsule_update_info structure. This commit adds the num_images member in the efi_capsule_update_info structure. All board files supporting EFI capsule update are updated. Signed-off-by: Masahisa Kojima <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2023-05-13fwu: fix config FWU_MULTI_BANK_UPDATEHeinrich Schuchardt
Symbol CONFIG_EFI_SETUP_EARLY does not exist anymore. CONFIG_FWU_MULTI_BANK_UPDATE without CONFIG_FWU_MDATA results in lib/fwu_updates/fwu.c:49: undefined reference to `fwu_get_mdata' Fixes: 86794052418b ("FWU: Add support for the FWU Multi Bank Update feature") Fixes: 023d9c93932c ("efi_loader: remove CONFIG_EFI_SETUP_EARLY") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Acked-by: Sughosh Ganu <[email protected]>
2022-10-31test: dm: Add test cases for FWU Metadata uclassSughosh Ganu
Add test cases for accessing the FWU Metadata on the sandbox platform. The sandbox platform also uses the metadata access driver for GPT partitioned block devices. The FWU feature will be tested on the sandbox64 variant with a raw capsule. Remove the FIT capsule testing from sandbox64 defconfig -- the FIT capsule test will be run on the sandbox_flattree variant. Signed-off-by: Sughosh Ganu <[email protected]> Suggested-by: Heinrich Schuchardt <[email protected]> Acked-by: Ilias Apalodimas <[email protected]>
2022-10-31FWU: Add support for the FWU Multi Bank Update featureSughosh Ganu
The FWU Multi Bank Update feature supports updating firmware images to one of multiple sets(also called banks) of images. The firmware images are clubbed together in banks, with the system booting images from the active bank. Information on the images such as which bank they belong to is stored as part of the metadata structure, which is stored on the same storage media as the firmware images on a dedicated partition. At the time of update, the metadata is read to identify the bank to which the images need to be flashed(update bank). On a successful update, the metadata is modified to set the updated bank as active bank to subsequently boot from. Signed-off-by: Sughosh Ganu <[email protected]> Acked-by: Ilias Apalodimas <[email protected]>
2022-10-31FWU: Add boot time checks as highlighted by the FWU specificationSughosh Ganu
The FWU Multi Bank Update specification requires the Update Agent to carry out certain checks at the time of platform boot. The Update Agent is the component which is responsible for updating the firmware components and maintaining and keeping the metadata in sync. The spec requires that the Update Agent perform the following checks at the time of boot * Sanity check of both the metadata copies maintained by the platform. * Get the boot index passed to U-Boot by the prior stage bootloader and use this value for metadata bookkeeping. * Check if the system is booting in Trial State. If the system boots in the Trial State for more than a specified number of boot counts, change the Active Bank to be booting the platform from. Call these checks through the main loop event at the time of platform boot. Signed-off-by: Sughosh Ganu <[email protected]> Reviewed-by: Etienne Carriere <[email protected]> Acked-by: Ilias Apalodimas <[email protected]>
2022-10-31FWU: Add helper functions for accessing FWU metadataSughosh Ganu
Add weak functions for getting the update index value and dfu alternate number needed for FWU Multi Bank update functionality. The current implementation for getting the update index value is for platforms with 2 banks. If a platform supports more than 2 banks, it can implement it's own function. The function to get the dfu alternate number has been added for platforms with GPT partitioned storage devices. Platforms with other storage partition scheme need to implement their own function. Signed-off-by: Sughosh Ganu <[email protected]> Reviewed-by: Patrick Delaunay <[email protected]> Acked-by: Etienne Carriere <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2022-10-31FWU: Add FWU metadata structure and driver for accessing metadataSughosh Ganu
In the FWU Multi Bank Update feature, the information about the updatable images is stored as part of the metadata, which is stored on a dedicated partition. Add the metadata structure, and a driver model uclass which provides functions to access the metadata. These are generic API's, and implementations can be added based on parameters like how the metadata partition is accessed and what type of storage device houses the metadata. Signed-off-by: Sughosh Ganu <[email protected]> Reviewed-by: Patrick Delaunay <[email protected]>