> +static int enter_ffu_mode(int *dev_fd) > +{ > + int ret; > + struct mmc_ioc_cmd cmd; > + memset(&cmd, 0, sizeof(cmd)); > > - /* > - * send image chunk: blksz and blocks essentially do not matter, as > - * long as the product is fw_size, but some hosts don't handle larger > - * blksz well. > - */ > - set_single_cmd(&multi_cmd->cmds[2], MMC_WRITE_MULTIPLE_BLOCK, > 1, bytes / 512, arg); > - mmc_ioc_cmd_set_data(multi_cmd->cmds[2], buf + offset); > + fill_switch_cmd(&cmd, EXT_CSD_MODE_CONFIG, EXT_CSD_FFU_MODE); > + ret = ioctl(*dev_fd, MMC_IOC_CMD, &cmd); > + if (ret) > + perror("enter FFU mode faled\n"); > + > + return ret; > +} Thinking aloud if we need the enter phase at all, because: 1) The first cmd6 is always part of the sequence, and 2) is it even safe to send it as a single ioctl? I guess the answer to 2) is yes, and having a start phase actually make sense: it makes clearer of what the ffu process comprised of: Start (enter ffu mode), repeat...., finish up. I would even add a comment in the code (and in the commit log) for all modes other than 1, emphasizing that from this point onward, the device is blocked in ffu mode. Thanks, Avri