Skip to contentSkip to conversation

mpc8313: ids8313 board updates

PATCH Superseded Heiko Schocher 3 participants 15 messages May 28, 2014 – Jun 11, 2014

Subsystems (2)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover mpc8313: ids8313 board updates

- introduce CONFIG_IMAGE_FORMAT_LEGACY for enabling booting legacy image format. Disable this per default if CONFIG_FIT_SIGNATURE is defined.
As the ids8313 board needs legacy image format and uses CONFIG_FIT_SIGNATURE, enable legacy image format for the ids8313 board

- add CONFIG_SYS_GENERIC_BOARD to the ids8313 board, therefore fdtdec_get_int() is moved out of lib/fdtdec.c as lib/fdtdec.c is only compiled if CONFIG_OF_CONTROL is defined, but defining this for the ids8313 board leads in conjunction with CONFIG_SYS_GENERIC_BOARD in booting error:

No valid FDT found - please append one to U-Boot binary, use u-boot-dtb.bin or define CONFIG_OF_EMBED. For sandbox, use -d <file.dtb>

So move the common used function fdtdec_get_int() out of lib/fdtdec.c into lib/fdtdec_common.c

Cc Simon Glass <[email protected]>
Cc Kim Phillips <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Tom Rini <[email protected]>
Cc Michael Conrad <[email protected]>

Tested this patchset on the ids8313 board, MAKEALL for powerpc and arm adds no compiler errors/warnings.

While testing this patchset on the ids8313 board, I found, that current U-Boot compiles fine with eldk 5.5, but if erasing the sectors where U-Boot resists in the NOR flash, u-boot commands are not longer working :-(

$ powerpc-linux-gcc -v
Using built-in specs.
COLLECT_GCC=powerpc-linux-gcc
COLLECT_LTO_WRAPPER=/opt/eldk-5.5/powerpc/sysroots/i686-eldk-linux/usr/libexec/powerpc-linux/gcc/powerpc-linux/4.8.1/lto-wrapper
Target: powerpc-linux
[...]
Thread model: posix
gcc version 4.8.1 (GCC) 
$

This problem does not pop up with eldk 5.4 or 5.3 !

Digged a little bit in it, and found that some (not all!) fmt strings are loaded from flash addresses not from ram addresses ...

gdb shows:
Program received signal SIGTRAP, Trace/breakpoint trap.
printf (fmt=0xfff5ad34 '\377' <repeats 200 times>..., fmt at entry=0x7fdad34 "parse_stream, end_trigger=%d\n") at /home/hs/ids/u-boot/common/console.c:479
^^^^^^^^^^
addr in nor flash not in ram
479 {
(gdb) bt
#0 printf (fmt=0xfff5ad34 '\377' <repeats 200 times>..., fmt at entry=0x7fdad34 "parse_stream, end_trigger=%d\n") at /home/hs/ids/u-boot/common/console.c:479 #1 0x07f88c4c in parse_stream (end_trigger=10, input=0x775fe00, ctx=0x775fd60, dest=0x775fd7c) at /home/hs/ids/u-boot/common/hush.c:2942

this leads, if flash is erased, in a crash ... try to find out more ...

This problem seems a toolchain problem, as I tried older U-Boot versions with eldk 5.5 on this board, and all versions break ... I have no other mpc83xx board handy ... can somebody try this scenario on a mpc83xx based board? Kim?

Current U-Boot does work fine on a mpc52xx based board compiled with eldk 5.5, so it seems a mpc83xx specific problem?

Heiko Schocher (4):
bootm: make use of legacy image format configurable mpc8313, signed fit: enable legacy image format on ids8313 board lib, fdt: move fdtdec_get_int() out of lib/fdtdec.c
mpc8313: add CONFIG_SYS_GENERIC_BOARD to ids8313 board

 README                        | 18 ++++++++++++++++++
 common/cmd_bootm.c            | 14 ++++++++++++++
 common/cmd_disk.c             |  4 ++++
 common/cmd_fdc.c              |  4 ++++
 common/cmd_fpga.c             |  2 ++
 common/cmd_nand.c             |  4 ++++
 common/cmd_source.c           |  4 ++++
 common/cmd_ximg.c             |  9 +++++++--
 common/image-fdt.c            | 10 ++++++++--
 common/image.c                | 25 ++++++++++++++++++-------
 doc/uImage.FIT/signature.txt  |  3 +++
 include/config_fallbacks.h    |  8 ++++++++
 include/configs/ids8313.h     |  4 +++-
 include/configs/zynq-common.h |  1 +
 include/image.h               |  2 ++
 lib/Makefile                  |  1 +
 lib/fdtdec.c                  | 36 ------------------------------------
 lib/fdtdec_common.c           | 38 ++++++++++++++++++++++++++++++++++++++
 tools/fdtdec.c                |  1 +
 19 files changed, 140 insertions(+), 48 deletions(-)
 create mode 100644 lib/fdtdec_common.c
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v5 1/4 bootm: make use of legacy image format configurable

make the use of legacy image format configurable through the config define CONFIG_IMAGE_FORMAT_LEGACY.

When relying on signed FIT images with required signature check the legacy image format should be disabled. Therefore introduce this new define and enable legacy image format if CONFIG_FIT_SIGNATURE is not set. If CONFIG_FIT_SIGNATURE is set disable per default the legacy image format.

Cc Simon Glass <[email protected]>
Cc Lars Steubesand <[email protected]>
Cc Mike Pearce <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Tom Rini <[email protected]>
Cc Michal Simek <[email protected]>

---
- changes for v2:
- make the legacy image format configurable through the define CONFIG_IMAGE_FORMAT_LEGACY.

Default:
if not CONFIG_FIT_SIGNATURE is defined it is enabled, else disabled.

Disable it with CONFIG_DISABLE_IMAGE_LEGACY if CONFIG_FIT_SIGNATURE is not defined.
- changes for v3:
- enable legacy image format for zync as default, as Michak suggested.

- changes for v4:
move changes for default settings in include/config_defaults.h to include/config_fallbacks.h, so board settings are considered as Lars Steubesand suggested.

- changes for v5:
- rebased against current master
- fix build error in common_cmd_ximg.c for sandbox as Simon Glass detected

---
 README                        | 18 ++++++++++++++++++
 common/cmd_bootm.c            | 14 ++++++++++++++
 common/cmd_disk.c             |  4 ++++
 common/cmd_fdc.c              |  4 ++++
 common/cmd_fpga.c             |  2 ++
 common/cmd_nand.c             |  4 ++++
 common/cmd_source.c           |  4 ++++
 common/cmd_ximg.c             |  9 +++++++--
 common/image-fdt.c            | 10 ++++++++--
 common/image.c                | 25 ++++++++++++++++++-------
 doc/uImage.FIT/signature.txt  |  3 +++
 include/config_fallbacks.h    |  8 ++++++++
 include/configs/zynq-common.h |  1 +
 include/image.h               |  2 ++
 14 files changed, 97 insertions(+), 11 deletions(-)
README +18 -0
index a280435..10fd961 100644
@@ -3202,6 +3202,19 @@ FIT uImage format:
  -150	common/cmd_nand.c	Incorrect FIT image format
   151	common/cmd_nand.c	FIT image format OK
 
+- legacy image format:
+		CONFIG_IMAGE_FORMAT_LEGACY
+		enables the legacy image format support in U-Boot.
+
+		Default:
+		enabled if CONFIG_FIT_SIGNATURE is not defined.
+
+		CONFIG_DISABLE_IMAGE_LEGACY
+		disable the legacy image format
+
+		This define is introduced, as the legacy image format is
+		enabled per default for backward compatibility.
+
 - FIT image support:
 		CONFIG_FIT
 		Enable support for the FIT uImage format.
@@ -3218,6 +3231,11 @@ FIT uImage format:
 		using a hash signed and verified using RSA. See
 		doc/uImage.FIT/signature.txt for more details.
 
+		WARNING: When relying on signed FIT images with required
+		signature check the legacy image format is default
+		disabled. If a board need legacy image format support
+		enable this through CONFIG_IMAGE_FORMAT_LEGACY
+
 - Standalone program support:
 		CONFIG_STANDALONE_LOAD_ADDR
 
common/cmd_bootm.c +14 -0
index 34b4b58..9c608c3 100644
@@ -234,6 +234,7 @@ static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc,
 
 	/* get image parameters */
 	switch (genimg_get_format(os_hdr)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	case IMAGE_FORMAT_LEGACY:
 		images.os.type = image_get_type(os_hdr);
 		images.os.comp = image_get_comp(os_hdr);
@@ -242,6 +243,7 @@ static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc,
 		images.os.end = image_get_image_end(os_hdr);
 		images.os.load = image_get_load(os_hdr);
 		break;
+#endif
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
 		if (fit_image_get_type(images.fit_hdr_os,
@@ -851,6 +853,7 @@ int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
 	return 0;
 }
 
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 /**
  * image_get_kernel - verify legacy format kernel image
  * @img_addr: in RAM address of the legacy format image to be verified
@@ -901,6 +904,7 @@ static image_header_t *image_get_kernel(ulong img_addr, int verify)
 	}
 	return hdr;
 }
+#endif
 
 /**
  * boot_get_kernel - find kernel image
@@ -918,7 +922,9 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
 		char * const argv[], bootm_headers_t *images, ulong *os_data,
 		ulong *os_len)
 {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	image_header_t	*hdr;
+#endif
 	ulong		img_addr;
 	const void *buf;
 #if defined(CONFIG_FIT)
@@ -956,6 +962,7 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
 	*os_data = *os_len = 0;
 	buf = map_sysmem(img_addr, 0);
 	switch (genimg_get_format(buf)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	case IMAGE_FORMAT_LEGACY:
 		printf("## Booting kernel from Legacy Image at %08lx ...\n",
 				img_addr);
@@ -998,6 +1005,7 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
 		images->legacy_hdr_valid = 1;
 		bootstage_mark(BOOTSTAGE_ID_DECOMP_IMAGE);
 		break;
+#endif
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
 		os_noffset = fit_image_load(images, FIT_KERNEL_PROP,
@@ -1135,6 +1143,7 @@ static int image_info(ulong addr)
 	printf("\n## Checking Image at %08lx ...\n", addr);
 
 	switch (genimg_get_format(hdr)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	case IMAGE_FORMAT_LEGACY:
 		puts("   Legacy image found\n");
 		if (!image_check_magic(hdr)) {
@@ -1156,6 +1165,7 @@ static int image_info(ulong addr)
 		}
 		puts("OK\n");
 		return 0;
+#endif
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
 		puts("   FIT image found\n");
@@ -1215,6 +1225,7 @@ static int do_imls_nor(void)
 				goto next_sector;
 
 			switch (genimg_get_format(hdr)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 			case IMAGE_FORMAT_LEGACY:
 				if (!image_check_hcrc(hdr))
 					goto next_sector;
@@ -1229,6 +1240,7 @@ static int do_imls_nor(void)
 					puts("OK\n");
 				}
 				break;
+#endif
 #if defined(CONFIG_FIT)
 			case IMAGE_FORMAT_FIT:
 				if (!fit_check_format(hdr))
@@ -1363,12 +1375,14 @@ static int do_imls_nand(void)
 			}
 
 			switch (genimg_get_format(buffer)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 			case IMAGE_FORMAT_LEGACY:
 				header = (const image_header_t *)buffer;
 
 				len = image_get_image_size(header);
 				nand_imls_legacyimage(nand, nand_dev, off, len);
 				break;
+#endif
 #if defined(CONFIG_FIT)
 			case IMAGE_FORMAT_FIT:
 				len = fit_get_size(buffer);
common/cmd_disk.c +4 -0
index 3e457f6..8a1fda9 100644
@@ -17,7 +17,9 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
 	ulong addr = CONFIG_SYS_LOAD_ADDR;
 	ulong cnt;
 	disk_partition_t info;
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	image_header_t *hdr;
+#endif
 	block_dev_desc_t *dev_desc;
 
 #if defined(CONFIG_FIT)
@@ -62,6 +64,7 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
 	bootstage_mark(BOOTSTAGE_ID_IDE_PART_READ);
 
 	switch (genimg_get_format((void *) addr)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	case IMAGE_FORMAT_LEGACY:
 		hdr = (image_header_t *) addr;
 
@@ -78,6 +81,7 @@ int common_diskboot(cmd_tbl_t *cmdtp, const char *intf, int argc,
 
 		cnt = image_get_image_size(hdr);
 		break;
+#endif
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
 		fit_hdr = (const void *) addr;
common/cmd_fdc.c +4 -0
index 1cfb656..5766b56 100644
@@ -635,7 +635,9 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	FD_GEO_STRUCT *pFG = (FD_GEO_STRUCT *)floppy_type;
 	FDC_COMMAND_STRUCT *pCMD = &cmd;
 	unsigned long addr,imsize;
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	image_header_t *hdr;  /* used for fdc boot */
+#endif
 	unsigned char boot_drive;
 	int i,nrofblk;
 #if defined(CONFIG_FIT)
@@ -689,12 +691,14 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	}
 
 	switch (genimg_get_format ((void *)addr)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	case IMAGE_FORMAT_LEGACY:
 		hdr = (image_header_t *)addr;
 		image_print_contents (hdr);
 
 		imsize = image_get_image_size (hdr);
 		break;
+#endif
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
 		fit_hdr = (const void *)addr;
common/cmd_fpga.c +2 -0
index bda5c8f..8c5bf44 100644
@@ -201,6 +201,7 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 #if defined(CONFIG_CMD_FPGA_LOADMK)
 	case FPGA_LOADMK:
 		switch (genimg_get_format(fpga_data)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 		case IMAGE_FORMAT_LEGACY:
 			{
 				image_header_t *hdr =
@@ -229,6 +230,7 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 					       BIT_FULL);
 			}
 			break;
+#endif
 #if defined(CONFIG_FIT)
 		case IMAGE_FORMAT_FIT:
 			{
common/cmd_nand.c +4 -0
index a84f7dc..f9ced9d 100644
@@ -898,7 +898,9 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
 	int r;
 	char *s;
 	size_t cnt;
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	image_header_t *hdr;
+#endif
 #if defined(CONFIG_FIT)
 	const void *fit_hdr = NULL;
 #endif
@@ -924,6 +926,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
 	bootstage_mark(BOOTSTAGE_ID_NAND_HDR_READ);
 
 	switch (genimg_get_format ((void *)addr)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	case IMAGE_FORMAT_LEGACY:
 		hdr = (image_header_t *)addr;
 
@@ -932,6 +935,7 @@ static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
 
 		cnt = image_get_image_size (hdr);
 		break;
+#endif
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
 		fit_hdr = (const void *)addr;
common/cmd_source.c +4 -0
index 54ffd16..f3e9e60 100644
@@ -29,7 +29,9 @@ int
 source (ulong addr, const char *fit_uname)
 {
 	ulong		len;
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	const image_header_t *hdr;
+#endif
 	ulong		*data;
 	int		verify;
 	void *buf;
@@ -44,6 +46,7 @@ source (ulong addr, const char *fit_uname)
 
 	buf = map_sysmem(addr, 0);
 	switch (genimg_get_format(buf)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	case IMAGE_FORMAT_LEGACY:
 		hdr = buf;
 
@@ -84,6 +87,7 @@ source (ulong addr, const char *fit_uname)
 		 */
 		while (*data++);
 		break;
+#endif
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
 		if (fit_uname == NULL) {
common/cmd_ximg.c +7 -2
index 65a8319..ae2714d 100644
@@ -32,10 +32,13 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
 	ulong		addr = load_addr;
 	ulong		dest = 0;
-	ulong		data, len, count;
+	ulong		data, len;
 	int		verify;
 	int		part = 0;
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
+	ulong		count;
 	image_header_t	*hdr = NULL;
+#endif
 #if defined(CONFIG_FIT)
 	const char	*uname = NULL;
 	const void*	fit_hdr;
@@ -64,6 +67,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 	}
 
 	switch (genimg_get_format((void *)addr)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	case IMAGE_FORMAT_LEGACY:
 
 		printf("## Copying part %d from legacy image "
@@ -114,6 +118,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 
 		image_multi_getimg(hdr, part, &data, &len);
 		break;
+#endif
 #if defined(CONFIG_FIT)
 	case IMAGE_FORMAT_FIT:
 		if (uname == NULL) {
@@ -211,7 +216,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 			}
 			break;
 #endif
-#if defined(CONFIG_BZIP2)
+#if defined(CONFIG_BZIP2) && defined(CONFIG_IMAGE_FORMAT_LEGACY)
 		case IH_COMP_BZIP2:
 			{
 				int i;
common/image-fdt.c +8 -2
index 5d64009..ac4563f 100644
@@ -29,6 +29,7 @@ static void fdt_error(const char *msg)
 	puts(" - must RESET the board to recover.\n");
 }
 
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 static const image_header_t *image_get_fdt(ulong fdt_addr)
 {
 	const image_header_t *fdt_hdr = map_sysmem(fdt_addr, 0);
@@ -61,6 +62,7 @@ static const image_header_t *image_get_fdt(ulong fdt_addr)
 	}
 	return fdt_hdr;
 }
+#endif
 
 /**
  * boot_fdt_add_mem_rsv_regions - Mark the memreserve sections as unusable
@@ -220,11 +222,13 @@ error:
 int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
 		bootm_headers_t *images, char **of_flat_tree, ulong *of_size)
 {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	const image_header_t *fdt_hdr;
+	ulong		load, load_end;
+	ulong		image_start, image_data, image_end;
+#endif
 	ulong		fdt_addr;
 	char		*fdt_blob = NULL;
-	ulong		image_start, image_data, image_end;
-	ulong		load, load_end;
 	void		*buf;
 #if defined(CONFIG_FIT)
 	const char	*fit_uname_config = images->fit_uname_cfg;
@@ -298,6 +302,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
 		 */
 		buf = map_sysmem(fdt_addr, 0);
 		switch (genimg_get_format(buf)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 		case IMAGE_FORMAT_LEGACY:
 			/* verify fdt_addr points to a valid image header */
 			printf("## Flattened Device Tree from Legacy Image at %08lx\n",
@@ -337,6 +342,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
 
 			fdt_addr = load;
 			break;
+#endif
 		case IMAGE_FORMAT_FIT:
 			/*
 			 * This case will catch both: new uImage format
common/image.c +18 -7
index fa4864d..384bd10 100644
@@ -44,8 +44,10 @@ extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
 						int verify);
+#endif
 #else
 #include "mkimage.h"
 #include <u-boot/md5.h>
@@ -329,6 +331,7 @@ void image_print_contents(const void *ptr)
 
 
 #ifndef USE_HOSTCC
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 /**
  * image_get_ramdisk - get and verify ramdisk image
  * @rd_addr: ramdisk image start address
@@ -390,6 +393,7 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch,
 
 	return rd_hdr;
 }
+#endif
 #endif /* !USE_HOSTCC */
 
 /*****************************************************************************/
@@ -653,22 +657,23 @@ int genimg_get_comp_id(const char *name)
  */
 int genimg_get_format(const void *img_addr)
 {
-	ulong format = IMAGE_FORMAT_INVALID;
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	const image_header_t *hdr;
 
 	hdr = (const image_header_t *)img_addr;
 	if (image_check_magic(hdr))
-		format = IMAGE_FORMAT_LEGACY;
+		return IMAGE_FORMAT_LEGACY;
+#endif
 #if defined(CONFIG_FIT) || defined(CONFIG_OF_LIBFDT)
-	else if (fdt_check_header(img_addr) == 0)
-		format = IMAGE_FORMAT_FIT;
+	if (fdt_check_header(img_addr) == 0)
+		return IMAGE_FORMAT_FIT;
 #endif
 #ifdef CONFIG_ANDROID_BOOT_IMAGE
-	else if (android_image_check_header(img_addr) == 0)
-		format = IMAGE_FORMAT_ANDROID;
+	if (android_image_check_header(img_addr) == 0)
+		return IMAGE_FORMAT_ANDROID;
 #endif
 
-	return format;
+	return IMAGE_FORMAT_INVALID;
 }
 
 /**
@@ -710,12 +715,14 @@ ulong genimg_get_image(ulong img_addr)
 
 		/* get data size */
 		switch (genimg_get_format(buf)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 		case IMAGE_FORMAT_LEGACY:
 			d_size = image_get_data_size(buf);
 			debug("   Legacy format image found at 0x%08lx, "
 					"size 0x%08lx\n",
 					ram_addr, d_size);
 			break;
+#endif
 #if defined(CONFIG_FIT)
 		case IMAGE_FORMAT_FIT:
 			d_size = fit_get_size(buf) - h_size;
@@ -791,7 +798,9 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
 {
 	ulong rd_addr, rd_load;
 	ulong rd_data, rd_len;
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 	const image_header_t *rd_hdr;
+#endif
 	void *buf;
 #ifdef CONFIG_SUPPORT_RAW_INITRD
 	char *end;
@@ -874,6 +883,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
 		 */
 		buf = map_sysmem(rd_addr, 0);
 		switch (genimg_get_format(buf)) {
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 		case IMAGE_FORMAT_LEGACY:
 			printf("## Loading init Ramdisk from Legacy "
 					"Image at %08lx ...\n", rd_addr);
@@ -889,6 +899,7 @@ int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images,
 			rd_len = image_get_data_size(rd_hdr);
 			rd_load = image_get_load(rd_hdr);
 			break;
+#endif
 #if defined(CONFIG_FIT)
 		case IMAGE_FORMAT_FIT:
 			rd_noffset = fit_image_load(images, FIT_RAMDISK_PROP,
doc/uImage.FIT/signature.txt +3 -0
index 9502037..672dc35 100644
@@ -328,6 +328,9 @@ be enabled:
 CONFIG_FIT_SIGNATURE - enable signing and verfication in FITs
 CONFIG_RSA - enable RSA algorithm for signing
 
+WARNING: When relying on signed FIT images with required signature check
+the legacy image format is default disabled by not defining
+CONFIG_IMAGE_FORMAT_LEGACY
 
 Testing
 -------
include/config_fallbacks.h +8 -0
index b304a41..76818f6 100644
@@ -83,4 +83,12 @@
 #define CONFIG_SYS_HZ		1000
 #endif
 
+#ifndef CONFIG_FIT_SIGNATURE
+#define CONFIG_IMAGE_FORMAT_LEGACY
+#endif
+
+#ifdef CONFIG_DISABLE_IMAGE_LEGACY
+#undef CONFIG_IMAGE_FORMAT_LEGACY
+#endif
+
 #endif	/* __CONFIG_FALLBACKS_H */
include/configs/zynq-common.h +1 -0
index dc5bc22..fa252c0 100644
@@ -225,6 +225,7 @@
 /* FIT support */
 #define CONFIG_FIT
 #define CONFIG_FIT_VERBOSE	1 /* enable fit_format_{error,warning}() */
+#define CONFIG_IMAGE_FORMAT_LEGACY /* enable also legacy image format */
 
 /* FDT support */
 #define CONFIG_OF_CONTROL
include/image.h +2 -0
index 1886168..5d6ec2c 100644
@@ -411,7 +411,9 @@ enum fit_load_op {
 #ifndef USE_HOSTCC
 /* Image format types, returned by _get_format() routine */
 #define IMAGE_FORMAT_INVALID	0x00
+#if defined(CONFIG_IMAGE_FORMAT_LEGACY)
 #define IMAGE_FORMAT_LEGACY	0x01	/* legacy image_header based format */
+#endif
 #define IMAGE_FORMAT_FIT	0x02	/* new, libfdt based format */
 #define IMAGE_FORMAT_ANDROID	0x03	/* Android boot image */
 
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH v5 1/4 bootm: make use of legacy image format configurable

Hi Heiko,

Quoted 9 lines · Heiko Schocher

make the use of legacy image format configurable through the config define CONFIG_IMAGE_FORMAT_LEGACY.

When relying on signed FIT images with required signature check the legacy image format should be disabled. Therefore introduce this new define and enable legacy image format if CONFIG_FIT_SIGNATURE is not set. If CONFIG_FIT_SIGNATURE is set disable per default the legacy image format.

Quoted 7 lines
Cc Simon Glass <[email protected]>
Cc Lars Steubesand <[email protected]>
Cc Mike Pearce <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Tom Rini <[email protected]>
Cc Michal Simek <[email protected]>

(Some question about the logic in cmd_ximg, but I don't know anything about that).

Regards,
Simon

#3 lore raw

PATCH v5 1/4 bootm: make use of legacy image format configurable

In reply to Heiko Schocher
Quoted 9 lines · Heiko Schocher

make the use of legacy image format configurable through the config define CONFIG_IMAGE_FORMAT_LEGACY.

When relying on signed FIT images with required signature check the legacy image format should be disabled. Therefore introduce this new define and enable legacy image format if CONFIG_FIT_SIGNATURE is not set. If CONFIG_FIT_SIGNATURE is set disable per default the legacy image format.

Quoted 8 lines
Cc Simon Glass <[email protected]>
Cc Lars Steubesand <[email protected]>
Cc Mike Pearce <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Tom Rini <[email protected]>
Cc Michal Simek <[email protected]>

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140605/0ada795c/attachment.pgp>
#4 lore raw

PATCH v5 2/4 mpc8313, signed fit: enable legacy image format on ids8313 board

In reply to Heiko Schocher

Enable legacy image format with CONFIG_IMAGE_FORMAT_LEGACY on the ids8313 board, as it uses signed FIT images for booting Linux and need the legacy image format.

Cc Simon Glass <[email protected]>
Cc Kim Phillips <[email protected]>
Cc Michael Conrad <[email protected]>

---
- changes for v2:
- enable (not disable) the legacy image format for this board
- changes for v3:
none
- changes for v4:
none
- changes for v5:
none

---
 include/configs/ids8313.h | 1 +
 1 file changed, 1 insertion(+)
include/configs/ids8313.h +1 -0
index c1b3b63..1de5750 100644
@@ -576,6 +576,7 @@
 
 #define CONFIG_FIT
 #define CONFIG_FIT_SIGNATURE
+#define CONFIG_IMAGE_FORMAT_LEGACY
 #define CONFIG_CMD_FDT
 #define CONFIG_CMD_HASH
 #define CONFIG_RSA
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH v5 2/4 mpc8313, signed fit: enable legacy image format on ids8313 board

Quoted 8 lines · Heiko Schocher

Enable legacy image format with CONFIG_IMAGE_FORMAT_LEGACY on the ids8313 board, as it uses signed FIT images for booting Linux and need the legacy image format.

Cc Simon Glass <[email protected]>
Cc Kim Phillips <[email protected]>
Cc Michael Conrad <[email protected]>
#6 lore raw

PATCH v5 2/4 mpc8313, signed fit: enable legacy image format on ids8313 board

Quoted 11 lines · Simon Glass
Quoted 8 lines · Heiko Schocher

Enable legacy image format with CONFIG_IMAGE_FORMAT_LEGACY on the ids8313 board, as it uses signed FIT images for booting Linux and need the legacy image format.

Cc Simon Glass <[email protected]>
Cc Kim Phillips <[email protected]>
Cc Michael Conrad <[email protected]>

No, I didn't change it, sorry.

#7 lore raw

PATCH v5 2/4 mpc8313, signed fit: enable legacy image format on ids8313 board

In reply to Heiko Schocher
Quoted 10 lines · Heiko Schocher

Enable legacy image format with CONFIG_IMAGE_FORMAT_LEGACY on the ids8313 board, as it uses signed FIT images for booting Linux and need the legacy image format.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140605/9980726b/attachment.pgp>
#8 lore raw

PATCH v5 3/4 lib, fdt: move fdtdec_get_int() out of lib/fdtdec.c

In reply to Heiko Schocher

move fdtdec_get_int() out of lib/fdtdec.c into lib/fdtdec_common.c as this function is also used, if CONFIG_OF_CONTROL is not used. Poped up on the ids8313 board using signed FIT images, and activating CONFIG_SYS_GENERIC_BOARD. Without this patch it shows on boot:

No valid FDT found - please append one to U-Boot binary, use u-boot-dtb.bin or define CONFIG_OF_EMBED. For sandbox, use -d <file.dtb>

With this patch, it boots again with CONFIG_SYS_GENERIC_BOARD enabled.

---
- changes for v2:
- remove fdtdec_get_int() in lib/fdtdec.c
- only one fdtdec_get_int() implementation
Tested on the ids8313 board (on host and target side)
- changes for v3:
use fdt_getprop() instead fdt_getprop_w() so we avoid a cast as Simon suggested.
- changes for v4:
none
- changes for v5:
- keep debug for non host side as Simon Glass suggested.
- add Acked-by from Simon Glass

---
 lib/Makefile        |  1 +
 lib/fdtdec.c        | 36 ------------------------------------
 lib/fdtdec_common.c | 38 ++++++++++++++++++++++++++++++++++++++
 tools/fdtdec.c      |  1 +
 4 files changed, 40 insertions(+), 36 deletions(-)
 create mode 100644 lib/fdtdec_common.c
lib/Makefile +1 -0
index 377ab13..fbe7d93 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_USB_TTY) += circbuf.o
 obj-y += crc7.o
 obj-y += crc8.o
 obj-y += crc16.o
+obj-y += fdtdec_common.o
 obj-$(CONFIG_OF_CONTROL) += fdtdec.o
 obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
 obj-$(CONFIG_GZIP) += gunzip.o
lib/fdtdec.c +0 -36
index 8ecb80f..21d5e85 100644
@@ -109,24 +109,6 @@ fdt_addr_t fdtdec_get_addr(const void *blob, int node,
 	return fdtdec_get_addr_size(blob, node, prop_name, NULL);
 }
 
-s32 fdtdec_get_int(const void *blob, int node, const char *prop_name,
-		s32 default_val)
-{
-	const s32 *cell;
-	int len;
-
-	debug("%s: %s: ", __func__, prop_name);
-	cell = fdt_getprop(blob, node, prop_name, &len);
-	if (cell && len >= sizeof(s32)) {
-		s32 val = fdt32_to_cpu(cell[0]);
-
-		debug("%#x (%d)\n", val, val);
-		return val;
-	}
-	debug("(not found)\n");
-	return default_val;
-}
-
 uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name,
 		uint64_t default_val)
 {
@@ -646,22 +628,4 @@ int fdtdec_read_fmap_entry(const void *blob, int node, const char *name,
 
 	return 0;
 }
-#else
-#include "libfdt.h"
-#include "fdt_support.h"
-
-int fdtdec_get_int(const void *blob, int node, const char *prop_name,
-		int default_val)
-{
-	const int *cell;
-	int len;
-
-	cell = fdt_getprop_w((void *)blob, node, prop_name, &len);
-	if (cell && len >= sizeof(int)) {
-		int val = fdt32_to_cpu(cell[0]);
-
-		return val;
-	}
-	return default_val;
-}
 #endif
lib/fdtdec_common.c new file +38 -0
new file mode 100644
index 0000000..757931a
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2014
+ * Heiko Schocher, DENX Software Engineering, hs at denx.de.
+ *
+ * Based on lib/fdtdec.c:
+ * Copyright (c) 2011 The Chromium OS Authors.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef USE_HOSTCC
+#include <common.h>
+#include <libfdt.h>
+#include <fdtdec.h>
+#else
+#include "libfdt.h"
+#include "fdt_support.h"
+
+#define debug(...)
+#endif
+
+int fdtdec_get_int(const void *blob, int node, const char *prop_name,
+		int default_val)
+{
+	const int *cell;
+	int len;
+
+	debug("%s: %s: ", __func__, prop_name);
+	cell = fdt_getprop(blob, node, prop_name, &len);
+	if (cell && len >= sizeof(int)) {
+		int val = fdt32_to_cpu(cell[0]);
+
+		debug("%#x (%d)\n", val, val);
+		return val;
+	}
+	debug("(not found)\n");
+	return default_val;
+}
tools/fdtdec.c +1 -0
index f1c2256..9987f83 100644
@@ -1 +1,2 @@
+#include "../lib/fdtdec_common.c"
 #include "../lib/fdtdec.c"
Signature · 1 line
1.8.3.1
#9 lore raw

PATCH v5 3/4 lib, fdt: move fdtdec_get_int() out of lib/fdtdec.c

Hi Heiko,

Quoted 6 lines · Heiko Schocher

move fdtdec_get_int() out of lib/fdtdec.c into lib/fdtdec_common.c as this function is also used, if CONFIG_OF_CONTROL is not used. Poped up on the ids8313 board using signed FIT images, and activating CONFIG_SYS_GENERIC_BOARD. Without this patch it shows on boot:

Quoted 8 lines

No valid FDT found - please append one to U-Boot binary, use u-boot-dtb.bin or define CONFIG_OF_EMBED. For sandbox, use -d <file.dtb>

With this patch, it boots again with CONFIG_SYS_GENERIC_BOARD enabled.

FYI I just noticed some apparent failures for this:

$ ./tools/buildman/buildman -b try-heiko3 -s
...
04: lib, fdt: move fdtdec_get_int() out of lib/fdtdec.c
     sparc: +   grsim grsim_leon2 gr_cpci_ax2000 gr_xc3s_1500 gr_ep2s60
        sh: +   ms7750se ap_sh4a_4a sh7753evb sh7763rdp r0p7734
r2dplus ms7720se shmin sh7752evb espt ap325rxa mpr2 ms7722se r7780mp
ecovec sh7785lcr sh7757lcr MigoR sh7785lcr_32bit
  blackfin: +   cm-bf561 blackstamp bf537-minotaur br4 cm-bf527
bf506f-ezkit ip04 bf527-sdp pr1 bf527-ezkit-v2 tcm-bf518 bf537-pnav
bf537-srv1 cm-bf548 bf548-ezkit bf525-ucr2 blackvme bf527-ezkit
bf518f-ezbrd bf527-ad7160-eval bf526-ezbrd
     nds32: +   adp-ag101p adp-ag102 adp-ag101

For example:

$ ./tools/buildman/buildman -b try-heiko3 -se grsim
...
04: lib, fdt: move fdtdec_get_int() out of lib/fdtdec.c
     sparc: +   grsim grsim_leon2
+lib/built-in.o: In function `fdtdec_get_int':
+/usr/local/google/c/cosarm/src/third_party/u-boot/try-heiko3/.bm-work/14/lib/fdtdec_common.c:29:
undefined reference to `fdt_getprop'
+make[1]: *** [u-boot] Error 1
+make: *** [sub-make] Error 2
+/usr/local/google/c/cosarm/src/third_party/u-boot/try-heiko3/.bm-work/19/lib/fdtdec_common.c:29:
undefined reference to `fdt_getprop'

Regards,
Simon

#10 lore raw

PATCH v5 3/4 lib, fdt: move fdtdec_get_int() out of lib/fdtdec.c

In reply to Heiko Schocher
Quoted 6 lines · Heiko Schocher

move fdtdec_get_int() out of lib/fdtdec.c into lib/fdtdec_common.c as this function is also used, if CONFIG_OF_CONTROL is not used. Poped up on the ids8313 board using signed FIT images, and activating CONFIG_SYS_GENERIC_BOARD. Without this patch it shows on boot:

Quoted 8 lines

No valid FDT found - please append one to U-Boot binary, use u-boot-dtb.bin or define CONFIG_OF_EMBED. For sandbox, use -d <file.dtb>

With this patch, it boots again with CONFIG_SYS_GENERIC_BOARD enabled.

The problem is that on architectures with old compilers (sparc, blackfin, nds32) this doesn't get discarded due to not being used but instead causes link errors. Can you figure out which option (CONFIG_FIT_SIGNATURE I suspect) drives this need and make sure we include fdtdec_common.o then? Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140605/b60befe2/attachment.pgp>
#11 lore raw

PATCH v5 3/4 lib, fdt: move fdtdec_get_int() out of lib/fdtdec.c

Hello Tom,

Am 05.06.2014 21:15, schrieb Tom Rini:

Quoted 17 lines · Heiko Schocher
Quoted 7 lines

move fdtdec_get_int() out of lib/fdtdec.c into lib/fdtdec_common.c as this function is also used, if CONFIG_OF_CONTROL is not used. Poped up on the ids8313 board using signed FIT images, and activating CONFIG_SYS_GENERIC_BOARD. Without this patch it shows on boot:

Quoted 8 lines

No valid FDT found - please append one to U-Boot binary, use u-boot-dtb.bin or define CONFIG_OF_EMBED. For sandbox, use -d<file.dtb>

With this patch, it boots again with CONFIG_SYS_GENERIC_BOARD enabled.

Quoted 5 lines

The problem is that on architectures with old compilers (sparc, blackfin, nds32) this doesn't get discarded due to not being used but instead causes link errors. Can you figure out which option (CONFIG_FIT_SIGNATURE I suspect) drives this need and make sure we include fdtdec_common.o then? Thanks!

I look into it ... but I think it is not only one config option, as this code is not FIT specific and used also for code which uses DT ... (maybe CONFIG_OF_CONTROL or CONFIG_FIT_SIGNATURE).

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#12 lore raw

PATCH v5 3/4 lib, fdt: move fdtdec_get_int() out of lib/fdtdec.c

Quoted 26 lines · Heiko Schocher

Hello Tom,

Am 05.06.2014 21:15, schrieb Tom Rini:

Quoted 17 lines · Heiko Schocher
Quoted 7 lines

move fdtdec_get_int() out of lib/fdtdec.c into lib/fdtdec_common.c as this function is also used, if CONFIG_OF_CONTROL is not used. Poped up on the ids8313 board using signed FIT images, and activating CONFIG_SYS_GENERIC_BOARD. Without this patch it shows on boot:

Quoted 8 lines

No valid FDT found - please append one to U-Boot binary, use u-boot-dtb.bin or define CONFIG_OF_EMBED. For sandbox, use -d<file.dtb>

With this patch, it boots again with CONFIG_SYS_GENERIC_BOARD enabled.

Quoted 5 lines

The problem is that on architectures with old compilers (sparc, blackfin, nds32) this doesn't get discarded due to not being used but instead causes link errors. Can you figure out which option (CONFIG_FIT_SIGNATURE I suspect) drives this need and make sure we include fdtdec_common.o then? Thanks!

Quoted 3 lines

I look into it ... but I think it is not only one config option, as this code is not FIT specific and used also for code which uses DT ... (maybe CONFIG_OF_CONTROL or CONFIG_FIT_SIGNATURE).

That's fine, we can have multiple obj-$(CONFIG_...) += fdtdec_common.o (or rename it to fdtdec_get_int.o?).

But.. how is this only a runtime not link time failure?

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140611/fe252a3b/attachment.pgp>
#13 lore raw

PATCH v5 4/4 mpc8313: add CONFIG_SYS_GENERIC_BOARD to ids8313 board

In reply to Heiko Schocher

- add CONFIG_SYS_GENERIC_BOARD
- remove CONFIG_OF_CONTROL to boot again

---
- changes for v2:
- added acked-by from Kim
- changes for v3:
none
- changes for v4:
none
- changes for v5:
none

---
 include/configs/ids8313.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/configs/ids8313.h +2 -1
index 1de5750..3e55247 100644
@@ -19,6 +19,8 @@
 #define CONFIG_MPC8313
 #define CONFIG_IDS8313
 
+#define CONFIG_SYS_GENERIC_BOARD
+
 #define CONFIG_FSL_ELBC
 
 #define CONFIG_MISC_INIT_R
@@ -582,6 +584,5 @@
 #define CONFIG_RSA
 #define CONFIG_SHA1
 #define CONFIG_SHA256
-#define CONFIG_OF_CONTROL
 
 #endif	/* __CONFIG_H */
Signature · 1 line
1.8.3.1