diff mbox series

[4/9] dfu: mmc: add support for in-partition offset

Message ID 20181107150105.23165-5-m.szyprowski@samsung.com
State Accepted
Commit d2d8eab42118f8c25e8562495438c903893b83fd
Headers show
Series ARM: Exynos: Add TM2 board support | expand

Commit Message

Marek Szyprowski Nov. 7, 2018, 3:01 p.m. UTC
Add possibility to define a part of partition as a separate DFU entity.
This allows to have more than one items on the given partiton.

The real use case for this option is TM2 board. It can use u-boot stored
as Linux kernel on the defined partiton (as RAW data) and load the real
kernel from the same partition, but stored under the certain offset.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 drivers/dfu/dfu_mmc.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Minkyu Kang Nov. 19, 2018, 10:23 a.m. UTC | #1
Dear Marek Szyprowski,

On 08/11/18 00:01, Marek Szyprowski wrote:
> Add possibility to define a part of partition as a separate DFU entity.
> This allows to have more than one items on the given partiton.
> 
> The real use case for this option is TM2 board. It can use u-boot stored
> as Linux kernel on the defined partiton (as RAW data) and load the real
> kernel from the same partition, but stored under the certain offset.
> 
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>  drivers/dfu/dfu_mmc.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
> index b45e6dc54c..826e70ffec 100644
> --- a/drivers/dfu/dfu_mmc.c
> +++ b/drivers/dfu/dfu_mmc.c
> @@ -357,6 +357,7 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
>  		struct blk_desc *blk_dev = mmc_get_blk_desc(mmc);
>  		int mmcdev = second_arg;
>  		int mmcpart = third_arg;
> +		int offset = 0;
>  
>  		if (part_get_info(blk_dev, mmcpart, &partinfo) != 0) {
>  			pr_err("Couldn't find part #%d on mmc device #%d\n",
> @@ -364,9 +365,17 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
>  			return -ENODEV;
>  		}
>  
> +		/*
> +		 * Check for an extra entry at dfu_alt_info env variable
> +		 * specifying the mmc HW defined partition number
> +		 */
> +		if (s)
> +			if (!strcmp(strsep(&s, " "), "offset"))
> +				offset = simple_strtoul(s, NULL, 0);
> +
>  		dfu->layout			= DFU_RAW_ADDR;
> -		dfu->data.mmc.lba_start		= partinfo.start;
> -		dfu->data.mmc.lba_size		= partinfo.size;
> +		dfu->data.mmc.lba_start		= partinfo.start+offset;

please add space.
partinfo.start + offset

> +		dfu->data.mmc.lba_size		= partinfo.size-offset;

partinfo.size - offset

>  		dfu->data.mmc.lba_blk_size	= partinfo.blksz;
>  	} else if (!strcmp(entity_type, "fat")) {
>  		dfu->layout = DFU_FS_FAT;
> 

Thanks,
Minkyu Kang.
Lukasz Majewski Nov. 21, 2018, 12:56 a.m. UTC | #2
On Wed, 07 Nov 2018 16:01:00 +0100
Marek Szyprowski <m.szyprowski@samsung.com> wrote:

> Add possibility to define a part of partition as a separate DFU

> entity. This allows to have more than one items on the given partiton.

> 

> The real use case for this option is TM2 board. It can use u-boot

> stored as Linux kernel on the defined partiton (as RAW data) and load

> the real kernel from the same partition, but stored under the certain

> offset.

> 

> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---

>  drivers/dfu/dfu_mmc.c | 13 +++++++++++--

>  1 file changed, 11 insertions(+), 2 deletions(-)

> 

> diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c

> index b45e6dc54c..826e70ffec 100644

> --- a/drivers/dfu/dfu_mmc.c

> +++ b/drivers/dfu/dfu_mmc.c

> @@ -357,6 +357,7 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu,

> char *devstr, char *s) struct blk_desc *blk_dev =

> mmc_get_blk_desc(mmc); int mmcdev = second_arg;

>  		int mmcpart = third_arg;

> +		int offset = 0;

>  

>  		if (part_get_info(blk_dev, mmcpart, &partinfo) != 0)

> { pr_err("Couldn't find part #%d on mmc device #%d\n",

> @@ -364,9 +365,17 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu,

> char *devstr, char *s) return -ENODEV;

>  		}

>  

> +		/*

> +		 * Check for an extra entry at dfu_alt_info env

> variable

> +		 * specifying the mmc HW defined partition number

> +		 */

> +		if (s)

> +			if (!strcmp(strsep(&s, " "), "offset"))

> +				offset = simple_strtoul(s, NULL, 0);

> +

>  		dfu->layout			= DFU_RAW_ADDR;

> -		dfu->data.mmc.lba_start		=

> partinfo.start;

> -		dfu->data.mmc.lba_size		=

> partinfo.size;

> +		dfu->data.mmc.lba_start		=

> partinfo.start+offset;

> +		dfu->data.mmc.lba_size		=

> partinfo.size-offset; dfu->data.mmc.lba_blk_size	=

> partinfo.blksz; } else if (!strcmp(entity_type, "fat")) {

>  		dfu->layout = DFU_FS_FAT;


Acked-by: Lukasz Majewski <lukma@denx.de>



Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
diff mbox series

Patch

diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index b45e6dc54c..826e70ffec 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -357,6 +357,7 @@  int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
 		struct blk_desc *blk_dev = mmc_get_blk_desc(mmc);
 		int mmcdev = second_arg;
 		int mmcpart = third_arg;
+		int offset = 0;
 
 		if (part_get_info(blk_dev, mmcpart, &partinfo) != 0) {
 			pr_err("Couldn't find part #%d on mmc device #%d\n",
@@ -364,9 +365,17 @@  int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
 			return -ENODEV;
 		}
 
+		/*
+		 * Check for an extra entry at dfu_alt_info env variable
+		 * specifying the mmc HW defined partition number
+		 */
+		if (s)
+			if (!strcmp(strsep(&s, " "), "offset"))
+				offset = simple_strtoul(s, NULL, 0);
+
 		dfu->layout			= DFU_RAW_ADDR;
-		dfu->data.mmc.lba_start		= partinfo.start;
-		dfu->data.mmc.lba_size		= partinfo.size;
+		dfu->data.mmc.lba_start		= partinfo.start+offset;
+		dfu->data.mmc.lba_size		= partinfo.size-offset;
 		dfu->data.mmc.lba_blk_size	= partinfo.blksz;
 	} else if (!strcmp(entity_type, "fat")) {
 		dfu->layout = DFU_FS_FAT;