From b5f3405b9d8666bd0ab627c298cea1c927da081a Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Tue, 22 Dec 2020 11:32:21 +0100 Subject: [PATCH] dfu: add 'SKIP' entity Define a new 'SKIP' type for the DFU entities. The flashed data for that entity is simply ignored without returning any error values. This allows to have one flashing procedure and images for the different board types or variants, where each board uses only the images relevant to it and skips the rest. This is especially usefull for the THOR protocol, which usually transfers more than one file in a single session. Signed-off-by: Jaehoon Chung Reviewed-by: Minkyu Kang [mszyprow: rephrased commit message and docs for easier reading, changed subject to "dfu: add 'SKIP' entity"] Signed-off-by: Marek Szyprowski --- doc/README.dfu | 15 ++++++++++++++- drivers/dfu/dfu.c | 2 +- drivers/dfu/dfu_mmc.c | 9 +++++++++ include/dfu.h | 1 + 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/doc/README.dfu b/doc/README.dfu index be53b5b393..6cb1cba9d7 100644 --- a/doc/README.dfu +++ b/doc/README.dfu @@ -17,7 +17,7 @@ Overview: - The access to mediums is done in DFU backends (driver/dfu) Today the supported DFU backends are: - - MMC (RAW or FAT / EXT2 / EXT3 / EXT4 file system) + - MMC (RAW or FAT / EXT2 / EXT3 / EXT4 file system / SKIP) - NAND - RAM - SF (serial flash) @@ -91,6 +91,7 @@ Commands: part [mmcpart ] raw access to partition fat [mmcpart ] file in FAT partition ext4 [mmcpart ] file in EXT4 partition + skip 0 0 ignore flashed data with being the GPT or DOS partition index, with being the eMMC hardware partition number. @@ -103,6 +104,18 @@ Commands: "u-boot raw 0x80 0x800;uImage ext4 0 2" + If don't want to flash given image file to storage, use "skip" type + entity. + - It can be used to protect flashing wrong image for the specific board. + - Especailly, this layout will be useful when thor protocol is used, + which performs flashing in batch mode, where more than one file is + processed. + For example, if one makes a single tar file with support for the two + boards with u-boot-.bin and u-boot-.bin files, one + can use it to flash a proper u-boot image on both without a failure: + + "u-boot-.bin raw 0x80 0x800; u-boot-.bin skip 0 0" + "nand" (raw slc nand device) cmd: dfu 0 nand each element in "dfu_alt_info" = diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c index 501a60b344..fc32a53323 100644 --- a/drivers/dfu/dfu.c +++ b/drivers/dfu/dfu.c @@ -614,7 +614,7 @@ const char *dfu_get_dev_type(enum dfu_device_type t) const char *dfu_get_layout(enum dfu_layout l) { const char *const dfu_layout[] = {NULL, "RAW_ADDR", "FAT", "EXT2", - "EXT3", "EXT4", "RAM_ADDR" }; + "EXT3", "EXT4", "RAM_ADDR", "SKIP" }; return dfu_layout[l]; } diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c index 784d0ec76b..d1af11d94c 100644 --- a/drivers/dfu/dfu_mmc.c +++ b/drivers/dfu/dfu_mmc.c @@ -108,6 +108,8 @@ static int mmc_file_op(enum dfu_op op, struct dfu_entity *dfu, case DFU_FS_EXT4: fstype = FS_TYPE_EXT; break; + case DFU_SKIP: + return 0; default: printf("%s: Layout (%s) not (yet) supported!\n", __func__, dfu_get_layout(dfu->layout)); @@ -204,6 +206,9 @@ int dfu_write_medium_mmc(struct dfu_entity *dfu, case DFU_FS_EXT4: ret = mmc_file_buf_write(dfu, offset, buf, len); break; + case DFU_SKIP: + ret = 0; + break; default: printf("%s: Layout (%s) not (yet) supported!\n", __func__, dfu_get_layout(dfu->layout)); @@ -238,6 +243,8 @@ int dfu_get_medium_size_mmc(struct dfu_entity *dfu, u64 *size) if (ret < 0) return ret; return 0; + case DFU_SKIP: + return 0; default: printf("%s: Layout (%s) not (yet) supported!\n", __func__, dfu_get_layout(dfu->layout)); @@ -399,6 +406,8 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s) dfu->layout = DFU_FS_FAT; } else if (!strcmp(entity_type, "ext4")) { dfu->layout = DFU_FS_EXT4; + } else if (!strcmp(entity_type, "skip")) { + dfu->layout = DFU_SKIP; } else { pr_err("Memory layout (%s) not supported!\n", entity_type); return -ENODEV; diff --git a/include/dfu.h b/include/dfu.h index a767adee41..0b1dae0b3b 100644 --- a/include/dfu.h +++ b/include/dfu.h @@ -33,6 +33,7 @@ enum dfu_layout { DFU_FS_EXT3, DFU_FS_EXT4, DFU_RAM_ADDR, + DFU_SKIP, }; enum dfu_op {