Re: [PATCH] rockchip: puma: fix GPT table corruption when saving U-Boot environment

2022-12-18 Thread Kever Yang



On 2022/10/25 18:58, Quentin Schulz wrote:

From: Quentin Schulz 

The GPT table is taking the first 34 sectors, which amounts to 0x4400
bytes. Saving the environment below this address in storage will corrupt
the GPT table.

While technically the table ends at 0x4400, some tools (e.g. bmaptool)
are rounding everything to the logical block size (0x1000), so it is
safer to make it point to 0x5000 so that the environment could still
persist when flashing a sparse image with bmaptool or similar tools.

Obviously, the default 0x4000 environment size does not work anymore, so
let's set it to 0x3000 so it does fill the gap between the GPT table
(rounded to 0x1000) and the start of the idbloader.img.

Fixes: 56f580d3eb8d ("rockchip: dts: rk3399-puma: put environment (in MMC/SD 
configurations) before SPL")
Cc: Quentin Schulz 
Signed-off-by: Quentin Schulz 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
To: Simon Glass 
To: Philipp Tomsich 
To: Kever Yang 
To: Klaus Goger 
Cc: u-boot@lists.denx.de
---
  arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi | 2 +-
  configs/puma-rk3399_defconfig   | 1 +
  2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi 
b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
index f8335c74a7..d2349ae90e 100644
--- a/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
+++ b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
@@ -15,7 +15,7 @@
  / {
config {
u-boot,spl-payload-offset = <0x8>; /* @ 512KB */
-   u-boot,mmc-env-offset = <0x4000>;  /* @  16KB */
+   u-boot,mmc-env-offset = <0x5000>;  /* @  20KB */
u-boot,efi-partition-entries-offset = <0x20>; /* 2MB */
u-boot,boot-led = "module_led";
sysreset-gpio = <&gpio1 RK_PA6 GPIO_ACTIVE_HIGH>;
diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig
index 34186d1caa..91f31b37e8 100644
--- a/configs/puma-rk3399_defconfig
+++ b/configs/puma-rk3399_defconfig
@@ -5,6 +5,7 @@ CONFIG_ARCH_ROCKCHIP=y
  CONFIG_SYS_TEXT_BASE=0x0020
  CONFIG_SPL_GPIO=y
  CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x3000
  CONFIG_ENV_OFFSET=0x3F8000
  CONFIG_DEFAULT_DEVICE_TREE="rk3399-puma-haikou"
  CONFIG_ROCKCHIP_RK3399=y

---
base-commit: 1e892ef0b59a4a04971ac23619b95917020b3e18
change-id: 20221025-upstream-puma-mmc-env-gpt-6f42cd038fdd

Best regards,


[PATCH] rockchip: puma: fix GPT table corruption when saving U-Boot environment

2022-10-25 Thread Quentin Schulz
From: Quentin Schulz 

The GPT table is taking the first 34 sectors, which amounts to 0x4400
bytes. Saving the environment below this address in storage will corrupt
the GPT table.

While technically the table ends at 0x4400, some tools (e.g. bmaptool)
are rounding everything to the logical block size (0x1000), so it is
safer to make it point to 0x5000 so that the environment could still
persist when flashing a sparse image with bmaptool or similar tools.

Obviously, the default 0x4000 environment size does not work anymore, so
let's set it to 0x3000 so it does fill the gap between the GPT table
(rounded to 0x1000) and the start of the idbloader.img.

Fixes: 56f580d3eb8d ("rockchip: dts: rk3399-puma: put environment (in MMC/SD 
configurations) before SPL")
Cc: Quentin Schulz 
Signed-off-by: Quentin Schulz 
---
To: Simon Glass 
To: Philipp Tomsich 
To: Kever Yang 
To: Klaus Goger 
Cc: u-boot@lists.denx.de
---
 arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi | 2 +-
 configs/puma-rk3399_defconfig   | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi 
b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
index f8335c74a7..d2349ae90e 100644
--- a/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
+++ b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi
@@ -15,7 +15,7 @@
 / {
config {
u-boot,spl-payload-offset = <0x8>; /* @ 512KB */
-   u-boot,mmc-env-offset = <0x4000>;  /* @  16KB */
+   u-boot,mmc-env-offset = <0x5000>;  /* @  20KB */
u-boot,efi-partition-entries-offset = <0x20>; /* 2MB */
u-boot,boot-led = "module_led";
sysreset-gpio = <&gpio1 RK_PA6 GPIO_ACTIVE_HIGH>;
diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig
index 34186d1caa..91f31b37e8 100644
--- a/configs/puma-rk3399_defconfig
+++ b/configs/puma-rk3399_defconfig
@@ -5,6 +5,7 @@ CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x0020
 CONFIG_SPL_GPIO=y
 CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x3000
 CONFIG_ENV_OFFSET=0x3F8000
 CONFIG_DEFAULT_DEVICE_TREE="rk3399-puma-haikou"
 CONFIG_ROCKCHIP_RK3399=y

---
base-commit: 1e892ef0b59a4a04971ac23619b95917020b3e18
change-id: 20221025-upstream-puma-mmc-env-gpt-6f42cd038fdd

Best regards,
-- 
Quentin Schulz