mmc-utils: Add FFU optional mode 2 using CMD25+CMD12 for Open-ended write download FW

Introduced a new FFU mode 2 of leveraging CMD25+CMD12 for Open-ended Multiple-block write to
download the firmware bundle. In this mmode, the device remains in FFU mode during firmware
download until the downloading is completed.

Signed-off-by: Bean Huo <beanhuo@micron.com>
Acked-by: Avri Altman <avri.altman@wdc.com>
Message-ID: <20241025203454.162710-4-beanhuo@iokpp.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
Bean Huo 2024-10-25 22:34:52 +02:00 committed by Ulf Hansson
parent b9c9eff4c4
commit f3d144021c
5 changed files with 23 additions and 1 deletions

3
mmc.1
View File

@ -195,6 +195,9 @@ if [\fIchunk\-bytes\fR] is omitted, mmc-utils will try to run ffu using the larg
.BI opt_ffu1 " \fIimage\-file\-name\fR " " \fIdevice\fR " " [\fIchunk\-bytes\fR]
Optional FFU mode 1, it's the same as 'ffu', but uses CMD23+CMD25 for repeated downloads and remains in FFU mode until completion.
.TP
.BI opt_ffu2 " \fIimage\-file\-name\fR " " \fIdevice\fR " " [\fIchunk\-bytes\fR]
Optional FFU mode 2, uses CMD25+CMD12 Open-ended Multiple-block write to download and remains in FFU mode until completion.
.TP
.BI erase " " \fItype\fR " " \fIstart-address\fR " " \fIend\-address\fR " " \fIdevice\fR
Send Erase CMD38 with specific argument to the device.
.br

5
mmc.c
View File

@ -239,6 +239,11 @@ static struct Command commands[] = {
"Optional FFU mode 1, it's the same as 'ffu', but uses CMD23+CMD25 for repeated downloads and remains in FFU mode until completion.\n",
NULL
},
{ do_opt_ffu2, -2,
"opt_ffu2", "<image name> <device> [chunk-bytes]\n"
"Optional FFU mode 2, uses CMD25+CMD12 Open-ended Multiple-block write to download and remains in FFU mode until completion.\n",
NULL
},
{ do_erase, -4,
"erase", "<type> " "<start address> " "<end address> " "<device>\n"
"Send Erase CMD38 with specific argument to the <device>\n\n"

1
mmc.h
View File

@ -27,6 +27,7 @@
#define MMC_BOOT_INITIATION_ARG 0xFFFFFFFA
#define MMC_SWITCH 6 /* ac [31:0] See below R1b */
#define MMC_SEND_EXT_CSD 8 /* adtc R1 */
#define MMC_STOP_TRANSMISSION 12 /* ac R1b */
#define MMC_SEND_STATUS 13 /* ac [31:16] RCA R1 */
#define R1_SWITCH_ERROR (1 << 7) /* sx, c */
#define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target to value */

View File

@ -63,7 +63,8 @@
// Firmware Update (FFU) download modes
enum ffu_download_mode {
FFU_DEFAULT_MODE, // Default mode: Uses CMD23+CMD25; exits FFU mode after each loop.
FFU_OPT_MODE1 // Optional mode 1: Uses CMD23+CMD25; but stays in FFU mode during download.
FFU_OPT_MODE1, // Optional mode 1: Uses CMD23+CMD25; but stays in FFU mode during download.
FFU_OPT_MODE2 // Optional mode 2: Uses CMD25+CMD12 Open-ended Multiple-block write to download
};
static inline __u32 per_byte_htole32(__u8 *arr)
@ -2853,6 +2854,12 @@ static void set_ffu_download_cmd(struct mmc_ioc_multi_cmd *multi_cmd,
multi_cmd->cmds[0].flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC;
set_single_cmd(&multi_cmd->cmds[1], MMC_WRITE_MULTIPLE_BLOCK, 1, bytes / 512, arg);
mmc_ioc_cmd_set_data(multi_cmd->cmds[1], buf + offset);
} else if (ffu_mode == FFU_OPT_MODE2) {
set_single_cmd(&multi_cmd->cmds[0], MMC_WRITE_MULTIPLE_BLOCK, 1, bytes / 512, arg);
multi_cmd->cmds[0].flags = MMC_RSP_R1 | MMC_CMD_ADTC;
mmc_ioc_cmd_set_data(multi_cmd->cmds[0], buf + offset);
set_single_cmd(&multi_cmd->cmds[1], MMC_STOP_TRANSMISSION, 0, 0, 0);
multi_cmd->cmds[1].flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
}
}
@ -3205,6 +3212,11 @@ int do_opt_ffu1(int nargs, char **argv)
return __do_ffu(nargs, argv, FFU_OPT_MODE1);
}
int do_opt_ffu2(int nargs, char **argv)
{
return __do_ffu(nargs, argv, FFU_OPT_MODE2);
}
int do_general_cmd_read(int nargs, char **argv)
{
int dev_fd;

View File

@ -43,6 +43,7 @@ int do_cache_en(int nargs, char **argv);
int do_cache_dis(int nargs, char **argv);
int do_ffu(int nargs, char **argv);
int do_opt_ffu1(int nargs, char **argv);
int do_opt_ffu2(int nargs, char **argv);
int do_read_scr(int argc, char **argv);
int do_read_cid(int argc, char **argv);
int do_read_csd(int argc, char **argv);