[PATCH v1 0/6] Enable SYS_64BIT_LBA flag for STM32MP

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(-)

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);

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",
} else { /* erase */ if (fb_mmc_erase_mmc_hwpart(dev_desc)) { pr_err("Failed to erase EMMC_BOOT%d\n", hwpart);(u64)(blkcnt * blksz), hwpart);
-- 2.25.1

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

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);

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

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) {

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

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

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

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

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

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

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

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
participants (4)
-
Heinrich Schuchardt
-
Mattijs Korpershoek
-
Patrice Chotard
-
Patrick DELAUNAY