All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/6] Enable SYS_64BIT_LBA flag for STM32MP
@ 2024-11-29 12:27 Patrice Chotard
  2024-11-29 12:27 ` [PATCH v1 1/6] fastboot: Fix warning when CONFIG_SYS_64BIT_LBA is enable Patrice Chotard
                   ` (5 more replies)
  0 siblings, 6 replies; 21+ messages in thread
From: Patrice Chotard @ 2024-11-29 12:27 UTC (permalink / raw)
  To: u-boot
  Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32,
	Heinrich Schuchardt, Igor Opaniuk, Ilias Apalodimas,
	Jerome Forissier, Mattijs Korpershoek, Simon Glass, Sughosh Ganu,
	Tom Rini

Enable SYS_64BIT_LBA flag in order to fix issue when flashing
big binary using stm32prog.

Patrice Chotard (6):
  fastboot: Fix warning when CONFIG_SYS_64BIT_LBA is enable
  arm: stm32mp: stm32prog: fix warning when CONFIG_SYS_64BIT_LBA is
    enable
  arm: stm32mp: stm32prog: update multiplier is part-size is above SZ_1G
  configs: stm32mp13: enable CONFIG_SYS_64BIT_LBA
  configs: stm32mp15: enable CONFIG_SYS_64BIT_LBA
  configs: stm32mp25: enable CONFIG_SYS_64BIT_LBA

 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 9 ++++++---
 configs/stm32mp13_defconfig                     | 1 +
 configs/stm32mp15_basic_defconfig               | 1 +
 configs/stm32mp15_defconfig                     | 1 +
 configs/stm32mp15_trusted_defconfig             | 1 +
 configs/stm32mp25_defconfig                     | 1 +
 drivers/fastboot/fb_mmc.c                       | 8 ++++----
 7 files changed, 15 insertions(+), 7 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v1 1/6] fastboot: Fix warning when CONFIG_SYS_64BIT_LBA is enable
  2024-11-29 12:27 [PATCH v1 0/6] Enable SYS_64BIT_LBA flag for STM32MP Patrice Chotard
@ 2024-11-29 12:27 ` Patrice Chotard
  2024-12-03  9:46   ` Mattijs Korpershoek
  2025-01-08 18:48   ` Patrick DELAUNAY
  2024-11-29 12:27 ` [PATCH v1 2/6] arm: stm32mp: stm32prog: fix " Patrice Chotard
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 21+ messages in thread
From: Patrice Chotard @ 2024-11-29 12:27 UTC (permalink / raw)
  To: u-boot
  Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32,
	Mattijs Korpershoek, Tom Rini

If CONFIG_SYS_64BIT_LBA is enable, following compilation warning is
triggered:

 CC      drivers/fastboot/fb_mmc.o
../drivers/fastboot/fb_mmc.c: In function 'fb_mmc_erase_mmc_hwpart':
../drivers/fastboot/fb_mmc.c:215:35: warning: format '%lu' expects
argument of type 'long unsigned int', but argument 2 has type
'long long unsigned int' [-Wformat=]
  215 |         printf("........ erased %lu bytes from mmc hwpart[%u]\n",
      |                                 ~~^
      |                                   |
      |                                   long unsigned int
      |                                 %llu
  216 |                dev_desc->lba * dev_desc->blksz, dev_desc->hwpart);
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                              |
      |                              long long unsigned int
../drivers/fastboot/fb_mmc.c: In function 'fb_mmc_boot_ops':
../drivers/fastboot/fb_mmc.c:261:42: warning: format '%lu' expects
argument of type 'long unsigned int', but argument 2 has type
'long long unsigned int' [-Wformat=]
  261 |                 printf("........ wrote %lu bytes to EMMC_BOOT%d\n",
      |                                        ~~^
      |                                          |
      |                                          long unsigned int
      |                                        %llu
  262 |                        blkcnt * blksz, hwpart);
      |                        ~~~~~~~~~~~~~~
      |                               |
      |                               long long unsigned int

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---

 drivers/fastboot/fb_mmc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index f11eb66761b..dca7c222f35 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -211,8 +211,8 @@ static int fb_mmc_erase_mmc_hwpart(struct blk_desc *dev_desc)
 		return 1;
 	}
 
-	printf("........ erased %lu bytes from mmc hwpart[%u]\n",
-	       dev_desc->lba * dev_desc->blksz, dev_desc->hwpart);
+	printf("........ erased %llu bytes from mmc hwpart[%u]\n",
+	       (u64)(dev_desc->lba * dev_desc->blksz), dev_desc->hwpart);
 
 	return 0;
 }
@@ -257,8 +257,8 @@ static void fb_mmc_boot_ops(struct blk_desc *dev_desc, void *buffer,
 			return;
 		}
 
-		printf("........ wrote %lu bytes to EMMC_BOOT%d\n",
-		       blkcnt * blksz, hwpart);
+		printf("........ wrote %llu bytes to EMMC_BOOT%d\n",
+		       (u64)(blkcnt * blksz), hwpart);
 	} else { /* erase */
 		if (fb_mmc_erase_mmc_hwpart(dev_desc)) {
 			pr_err("Failed to erase EMMC_BOOT%d\n", hwpart);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v1 2/6] arm: stm32mp: stm32prog: fix warning when CONFIG_SYS_64BIT_LBA is enable
  2024-11-29 12:27 [PATCH v1 0/6] Enable SYS_64BIT_LBA flag for STM32MP Patrice Chotard
  2024-11-29 12:27 ` [PATCH v1 1/6] fastboot: Fix warning when CONFIG_SYS_64BIT_LBA is enable Patrice Chotard
@ 2024-11-29 12:27 ` Patrice Chotard
  2025-01-08 18:48   ` Patrick DELAUNAY
  2024-11-29 12:27 ` [PATCH v1 3/6] arm: stm32mp: stm32prog: update multiplier is part-size is above SZ_1G Patrice Chotard
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 21+ messages in thread
From: Patrice Chotard @ 2024-11-29 12:27 UTC (permalink / raw)
  To: u-boot; +Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32, Tom Rini

If CONFIG_SYS_64BIT_LBA flag is enable, following warning is triggered:

../arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c: In function 'init_device':
../arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c:793:27: warning: format
'%ld' expects argument of type 'long int', but argument 8 has type
'lbaint_t' {aka 'long long unsigned int'} [-Wformat=]
  793 |                 log_debug("MMC %d: lba=%ld blksz=%ld\n", dev->dev_id,
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/log.h:157:21: note: in definition of macro 'pr_fmt'
  157 | #define pr_fmt(fmt) fmt
      |                     ^~~
../include/log.h:182:33: note: in expansion of macro 'log'
  182 | #define log_debug(_fmt...)      log(LOG_CATEGORY, LOGL_DEBUG, ##_fmt)
      |                                 ^~~
../arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c:793:17: note: in expansion
of macro 'log_debug'
  793 |                 log_debug("MMC %d: lba=%ld blksz=%ld\n", dev->dev_id,
      |                 ^~~~~~~~~
../arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c:793:42: note: format string
is defined here
  793 |                 log_debug("MMC %d: lba=%ld blksz=%ld\n", dev->dev_id,
      |                                        ~~^
      |                                          |
      |                                          long int
      |                                        %lld

Cast block_dev->lba to u64 and set the length specifier to %lld which
is ok with or without CONFIG_SYS_64BIT_LBA flag.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---

 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index 393f9a1b411..f0e019e8da1 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -790,8 +790,8 @@ static int init_device(struct stm32prog_data *data,
 			last_addr = (u64)(block_dev->lba - GPT_HEADER_SZ - 1) *
 				    block_dev->blksz;
 		}
-		log_debug("MMC %d: lba=%ld blksz=%ld\n", dev->dev_id,
-			  block_dev->lba, block_dev->blksz);
+		log_debug("MMC %d: lba=%lld blksz=%ld\n", dev->dev_id,
+			  (u64)block_dev->lba, block_dev->blksz);
 		log_debug(" available address = 0x%llx..0x%llx\n",
 			  first_addr, last_addr);
 		log_debug(" full_update = %d\n", dev->full_update);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v1 3/6] arm: stm32mp: stm32prog: update multiplier is part-size is above SZ_1G
  2024-11-29 12:27 [PATCH v1 0/6] Enable SYS_64BIT_LBA flag for STM32MP Patrice Chotard
  2024-11-29 12:27 ` [PATCH v1 1/6] fastboot: Fix warning when CONFIG_SYS_64BIT_LBA is enable Patrice Chotard
  2024-11-29 12:27 ` [PATCH v1 2/6] arm: stm32mp: stm32prog: fix " Patrice Chotard
@ 2024-11-29 12:27 ` Patrice Chotard
  2025-01-08 18:49   ` Patrick DELAUNAY
  2024-11-29 12:27 ` [PATCH v1 4/6] configs: stm32mp13: enable CONFIG_SYS_64BIT_LBA Patrice Chotard
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 21+ messages in thread
From: Patrice Chotard @ 2024-11-29 12:27 UTC (permalink / raw)
  To: u-boot; +Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32, Tom Rini

Set multiplier to 'G' if part->size if above SZ_1G.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---

 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index f0e019e8da1..353aecc09de 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -1229,7 +1229,10 @@ static int stm32prog_alt_add(struct stm32prog_data *data,
 	char multiplier,  type;
 
 	/* max 3 digit for sector size */
-	if (part->size > SZ_1M) {
+	if (part->size > SZ_1G) {
+		size = (u32)(part->size / SZ_1G);
+		multiplier = 'G';
+	} else if (part->size > SZ_1M) {
 		size = (u32)(part->size / SZ_1M);
 		multiplier = 'M';
 	} else if (part->size > SZ_1K) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v1 4/6] configs: stm32mp13: enable CONFIG_SYS_64BIT_LBA
  2024-11-29 12:27 [PATCH v1 0/6] Enable SYS_64BIT_LBA flag for STM32MP Patrice Chotard
                   ` (2 preceding siblings ...)
  2024-11-29 12:27 ` [PATCH v1 3/6] arm: stm32mp: stm32prog: update multiplier is part-size is above SZ_1G Patrice Chotard
@ 2024-11-29 12:27 ` Patrice Chotard
  2025-01-08 18:49   ` Patrick DELAUNAY
  2024-11-29 12:27 ` [PATCH v1 5/6] configs: stm32mp15: " Patrice Chotard
  2024-11-29 12:27 ` [PATCH v1 6/6] configs: stm32mp25: " Patrice Chotard
  5 siblings, 1 reply; 21+ messages in thread
From: Patrice Chotard @ 2024-11-29 12:27 UTC (permalink / raw)
  To: u-boot
  Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32, Igor Opaniuk,
	Simon Glass, Sughosh Ganu, Tom Rini

In arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c, in init_device(),
in case of RAW_IMAGE, part->size = block_dev->lba * block_dev->blksz.

  _ part->size is declared as u64.
  _ block_dev->lba is declared as lbaint_t which is uint64_t
    if CONFIG_SYS_64BIT_LBA is enable, otherwise ulong.
  _ block_dev->blksz is declared as unsigned long.

For example, in case block_dev->lba = 0x1dacc00, block_dev->blksz = 0x200
then part->size 0x5980000 which is incorrect as both are declared as ulong.

To fix this overflow issue, enable CONFIG_SYS_64BIT_LBA, block_dev->lba is
then declared as uint64_t and part->size get the correct value 0x3b5980000.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---

 configs/stm32mp13_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/stm32mp13_defconfig b/configs/stm32mp13_defconfig
index 7f705808089..e4c92e851e1 100644
--- a/configs/stm32mp13_defconfig
+++ b/configs/stm32mp13_defconfig
@@ -54,6 +54,7 @@ CONFIG_SYS_MMC_ENV_DEV=-1
 CONFIG_ENV_MMC_USE_DT=y
 CONFIG_BUTTON=y
 CONFIG_BUTTON_GPIO=y
+CONFIG_SYS_64BIT_LBA=y
 CONFIG_CLK_SCMI=y
 CONFIG_SET_DFU_ALT_INFO=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v1 5/6] configs: stm32mp15: enable CONFIG_SYS_64BIT_LBA
  2024-11-29 12:27 [PATCH v1 0/6] Enable SYS_64BIT_LBA flag for STM32MP Patrice Chotard
                   ` (3 preceding siblings ...)
  2024-11-29 12:27 ` [PATCH v1 4/6] configs: stm32mp13: enable CONFIG_SYS_64BIT_LBA Patrice Chotard
@ 2024-11-29 12:27 ` Patrice Chotard
  2025-01-08 18:49   ` Patrick DELAUNAY
  2024-11-29 12:27 ` [PATCH v1 6/6] configs: stm32mp25: " Patrice Chotard
  5 siblings, 1 reply; 21+ messages in thread
From: Patrice Chotard @ 2024-11-29 12:27 UTC (permalink / raw)
  To: u-boot
  Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32, Ilias Apalodimas,
	Simon Glass, Sughosh Ganu, Tom Rini

In arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c, in init_device(),
in case of RAW_IMAGE, part->size = block_dev->lba * block_dev->blksz.

  _ part->size is declared as u64.
  _ block_dev->lba is declared as lbaint_t which is uint64_t
    if CONFIG_SYS_64BIT_LBA is enable, otherwise ulong.
  _ block_dev->blksz is declared as unsigned long.

For example, in case block_dev->lba = 0x1dacc00, block_dev->blksz = 0x200
then part->size 0x5980000 which is incorrect as both are declared as ulong.

To fix this overflow issue, enable CONFIG_SYS_64BIT_LBA, block_dev->lba is
then declared as uint64_t and part->size get the correct value 0x3b5980000.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---

 configs/stm32mp15_basic_defconfig   | 1 +
 configs/stm32mp15_defconfig         | 1 +
 configs/stm32mp15_trusted_defconfig | 1 +
 3 files changed, 3 insertions(+)

diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig
index 1c0d0d0a073..a8861faab0e 100644
--- a/configs/stm32mp15_basic_defconfig
+++ b/configs/stm32mp15_basic_defconfig
@@ -95,6 +95,7 @@ CONFIG_TFTP_TSIZE=y
 CONFIG_USE_SERVERIP=y
 CONFIG_SERVERIP="192.168.1.1"
 CONFIG_STM32_ADC=y
+CONFIG_SYS_64BIT_LBA=y
 CONFIG_BUTTON=y
 CONFIG_BUTTON_GPIO=y
 CONFIG_SET_DFU_ALT_INFO=y
diff --git a/configs/stm32mp15_defconfig b/configs/stm32mp15_defconfig
index f58a514308b..d31349e3f2b 100644
--- a/configs/stm32mp15_defconfig
+++ b/configs/stm32mp15_defconfig
@@ -69,6 +69,7 @@ CONFIG_TFTP_TSIZE=y
 CONFIG_USE_SERVERIP=y
 CONFIG_SERVERIP="192.168.1.1"
 CONFIG_STM32_ADC=y
+CONFIG_SYS_64BIT_LBA=y
 CONFIG_BUTTON=y
 CONFIG_BUTTON_GPIO=y
 CONFIG_CLK_SCMI=y
diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig
index 2e99b8e6a85..1f807f37c69 100644
--- a/configs/stm32mp15_trusted_defconfig
+++ b/configs/stm32mp15_trusted_defconfig
@@ -70,6 +70,7 @@ CONFIG_TFTP_TSIZE=y
 CONFIG_USE_SERVERIP=y
 CONFIG_SERVERIP="192.168.1.1"
 CONFIG_STM32_ADC=y
+CONFIG_SYS_64BIT_LBA=y
 CONFIG_BUTTON=y
 CONFIG_BUTTON_GPIO=y
 CONFIG_CLK_SCMI=y
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v1 6/6] configs: stm32mp25: enable CONFIG_SYS_64BIT_LBA
  2024-11-29 12:27 [PATCH v1 0/6] Enable SYS_64BIT_LBA flag for STM32MP Patrice Chotard
                   ` (4 preceding siblings ...)
  2024-11-29 12:27 ` [PATCH v1 5/6] configs: stm32mp15: " Patrice Chotard
@ 2024-11-29 12:27 ` Patrice Chotard
  2025-01-08 18:50   ` Patrick DELAUNAY
  5 siblings, 1 reply; 21+ messages in thread
From: Patrice Chotard @ 2024-11-29 12:27 UTC (permalink / raw)
  To: u-boot
  Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Sughosh Ganu, Tom Rini

In arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c, in init_device(),
in case of RAW_IMAGE, part->size = block_dev->lba * block_dev->blksz.

  _ part->size is declared as u64.
  _ block_dev->lba is declared as lbaint_t which is uint64_t
    if CONFIG_SYS_64BIT_LBA is enable, otherwise ulong.
  _ block_dev->blksz is declared as unsigned long.

For example, in case block_dev->lba = 0x1dacc00, block_dev->blksz = 0x200
then part->size 0x5980000 which is incorrect as both are declared as ulong.

To fix this overflow issue, enable CONFIG_SYS_64BIT_LBA, block_dev->lba is
then declared as uint64_t and part->size get the correct value 0x3b5980000.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
---

 configs/stm32mp25_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/stm32mp25_defconfig b/configs/stm32mp25_defconfig
index d3f0c088157..073172c3804 100644
--- a/configs/stm32mp25_defconfig
+++ b/configs/stm32mp25_defconfig
@@ -33,6 +33,7 @@ CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_LOG=y
 CONFIG_OF_LIVE=y
 CONFIG_NO_NET=y
+CONFIG_SYS_64BIT_LBA=y
 CONFIG_GPIO_HOG=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_STM32F7=y
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH v1 1/6] fastboot: Fix warning when CONFIG_SYS_64BIT_LBA is enable
  2024-11-29 12:27 ` [PATCH v1 1/6] fastboot: Fix warning when CONFIG_SYS_64BIT_LBA is enable Patrice Chotard
@ 2024-12-03  9:46   ` Mattijs Korpershoek
  2025-01-08 18:48   ` Patrick DELAUNAY
  1 sibling, 0 replies; 21+ messages in thread
From: Mattijs Korpershoek @ 2024-12-03  9:46 UTC (permalink / raw)
  To: Patrice Chotard, u-boot
  Cc: Patrice CHOTARD, Patrick DELAUNAY, U-Boot STM32, Tom Rini

Hi Patrice,

Thank you for the patch.

On ven., nov. 29, 2024 at 13:27, Patrice Chotard <patrice.chotard@foss.st.com> wrote:

> If CONFIG_SYS_64BIT_LBA is enable, following compilation warning is
> triggered:
>
>  CC      drivers/fastboot/fb_mmc.o
> ../drivers/fastboot/fb_mmc.c: In function 'fb_mmc_erase_mmc_hwpart':
> ../drivers/fastboot/fb_mmc.c:215:35: warning: format '%lu' expects
> argument of type 'long unsigned int', but argument 2 has type
> 'long long unsigned int' [-Wformat=]
>   215 |         printf("........ erased %lu bytes from mmc hwpart[%u]\n",
>       |                                 ~~^
>       |                                   |
>       |                                   long unsigned int
>       |                                 %llu
>   216 |                dev_desc->lba * dev_desc->blksz, dev_desc->hwpart);
>       |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>       |                              |
>       |                              long long unsigned int
> ../drivers/fastboot/fb_mmc.c: In function 'fb_mmc_boot_ops':
> ../drivers/fastboot/fb_mmc.c:261:42: warning: format '%lu' expects
> argument of type 'long unsigned int', but argument 2 has type
> 'long long unsigned int' [-Wformat=]
>   261 |                 printf("........ wrote %lu bytes to EMMC_BOOT%d\n",
>       |                                        ~~^
>       |                                          |
>       |                                          long unsigned int
>       |                                        %llu
>   262 |                        blkcnt * blksz, hwpart);
>       |                        ~~~~~~~~~~~~~~
>       |                               |
>       |                               long long unsigned int
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

Please feel free to take this through your tree.

Acked-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

> ---
>
>  drivers/fastboot/fb_mmc.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
> index f11eb66761b..dca7c222f35 100644
> --- a/drivers/fastboot/fb_mmc.c
> +++ b/drivers/fastboot/fb_mmc.c
> @@ -211,8 +211,8 @@ static int fb_mmc_erase_mmc_hwpart(struct blk_desc *dev_desc)
>  		return 1;
>  	}
>  
> -	printf("........ erased %lu bytes from mmc hwpart[%u]\n",
> -	       dev_desc->lba * dev_desc->blksz, dev_desc->hwpart);
> +	printf("........ erased %llu bytes from mmc hwpart[%u]\n",
> +	       (u64)(dev_desc->lba * dev_desc->blksz), dev_desc->hwpart);
>  
>  	return 0;
>  }
> @@ -257,8 +257,8 @@ static void fb_mmc_boot_ops(struct blk_desc *dev_desc, void *buffer,
>  			return;
>  		}
>  
> -		printf("........ wrote %lu bytes to EMMC_BOOT%d\n",
> -		       blkcnt * blksz, hwpart);
> +		printf("........ wrote %llu bytes to EMMC_BOOT%d\n",
> +		       (u64)(blkcnt * blksz), hwpart);
>  	} else { /* erase */
>  		if (fb_mmc_erase_mmc_hwpart(dev_desc)) {
>  			pr_err("Failed to erase EMMC_BOOT%d\n", hwpart);
> -- 
> 2.25.1

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v1 1/6] fastboot: Fix warning when CONFIG_SYS_64BIT_LBA is enable
  2024-11-29 12:27 ` [PATCH v1 1/6] fastboot: Fix warning when CONFIG_SYS_64BIT_LBA is enable Patrice Chotard
  2024-12-03  9:46   ` Mattijs Korpershoek
@ 2025-01-08 18:48   ` Patrick DELAUNAY
  2025-01-31  7:56     ` Patrice CHOTARD
  1 sibling, 1 reply; 21+ messages in thread
From: Patrick DELAUNAY @ 2025-01-08 18:48 UTC (permalink / raw)
  To: Patrice Chotard, u-boot; +Cc: U-Boot STM32, Mattijs Korpershoek, Tom Rini

Hi,

On 11/29/24 13:27, Patrice Chotard wrote:
> If CONFIG_SYS_64BIT_LBA is enable, following compilation warning is
> triggered:
>
>   CC      drivers/fastboot/fb_mmc.o
> ../drivers/fastboot/fb_mmc.c: In function 'fb_mmc_erase_mmc_hwpart':
> ../drivers/fastboot/fb_mmc.c:215:35: warning: format '%lu' expects
> argument of type 'long unsigned int', but argument 2 has type
> 'long long unsigned int' [-Wformat=]
>    215 |         printf("........ erased %lu bytes from mmc hwpart[%u]\n",
>        |                                 ~~^
>        |                                   |
>        |                                   long unsigned int
>        |                                 %llu
>    216 |                dev_desc->lba * dev_desc->blksz, dev_desc->hwpart);
>        |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>        |                              |
>        |                              long long unsigned int
> ../drivers/fastboot/fb_mmc.c: In function 'fb_mmc_boot_ops':
> ../drivers/fastboot/fb_mmc.c:261:42: warning: format '%lu' expects
> argument of type 'long unsigned int', but argument 2 has type
> 'long long unsigned int' [-Wformat=]
>    261 |                 printf("........ wrote %lu bytes to EMMC_BOOT%d\n",
>        |                                        ~~^
>        |                                          |
>        |                                          long unsigned int
>        |                                        %llu
>    262 |                        blkcnt * blksz, hwpart);
>        |                        ~~~~~~~~~~~~~~
>        |                               |
>        |                               long long unsigned int
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
>   drivers/fastboot/fb_mmc.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>


Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v1 2/6] arm: stm32mp: stm32prog: fix warning when CONFIG_SYS_64BIT_LBA is enable
  2024-11-29 12:27 ` [PATCH v1 2/6] arm: stm32mp: stm32prog: fix " Patrice Chotard
@ 2025-01-08 18:48   ` Patrick DELAUNAY
  2025-01-31  7:56     ` Patrice CHOTARD
  0 siblings, 1 reply; 21+ messages in thread
From: Patrick DELAUNAY @ 2025-01-08 18:48 UTC (permalink / raw)
  To: Patrice Chotard, u-boot; +Cc: U-Boot STM32, Tom Rini

Hi,

On 11/29/24 13:27, Patrice Chotard wrote:
> If CONFIG_SYS_64BIT_LBA flag is enable, following warning is triggered:
>
> ../arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c: In function 'init_device':
> ../arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c:793:27: warning: format
> '%ld' expects argument of type 'long int', but argument 8 has type
> 'lbaint_t' {aka 'long long unsigned int'} [-Wformat=]
>    793 |                 log_debug("MMC %d: lba=%ld blksz=%ld\n", dev->dev_id,
>        |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../include/log.h:157:21: note: in definition of macro 'pr_fmt'
>    157 | #define pr_fmt(fmt) fmt
>        |                     ^~~
> ../include/log.h:182:33: note: in expansion of macro 'log'
>    182 | #define log_debug(_fmt...)      log(LOG_CATEGORY, LOGL_DEBUG, ##_fmt)
>        |                                 ^~~
> ../arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c:793:17: note: in expansion
> of macro 'log_debug'
>    793 |                 log_debug("MMC %d: lba=%ld blksz=%ld\n", dev->dev_id,
>        |                 ^~~~~~~~~
> ../arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c:793:42: note: format string
> is defined here
>    793 |                 log_debug("MMC %d: lba=%ld blksz=%ld\n", dev->dev_id,
>        |                                        ~~^
>        |                                          |
>        |                                          long int
>        |                                        %lld
>
> Cast block_dev->lba to u64 and set the length specifier to %lld which
> is ok with or without CONFIG_SYS_64BIT_LBA flag.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
>   arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>


Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v1 3/6] arm: stm32mp: stm32prog: update multiplier is part-size is above SZ_1G
  2024-11-29 12:27 ` [PATCH v1 3/6] arm: stm32mp: stm32prog: update multiplier is part-size is above SZ_1G Patrice Chotard
@ 2025-01-08 18:49   ` Patrick DELAUNAY
  2025-01-31  7:56     ` Patrice CHOTARD
  0 siblings, 1 reply; 21+ messages in thread
From: Patrick DELAUNAY @ 2025-01-08 18:49 UTC (permalink / raw)
  To: Patrice Chotard, u-boot; +Cc: U-Boot STM32, Tom Rini

Hi

On 11/29/24 13:27, Patrice Chotard wrote:
> Set multiplier to 'G' if part->size if above SZ_1G.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
>   arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> index f0e019e8da1..353aecc09de 100644
> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> @@ -1229,7 +1229,10 @@ static int stm32prog_alt_add(struct stm32prog_data *data,
>   	char multiplier,  type;
>   
>   	/* max 3 digit for sector size */
> -	if (part->size > SZ_1M) {
> +	if (part->size > SZ_1G) {
> +		size = (u32)(part->size / SZ_1G);
> +		multiplier = 'G';
> +	} else if (part->size > SZ_1M) {
>   		size = (u32)(part->size / SZ_1M);
>   		multiplier = 'M';
>   	} else if (part->size > SZ_1K) {



Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v1 4/6] configs: stm32mp13: enable CONFIG_SYS_64BIT_LBA
  2024-11-29 12:27 ` [PATCH v1 4/6] configs: stm32mp13: enable CONFIG_SYS_64BIT_LBA Patrice Chotard
@ 2025-01-08 18:49   ` Patrick DELAUNAY
  2025-01-31  7:57     ` Patrice CHOTARD
  0 siblings, 1 reply; 21+ messages in thread
From: Patrick DELAUNAY @ 2025-01-08 18:49 UTC (permalink / raw)
  To: Patrice Chotard, u-boot
  Cc: U-Boot STM32, Igor Opaniuk, Simon Glass, Sughosh Ganu, Tom Rini

Hi,

On 11/29/24 13:27, Patrice Chotard wrote:
> In arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c, in init_device(),
> in case of RAW_IMAGE, part->size = block_dev->lba * block_dev->blksz.
>
>    _ part->size is declared as u64.
>    _ block_dev->lba is declared as lbaint_t which is uint64_t
>      if CONFIG_SYS_64BIT_LBA is enable, otherwise ulong.
>    _ block_dev->blksz is declared as unsigned long.
>
> For example, in case block_dev->lba = 0x1dacc00, block_dev->blksz = 0x200
> then part->size 0x5980000 which is incorrect as both are declared as ulong.
>
> To fix this overflow issue, enable CONFIG_SYS_64BIT_LBA, block_dev->lba is
> then declared as uint64_t and part->size get the correct value 0x3b5980000.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
>   configs/stm32mp13_defconfig | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/configs/stm32mp13_defconfig b/configs/stm32mp13_defconfig
> index 7f705808089..e4c92e851e1 100644
> --- a/configs/stm32mp13_defconfig
> +++ b/configs/stm32mp13_defconfig
> @@ -54,6 +54,7 @@ CONFIG_SYS_MMC_ENV_DEV=-1
>   CONFIG_ENV_MMC_USE_DT=y
>   CONFIG_BUTTON=y
>   CONFIG_BUTTON_GPIO=y
> +CONFIG_SYS_64BIT_LBA=y
>   CONFIG_CLK_SCMI=y
>   CONFIG_SET_DFU_ALT_INFO=y
>   CONFIG_USB_FUNCTION_FASTBOOT=y

Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v1 5/6] configs: stm32mp15: enable CONFIG_SYS_64BIT_LBA
  2024-11-29 12:27 ` [PATCH v1 5/6] configs: stm32mp15: " Patrice Chotard
@ 2025-01-08 18:49   ` Patrick DELAUNAY
  2025-01-31  7:57     ` Patrice CHOTARD
  0 siblings, 1 reply; 21+ messages in thread
From: Patrick DELAUNAY @ 2025-01-08 18:49 UTC (permalink / raw)
  To: Patrice Chotard, u-boot
  Cc: U-Boot STM32, Ilias Apalodimas, Simon Glass, Sughosh Ganu,
	Tom Rini

Hi,

On 11/29/24 13:27, Patrice Chotard wrote:
> In arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c, in init_device(),
> in case of RAW_IMAGE, part->size = block_dev->lba * block_dev->blksz.
>
>    _ part->size is declared as u64.
>    _ block_dev->lba is declared as lbaint_t which is uint64_t
>      if CONFIG_SYS_64BIT_LBA is enable, otherwise ulong.
>    _ block_dev->blksz is declared as unsigned long.
>
> For example, in case block_dev->lba = 0x1dacc00, block_dev->blksz = 0x200
> then part->size 0x5980000 which is incorrect as both are declared as ulong.
>
> To fix this overflow issue, enable CONFIG_SYS_64BIT_LBA, block_dev->lba is
> then declared as uint64_t and part->size get the correct value 0x3b5980000.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
>   configs/stm32mp15_basic_defconfig   | 1 +
>   configs/stm32mp15_defconfig         | 1 +
>   configs/stm32mp15_trusted_defconfig | 1 +
>   3 files changed, 3 insertions(+)
>
> diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig
> index 1c0d0d0a073..a8861faab0e 100644
> --- a/configs/stm32mp15_basic_defconfig
> +++ b/configs/stm32mp15_basic_defconfig
> @@ -95,6 +95,7 @@ CONFIG_TFTP_TSIZE=y
>   CONFIG_USE_SERVERIP=y
>   CONFIG_SERVERIP="192.168.1.1"
>   CONFIG_STM32_ADC=y
> +CONFIG_SYS_64BIT_LBA=y
>   CONFIG_BUTTON=y
>   CONFIG_BUTTON_GPIO=y
>   CONFIG_SET_DFU_ALT_INFO=y
> diff --git a/configs/stm32mp15_defconfig b/configs/stm32mp15_defconfig
> index f58a514308b..d31349e3f2b 100644
> --- a/configs/stm32mp15_defconfig
> +++ b/configs/stm32mp15_defconfig
> @@ -69,6 +69,7 @@ CONFIG_TFTP_TSIZE=y
>   CONFIG_USE_SERVERIP=y
>   CONFIG_SERVERIP="192.168.1.1"
>   CONFIG_STM32_ADC=y
> +CONFIG_SYS_64BIT_LBA=y
>   CONFIG_BUTTON=y
>   CONFIG_BUTTON_GPIO=y
>   CONFIG_CLK_SCMI=y
> diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig
> index 2e99b8e6a85..1f807f37c69 100644
> --- a/configs/stm32mp15_trusted_defconfig
> +++ b/configs/stm32mp15_trusted_defconfig
> @@ -70,6 +70,7 @@ CONFIG_TFTP_TSIZE=y
>   CONFIG_USE_SERVERIP=y
>   CONFIG_SERVERIP="192.168.1.1"
>   CONFIG_STM32_ADC=y
> +CONFIG_SYS_64BIT_LBA=y
>   CONFIG_BUTTON=y
>   CONFIG_BUTTON_GPIO=y
>   CONFIG_CLK_SCMI=y


Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v1 6/6] configs: stm32mp25: enable CONFIG_SYS_64BIT_LBA
  2024-11-29 12:27 ` [PATCH v1 6/6] configs: stm32mp25: " Patrice Chotard
@ 2025-01-08 18:50   ` Patrick DELAUNAY
  2025-01-08 21:12     ` Heinrich Schuchardt
  2025-01-31  7:57     ` Patrice CHOTARD
  0 siblings, 2 replies; 21+ messages in thread
From: Patrick DELAUNAY @ 2025-01-08 18:50 UTC (permalink / raw)
  To: Patrice Chotard, u-boot
  Cc: U-Boot STM32, Heinrich Schuchardt, Ilias Apalodimas,
	Jerome Forissier, Sughosh Ganu, Tom Rini

Hi,

On 11/29/24 13:27, Patrice Chotard wrote:
> In arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c, in init_device(),
> in case of RAW_IMAGE, part->size = block_dev->lba * block_dev->blksz.
>
>    _ part->size is declared as u64.
>    _ block_dev->lba is declared as lbaint_t which is uint64_t
>      if CONFIG_SYS_64BIT_LBA is enable, otherwise ulong.
>    _ block_dev->blksz is declared as unsigned long.
>
> For example, in case block_dev->lba = 0x1dacc00, block_dev->blksz = 0x200
> then part->size 0x5980000 which is incorrect as both are declared as ulong.
>
> To fix this overflow issue, enable CONFIG_SYS_64BIT_LBA, block_dev->lba is
> then declared as uint64_t and part->size get the correct value 0x3b5980000.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> ---
>
>   configs/stm32mp25_defconfig | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/configs/stm32mp25_defconfig b/configs/stm32mp25_defconfig
> index d3f0c088157..073172c3804 100644
> --- a/configs/stm32mp25_defconfig
> +++ b/configs/stm32mp25_defconfig
> @@ -33,6 +33,7 @@ CONFIG_CMD_REGULATOR=y
>   CONFIG_CMD_LOG=y
>   CONFIG_OF_LIVE=y
>   CONFIG_NO_NET=y
> +CONFIG_SYS_64BIT_LBA=y
>   CONFIG_GPIO_HOG=y
>   CONFIG_DM_I2C=y
>   CONFIG_SYS_I2C_STM32F7=y



Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick




^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v1 6/6] configs: stm32mp25: enable CONFIG_SYS_64BIT_LBA
  2025-01-08 18:50   ` Patrick DELAUNAY
@ 2025-01-08 21:12     ` Heinrich Schuchardt
  2025-01-31  7:57     ` Patrice CHOTARD
  1 sibling, 0 replies; 21+ messages in thread
From: Heinrich Schuchardt @ 2025-01-08 21:12 UTC (permalink / raw)
  To: Patrick DELAUNAY, Patrice Chotard, u-boot
  Cc: U-Boot STM32, Ilias Apalodimas, Jerome Forissier, Sughosh Ganu,
	Tom Rini

Am 8. Januar 2025 19:50:07 MEZ schrieb Patrick DELAUNAY <patrick.delaunay@foss.st.com>:
>Hi,
>
>On 11/29/24 13:27, Patrice Chotard wrote:
>> In arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c, in init_device(),
>> in case of RAW_IMAGE, part->size = block_dev->lba * block_dev->blksz.
>> 
>>    _ part->size is declared as u64.
>>    _ block_dev->lba is declared as lbaint_t which is uint64_t
>>      if CONFIG_SYS_64BIT_LBA is enable, otherwise ulong.
>>    _ block_dev->blksz is declared as unsigned long.
>> 
>> For example, in case block_dev->lba = 0x1dacc00, block_dev->blksz = 0x200
>> then part->size 0x5980000 which is incorrect as both are declared as ulong.
>> 
>> To fix this overflow issue, enable CONFIG_SYS_64BIT_LBA, block_dev->lba is
>> then declared as uint64_t and part->size get the correct value 0x3b5980000.
>> 
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>> 
>>   configs/stm32mp25_defconfig | 1 +
>>   1 file changed, 1 insertion(+)
>> 
>> diff --git a/configs/stm32mp25_defconfig b/configs/stm32mp25_defconfig
>> index d3f0c088157..073172c3804 100644
>> --- a/configs/stm32mp25_defconfig
>> +++ b/configs/stm32mp25_defconfig
>> @@ -33,6 +33,7 @@ CONFIG_CMD_REGULATOR=y
>>   CONFIG_CMD_LOG=y
>>   CONFIG_OF_LIVE=y
>>   CONFIG_NO_NET=y
>> +CONFIG_SYS_64BIT_LBA=y

I wonder why we have to set this in individual defconfigs. Shouldn't this value be the global default?

Best regards

Heinrich

>>   CONFIG_GPIO_HOG=y
>>   CONFIG_DM_I2C=y
>>   CONFIG_SYS_I2C_STM32F7=y
>
>
>
>Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
>
>Thanks
>Patrick
>
>
>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v1 1/6] fastboot: Fix warning when CONFIG_SYS_64BIT_LBA is enable
  2025-01-08 18:48   ` Patrick DELAUNAY
@ 2025-01-31  7:56     ` Patrice CHOTARD
  0 siblings, 0 replies; 21+ messages in thread
From: Patrice CHOTARD @ 2025-01-31  7:56 UTC (permalink / raw)
  To: Patrick DELAUNAY, u-boot; +Cc: U-Boot STM32, Mattijs Korpershoek, Tom Rini



On 1/8/25 19:48, Patrick DELAUNAY wrote:
> Hi,
> 
> On 11/29/24 13:27, Patrice Chotard wrote:
>> If CONFIG_SYS_64BIT_LBA is enable, following compilation warning is
>> triggered:
>>
>>   CC      drivers/fastboot/fb_mmc.o
>> ../drivers/fastboot/fb_mmc.c: In function 'fb_mmc_erase_mmc_hwpart':
>> ../drivers/fastboot/fb_mmc.c:215:35: warning: format '%lu' expects
>> argument of type 'long unsigned int', but argument 2 has type
>> 'long long unsigned int' [-Wformat=]
>>    215 |         printf("........ erased %lu bytes from mmc hwpart[%u]\n",
>>        |                                 ~~^
>>        |                                   |
>>        |                                   long unsigned int
>>        |                                 %llu
>>    216 |                dev_desc->lba * dev_desc->blksz, dev_desc->hwpart);
>>        |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>        |                              |
>>        |                              long long unsigned int
>> ../drivers/fastboot/fb_mmc.c: In function 'fb_mmc_boot_ops':
>> ../drivers/fastboot/fb_mmc.c:261:42: warning: format '%lu' expects
>> argument of type 'long unsigned int', but argument 2 has type
>> 'long long unsigned int' [-Wformat=]
>>    261 |                 printf("........ wrote %lu bytes to EMMC_BOOT%d\n",
>>        |                                        ~~^
>>        |                                          |
>>        |                                          long unsigned int
>>        |                                        %llu
>>    262 |                        blkcnt * blksz, hwpart);
>>        |                        ~~~~~~~~~~~~~~
>>        |                               |
>>        |                               long long unsigned int
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>>   drivers/fastboot/fb_mmc.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
> 
> 
> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> 
> Thanks
> Patrick
> 
Applied to u-boot-stm32/master

Thanks
Patrice

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v1 2/6] arm: stm32mp: stm32prog: fix warning when CONFIG_SYS_64BIT_LBA is enable
  2025-01-08 18:48   ` Patrick DELAUNAY
@ 2025-01-31  7:56     ` Patrice CHOTARD
  0 siblings, 0 replies; 21+ messages in thread
From: Patrice CHOTARD @ 2025-01-31  7:56 UTC (permalink / raw)
  To: Patrick DELAUNAY, u-boot; +Cc: U-Boot STM32, Tom Rini



On 1/8/25 19:48, Patrick DELAUNAY wrote:
> Hi,
> 
> On 11/29/24 13:27, Patrice Chotard wrote:
>> If CONFIG_SYS_64BIT_LBA flag is enable, following warning is triggered:
>>
>> ../arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c: In function 'init_device':
>> ../arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c:793:27: warning: format
>> '%ld' expects argument of type 'long int', but argument 8 has type
>> 'lbaint_t' {aka 'long long unsigned int'} [-Wformat=]
>>    793 |                 log_debug("MMC %d: lba=%ld blksz=%ld\n", dev->dev_id,
>>        |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> ../include/log.h:157:21: note: in definition of macro 'pr_fmt'
>>    157 | #define pr_fmt(fmt) fmt
>>        |                     ^~~
>> ../include/log.h:182:33: note: in expansion of macro 'log'
>>    182 | #define log_debug(_fmt...)      log(LOG_CATEGORY, LOGL_DEBUG, ##_fmt)
>>        |                                 ^~~
>> ../arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c:793:17: note: in expansion
>> of macro 'log_debug'
>>    793 |                 log_debug("MMC %d: lba=%ld blksz=%ld\n", dev->dev_id,
>>        |                 ^~~~~~~~~
>> ../arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c:793:42: note: format string
>> is defined here
>>    793 |                 log_debug("MMC %d: lba=%ld blksz=%ld\n", dev->dev_id,
>>        |                                        ~~^
>>        |                                          |
>>        |                                          long int
>>        |                                        %lld
>>
>> Cast block_dev->lba to u64 and set the length specifier to %lld which
>> is ok with or without CONFIG_SYS_64BIT_LBA flag.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>>   arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
> 
> 
> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> 
> Thanks
> Patrick
> 
Applied to u-boot-stm32/master

Thanks
Patrice

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v1 3/6] arm: stm32mp: stm32prog: update multiplier is part-size is above SZ_1G
  2025-01-08 18:49   ` Patrick DELAUNAY
@ 2025-01-31  7:56     ` Patrice CHOTARD
  0 siblings, 0 replies; 21+ messages in thread
From: Patrice CHOTARD @ 2025-01-31  7:56 UTC (permalink / raw)
  To: Patrick DELAUNAY, u-boot; +Cc: U-Boot STM32, Tom Rini



On 1/8/25 19:49, Patrick DELAUNAY wrote:
> Hi
> 
> On 11/29/24 13:27, Patrice Chotard wrote:
>> Set multiplier to 'G' if part->size if above SZ_1G.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>>   arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
>> index f0e019e8da1..353aecc09de 100644
>> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
>> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
>> @@ -1229,7 +1229,10 @@ static int stm32prog_alt_add(struct stm32prog_data *data,
>>       char multiplier,  type;
>>         /* max 3 digit for sector size */
>> -    if (part->size > SZ_1M) {
>> +    if (part->size > SZ_1G) {
>> +        size = (u32)(part->size / SZ_1G);
>> +        multiplier = 'G';
>> +    } else if (part->size > SZ_1M) {
>>           size = (u32)(part->size / SZ_1M);
>>           multiplier = 'M';
>>       } else if (part->size > SZ_1K) {
> 
> 
> 
> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> 
> Thanks
> Patrick
> 
Applied to u-boot-stm32/master

Thanks
Patrice

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v1 4/6] configs: stm32mp13: enable CONFIG_SYS_64BIT_LBA
  2025-01-08 18:49   ` Patrick DELAUNAY
@ 2025-01-31  7:57     ` Patrice CHOTARD
  0 siblings, 0 replies; 21+ messages in thread
From: Patrice CHOTARD @ 2025-01-31  7:57 UTC (permalink / raw)
  To: Patrick DELAUNAY, u-boot
  Cc: U-Boot STM32, Igor Opaniuk, Simon Glass, Sughosh Ganu, Tom Rini



On 1/8/25 19:49, Patrick DELAUNAY wrote:
> Hi,
> 
> On 11/29/24 13:27, Patrice Chotard wrote:
>> In arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c, in init_device(),
>> in case of RAW_IMAGE, part->size = block_dev->lba * block_dev->blksz.
>>
>>    _ part->size is declared as u64.
>>    _ block_dev->lba is declared as lbaint_t which is uint64_t
>>      if CONFIG_SYS_64BIT_LBA is enable, otherwise ulong.
>>    _ block_dev->blksz is declared as unsigned long.
>>
>> For example, in case block_dev->lba = 0x1dacc00, block_dev->blksz = 0x200
>> then part->size 0x5980000 which is incorrect as both are declared as ulong.
>>
>> To fix this overflow issue, enable CONFIG_SYS_64BIT_LBA, block_dev->lba is
>> then declared as uint64_t and part->size get the correct value 0x3b5980000.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>>   configs/stm32mp13_defconfig | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/configs/stm32mp13_defconfig b/configs/stm32mp13_defconfig
>> index 7f705808089..e4c92e851e1 100644
>> --- a/configs/stm32mp13_defconfig
>> +++ b/configs/stm32mp13_defconfig
>> @@ -54,6 +54,7 @@ CONFIG_SYS_MMC_ENV_DEV=-1
>>   CONFIG_ENV_MMC_USE_DT=y
>>   CONFIG_BUTTON=y
>>   CONFIG_BUTTON_GPIO=y
>> +CONFIG_SYS_64BIT_LBA=y
>>   CONFIG_CLK_SCMI=y
>>   CONFIG_SET_DFU_ALT_INFO=y
>>   CONFIG_USB_FUNCTION_FASTBOOT=y
> 
> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> 
> Thanks
> Patrick
> 
Applied to u-boot-stm32/master

Thanks
Patrice

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v1 5/6] configs: stm32mp15: enable CONFIG_SYS_64BIT_LBA
  2025-01-08 18:49   ` Patrick DELAUNAY
@ 2025-01-31  7:57     ` Patrice CHOTARD
  0 siblings, 0 replies; 21+ messages in thread
From: Patrice CHOTARD @ 2025-01-31  7:57 UTC (permalink / raw)
  To: Patrick DELAUNAY, u-boot
  Cc: U-Boot STM32, Ilias Apalodimas, Simon Glass, Sughosh Ganu,
	Tom Rini



On 1/8/25 19:49, Patrick DELAUNAY wrote:
> Hi,
> 
> On 11/29/24 13:27, Patrice Chotard wrote:
>> In arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c, in init_device(),
>> in case of RAW_IMAGE, part->size = block_dev->lba * block_dev->blksz.
>>
>>    _ part->size is declared as u64.
>>    _ block_dev->lba is declared as lbaint_t which is uint64_t
>>      if CONFIG_SYS_64BIT_LBA is enable, otherwise ulong.
>>    _ block_dev->blksz is declared as unsigned long.
>>
>> For example, in case block_dev->lba = 0x1dacc00, block_dev->blksz = 0x200
>> then part->size 0x5980000 which is incorrect as both are declared as ulong.
>>
>> To fix this overflow issue, enable CONFIG_SYS_64BIT_LBA, block_dev->lba is
>> then declared as uint64_t and part->size get the correct value 0x3b5980000.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>>   configs/stm32mp15_basic_defconfig   | 1 +
>>   configs/stm32mp15_defconfig         | 1 +
>>   configs/stm32mp15_trusted_defconfig | 1 +
>>   3 files changed, 3 insertions(+)
>>
>> diff --git a/configs/stm32mp15_basic_defconfig b/configs/stm32mp15_basic_defconfig
>> index 1c0d0d0a073..a8861faab0e 100644
>> --- a/configs/stm32mp15_basic_defconfig
>> +++ b/configs/stm32mp15_basic_defconfig
>> @@ -95,6 +95,7 @@ CONFIG_TFTP_TSIZE=y
>>   CONFIG_USE_SERVERIP=y
>>   CONFIG_SERVERIP="192.168.1.1"
>>   CONFIG_STM32_ADC=y
>> +CONFIG_SYS_64BIT_LBA=y
>>   CONFIG_BUTTON=y
>>   CONFIG_BUTTON_GPIO=y
>>   CONFIG_SET_DFU_ALT_INFO=y
>> diff --git a/configs/stm32mp15_defconfig b/configs/stm32mp15_defconfig
>> index f58a514308b..d31349e3f2b 100644
>> --- a/configs/stm32mp15_defconfig
>> +++ b/configs/stm32mp15_defconfig
>> @@ -69,6 +69,7 @@ CONFIG_TFTP_TSIZE=y
>>   CONFIG_USE_SERVERIP=y
>>   CONFIG_SERVERIP="192.168.1.1"
>>   CONFIG_STM32_ADC=y
>> +CONFIG_SYS_64BIT_LBA=y
>>   CONFIG_BUTTON=y
>>   CONFIG_BUTTON_GPIO=y
>>   CONFIG_CLK_SCMI=y
>> diff --git a/configs/stm32mp15_trusted_defconfig b/configs/stm32mp15_trusted_defconfig
>> index 2e99b8e6a85..1f807f37c69 100644
>> --- a/configs/stm32mp15_trusted_defconfig
>> +++ b/configs/stm32mp15_trusted_defconfig
>> @@ -70,6 +70,7 @@ CONFIG_TFTP_TSIZE=y
>>   CONFIG_USE_SERVERIP=y
>>   CONFIG_SERVERIP="192.168.1.1"
>>   CONFIG_STM32_ADC=y
>> +CONFIG_SYS_64BIT_LBA=y
>>   CONFIG_BUTTON=y
>>   CONFIG_BUTTON_GPIO=y
>>   CONFIG_CLK_SCMI=y
> 
> 
> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> 
> Thanks
> Patrick
> 
Applied to u-boot-stm32/master

Thanks
Patrice

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v1 6/6] configs: stm32mp25: enable CONFIG_SYS_64BIT_LBA
  2025-01-08 18:50   ` Patrick DELAUNAY
  2025-01-08 21:12     ` Heinrich Schuchardt
@ 2025-01-31  7:57     ` Patrice CHOTARD
  1 sibling, 0 replies; 21+ messages in thread
From: Patrice CHOTARD @ 2025-01-31  7:57 UTC (permalink / raw)
  To: Patrick DELAUNAY, u-boot
  Cc: U-Boot STM32, Heinrich Schuchardt, Ilias Apalodimas,
	Jerome Forissier, Sughosh Ganu, Tom Rini



On 1/8/25 19:50, Patrick DELAUNAY wrote:
> Hi,
> 
> On 11/29/24 13:27, Patrice Chotard wrote:
>> In arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c, in init_device(),
>> in case of RAW_IMAGE, part->size = block_dev->lba * block_dev->blksz.
>>
>>    _ part->size is declared as u64.
>>    _ block_dev->lba is declared as lbaint_t which is uint64_t
>>      if CONFIG_SYS_64BIT_LBA is enable, otherwise ulong.
>>    _ block_dev->blksz is declared as unsigned long.
>>
>> For example, in case block_dev->lba = 0x1dacc00, block_dev->blksz = 0x200
>> then part->size 0x5980000 which is incorrect as both are declared as ulong.
>>
>> To fix this overflow issue, enable CONFIG_SYS_64BIT_LBA, block_dev->lba is
>> then declared as uint64_t and part->size get the correct value 0x3b5980000.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
>> ---
>>
>>   configs/stm32mp25_defconfig | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/configs/stm32mp25_defconfig b/configs/stm32mp25_defconfig
>> index d3f0c088157..073172c3804 100644
>> --- a/configs/stm32mp25_defconfig
>> +++ b/configs/stm32mp25_defconfig
>> @@ -33,6 +33,7 @@ CONFIG_CMD_REGULATOR=y
>>   CONFIG_CMD_LOG=y
>>   CONFIG_OF_LIVE=y
>>   CONFIG_NO_NET=y
>> +CONFIG_SYS_64BIT_LBA=y
>>   CONFIG_GPIO_HOG=y
>>   CONFIG_DM_I2C=y
>>   CONFIG_SYS_I2C_STM32F7=y
> 
> 
> 
> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> 
> Thanks
> Patrick
> 
> 
> 
Applied to u-boot-stm32/master

Thanks
Patrice

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2025-01-31  8:00 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-29 12:27 [PATCH v1 0/6] Enable SYS_64BIT_LBA flag for STM32MP Patrice Chotard
2024-11-29 12:27 ` [PATCH v1 1/6] fastboot: Fix warning when CONFIG_SYS_64BIT_LBA is enable Patrice Chotard
2024-12-03  9:46   ` Mattijs Korpershoek
2025-01-08 18:48   ` Patrick DELAUNAY
2025-01-31  7:56     ` Patrice CHOTARD
2024-11-29 12:27 ` [PATCH v1 2/6] arm: stm32mp: stm32prog: fix " Patrice Chotard
2025-01-08 18:48   ` Patrick DELAUNAY
2025-01-31  7:56     ` Patrice CHOTARD
2024-11-29 12:27 ` [PATCH v1 3/6] arm: stm32mp: stm32prog: update multiplier is part-size is above SZ_1G Patrice Chotard
2025-01-08 18:49   ` Patrick DELAUNAY
2025-01-31  7:56     ` Patrice CHOTARD
2024-11-29 12:27 ` [PATCH v1 4/6] configs: stm32mp13: enable CONFIG_SYS_64BIT_LBA Patrice Chotard
2025-01-08 18:49   ` Patrick DELAUNAY
2025-01-31  7:57     ` Patrice CHOTARD
2024-11-29 12:27 ` [PATCH v1 5/6] configs: stm32mp15: " Patrice Chotard
2025-01-08 18:49   ` Patrick DELAUNAY
2025-01-31  7:57     ` Patrice CHOTARD
2024-11-29 12:27 ` [PATCH v1 6/6] configs: stm32mp25: " Patrice Chotard
2025-01-08 18:50   ` Patrick DELAUNAY
2025-01-08 21:12     ` Heinrich Schuchardt
2025-01-31  7:57     ` Patrice CHOTARD

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.