From cdd2ba4fcbc916005df27a9cdd3b3addbc4bef38 Mon Sep 17 00:00:00 2001 From: Gokul Sriram Palanisamy Date: Thu, 14 Jul 2022 08:48:07 +0530 Subject: [PATCH] ipq5332: TINY NOR: remove unused commands and functions Below commands and functions are disabled for reducing image footprint. Introduced new config CONFIG_REDUCE_FOOTPRINT to use for non-standard size reductions. Commands disabled ----------------- base, bootp, chpart, fdt Added new configs to control enablement of above commands respectively. CONFIG_CMD_DISABLE_BASE CONFIG_CMD_DISABLE_BOOTP, CONFIG_CMD_DISABLE_CHPART Functions disabled ------------------ - remove complete fdt support - fit_image_print, fit_image_print_data, fit_image_print_verification_data - fit_image_check_target_arch - fit_image_get_os, fit_image_get_arch, fit_image_get_type, fit_image_get_comp, - fit_image_check_os, fit_image_check_arch, fit_image_check_type, fit_image_check_comp, - get_table_entry_id, genimg_get_os_id, genimg_get_arch_id, genimg_get_type_id, genimg_get_comp_id Change-Id: I10259c0b70f6e84c850fd28f551df752b3cba814 Signed-off-by: Gokul Sriram Palanisamy Signed-off-by: Timple Raj M --- arch/arm/lib/bootm.c | 2 ++ common/Makefile | 5 ++++- common/bootm.c | 11 ++++++++++- common/cmd_mem.c | 16 +++++++++------- common/cmd_mtdparts.c | 18 ++++++++++-------- common/cmd_net.c | 2 ++ common/cmd_source.c | 2 ++ common/cmd_ximg.c | 6 ++++++ common/image-fdt.c | 2 +- common/image-fit.c | 18 ++++++++++++++++++ common/image.c | 2 ++ include/configs/ipq5332.h | 10 ++++++++++ include/image.h | 2 ++ 13 files changed, 78 insertions(+), 18 deletions(-) diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index 4ef3dbb697..a2c2dc6dce 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -363,7 +363,9 @@ int do_bootm_linux(int flag, int argc, char * const argv[], return 0; } +#ifndef CONFIG_REDUCE_FOOTPRINT boot_prep_linux(images); +#endif boot_jump_linux(images, flag); return 0; } diff --git a/common/Makefile b/common/Makefile index c8f28287af..b4d039da10 100644 --- a/common/Makefile +++ b/common/Makefile @@ -98,7 +98,10 @@ obj-$(CONFIG_CMD_EXT4) += cmd_ext4.o obj-$(CONFIG_CMD_EXT2) += cmd_ext2.o obj-$(CONFIG_CMD_FAT) += cmd_fat.o obj-$(CONFIG_CMD_FDC) += cmd_fdc.o -obj-$(CONFIG_OF_LIBFDT) += cmd_fdt.o fdt_support.o +ifndef CONFIG_CMD_DISABLE_FDT +obj-y += cmd_fdt.o +endif +obj-$(CONFIG_OF_LIBFDT) += fdt_support.o obj-$(CONFIG_CMD_FITUPD) += cmd_fitupd.o obj-$(CONFIG_CMD_FLASH) += cmd_flash.o obj-$(CONFIG_CMD_FLASHWRITE) += cmd_flashwrite.o diff --git a/common/bootm.c b/common/bootm.c index 64edcc59fe..2e706680e7 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -112,6 +112,12 @@ static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc, #endif #if defined(CONFIG_FIT) case IMAGE_FORMAT_FIT: +#ifdef CONFIG_REDUCE_FOOTPRINT + images.os.type = IH_TYPE_KERNEL; + images.os.comp = IH_COMP_LZMA; + images.os.os = IH_OS_LINUX; + images.os.arch = IH_ARCH_ARM; +#else if (fit_image_get_type(images.fit_hdr_os, images.fit_noffset_os, &images.os.type)) { @@ -141,6 +147,7 @@ static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc, puts("Can't get image ARCH!\n"); return 1; } +#endif images.os.end = fit_get_end(images.fit_hdr_os); @@ -244,7 +251,7 @@ int bootm_find_images(int flag, int argc, char * const argv[]) puts("Could not find a valid device tree\n"); return 1; } - set_working_fdt_addr((ulong)images.ft_addr); + setenv_hex("fdtaddr", (ulong)images.ft_addr); #endif #if defined(CONFIG_FIT) @@ -914,6 +921,7 @@ void memmove_wd(void *to, void *from, size_t len, ulong chunksz) memmove(to, from, len); } +#ifdef CONFIG_FIT_SIGNATURE static int bootm_host_load_image(const void *fit, int req_image_type, int cfg_noffset) { const char *fit_uname_config = NULL; @@ -979,5 +987,6 @@ int bootm_host_load_images(const void *fit, int cfg_noffset) /* Return the first error we found */ return err; } +#endif #endif /* ndef USE_HOSTCC */ diff --git a/common/cmd_mem.c b/common/cmd_mem.c index efa39296ef..210ea13a1e 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -492,6 +492,7 @@ static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } +#ifndef CONFIG_CMD_DISABLE_BASE static int do_mem_base(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -506,6 +507,14 @@ static int do_mem_base(cmd_tbl_t *cmdtp, int flag, int argc, return 0; } +U_BOOT_CMD( + base, 2, 1, do_mem_base, + "print or set address offset", + "\n - print address offset for memory commands\n" + "base off\n - set address offset for memory commands to 'off'" +); +#endif + static int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -1342,13 +1351,6 @@ static int do_mem_info(cmd_tbl_t *cmdtp, int flag, int argc, } #endif -U_BOOT_CMD( - base, 2, 1, do_mem_base, - "print or set address offset", - "\n - print address offset for memory commands\n" - "base off\n - set address offset for memory commands to 'off'" -); - U_BOOT_CMD( loop, 3, 1, do_mem_loop, "infinite loop on address range", diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c index 9a9f587ceb..e3159c5cda 100644 --- a/common/cmd_mtdparts.c +++ b/common/cmd_mtdparts.c @@ -1899,6 +1899,7 @@ static struct part_info* mtd_part_info(struct mtd_device *dev, unsigned int part return NULL; } +#ifndef CONFIG_CMD_DISABLE_CHPART /***************************************************/ /* U-boot commands */ /***************************************************/ @@ -1941,6 +1942,15 @@ static int do_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; } +/***************************************************/ +U_BOOT_CMD( + chpart, 2, 0, do_chpart, + "change active partition", + "part-id\n" + " - change active partition (e.g. part-id = nand0,1)" +); +#endif + /** * Routine implementing u-boot mtdparts command. Initialize/update default global * partition list and process user partition request (list, add, del). @@ -2068,14 +2078,6 @@ static int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, return CMD_RET_USAGE; } -/***************************************************/ -U_BOOT_CMD( - chpart, 2, 0, do_chpart, - "change active partition", - "part-id\n" - " - change active partition (e.g. part-id = nand0,1)" -); - #ifdef CONFIG_SYS_LONGHELP static char mtdparts_help_text[] = "\n" diff --git a/common/cmd_net.c b/common/cmd_net.c index b2f3c7b709..1e58e05faa 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -14,6 +14,7 @@ static int netboot_common(enum proto_t, cmd_tbl_t *, int, char * const []); +#ifndef CONFIG_CMD_DISABLE_BOOTP static int do_bootp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { return netboot_common(BOOTP, cmdtp, argc, argv); @@ -24,6 +25,7 @@ U_BOOT_CMD( "boot image via network using BOOTP/TFTP protocol", "[loadAddress] [[hostIPaddr:]bootfilename]" ); +#endif int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { diff --git a/common/cmd_source.c b/common/cmd_source.c index 9a35cad2f1..c578e3e3d4 100644 --- a/common/cmd_source.c +++ b/common/cmd_source.c @@ -109,10 +109,12 @@ source (ulong addr, const char *fit_uname) return 1; } +#ifndef CONFIG_REDUCE_FOOTPRINT if (!fit_image_check_type (fit_hdr, noffset, IH_TYPE_SCRIPT)) { puts ("Not a image image\n"); return 1; } +#endif /* verify integrity */ if (verify) { diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c index 4b6f2a12e8..fcf3a0a74b 100644 --- a/common/cmd_ximg.c +++ b/common/cmd_ximg.c @@ -144,6 +144,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) return 1; } +#ifndef CONFIG_REDUCE_FOOTPRINT if (!fit_image_check_comp(fit_hdr, noffset, IH_COMP_NONE) && (argc < 4)) { printf("Must specify load address for %s command " @@ -151,6 +152,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) cmdtp->name); return 1; } +#endif /* verify integrity */ if (verify) { @@ -167,11 +169,15 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) return 1; } +#ifdef CONFIG_REDUCE_FOOTPRINT + comp = IH_COMP_NONE; +#else if (fit_image_get_comp(fit_hdr, noffset, &comp)) { puts("Could not find script subimage " "compression type\n"); return 1; } +#endif data = (ulong)fit_data; len = (ulong)fit_len; diff --git a/common/image-fdt.c b/common/image-fdt.c index a8c24bafee..1206b3ca29 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -191,7 +191,7 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size) *of_flat_tree = of_start; *of_size = of_len; - set_working_fdt_addr((ulong)*of_flat_tree); + setenv_hex("fdtaddr", (ulong)*of_flat_tree); return 0; error: diff --git a/common/image-fit.c b/common/image-fit.c index b5b6f961ce..d1b60e1a1d 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -207,7 +207,9 @@ void fit_print_contents(const void *fit) printf("%s Image %u (%s)\n", p, count++, fit_get_name(fit, noffset, NULL)); +#ifndef CONFIG_REDUCE_FOOTPRINT fit_image_print(fit, noffset, p); +#endif } } @@ -242,6 +244,7 @@ void fit_print_contents(const void *fit) } } +#ifndef CONFIG_REDUCE_FOOTPRINT /** * fit_image_print_data() - prints out the hash node details * @fit: pointer to the FIT format image header @@ -451,6 +454,7 @@ void fit_image_print(const void *fit, int image_noffset, const char *p) } } } +#endif #endif /* !defined(CONFIG_SPL_BUILD) || defined(CONFIG_FIT_SPL_PRINT) */ @@ -547,6 +551,7 @@ int fit_image_get_node(const void *fit, const char *image_uname) return noffset; } +#ifndef CONFIG_REDUCE_FOOTPRINT /** * fit_image_get_os - get os id for a given component image node * @fit: pointer to the FIT format image header @@ -674,6 +679,7 @@ int fit_image_get_comp(const void *fit, int noffset, uint8_t *comp) *comp = genimg_get_comp_id(data); return 0; } +#endif /** * fit_image_get_load() - get load addr property for given component image node @@ -1113,6 +1119,7 @@ int fit_all_image_verify(const void *fit) return 1; } +#ifndef CONFIG_REDUCE_FOOTPRINT /** * fit_image_check_os - check whether image node is of a given os type * @fit: pointer to the FIT format image header @@ -1202,6 +1209,7 @@ int fit_image_check_comp(const void *fit, int noffset, uint8_t comp) return 0; return (comp == image_comp); } +#endif /** * fdt_check_no_at() - Check for nodes whose names contain '@' @@ -1563,7 +1571,9 @@ void fit_conf_print(const void *fit, int noffset, const char *p) static int fit_image_select(const void *fit, int rd_noffset, int verify) { +#ifndef CONFIG_REDUCE_FOOTPRINT fit_image_print(fit, rd_noffset, " "); +#endif if (verify) { puts(" Verifying Hash Integrity ... "); @@ -1733,6 +1743,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr, } bootstage_mark(bootstage_id + BOOTSTAGE_SUB_CHECK_ARCH); +#ifndef CONFIG_REDUCE_FOOTPRINT #if !defined(USE_HOSTCC) && !defined(CONFIG_SANDBOX) if (!fit_image_check_target_arch(fit, noffset)) { puts("Unsupported Architecture\n"); @@ -1740,15 +1751,21 @@ int fit_image_load(bootm_headers_t *images, ulong addr, return -ENOEXEC; } #endif + #if !defined(CONFIG_DTB_COMPRESSION) if (image_type == IH_TYPE_FLATDT && !fit_image_check_comp(fit, noffset, IH_COMP_NONE)) { puts("FDT image is compressed"); return -EPROTONOSUPPORT; } +#endif #endif bootstage_mark(bootstage_id + BOOTSTAGE_SUB_CHECK_ALL); +#ifdef CONFIG_REDUCE_FOOTPRINT + type_ok = 1; + os_ok = 1; +#else type_ok = fit_image_check_type(fit, noffset, image_type) || (image_type == IH_TYPE_KERNEL && fit_image_check_type(fit, noffset, @@ -1757,6 +1774,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr, os_ok = image_type == IH_TYPE_FLATDT || fit_image_check_os(fit, noffset, IH_OS_LINUX) || fit_image_check_os(fit, noffset, IH_OS_OPENRTOS); +#endif /* * If either of the checks fail, we should report an error, but diff --git a/common/image.c b/common/image.c index c36927fca8..e20a15c9b3 100644 --- a/common/image.c +++ b/common/image.c @@ -623,6 +623,7 @@ const char *genimg_get_comp_name(uint8_t comp) comp)); } +#ifndef CONFIG_REDUCE_FOOTPRINT /** * get_table_entry_id - translate short entry name to id * @table: pointer to a translation table for entries of a specific type @@ -674,6 +675,7 @@ int genimg_get_comp_id(const char *name) { return (get_table_entry_id(uimage_comp, "Compression", name)); } +#endif #ifndef USE_HOSTCC /** diff --git a/include/configs/ipq5332.h b/include/configs/ipq5332.h index 56ad8ef805..a8a72e2388 100644 --- a/include/configs/ipq5332.h +++ b/include/configs/ipq5332.h @@ -433,6 +433,16 @@ extern loff_t board_env_size; #define CONFIG_DM_I2C #endif +/* + * TINY NOR 16M Profile + */ +#ifdef CONFIG_IPQ_TINY_SPI_NOR +#define CONFIG_CMD_DISABLE_BASE +#define CONFIG_CMD_DISABLE_BOOTP +#define CONFIG_CMD_DISABLE_CHPART +#define CONFIG_CMD_DISABLE_FDT +#endif + /* * ELF authentication */ diff --git a/include/image.h b/include/image.h index 558ae7cbbe..51fa422f09 100644 --- a/include/image.h +++ b/include/image.h @@ -1119,6 +1119,7 @@ struct image_region *fit_region_make_list(const void *fit, struct fdt_region *fdt_regions, int count, struct image_region *region); +#ifndef CONFIG_REDUCE_FOOTPRINT static inline int fit_image_check_target_arch(const void *fdt, int node) { #ifndef USE_HOSTCC @@ -1128,6 +1129,7 @@ static inline int fit_image_check_target_arch(const void *fdt, int node) return 0; #endif } +#endif #ifdef CONFIG_FIT_VERBOSE #define fit_unsupported(msg) printf("! %s:%d " \