Following the discussions with Avri at the 2024 ALPSS, I am submitting these patches to introduce multiple FFU modes, as defined in the eMMC specification 6.6.18. The new FFU implementation can support diverse vendor requirements and operational conditions. The key benefits include: 1, The host can select the most appropriate update mode based on device capabilities and firmware size. 2, The patches ensure that firmware downloads are treated as a single, uninterrupted operation, preventing partial updates that could compromise device stability. 3, Some new modes keep the device in FFU mode throughout the process, reducing the risk of premature exits and update failures. By supporting these modes, we can better accommodate varying firmware sizes and ensure smoother, more reliable firmware updates across different scenarios. Summary of Changes: Default FFU mode: "mmc ffu" Uses CMD6 to enter FFU mode, CMD23 to set the block count, CMD25 for multiple-block write, and CMD6 to exit FFU mode. This mode may exit FFU mode during the download if the firmware size exceeds the chunk size. Optional FFU mode 1: Similar to default FFU mode, but repeats CMD23+CMD25 for each chunk, ensuring FFU mode is maintained throughout the firmware download. FFU mode is only exited after the entire firmware has been successfully downloaded. Optional FFU mode 2: use CMD25+CMD12 for open-ended multiple-block write Introduces a method using CMD25 for open-ended multiple-block writes followed by CMD12 to stop the transmission. This allows for a smoother and more continuous firmware bundle download. Optional FFU mode 3: use CMD6 and CMD24 for single-block write A new mode that uses CMD6 to enter FFU mode, CMD24 for single-block writes, and CMD6 to exit FFU mode after each write cycle. This ensures granular control over each block but may introduce more frequent mode transitions. Optional FFU mode 4: use CMD6 and repeated CMD24 sequence In this mode, CMD6 is used to enter FFU mode, followed by repeated CMD24 single-block writes. After all firmware data is written, CMD6 is used to exit FFU mode, ensuring an atomic and uninterrupted download process. Changelog: v1 -- v2: 1. Added memset() to clean command structure v2 -- V3: 1. Refactor patch, and remove ffu dedicated file mmc_ffu.c v3 -- v4: 1. Incorporated Avri’s comments 2. Due to "ERROR: in command 'ffu', 'ffu' is ambiguous" when using "mmc ffu", update default FFU mode 'ffu' to 'ffu1' v4 -- v5: 1. Retain the default FFU mode as 'ffu' and rename the other FFU modes to 'opt_ffux' for consistency. v5 -- v6: 1. Fix a typo in patch [4/5] commit subject Bean Huo (5): mmc-utils: Refactor common FFU code into functions to support additional FFU modes mmc-utils: Add FFU optional mode 1 mmc-utils: Add FFU optional mode 2 using CMD25+CMD12 for Open-ended write download FW mmc-utils: Add FFU optional mode 3 that uses CMD6 and CMD24 single-block write to download firmware mmc-utils: Add FFU optional mode 4 for firmware download using repeated CMD24 single-block write command mmc.1 | 12 ++ mmc.c | 20 +++ mmc.h | 1 + mmc_cmds.c | 492 ++++++++++++++++++++++++++++++++++++++--------------- mmc_cmds.h | 4 + 5 files changed, 389 insertions(+), 140 deletions(-) -- 2.34.1