diff mbox

[U-Boot,v2,1/4] rockchip: mkimage: simplify start/size calculation for rc4_encode

Message ID 1489576125-32355-2-git-send-email-philipp.tomsich@theobroma-systems.com
State Accepted
Commit f3edf8b18ff6a6f5bf9893da5460449bae028430
Delegated to: Simon Glass
Headers show

Commit Message

Philipp Tomsich March 15, 2017, 11:08 a.m. UTC
The RC4 encoding works on full blocks, but the calculation of the
starting offset and size are needlessly complicated by using a
reference value known to be offset into a block by the size of the
header and then correcting for the (hard-coded) size of the header
(i.e. 4 bytes).

We change this over to use the RK_SPL_HDR_START directly (which is
known to be on a block boundary).

X-AffectedPlatforms: RK3399-Q7
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tested-by: Klaus Goger <klaus.goger@theobroma-systems.com>
---

Changes in v2: None

 tools/rksd.c  | 4 ++--
 tools/rkspi.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Simon Glass March 26, 2017, 2:40 a.m. UTC | #1
On 15 March 2017 at 05:08, Philipp Tomsich
<philipp.tomsich@theobroma-systems.com> wrote:
> The RC4 encoding works on full blocks, but the calculation of the
> starting offset and size are needlessly complicated by using a
> reference value known to be offset into a block by the size of the
> header and then correcting for the (hard-coded) size of the header
> (i.e. 4 bytes).
>
> We change this over to use the RK_SPL_HDR_START directly (which is
> known to be on a block boundary).
>
> X-AffectedPlatforms: RK3399-Q7
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Tested-by: Klaus Goger <klaus.goger@theobroma-systems.com>
> ---
>
> Changes in v2: None
>
>  tools/rksd.c  | 4 ++--
>  tools/rkspi.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)

Applied to u-boot-rockchip, thanks!
diff mbox

Patch

diff --git a/tools/rksd.c b/tools/rksd.c
index ff2233f..e55c522 100644
--- a/tools/rksd.c
+++ b/tools/rksd.c
@@ -43,8 +43,8 @@  static void rksd_set_header(void *buf,  struct stat *sbuf,  int ifd,
 	       RK_SPL_HDR_SIZE);
 
 	if (rkcommon_need_rc4_spl(params))
-		rkcommon_rc4_encode_spl(buf, RK_SPL_START - 4,
-					params->file_size - RK_SPL_START + 4);
+		rkcommon_rc4_encode_spl(buf, RK_SPL_HDR_START,
+					params->file_size - RK_SPL_HDR_START);
 }
 
 static int rksd_extract_subimage(void *buf,  struct image_tool_params *params)
diff --git a/tools/rkspi.c b/tools/rkspi.c
index 0271d2e..9fa43e8 100644
--- a/tools/rkspi.c
+++ b/tools/rkspi.c
@@ -49,8 +49,8 @@  static void rkspi_set_header(void *buf, struct stat *sbuf, int ifd,
 	       RK_SPL_HDR_SIZE);
 
 	if (rkcommon_need_rc4_spl(params))
-		rkcommon_rc4_encode_spl(buf, RK_SPL_START - 4,
-					params->file_size - RK_SPL_START + 4);
+		rkcommon_rc4_encode_spl(buf, RK_SPL_HDR_START,
+					params->file_size - RK_SPL_HDR_START);
 
 	/*
 	 * Spread the image out so we only use the first 2KB of each 4KB