[U-Boot] [PATCH v3 2/3] rockchip: mkimage: force 2KB alignment for init_size

Philipp Tomsich philipp.tomsich at theobroma-systems.com
Tue May 30 21:32:09 UTC 2017


The Rockchip BootROM relies on init_size being aligned to 2KB
(see https://lists.denx.de/pipermail/u-boot/2017-May/293268.html).

This pads the image to 2KB both for SD card images and SPI images
and uses a common symbolic constant for the alignment.

Signed-off-by: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>

---

Changes in v3:
- (added patch) forces the alignment/padding to 2KB for SD images, as
  this would otherwise break the back-to-bootrom functionality

Changes in v2: None

 tools/rkcommon.h | 1 +
 tools/rksd.c     | 6 +++---
 tools/rkspi.c    | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/rkcommon.h b/tools/rkcommon.h
index 75a4ed6..8790f1c 100644
--- a/tools/rkcommon.h
+++ b/tools/rkcommon.h
@@ -10,6 +10,7 @@
 
 enum {
 	RK_BLK_SIZE		= 512,
+	RK_INIT_SIZE_ALIGN      = 2048,
 	RK_INIT_OFFSET		= 4,
 	RK_MAX_BOOT_SIZE	= 512 << 10,
 	RK_SPL_HDR_START	= RK_INIT_OFFSET * RK_BLK_SIZE,
diff --git a/tools/rksd.c b/tools/rksd.c
index a880a26..c56153d 100644
--- a/tools/rksd.c
+++ b/tools/rksd.c
@@ -46,10 +46,10 @@ static int rksd_vrec_header(struct image_tool_params *params,
 			    struct image_type_params *tparams)
 {
 	/*
-	 * Pad to the RK_BLK_SIZE (512 bytes) to be consistent with init_size
-	 * being encoded in RK_BLK_SIZE units in header0 (see rkcommon.c).
+	 * Pad to a 2KB alignment, as required for init_size by the ROM
+	 * (see https://lists.denx.de/pipermail/u-boot/2017-May/293268.html)
 	 */
-	return rkcommon_vrec_header(params, tparams, RK_BLK_SIZE);
+	return rkcommon_vrec_header(params, tparams, RK_INIT_SIZE_ALIGN);
 }
 
 /*
diff --git a/tools/rkspi.c b/tools/rkspi.c
index f8a565d..4332ce1 100644
--- a/tools/rkspi.c
+++ b/tools/rkspi.c
@@ -63,7 +63,7 @@ static int rkspi_check_image_type(uint8_t type)
 static int rkspi_vrec_header(struct image_tool_params *params,
 			     struct image_type_params *tparams)
 {
-	int padding = rkcommon_vrec_header(params, tparams, 2048);
+	int padding = rkcommon_vrec_header(params, tparams, RK_INIT_SIZE_ALIGN);
 	/*
 	 * The file size has not been adjusted at this point (our caller will
 	 * eventually add the header/padding to the file_size), so we need to
-- 
1.9.1



More information about the U-Boot mailing list