mmc-utils: modified FFU to use multiple write command
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 mmc-utils: modified FFU to use multiple write command
Until now the FW was written in a Single Write Command (CMD24) mode.
In order to write the firmware, the host sends hundreds of CMD24.
By using new mode (closed ended multiple write: CMD23,CMD25), the number of write commands is reduced to few commands. In case the host doesn't support closed ended writing, flash the ffu by single sector writing.
By set [sector] to 1 or omit this parameter.
--- mmc.c | 10 +++- mmc.h | 1 + mmc_cmds.c | 184 ++++++++++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 146 insertions(+), 49 deletions(-)
mmc.c +9 -2
@@ -211,8 +211,14 @@ static struct Command commands[] = {NULL }, { do_ffu, -2, -"ffu" ,"<image name> <device>\n" -"Run Field Firmware Update with <image name> on <device>.\n" , +"ffu" ,"<image name> <device> [sectors]\n" +"Run Field Firmware Update with <image name> on <device>\n" +"Write FFU file into device with number of blocks = <sectors>\n" +"[sectors] is optional ,default value of the <sector> is 1 sector.\n" +"In case the platform has [sectors] limitation\n" +"(e.g. limited by hw, unsupported close ended writing),\n" +"use default (one sector) command.\n" + "[sectors] parameter cannot be more then MMC_IOC_MAX_BYTES/device +sector size\n", NULL },
{ 0, 0, 0, 0 }
mmc.h +1 -0
@@ -37,6 +37,7 @@#define R1_SWITCH_ERROR (1 << 7)/* sx, c */ #define MMC_SWITCH_MODE_WRITE_BYTE 0x03/* Set target to value */ #define MMC_READ_MULTIPLE_BLOCK 18/* adtc [31:0] data addr R1 */ +#define MMC_SET_BLOCK_COUNT 23/* adtc [31:0] data addr R1 */ #define MMC_WRITE_BLOCK 24/* adtc [31:0] data addr R1 */ #define MMC_WRITE_MULTIPLE_BLOCK 25/* adtc R1 */ #define MMC_SET_WRITE_PROT 28/* ac [31:0] data addr R1b */
mmc_cmds.c +120 -41
210 lines not on this page · raw message
} else {
fprintf(stderr, "Programmed %d/%jd bytes\r", sect_done * sect_size, (intmax_t)fw_size);
}
+ memset(buf, 0, num_ioctl_blks);
+ if (remain_fw_size >= bl_counter * sect_size)
+ num_ioctl_blks = bl_counter;
+ else
+ num_ioctl_blks = remain_fw_size / sect_size;
/* read the next firmware chunk (if any) */
- chunk_size = read(img_fd, buf, 512);
+ chunk_size = read(img_fd, buf, num_ioctl_blks * sect_size);
+ if (chunk_size > 0)
+ remain_fw_size = remain_fw_size - chunk_size;
+ /* Update the values for Multiple Write CMD */
+ if (bl_counter > 1) {
+ multi_cmd->cmds[1].arg = num_ioctl_blks & 0x0000FFFF;
+ multi_cmd->cmds[2].blocks = num_ioctl_blks;
+ }
}
-
if ((sect_done * sect_size) == fw_size) {
fprintf(stderr, "Programmed %jd/%jd bytes\n", (intmax_t)fw_size, (intmax_t)fw_size);
- fprintf(stderr, "Programming finished with status %d \n", ret);
+ fprintf(stderr, "Programming finished with status %d\n", ret);
}
else {
fprintf(stderr, "FW size and number of sectors written mismatch. Status return %d\n", ret); @@ -2529,9 +2619,9 @@ do_retry:
multi_cmd->cmds[1].blksz = 0;
multi_cmd->cmds[1].blocks = 0;
multi_cmd->cmds[1].arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
- (EXT_CSD_MODE_OPERATION_CODES << 16) |
- (EXT_CSD_FFU_INSTALL << 8) |
- EXT_CSD_CMD_SET_NORMAL;
+ (EXT_CSD_MODE_OPERATION_CODES << 16) |
+ (EXT_CSD_FFU_INSTALL << 8) |
+ EXT_CSD_CMD_SET_NORMAL;
multi_cmd->cmds[1].flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
multi_cmd->cmds[1].write_flag = 1;
--
1.7.9.5