mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-29 10:08:59 +00:00
0ea329fec4
Weijie Gao has submitted an updated version of the patchset adding support for MT7986 and MT7981 to U-Boot. Use that v2 patchset. Changes of v2: - Add cpu driver for print_cpuinfo() - Fix NULL pointer dereference in mtk_image (was already fixed in OpenWrt) - Fix coding style - Minor changes https://patchwork.ozlabs.org/project/uboot/list/?series=316148 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
90 lines
2.6 KiB
Diff
90 lines
2.6 KiB
Diff
From 1c9174cbf57ddc75bb5a25b2563333d974fd1a55 Mon Sep 17 00:00:00 2001
|
|
From: Weijie Gao <weijie.gao@mediatek.com>
|
|
Date: Wed, 31 Aug 2022 19:05:22 +0800
|
|
Subject: [PATCH 29/32] tools: mtk_image: split gfh header verification into a
|
|
new function
|
|
|
|
The verification code of gfh header for NAND and non-NAND are identical.
|
|
It's better to define a individual function to reduce redundancy.
|
|
|
|
Reviewed-by: Simon Glass <sjg@chromium.org>
|
|
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
|
|
---
|
|
tools/mtk_image.c | 51 +++++++++++++++++++----------------------------
|
|
1 file changed, 21 insertions(+), 30 deletions(-)
|
|
|
|
--- a/tools/mtk_image.c
|
|
+++ b/tools/mtk_image.c
|
|
@@ -480,6 +480,25 @@ static int mtk_image_vrec_header(struct
|
|
return SHA256_SUM_LEN;
|
|
}
|
|
|
|
+static int mtk_image_verify_gfh(struct gfh_header *gfh, uint32_t type, int print)
|
|
+{
|
|
+ if (strcmp(gfh->file_info.name, GFH_FILE_INFO_NAME))
|
|
+ return -1;
|
|
+
|
|
+ if (le32_to_cpu(gfh->file_info.flash_type) != type)
|
|
+ return -1;
|
|
+
|
|
+ if (print)
|
|
+ printf("Load Address: %08x\n",
|
|
+ le32_to_cpu(gfh->file_info.load_addr) +
|
|
+ le32_to_cpu(gfh->file_info.jump_offset));
|
|
+
|
|
+ if (print)
|
|
+ printf("Architecture: %s\n", is_arm64_image ? "ARM64" : "ARM");
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static int mtk_image_verify_gen_header(const uint8_t *ptr, int print)
|
|
{
|
|
union gen_boot_header *gbh = (union gen_boot_header *)ptr;
|
|
@@ -542,21 +561,7 @@ static int mtk_image_verify_gen_header(c
|
|
|
|
gfh = (struct gfh_header *)(ptr + gfh_offset);
|
|
|
|
- if (strcmp(gfh->file_info.name, GFH_FILE_INFO_NAME))
|
|
- return -1;
|
|
-
|
|
- if (le32_to_cpu(gfh->file_info.flash_type) != GFH_FLASH_TYPE_GEN)
|
|
- return -1;
|
|
-
|
|
- if (print)
|
|
- printf("Load Address: %08x\n",
|
|
- le32_to_cpu(gfh->file_info.load_addr) +
|
|
- le32_to_cpu(gfh->file_info.jump_offset));
|
|
-
|
|
- if (print)
|
|
- printf("Architecture: %s\n", is_arm64_image ? "ARM64" : "ARM");
|
|
-
|
|
- return 0;
|
|
+ return mtk_image_verify_gfh(gfh, GFH_FLASH_TYPE_GEN, print);
|
|
}
|
|
|
|
static int mtk_image_verify_nand_header(const uint8_t *ptr, int print)
|
|
@@ -610,21 +615,7 @@ static int mtk_image_verify_nand_header(
|
|
|
|
gfh = (struct gfh_header *)(ptr + 2 * le16_to_cpu(nh->pagesize));
|
|
|
|
- if (strcmp(gfh->file_info.name, GFH_FILE_INFO_NAME))
|
|
- return -1;
|
|
-
|
|
- if (le32_to_cpu(gfh->file_info.flash_type) != GFH_FLASH_TYPE_NAND)
|
|
- return -1;
|
|
-
|
|
- if (print)
|
|
- printf("Load Address: %08x\n",
|
|
- le32_to_cpu(gfh->file_info.load_addr) +
|
|
- le32_to_cpu(gfh->file_info.jump_offset));
|
|
-
|
|
- if (print)
|
|
- printf("Architecture: %s\n", is_arm64_image ? "ARM64" : "ARM");
|
|
-
|
|
- return 0;
|
|
+ return mtk_image_verify_gfh(gfh, GFH_FLASH_TYPE_NAND, print);
|
|
}
|
|
|
|
static uint32_t crc32be_cal(const void *data, size_t length)
|