1
0
mirror of https://github.com/cjdelisle/openwrt.git synced 2025-08-24 08:02:49 +00:00
Files
openwrt/package/boot/uboot-mediatek/patches/200-cmd-add-imsz-and-imszb.patch
Enrico Mioso 2a32d215ba uboot-mediatek: bump to v2025.04
The following upstreamed / superseded patches were dropped:

 060-01-clk-mediatek-mt7629-fix-parent-clock-of-some-top-clo.patch
 060-02-arm-dts-mt7629-fix-sgmii-clock-selection-for-etherne.patch
 060-03-net-mediatek-use-correct-register-field-for-SGMII-sp.patch
 060-04-net-mediatek-correct-register-name-of-ethsys-syscfg1.patch
 060-05-net-mediatek-fix-sgmii-selection-for-mt7622.patch
 060-06-net-mediatek-fix-gmac2-usability-for-mt7629.patch
 060-07-net-mediatek-add-support-for-10GBASE-R.patch
 060-08-net-mediatek-make-sgmii-usxgmii-optional.patch
 060-09-net-mediatek-don-t-enable-GDMA-cpu-bridge-unconditio.patch
 060-10-net-mediatek-fix-usability-with-wget-command.patch
 061-01-net-mediatek-split-ethernet-switch-code-from-mtk_eth.patch
 061-02-net-mediatek-add-support-for-MediaTek-MT7987-SoC.patch
 061-03-net-mediatek-add-support-for-Airoha-AN8855-ethernet-.patch
 070-01-board-mediatek-mt7622-remove-board_late_init.patch
 070-02-clk-mediatek-fix-uninitialized-fields-issue-in-INFRA.patch
 070-03-configs-mt7629-move-image-load-address-to-0x42000000.patch
 070-04-configs-mt7988-move-image-load-address-to-0x44000000.patch
 070-05-spi-mtk_spim-add-support-to-use-DT-live-tree.patch
 070-06-spi-mtk_spim-check-slave-device-mode-in-spi-mem-s-su.patch
 070-07-arm-dts-mediatek-add-quad-mode-capabilities-for-SPI-.patch
 070-08-pwm-mediatek-add-pwm3-support-for-mt7981.patch
 070-09-pci-mediatek-add-support-for-multiple-ports-in-media.patch
 070-10-arm-dts-mediatek-add-pcie-support-for-mt7988.patch
 070-11-arm-dts-medaitek-fix-internal-switch-link-speed-of-m.patch
 070-12-arm-dts-mediatek-add-support-for-all-three-GMACs-for.patch
 070-13-arm-dts-medaitek-add-flash-interface-driving-setting.patch
 070-14-arm-dts-mediatek-update-mt7981-mmc-node.patch
 070-15-MAINTAINERS-update-file-list-for-MediaTek-ARM-platfo.patch
 071-01-pinctrl-mediatek-update-mt7981-pinctrl-driver-based-.patch
 100-18-board-mt7629-add-support-for-booting-from-SPI-NAND.patch
 290-mt7981-add-USB-nodes.patch

Refreshed all the patches needing it.

Run-tested: GatoNetworks GDSP, Arcadyan Mozart (ynezz),
            Zbt WG3526 (dangowrt)

Signed-off-by: Enrico Mioso <mrkiko.rs@gmail.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz> [patch refresh, Mozart testing]
Signed-off-by: Daniel Golle <daniel@makrotopia.org> [rebased, tested on MT7621]
2025-05-31 21:16:41 +02:00

131 lines
3.2 KiB
Diff

--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -260,6 +260,67 @@ U_BOOT_CMD(
/* iminfo - print header info for a requested image */
/*******************************************************************/
#if defined(CONFIG_CMD_IMI)
+#if defined(CONFIG_FIT)
+#define SECTOR_SHIFT 9
+static int image_totalsize(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[], short int in_blocks)
+{
+ ulong addr;
+ void *fit;
+ int bsize, tsize;
+ char buf[16];
+
+ if (argc >= 2)
+ addr = simple_strtoul(argv[1], NULL, 16);
+ else
+ addr = image_load_addr;
+
+ fit = (void *)map_sysmem(addr, 0);
+ tsize = fit_get_totalsize(fit);
+ unmap_sysmem(fit);
+ if (tsize == 0)
+ return 1;
+
+ bsize = (tsize >> SECTOR_SHIFT) + ((tsize & ((1 << SECTOR_SHIFT) - 1))?1:0);
+
+ if (!in_blocks)
+ snprintf(buf, sizeof(buf), "%x", tsize);
+ else
+ snprintf(buf, sizeof(buf), "%x", bsize);
+
+ if (argc >= 3)
+ return env_set(argv[2], buf);
+ else
+ printf("%s\n", buf);
+
+ return 0;
+}
+
+static int do_imsz(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ return image_totalsize(cmdtp, flag, argc, argv, 0);
+}
+
+static int do_imszb(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ return image_totalsize(cmdtp, flag, argc, argv, 1);
+}
+
+U_BOOT_CMD(
+ imsz, CONFIG_SYS_MAXARGS, 1, do_imsz,
+ "get image total size (in bytes)",
+ "addr [maxhdrlen] [varname]\n"
+);
+
+U_BOOT_CMD(
+ imszb, CONFIG_SYS_MAXARGS, 1, do_imszb,
+ "get image total size (in blocks)",
+ "addr [maxhdrlen] [varname]\n"
+);
+
+#endif
static int do_iminfo(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
--- a/boot/image-fit.c
+++ b/boot/image-fit.c
@@ -2054,6 +2054,47 @@ static const char *fit_get_image_type_pr
return "unknown";
}
+size_t fit_get_totalsize(const void *fit)
+{
+ int ret, ndepth, noffset, images_noffset;
+ size_t data_size, hdrsize, img_total, max_size = 0;
+ const void *data;
+
+ ret = fdt_check_header(fit);
+ if (ret) {
+ debug("Wrong FIT format: not a flattened device tree (err=%d)\n",
+ ret);
+ return 0;
+ }
+
+ hdrsize = fdt_totalsize(fit);
+
+ /* take care of simple FIT with internal images */
+ max_size = hdrsize;
+
+ images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
+ if (images_noffset < 0)
+ goto out;
+
+ for (ndepth = 0,
+ noffset = fdt_next_node(fit, images_noffset, &ndepth);
+ (noffset >= 0) && (ndepth > 0);
+ noffset = fdt_next_node(fit, noffset, &ndepth)) {
+ if (ndepth == 1) {
+ ret = fit_image_get_data(fit, noffset, &data, &data_size);
+ if (ret)
+ goto out;
+
+ img_total = data_size + (data - fit);
+
+ max_size = (max_size > img_total) ? max_size : img_total;
+ }
+ }
+
+out:
+ return max_size;
+}
+
int fit_image_load(struct bootm_headers *images, ulong addr,
const char **fit_unamep, const char **fit_uname_configp,
int arch, int ph_type, int bootstage_id,
--- a/include/image.h
+++ b/include/image.h
@@ -1113,6 +1113,7 @@ int fit_parse_subimage(const char *spec,
ulong *addr, const char **image_name);
int fit_get_subimage_count(const void *fit, int images_noffset);
+size_t fit_get_totalsize(const void *fit);
void fit_print_contents(const void *fit);
void fit_image_print(const void *fit, int noffset, const char *p);