On 26-09-16 10:17:06, Philipp Tomsich wrote: > On Wed, 16 Sept 2026 at 10:12, Piotr Kubaj <[email protected]> wrote: > > > > From: Piotr Kubaj <[email protected]> > > > > rkcommon_verify_header() and rkcommon_print_header() compare the first > > four bytes of the image against RK_MAGIC_V2 using a raw host-endian read: > > > > if ((*(uint32_t *)buf) == RK_MAGIC_V2) > > > > The v2 header is written little-endian (rkcommon_set_header0_v2() uses > > cpu_to_le32(RK_MAGIC_V2)) and rkcommon_parse_header() already reads it > > back with le32_to_cpu(). On a big-endian build host the two raw reads > > above never match, so a valid v2 image (e.g. for RK3568) is not > > recognised as v2: verification falls through to the v1 path and fails > > with "Error: image verification failed". > > > > Read the magic with le32_to_cpu() at both sites so mkimage works when > > built on a big-endian host. This is a no-op on little-endian hosts. > > > > Signed-off-by: Piotr Kubaj <[email protected]> > > --- > > tools/rkcommon.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/tools/rkcommon.c b/tools/rkcommon.c > > index b39777f..0e456ae 100644 > > --- a/tools/rkcommon.c > > +++ b/tools/rkcommon.c > > @@ -473,7 +473,7 @@ int rkcommon_verify_header(unsigned char *buf, int size, > > int ret; > > > > /* spl_hdr is abandon on header_v2 */ > > - if ((*(uint32_t *)buf) == RK_MAGIC_V2) > > + if (le32_to_cpu(*(uint32_t *)buf) == RK_MAGIC_V2) > > If you would instead cpu_to_le32() the RK_MAGIC_V2 constant, then > you'd give the compiler a fighting chance to do the work at compile > time. > --Philipp. > > > return 0; > > > > ret = rkcommon_parse_header(buf, &header0, &img_spl_info); > > @@ -508,7 +508,7 @@ void rkcommon_print_header(const void *buf, struct > > image_tool_params *params) > > uint8_t image_type; > > int ret, boot_size, init_size; > > > > - if ((*(uint32_t *)buf) == RK_MAGIC_V2) { > > + if (le32_to_cpu(*(uint32_t *)buf) == RK_MAGIC_V2) { > > ret = rkcommon_parse_header_v2(buf, &header0_v2); > > > > if (ret < 0) { > > -- > > 2.52.0 > >
Ping, I updated the patch and it's at https://lists.u-boot-project.org/pipermail/u-boot/2026-September/631926.html.
signature.asc
Description: PGP signature
