mkimage: Put FIT loading in function and tidy error handling
PATCH v3 1/12 mkimage: Put FIT loading in function and tidy error handling
The fit_handle_file() function is quite long - split out the part that loads and checks a FIT into its own function. We will use this function for storing public keys into a destination FDT file.
The error handling is currently a bit repetitive - tidy it.
---
Changes in v3: None
Changes in v2:
- Fix spelling of quite
- Add comment about why mkimage needs to open FIT with O_RDWR
- Fix checkpatch checks about parenthesis alignment
tools/fit_image.c | 96 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 39 deletions(-)
tools/fit_image.c +57 -39
@@ -47,6 +47,48 @@ static int fit_check_image_types (uint8_t type)return EXIT_FAILURE ; } +int mmap_fdt (struct mkimage_params *params,const char *fname,void **blobp, +struct stat *sbuf) +{ +void *ptr; +int fd; + +/* Load FIT blob into memory (we need to write hashes/signatures) */ + fd =open (fname,O_RDWR |O_BINARY ); + +if (fd <0 ) { +fprintf (stderr,"%s: Can't open %s: %s\n" , + params->cmdname, fname,strerror (errno)); +unlink (fname); +return -1 ; + } + +if (fstat (fd, sbuf) <0 ) { +fprintf (stderr,"%s: Can't stat %s: %s\n" , + params->cmdname, fname,strerror (errno)); +unlink (fname); +return -1 ; + } + + ptr =mmap (0 , sbuf->st_size,PROT_READ |PROT_WRITE ,MAP_SHARED , fd,0 ); +if (ptr ==MAP_FAILED ) { +fprintf (stderr,"%s: Can't read %s: %s\n" , + params->cmdname, fname,strerror (errno)); +unlink (fname); +return -1 ; + } + +/* check if ptr has a valid blob */ +if (fdt_check_header (ptr)) { +fprintf (stderr,"%s: Invalid FIT blob\n" , params->cmdname); +unlink (fname); +return -1 ; + } + + *blobp = ptr; +return fd; +} +/** * fit_handle_file - main FIT file processing function *
@@ -65,7 +107,7 @@ static int fit_handle_file (struct mkimage_params *params)char cmd[MKIMAGE_MAX_DTC_CMDLINE_LEN ];int tfd;struct stat sbuf; -unsigned char *ptr; +void *ptr;/* Flattened Image Tree (FIT) format handling */ debug ("FIT format handling\n" );
@@ -87,57 +129,25 @@ static int fit_handle_file (struct mkimage_params *params)if (system (cmd) ==-1 ) {fprintf (stderr,"%s: system(%s) failed: %s\n" , params->cmdname, cmd,strerror (errno)); -unlink (tmpfile); -return (EXIT_FAILURE ); - } - -/* load FIT blob into memory */ - tfd =open (tmpfile,O_RDWR |O_BINARY ); - -if (tfd <0 ) { -fprintf (stderr,"%s: Can't open %s: %s\n" , - params->cmdname, tmpfile,strerror (errno)); -unlink (tmpfile); -return (EXIT_FAILURE ); - } - -if (fstat (tfd, &sbuf) <0 ) { -fprintf (stderr,"%s: Can't stat %s: %s\n" , - params->cmdname, tmpfile,strerror (errno)); -unlink (tmpfile); -return (EXIT_FAILURE ); - } - - ptr =mmap (0 , sbuf.st_size,PROT_READ |PROT_WRITE ,MAP_SHARED , - tfd,0 ); -if (ptr ==MAP_FAILED ) { -fprintf (stderr,"%s: Can't read %s: %s\n" , - params->cmdname, tmpfile,strerror (errno)); -unlink (tmpfile); -return (EXIT_FAILURE ); + goto err_system; } -/* check if ptr has a valid blob */ -if (fdt_check_header (ptr)) { -fprintf (stderr,"%s: Invalid FIT blob\n" , params->cmdname); -unlink (tmpfile); -return (EXIT_FAILURE ); - } + tfd =mmap_fdt (params, tmpfile, &ptr, &sbuf); +if (tfd <0 ) + goto err_mmap;/* set hashes for images in the blob */ if (fit_add_verification_data (ptr)) {fprintf (stderr,"%s Can't add hashes to FIT blob" , params->cmdname); -unlink (tmpfile); -return (EXIT_FAILURE ); + goto err_add_hashes; }/* add a timestamp at offset 0 i.e., root */ if (fit_set_timestamp (ptr,0 , sbuf.st_mtime)) {fprintf (stderr,"%s: Can't add image timestamp\n" , params->cmdname); -unlink (tmpfile); -return (EXIT_FAILURE ); + goto err_add_timestamp; }debug ("Added timestamp successfully\n" );
@@ -153,6 +163,14 @@ static int fit_handle_file (struct mkimage_params *params)return (EXIT_FAILURE ); }return (EXIT_SUCCESS ); + +err_add_timestamp: +err_add_hashes: +munmap (ptr, sbuf.st_size); +err_mmap: +err_system: +unlink (tmpfile); +return -1 ; }static int fit_check_params (struct mkimage_params *params)
Signature · 1 line
1.8.2.1
PATCH v3 2/12 image: Remove remaining #ifdefs in image-fit.c
There are only two left. One is unnecessary and the other can be moved to the header file.
---
Changes in v3: None
Changes in v2:
- Add new patch to remove #ifdefs in image-fit.c
common/image-fit.c | 9 ++------- common/image.c | 7 +------ include/image.h | 2 ++ 3 files changed, 5 insertions(+), 13 deletions(-)
common/image-fit.c +2 -7
@@ -149,11 +149,8 @@ void fit_print_contents(const void *fit)const char *p;time_t timestamp; -#ifdef USE_HOSTCC - p ="" ; -#else - p =" " ; -#endif +/* Indent string is defined in header image.h */ + p =IMAGE_INDENT_STRING ;/* Root node properties */ ret =fit_get_desc (fit,0 , &desc);
@@ -1463,7 +1460,6 @@ void fit_conf_print(const void *fit, int noffset, const char *p)* 1, on success * 0, on failure */ -#ifndef USE_HOSTCC int fit_check_ramdisk (const void *fit,int rd_noffset,uint8_t arch,int verify) {
@@ -1492,4 +1488,3 @@ int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch,bootstage_mark (BOOTSTAGE_ID_FIT_RD_CHECK_ALL_OK );return 1 ; } -#endif /* USE_HOSTCC */
common/image.c +1 -6
@@ -296,12 +296,7 @@ void image_print_contents(const void *ptr)const image_header_t *hdr = (const image_header_t *)ptr;const char *p; -#ifdef USE_HOSTCC - p ="" ; -#else - p =" " ; -#endif - + p =IMAGE_INDENT_STRING ;printf ("%sImage Name: %.*s\n" , p,IH_NMLEN ,image_get_name (hdr));if (IMAGE_ENABLE_TIMESTAMP ) {printf ("%sCreated: " , p);
include/image.h +2 -0
@@ -44,6 +44,7 @@#define CONFIG_FIT_VERBOSE 1/* enable fit_format_{error,warning}() */ #define IMAGE_ENABLE_IGNORE 0 +#define IMAGE_INDENT_STRING ""#else
@@ -53,6 +54,7 @@/* Take notice of the 'ignore' property for hashes */ #define IMAGE_ENABLE_IGNORE 1 +#define IMAGE_INDENT_STRING " "#endif /* USE_HOSTCC */
Signature · 1 line
1.8.2.1
PATCH v3 3/12 image: Add CONFIG_FIT_SPL_PRINT to control FIT image printing in SPL
In reply to Simon GlassThis code is very large, and in SPL it isn't always useful to print out image information (in fact there might not even be a console active). So disable this feature unless this option is set.
---
Changes in v3: None
Changes in v2:
- Add new patch to control FIT image printing in SPL
- Fix checkpatch warnings about space after cast
README | 6 ++++++ common/image-fit.c | 8 +++++--- include/image.h | 33 +++++++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 5 deletions(-)
README +6 -0
@@ -2996,6 +2996,12 @@ FIT uImage format: use an arch-specific makefile fragment instead, for example if more than one image needs to be produced. + CONFIG_FIT_SPL_PRINT + Printing information about a FIT image adds quite a bit of + code to SPL. So this is normally disabled in SPL. Use this + option to re-enable it. This will affect the output of the + bootm command when booting a FIT image. + Modem Support: --------------
common/image-fit.c +5 -3
@@ -124,6 +124,7 @@ static void fit_get_debug(const void *fit, int noffset, fdt_strerror(err)); } +#if !defined(CONFIG_SPL_BUILD ) || defined(CONFIG_FIT_SPL_PRINT )/** * fit_print_contents - prints out the contents of the FIT format image * @fit: pointer to the FIT format image header
@@ -402,6 +403,7 @@ void fit_image_print(const void *fit, int image_noffset, const char *p) } } } +#endif /** * fit_get_desc - get node description property
@@ -852,16 +854,16 @@ int fit_set_timestamp(void *fit, int noffset, time_t timestamp)int calculate_hash (const void *data,int data_len,const char *algo,uint8_t *value,int *value_len) { -if (strcmp (algo,"crc32" ) ==0 ) { +if (IMAGE_ENABLE_CRC32 &&strcmp (algo,"crc32" ) ==0 ) { *((uint32_t *)value) =crc32_wd (0 , data, data_len,CHUNKSZ_CRC32 ); *((uint32_t *)value) =cpu_to_uimage (*((uint32_t *)value)); *value_len =4 ; - }else if (strcmp (algo,"sha1" ) ==0 ) { + }else if (IMAGE_ENABLE_SHA1 &&strcmp (algo,"sha1" ) ==0 ) {sha1_csum_wd ((unsigned char *)data, data_len, (unsigned char *)value,CHUNKSZ_SHA1 ); *value_len =20 ; - }else if (strcmp (algo,"md5" ) ==0 ) { + }else if (IMAGE_ENABLE_MD5 &&strcmp (algo,"md5" ) ==0 ) {md5_wd ((unsigned char *)data, data_len, value,CHUNKSZ_MD5 ); *value_len =16 ; }else {
include/image.h +31 -2
@@ -61,8 +61,37 @@#if defined(CONFIG_FIT )#include <libfdt.h> #include <fdt_support.h> -#define CONFIG_MD5 /* FIT images need MD5 support */ -#define CONFIG_SHA1 /* and SHA1 */ +# ifdef CONFIG_SPL_BUILD +# ifdef CONFIG_SPL_CRC32_SUPPORT +# define IMAGE_ENABLE_CRC32 1 +# endif +# ifdef CONFIG_SPL_MD5_SUPPORT +# define IMAGE_ENABLE_MD5 1 +# endif +# ifdef CONFIG_SPL_SHA1_SUPPORT +# define IMAGE_ENABLE_SHA1 1 +# endif +# else +# define CONFIG_CRC32 /* FIT images need CRC32 support */ +# define CONFIG_MD5 /* and MD5 */ +# define CONFIG_SHA1 /* and SHA1 */ +# define IMAGE_ENABLE_CRC32 1 +# define IMAGE_ENABLE_MD5 1 +# define IMAGE_ENABLE_SHA1 1 +# endif + +#ifndef IMAGE_ENABLE_CRC32 +#define IMAGE_ENABLE_CRC32 0 +#endif + +#ifndef IMAGE_ENABLE_MD5 +#define IMAGE_ENABLE_MD5 0 +#endif + +#ifndef IMAGE_ENABLE_SHA1 +#define IMAGE_ENABLE_SHA1 0 +#endif +#endif /*
Signature · 1 line
1.8.2.1
PATCH v3 4/12 image: Split libfdt code into image-fdt.c
In reply to Simon GlassThe image file is still very large, and some of the code is only used when libfdt is in use. Move this code into a new file.
---
Changes in v3: None
Changes in v2:
- Fix checkpatch checks about parenthesis alignment
- Fix checkpatch warnings about split strings
common/Makefile | 1 + common/image-fdt.c | 591 +++++++++++++++++++++++++++++++++++++++++++++++++++++ common/image.c | 566 -------------------------------------------------- 3 files changed, 592 insertions(+), 566 deletions(-) create mode 100644 common/image-fdt.c
common/Makefile +1 -0
@@ -230,6 +230,7 @@ COBJS-$(CONFIG_BOUNCE_BUFFER) += bouncebuf.o COBJS-y += console.o COBJS-y += dlmalloc.o COBJS-y += image.o +COBJS-$(CONFIG_OF_LIBFDT) += image-fdt.o COBJS-$(CONFIG_FIT) += image-fit.o COBJS-y += memsize.o COBJS-y += stdio.o
common/image-fdt.c new file +591 -0
591 lines not on this page · raw message
common/image.c +0 -566
572 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH v3 5/12 image: Add device tree setup to image library
In reply to Simon GlassThis seems to be a common function for several architectures, so create a common function rather than duplicating the code in each arch.
Also make an attempt to avoid introducing #ifdefs in the new code, partly by removing useless #ifdefs around function declarations in the image.h header.
---
Changes in v3:
- Adjust indenting of #ifdefs
Changes in v2:
- Fix checkpatch checks about parenthesis alignment
common/image-fdt.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ common/image.c | 50 +++++++++++++++++++++++++++++++++++++++++ include/common.h | 10 +++++++++ include/fdt_support.h | 2 -- include/image.h | 61 ++++++++++++++++++++++++++++++++++++++++++-------- include/lmb.h | 2 -- 6 files changed, 174 insertions(+), 13 deletions(-)
common/image-fdt.c +62 -0
@@ -589,3 +589,65 @@ error: *of_size =0 ;return 1 ; } + +/* +* Verify the device tree. +* +* This function is called after all device tree fix-ups have been enacted, +* so that the final device tree can be verified. The definition of "verified" +* is up to the specific implementation. However, it generally means that the +* addresses of some of the devices in the device tree are compared with the +* actual addresses at which U-Boot has placed them. +* +* Returns 1 on success, 0 on failure. If 0 is returned, U-boot will halt the +* boot process. +*/ +__weak int ft_verify_fdt (void *fdt) +{ +return 1 ; +} + +__weak int arch_fixup_memory_node (void *blob) +{ +return 0 ; +} + +int image_setup_libfdt (bootm_headers_t *images,void *blob, +int of_size,struct lmb *lmb) +{ +ulong *initrd_start = &images->initrd_start; +ulong *initrd_end = &images->initrd_end; +int ret; + +if (fdt_chosen (blob,1 ) <0 ) { +puts ("ERROR: /chosen node create failed" ); +puts (" - must RESET the board to recover.\n" ); +return -1 ; + } +arch_fixup_memory_node (blob); +if (IMAAGE_OF_BOARD_SETUP ) +ft_board_setup (blob, gd->bd); +fdt_fixup_ethernet (blob); + +/* Delete the old LMB reservation */ +lmb_free (lmb, (phys_addr_t )(u32 )(uintptr_t )blob, + (phys_size_t )fdt_totalsize (blob)); + + ret =fdt_resize (blob); +if (ret <0 ) +return ret; + of_size = ret; + +if (*initrd_start && *initrd_end) { + of_size +=FDT_RAMDISK_OVERHEAD ; +fdt_set_totalsize (blob, of_size); + } +/* Create a new LMB reservation */ +lmb_reserve (lmb, (ulong )blob, of_size); + +fdt_initrd (blob, *initrd_start, *initrd_end,1 ); +if (!ft_verify_fdt (blob)) +return -1 ; + +return 0 ; +}
common/image.c +50 -0
60 lines not on this page · raw message
include/common.h +10 -0
@@ -323,6 +323,16 @@ int update_flash_size(int flash_size);*/ void board_show_dram (ulong size); +/** +* arch_fixup_memory_node() - Write arch-specific memory information to fdt +* +* Defined in arch/$(ARCH)/lib/bootm.c +* +* @blob: FDT blob to write to +* @return 0 if ok, or -ve FDT_ERR_... on failure +*/ +int arch_fixup_memory_node (void *blob); +/* common/flash.c */ void flash_perror (int );
include/fdt_support.h +0 -2
@@ -78,11 +78,9 @@ static inline void fdt_fixup_crypto_node(void *blob, int sec_rev) {}int fdt_pci_dma_ranges (void *blob,int phb_off,struct pci_controller *hose);#endif -#ifdef CONFIG_OF_BOARD_SETUP void ft_board_setup (void *blob,bd_t *bd);void ft_cpu_setup (void *blob,bd_t *bd);void ft_pci_setup (void *blob,bd_t *bd); -#endif void set_working_fdt_addr (void *addr);int fdt_resize (void *blob);
include/image.h +52 -9
100 lines not on this page · raw message
include/lmb.h +0 -2
@@ -1,7 +1,6 @@#ifndef _LINUX_LMB_H#define _LINUX_LMB_H#ifdef __KERNEL__ -#ifdef CONFIG_LMB #include <asm/types.h> /*
@@ -57,7 +56,6 @@ lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)void board_lmb_reserve (struct lmb *lmb);void arch_lmb_reserve (struct lmb *lmb); -#endif /* CONFIG_LMB */ #endif /* __KERNEL__ */ #endif /* _LINUX_LMB_H */
Signature · 1 line
1.8.2.1
PATCH v3 6/12 arm: Refactor bootm to reduce #ifdefs
In reply to Simon GlassWith fewer #ifdefs the code is more readable and more of the code is compiled for all boards. Add defines in the header file to control what features are enabled, and then use if() instead of #ifdef.
---
Changes in v3: None
Changes in v2:
- Fix checkpatch checks about parenthesis alignment
arch/arm/include/asm/bootm.h | 54 ++++++++++++++++++++++++- arch/arm/include/asm/u-boot-arm.h | 2 - arch/arm/lib/bootm.c | 84 ++++++++++----------------------------- common/cmd_bootm.c | 2 +- 4 files changed, 73 insertions(+), 69 deletions(-)
arch/arm/include/asm/bootm.h +52 -2
@@ -1,4 +1,7 @@ -/* Copyright (C) 2011 +/* +* Copyright (c) 2013, Google Inc. +* +* Copyright (C) 2011 * Corscience GmbH & Co. KG - Simon Schwarz <[email protected]> * * This program is free software; you can redistribute it and/or modify
@@ -19,8 +22,55 @@#ifndef ARM_BOOTM_H #define ARM_BOOTM_H -#ifdef CONFIG_USB_DEVICE extern void udc_disconnect (void ); + +#if defined(CONFIG_SETUP_MEMORY_TAGS ) || \ + defined(CONFIG_CMDLINE_TAG ) || \ + defined(CONFIG_INITRD_TAG ) || \ + defined(CONFIG_SERIAL_TAG ) || \ + defined(CONFIG_REVISION_TAG ) +# define BOOTM_ENABLE_TAGS 1 +#else +# define BOOTM_ENABLE_TAGS 0 +#endif + +#ifdef CONFIG_SETUP_MEMORY_TAGS +# define BOOTM_ENABLE_MEMORY_TAGS 1 +#else +# define BOOTM_ENABLE_MEMORY_TAGS 0 +#endif + +#ifdef CONFIG_CMDLINE_TAG +#define BOOTM_ENABLE_CMDLINE_TAG 1 +#else +#define BOOTM_ENABLE_CMDLINE_TAG 0 +#endif + +#ifdef CONFIG_INITRD_TAG +#define BOOTM_ENABLE_INITRD_TAG 1 +#else +#define BOOTM_ENABLE_INITRD_TAG 0 +#endif + +#ifdef CONFIG_SERIAL_TAG +#define BOOTM_ENABLE_SERIAL_TAG 1 +void get_board_serial (struct tag_serialnr *serialnr); +#else +#define BOOTM_ENABLE_SERIAL_TAG 0 +static inline void get_board_serial (struct tag_serialnr *serialnr) +{ +} +#endif + +#ifdef CONFIG_REVISION_TAG +#define BOOTM_ENABLE_REVISION_TAG 1 +u32 get_board_rev (void ); +#else +#define BOOTM_ENABLE_REVISION_TAG 0 +static inline u32 get_board_rev (void ) +{ +return 0 ; +}#endif #endif
arch/arm/include/asm/u-boot-arm.h +0 -2
@@ -54,8 +54,6 @@ int arch_early_init_r(void);int board_init (void );int dram_init (void );void dram_init_banksize (void ); -void setup_serial_tag (struct tag **params); -void setup_revision_tag (struct tag **params);/* cpu/.../interrupt.c */ int arch_interrupt_init (void );
arch/arm/lib/bootm.c +20 -64
178 lines not on this page · raw message
common/cmd_bootm.c +1 -1
@@ -276,7 +276,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]#if defined(CONFIG_FIT ) } else if (images.fit_uname_os) { ret =fit_image_get_entry (images.fit_hdr_os, - images.fit_noffset_os, &images.ep); + images.fit_noffset_os, &images.ep);if (ret) {puts ("Can't get entry point property!\n" );return 1 ;
Signature · 1 line
1.8.2.1
PATCH v3 7/12 arm: Use image_setup_linux() instead of local code
In reply to Simon GlassUse the common FDT setup function that is now available in image. Move the FDT-specific code to a new bootm-fdt.c and remove unused headers from bootm.c.
---
Changes in v3: None
Changes in v2: None
arch/arm/lib/Makefile | 1 + arch/arm/lib/bootm-fdt.c | 52 +++++++++++++++++++++++++++++++++++++++++++ arch/arm/lib/bootm.c | 57 +----------------------------------------------- 3 files changed, 54 insertions(+), 56 deletions(-) create mode 100644 arch/arm/lib/bootm-fdt.c
arch/arm/lib/Makefile +1 -0
@@ -45,6 +45,7 @@ endif COBJS-y += bss.o COBJS-y += bootm.o +COBJS-$(CONFIG_OF_LIBFDT) += bootm-fdt.o COBJS-$(CONFIG_SYS_L2_PL310) += cache-pl310.o SOBJS-$(CONFIG_USE_ARCH_MEMSET) += memset.o SOBJS-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
arch/arm/lib/bootm-fdt.c new file +52 -0
52 lines not on this page · raw message
arch/arm/lib/bootm.c +1 -56
81 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH v3 8/12 powerpc: Use image_setup_linux() instead of local code
In reply to Simon GlassRather than having similar code in powerpc, use image_setup_linux() which should be common across all architectures that use the FDT.
---
Changes in v3: None
Changes in v2: None
arch/powerpc/lib/bootm.c | 84 +----------------------------------------------- 1 file changed, 1 insertion(+), 83 deletions(-)
arch/powerpc/lib/bootm.c +1 -83
@@ -220,101 +220,19 @@ static int boot_bd_t_linux(bootm_headers_t *images)return ret; } -/* -* Verify the device tree. -* -* This function is called after all device tree fix-ups have been enacted, -* so that the final device tree can be verified. The definition of "verified" -* is up to the specific implementation. However, it generally means that the -* addresses of some of the devices in the device tree are compared with the -* actual addresses at which U-Boot has placed them. -* -* Returns 1 on success, 0 on failure. If 0 is returned, U-boot will halt the -* boot process. -*/ -static int __ft_verify_fdt (void *fdt) -{ -return 1 ; -} -__attribute__((weak,alias ("__ft_verify_fdt" )))int ft_verify_fdt (void *fdt); -static int boot_body_linux (bootm_headers_t *images) { -ulong rd_len; -struct lmb *lmb = &images->lmb; -ulong *initrd_start = &images->initrd_start; -ulong *initrd_end = &images->initrd_end; -#if defined(CONFIG_OF_LIBFDT ) -ulong of_size = images->ft_len; -char **of_flat_tree = &images->ft_addr; -#endif -int ret; -#if defined(CONFIG_OF_LIBFDT ) -boot_fdt_add_mem_rsv_regions (lmb, *of_flat_tree); -#endif - -/* allocate space and init command line */ - ret =boot_cmdline_linux (images); -if (ret) -return ret; -/* allocate space for kernel copy of board info */ ret =boot_bd_t_linux (images);if (ret)return ret; - rd_len = images->rd_end - images->rd_start; - ret =boot_ramdisk_high (lmb, images->rd_start, rd_len, initrd_start, initrd_end); -if (ret) -return ret; - -#if defined(CONFIG_OF_LIBFDT ) - ret =boot_relocate_fdt (lmb, of_flat_tree, &of_size); + ret =image_setup_linux (images);if (ret)return ret; -/* -* Add the chosen node if it doesn't exist, add the env and bd_t -* if the user wants it (the logic is in the subroutines). -*/ -if (of_size) { -if (fdt_chosen (*of_flat_tree,1 ) <0 ) { -puts ("ERROR: " ); -puts ("/chosen node create failed" ); -puts (" - must RESET the board to recover.\n" ); -return -1 ; - } -#ifdef CONFIG_OF_BOARD_SETUP -/* Call the board-specific fixup routine */ -ft_board_setup (*of_flat_tree, gd->bd); -#endif - -/* Delete the old LMB reservation */ -lmb_free (lmb, (phys_addr_t)(u32)*of_flat_tree, - (phys_size_t )fdt_totalsize (*of_flat_tree)); - - ret =fdt_resize (*of_flat_tree); -if (ret <0 ) -return ret; - of_size = ret; - -if (*initrd_start && *initrd_end) { - of_size +=FDT_RAMDISK_OVERHEAD ; -fdt_set_totalsize (*of_flat_tree, of_size); - } -/* Create a new LMB reservation */ -lmb_reserve (lmb, (ulong)*of_flat_tree, of_size); - -/* fixup the initrd now that we know where it should be */ -if (*initrd_start && *initrd_end) -fdt_initrd (*of_flat_tree, *initrd_start, *initrd_end,1 ); - -if (!ft_verify_fdt (*of_flat_tree)) -return -1 ; - } -#endif /* CONFIG_OF_LIBFDT */ return 0 ; }
Signature · 1 line
1.8.2.1
PATCH v3 9/12 m68k: Use image_setup_linux() instead of local code
In reply to Simon GlassRather than having similar code in m68k, use image_setup_linux() which should be common across all architectures that use the FDT.
---
Changes in v3: None
Changes in v2: None
arch/m68k/lib/bootm.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
arch/m68k/lib/bootm.c +3 -12
@@ -78,13 +78,6 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *imaif ((flag !=0 ) && (flag !=BOOTM_STATE_OS_GO ))return 1 ; -/* allocate space and init command line */ - ret =boot_get_cmdline (lmb, &cmd_start, &cmd_end); -if (ret) { -puts ("ERROR with allocation of cmdline\n" ); - goto error; - } -/* allocate space for kernel copy of board info */ ret =boot_get_kbd (lmb, &kbd);if (ret) {
@@ -93,14 +86,12 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima }set_clocks_in_mhz (kbd); - kernel = (void (*)(bd_t *,ulong ,ulong ,ulong ,ulong ))images->ep; - - rd_len = images->rd_end - images->rd_start; - ret =boot_ramdisk_high (lmb, images->rd_start, rd_len, - &initrd_start, &initrd_end); + ret =image_setup_linux (images);if (ret) goto error; + kernel = (void (*)(bd_t *,ulong ,ulong ,ulong ,ulong ))images->ep; +debug ("## Transferring control to Linux (at address %08lx) ...\n" , (ulong ) kernel);
Signature · 1 line
1.8.2.1
PATCH v3 10/12 sparc: Use image_setup_linux() instead of local code
In reply to Simon GlassSparc only really sets up the ramdisk, but we should still use image_setup_linux() so that setup is common across all architectures that use the FDT.
Cover-letter
Introduce a common image_setup_linux() function
This series continues the work to tidy up the image code. Each architecture has its own code for setting up ready for booting linux. An attempt is made here to unify these in a single image_setup_linux() function.
The part of the image code that deals with FDT is split into image-fdt.c and a few tweaks are added to make FIT images more viable in SPL. END
---
Changes in v3:
- Split the image_setup_linux() commits into their own series
Changes in v2: None
arch/sparc/lib/bootm.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
arch/sparc/lib/bootm.c +7 -10
@@ -95,10 +95,8 @@ void arch_lmb_reserve(struct lmb *lmb)int do_bootm_linux (int flag,int argc,char *const argv[],bootm_headers_t * images) {char *bootargs; -ulong initrd_start, initrd_end;ulong rd_len;void (*kernel) (struct linux_romvec *,void *); -struct lmb *lmb = &images->lmb;int ret;if ((flag !=0 ) && (flag !=BOOTM_STATE_OS_GO ))
@@ -131,24 +129,23 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t * im* extracted and is writeable. */ + ret =image_setup_linux (images); +if (ret) { +puts ("### Failed to relocate RAM disk\n" ); + goto error; + } +/* Calc length of RAM disk, if zero no ramdisk available */ rd_len = images->rd_end - images->rd_start;if (rd_len) { - ret =boot_ramdisk_high (lmb, images->rd_start, rd_len, - &initrd_start, &initrd_end); -if (ret) { -puts ("### Failed to relocate RAM disk\n" ); - goto error; - } -/* Update SPARC kernel header so that Linux knows * what is going on and where to find RAM disk. * * Set INITRD Image address relative to RAM Start */ linux_hdr->hdr_input.ver_0203.sparc_ramdisk_image = - initrd_start -CONFIG_SYS_RAM_BASE ; + images->initrd_start -CONFIG_SYS_RAM_BASE ; linux_hdr->hdr_input.ver_0203.sparc_ramdisk_size = rd_len;/* Clear READ ONLY flag if set to non-zero */ linux_hdr->hdr_input.ver_0203.root_flags =1 ;
Signature · 1 line
1.8.2.1
PATCH v3 11/12 buildman: Allow conflicting tags to avoid spurious errors
In reply to Simon GlassConflicting tags can prevent buildman from building two series which exist one after the other in a branch. There is no reason not to allow this sort of workflow with buildman, so ignore conflicting tags in buildman.
---
Changes in v3: None
Changes in v2: None
tools/buildman/control.py | 5 +++++ tools/patman/series.py | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-)
tools/buildman/control.py +5 -0
@@ -137,6 +137,11 @@ def DoBuildman(options, args): upstream_commit = gitutil.GetUpstream(options.git_dir, options.branch) series = patchstream.GetMetaDataForList(upstream_commit, options.git_dir, 1) + # Conflicting tags are not a problem for buildman, since it does not use + # then. For example, Series-version is not useful for buildman. On the + # other hand conflicting tags will cause an error. So allow later tags + # to overwrite earlier ones. + series.allow_overwrite = True series = patchstream.GetMetaDataForList(range_expr, options.git_dir, None, series)
tools/patman/series.py +3 -1
@@ -40,6 +40,7 @@ class Series(dict): notes: List of lines in the notes changes: (dict) List of changes for each version, The key is the integer version number + allow_overwrite: Allow tags to overwrite an existing tag """ def __init__(self): self.cc = []
@@ -49,6 +50,7 @@ class Series(dict): self.cover = None self.notes = [] self.changes = {} + self.allow_overwrite = False # Written in MakeCcFile() # key: name of patch file
@@ -72,7 +74,7 @@ class Series(dict): """ # If we already have it, then add to our list name = name.replace('-', '_') - if name in self: + if name in self and not self.allow_overwrite: values = value.split(',') values = [str.strip() for str in values] if type(self[name]) != type([]):
Signature · 1 line
1.8.2.1
PATCH v3 12/12 buildman: Produce a sensible error message when branch is missing
In reply to Simon GlassRather than a backtrace, produce a nice error message when an invalid branch is provided to buildman.
---
Changes in v3: None
Changes in v2: None
tools/buildman/control.py | 4 ++++ tools/patman/gitutil.py | 21 +++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-)
tools/buildman/control.py +4 -0
@@ -111,6 +111,10 @@ def DoBuildman(options, args): print col.Color(col.RED, str) sys.exit(1) count = gitutil.CountCommitsInBranch(options.git_dir, options.branch) + if count is None: + str = "Branch '%s' not found or has no upstream" % options.branch + print col.Color(col.RED, str) + sys.exit(1) count += 1 # Build upstream commit also if not count:
tools/patman/gitutil.py +15 -6
@@ -56,10 +56,14 @@ def GetUpstream(git_dir, branch): Returns: Name of upstream branch (e.g. 'upstream/master') or None if none """ - remote = command.OutputOneLine('git', '--git-dir', git_dir, 'config', - 'branch.%s.remote' % branch) - merge = command.OutputOneLine('git', '--git-dir', git_dir, 'config', - 'branch.%s.merge' % branch) + try: + remote = command.OutputOneLine('git', '--git-dir', git_dir, 'config', + 'branch.%s.remote' % branch) + merge = command.OutputOneLine('git', '--git-dir', git_dir, 'config', + 'branch.%s.merge' % branch) + except: + return None + if remote == '.': return merge elif remote and merge:
@@ -78,9 +82,11 @@ def GetRangeInBranch(git_dir, branch, include_upstream=False): branch: Name of branch Return: Expression in the form 'upstream..branch' which can be used to - access the commits. + access the commits. If the branch does not exist, returns None. """ upstream = GetUpstream(git_dir, branch) + if not upstream: + return None return '%s%s..%s' % (upstream, '~' if include_upstream else '', branch) def CountCommitsInBranch(git_dir, branch, include_upstream=False):
@@ -90,9 +96,12 @@ def CountCommitsInBranch(git_dir, branch, include_upstream=False): git_dir: Directory containing git repo branch: Name of branch Return: - Number of patches that exist on top of the branch + Number of patches that exist on top of the branch, or None if the + branch does not exist. """ range_expr = GetRangeInBranch(git_dir, branch, include_upstream) + if not range_expr: + return None pipe = [['git', '--git-dir', git_dir, 'log', '--oneline', '--no-decorate', range_expr], ['wc', '-l']]
Signature · 1 line
1.8.2.1
PATCH v3 1/12 mkimage: Put FIT loading in function and tidy error handling
In reply to Simon GlassQuoted 7 lines · Simon Glass
The
fit_handle_file()function is quite long - split out the part that loads and checks a FIT into its own function. We will use this function for storing public keys into a destination FDT file.The error handling is currently a bit repetitive - tidy it.
Signed-off-by Simon Glass <[email protected]>
Applied to u-boot/master, along with the rest of the series, 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/20130515/9e32b33c/attachment.pgp>