diff mbox series

[RFC,4/8] rockchip: pad u-boot-rockchip.bin correctly

Message ID 20220715153655.955874-5-foss+uboot@0leil.net
State RFC
Delegated to: Kever Yang
Headers show
Series migrate u-boot-rockchip.bin to binman and generate an image for SPI | expand

Commit Message

Quentin Schulz July 15, 2022, 3:36 p.m. UTC
From: Quentin Schulz <quentin.schulz@theobroma-systems.com>

On MMC storage media, the TPL/SPL needs to be flashed at offset 32KB.
Instead of requesting the user to put the input the appropriate offsets,
let's create u-boot-rockchip.bin with the padding already added.

Cc: Quentin Schulz <foss+uboot@0leil.net>
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
---
 arch/arm/dts/rockchip-u-boot.dtsi | 3 ++-
 doc/board/rockchip/rockchip.rst   | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Philipp Tomsich July 15, 2022, 4:06 p.m. UTC | #1
On Fri, 15 Jul 2022 at 17:37, Quentin Schulz <foss+uboot@0leil.net> wrote:
>
> From: Quentin Schulz <quentin.schulz@theobroma-systems.com>
>
> On MMC storage media, the TPL/SPL needs to be flashed at offset 32KB.
> Instead of requesting the user to put the input the appropriate offsets,
> let's create u-boot-rockchip.bin with the padding already added.

NAK.

The storage layout provided by Rockchip leaves space for a
(protective) MBR and a primary GPT.
A bootloader update will overwrite the partition table if you create
the image as you suggest.

> Cc: Quentin Schulz <foss+uboot@0leil.net>
> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
> ---
>  arch/arm/dts/rockchip-u-boot.dtsi | 3 ++-
>  doc/board/rockchip/rockchip.rst   | 2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
> index fc28ce5187..4cd243514e 100644
> --- a/arch/arm/dts/rockchip-u-boot.dtsi
> +++ b/arch/arm/dts/rockchip-u-boot.dtsi
> @@ -18,6 +18,7 @@
>                 pad-byte = <0xff>;
>
>                 mkimage {
> +                       offset = <(32 * 1024)>; /* 32KB */
>                         args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
>  #ifndef CONFIG_TPL
>                         u-boot-spl {
> @@ -38,7 +39,7 @@
>  #else
>                 u-boot-img {
>  #endif
> -                       offset = <((CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR - 64) * 512)>;
> +                       offset = <(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)>;
>                 };
>         };
>  };
> diff --git a/doc/board/rockchip/rockchip.rst b/doc/board/rockchip/rockchip.rst
> index 4ca7b00b1f..1995882244 100644
> --- a/doc/board/rockchip/rockchip.rst
> +++ b/doc/board/rockchip/rockchip.rst
> @@ -179,7 +179,7 @@ To write an image that boots from a SD card (assumed to be /dev/sda):
>
>  .. code-block:: bash
>
> -        sudo dd if=u-boot-rockchip.bin of=/dev/sda seek=64
> +        sudo dd if=u-boot-rockchip.bin of=/dev/sda
>          sync
>
>  eMMC
> --
> 2.36.1
>
Quentin Schulz July 18, 2022, 9:40 a.m. UTC | #2
Hi Philipp,

On 7/15/22 18:06, Philipp Tomsich wrote:
> On Fri, 15 Jul 2022 at 17:37, Quentin Schulz <foss+uboot@0leil.net> wrote:
>>
>> From: Quentin Schulz <quentin.schulz@theobroma-systems.com>
>>
>> On MMC storage media, the TPL/SPL needs to be flashed at offset 32KB.
>> Instead of requesting the user to put the input the appropriate offsets,
>> let's create u-boot-rockchip.bin with the padding already added.
> 
> NAK.
> 
> The storage layout provided by Rockchip leaves space for a
> (protective) MBR and a primary GPT.
> A bootloader update will overwrite the partition table if you create
> the image as you suggest.
> 

Ah, that was what I was missing. Thanks, makes complete sense!

Cheers,
Quentin
diff mbox series

Patch

diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
index fc28ce5187..4cd243514e 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -18,6 +18,7 @@ 
 		pad-byte = <0xff>;
 
 		mkimage {
+			offset = <(32 * 1024)>; /* 32KB */
 			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
 #ifndef CONFIG_TPL
 			u-boot-spl {
@@ -38,7 +39,7 @@ 
 #else
 		u-boot-img {
 #endif
-			offset = <((CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR - 64) * 512)>;
+			offset = <(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)>;
 		};
 	};
 };
diff --git a/doc/board/rockchip/rockchip.rst b/doc/board/rockchip/rockchip.rst
index 4ca7b00b1f..1995882244 100644
--- a/doc/board/rockchip/rockchip.rst
+++ b/doc/board/rockchip/rockchip.rst
@@ -179,7 +179,7 @@  To write an image that boots from a SD card (assumed to be /dev/sda):
 
 .. code-block:: bash
 
-        sudo dd if=u-boot-rockchip.bin of=/dev/sda seek=64
+        sudo dd if=u-boot-rockchip.bin of=/dev/sda
         sync
 
 eMMC