tools: mkimage: Add support for initialization table for Zynq and ZynqMP
Subsystems (4)
PATCH v2 1/1 tools: mkimage: Add support for initialization table for Zynq and ZynqMP
The Zynq/ZynqMP boot.bin file contains a region for register initialization data. Filling in proper values in this table can reduce boot time (e.g. about 50ms faster on QSPI boot) and also reduce the size of the SPL binary.
The table is a simple text file with register+data on each line. Other lines are simply skipped. The file can be passed to mkimage using the "-R" parameter.
It is recommended to add reg init file to board folder.
For example:CONFIG_BOOT_INIT_FILE="board/xilinx/zynqmp/xilinx_zynqmp_zcu102/reg.int
---
v2: Add ${srctree} to initialisation path to fix out-of-tree builds
arch/arm/cpu/armv8/zynqmp/Kconfig | 7 +++++++ arch/arm/mach-zynq/Kconfig | 7 +++++++ scripts/Makefile.spl | 4 ++-- tools/zynqimage.c | 28 ++++++++++++++++++++++++++++ tools/zynqmpimage.c | 28 ++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 2 deletions(-)
arch/arm/cpu/armv8/zynqmp/Kconfig +7 -0
@@ -41,6 +41,13 @@ config SYS_CONFIG_NAME Based on this option include/configs/<CONFIG_SYS_CONFIG_NAME>.h header will be used for board configuration. +config BOOT_INIT_FILE + string "boot.bin init register filename" + default "" + help + Add register writes to boot.bin format (max 256 pairs). + Expect a table of register-value pairs, e.g. "0x12345678 0x4321" + config ZYNQMP_USB bool "Configure ZynqMP USB"
arch/arm/mach-zynq/Kconfig +7 -0
@@ -44,4 +44,11 @@ config SYS_CONFIG_NAME config SYS_MALLOC_F_LEN default 0x600 +config BOOT_INIT_FILE + string "boot.bin init register filename" + default "" + help + Add register writes to boot.bin format (max 256 pairs). + Expect a table of register-value pairs, e.g. "0x12345678 0x4321" + endif
scripts/Makefile.spl +2 -2
@@ -142,10 +142,10 @@ boot.bin: $(obj)/u-boot-spl.bin FORCE $(call if_changed,mkimage) else ifdef CONFIG_ARCH_ZYNQ -MKIMAGEFLAGS_boot.bin = -T zynqimage +MKIMAGEFLAGS_boot.bin = -T zynqimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE) endif ifdef CONFIG_ARCH_ZYNQMP -MKIMAGEFLAGS_boot.bin = -T zynqmpimage +MKIMAGEFLAGS_boot.bin = -T zynqmpimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE) endif spl/boot.bin: $(obj)/u-boot-spl.bin FORCE
tools/zynqimage.c +28 -0
@@ -222,6 +222,30 @@ static int zynqimage_check_image_types(uint8_t type)return EXIT_FAILURE ; } +static void zynqimage_parse_initparams (struct zynq_header *zynqhdr, +const char *filename) +{ +/* Expect a table of register-value pairs, e.g. "0x12345678 0x4321" */ +FILE *fp =fopen (filename,"r" ); +struct zynq_reginit reginit; +unsigned int reg_count =0 ; +int r; + +if (!fp) { +fprintf (stderr,"Cannot open initparams file: %s\n" , filename); +exit (1 ); + } +do { + r =fscanf (fp,"%x %x" , ®init.address, ®init.data); +if (r ==2 ) { + zynqhdr->register_init[reg_count] = reginit; + ++reg_count; + } + r =fscanf (fp,"%*[^\n]\n" );/* Skip to next line */ + }while ((r !=EOF ) && (reg_count <HEADER_REGINITS )); +fclose (fp); +} +static void zynqimage_set_header (void *ptr,struct stat *sbuf,int ifd,struct image_tool_params *params) {
@@ -237,6 +261,10 @@ static void zynqimage_set_header(void *ptr, struct stat *sbuf, int ifd,if (params->eflag) zynqhdr->image_load =cpu_to_le32 ((uint32_t )params->ep); +/* User can pass in text file with init list */ +if (strlen (params->imagename2)) +zynqimage_parse_initparams (zynqhdr, params->imagename2); + zynqhdr->checksum =zynqimage_checksum (zynqhdr); }
tools/zynqmpimage.c +28 -0
@@ -234,6 +234,30 @@ static int zynqmpimage_check_image_types(uint8_t type)return EXIT_FAILURE ; } +static void zynqmpimage_parse_initparams (struct zynqmp_header *zynqhdr, +const char *filename) +{ +/* Expect a table of register-value pairs, e.g. "0x12345678 0x4321" */ +FILE *fp =fopen (filename,"r" ); +struct zynqmp_reginit reginit; +unsigned int reg_count =0 ; +int r; + +if (!fp) { +fprintf (stderr,"Cannot open initparams file: %s\n" , filename); +exit (1 ); + } +do { + r =fscanf (fp,"%x %x" , ®init.address, ®init.data); +if (r ==2 ) { + zynqhdr->register_init[reg_count] = reginit; + ++reg_count; + } + r =fscanf (fp,"%*[^\n]\n" );/* Skip to next line */ + }while ((r !=EOF ) && (reg_count <HEADER_REGINITS )); +fclose (fp); +} +static void zynqmpimage_set_header (void *ptr,struct stat *sbuf,int ifd,struct image_tool_params *params) {
@@ -250,6 +274,10 @@ static void zynqmpimage_set_header(void *ptr, struct stat *sbuf, int ifd,if (params->eflag) zynqhdr->image_load =cpu_to_le32 ((uint32_t )params->ep); +/* User can pass in text file with init list */ +if (strlen (params->imagename2)) +zynqmpimage_parse_initparams (zynqhdr, params->imagename2); + zynqhdr->checksum =zynqmpimage_checksum (zynqhdr); }
Signature · 1 line
1.9.1
Michal Simek
AppliedPATCH v2 1/1 tools: mkimage: Add support for initialization table for Zynq and ZynqMP
2016-09-27 22:41 GMT-07:00 Mike Looijmans <[email protected]>:
Quoted 182 lines
The Zynq/ZynqMP boot.bin file contains a region for register initialization data. Filling in proper values in this table can reduce boot time (e.g. about 50ms faster on QSPI boot) and also reduce the size of the SPL binary.
The table is a simple text file with register+data on each line. Other lines are simply skipped. The file can be passed to mkimage using the "-R" parameter.
It is recommended to add reg init file to board folder.
For example:CONFIG_BOOT_INIT_FILE="board/xilinx/zynqmp/xilinx_zynqmp_zcu102/reg.intSigned-off-by Mike Looijmans <[email protected]>Signed-off-by Michal Simek <[email protected]>---
v2: Add ${srctree} to initialisation path to fix out-of-tree buildsarch/arm/cpu/armv8/zynqmp/Kconfig | 7 +++++++ arch/arm/mach-zynq/Kconfig | 7 +++++++ scripts/Makefile.spl | 4 ++-- tools/zynqimage.c | 28 ++++++++++++++++++++++++++++ tools/zynqmpimage.c | 28 ++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 2 deletions(-)arch/arm/cpu/armv8/zynqmp/Kconfig +0
-0@@ -41,6 +41,13 @@ config SYS_CONFIG_NAME Based on this option include/configs/<CONFIG_SYS_CONFIG_NAME>.hheader
will be used for board configuration.arch/arm/cpu/armv8/zynqmp/Kconfig +7
-0+config BOOT_INIT_FILE + string "boot.bin init register filename" + default "" + help + Add register writes to boot.bin format (max 256 pairs). + Expect a table of register-value pairs, e.g. "0x12345678 0x4321" + config ZYNQMP_USB bool "Configure ZynqMP USB"arch/arm/mach-zynq/Kconfig +7
-0@@ -44,4 +44,11 @@ config SYS_CONFIG_NAME config SYS_MALLOC_F_LEN default 0x600 +config BOOT_INIT_FILE + string "boot.bin init register filename" + default "" + help + Add register writes to boot.bin format (max 256 pairs). + Expect a table of register-value pairs, e.g. "0x12345678 0x4321" + endifscripts/Makefile.spl +2
-2@@ -142,10 +142,10 @@ boot.bin: $(obj)/u-boot-spl.bin FORCE $(call if_changed,mkimage) else ifdef CONFIG_ARCH_ZYNQ -MKIMAGEFLAGS_boot.bin = -T zynqimage +MKIMAGEFLAGS_boot.bin = -T zynqimage -R $(srctree)/$(CONFIG_BOOT_INIT_ FILE) endif ifdef CONFIG_ARCH_ZYNQMP -MKIMAGEFLAGS_boot.bin = -T zynqmpimage +MKIMAGEFLAGS_boot.bin = -T zynqmpimage -R $(srctree)/$(CONFIG_BOOT_INIT_ FILE) endifspl/boot.bin: $(obj)/u-boot-spl.bin FORCE
tools/zynqimage.c +4
-0@@ -222,6 +222,30 @@ static int zynqimage_check_image_types(uint8_t type)return EXIT_FAILURE ; } +static void zynqimage_parse_initparams (struct zynq_header *zynqhdr, +const char *filename) +{ +/* Expect a table of register-value pairs, e.g. "0x12345678
0x4321" */tools/zynqimage.c +7
-0+FILE *fp =fopen (filename,"r" ); +struct zynq_reginit reginit; +unsigned int reg_count =0 ; +int r; + +if (!fp) { + fprintf(stderr, "Cannot open initparams file: %s\n",filename);
tools/zynqimage.c +17
-0+exit (1 ); + } +do { + r =fscanf (fp,"%x %x" , ®init.address, ®init.data); +if (r ==2 ) { + zynqhdr->register_init[reg_count] = reginit; + ++reg_count; + } + r =fscanf (fp,"%*[^\n]\n" );/* Skip to next line */ + }while ((r !=EOF ) && (reg_count <HEADER_REGINITS )); +fclose (fp); +} +static void zynqimage_set_header (void *ptr,struct stat *sbuf,int ifd,struct image_tool_params *params) {@@ -237,6 +261,10 @@ static void zynqimage_set_header(void *ptr, struct stat *sbuf, int ifd, if (params->eflag) zynqhdr->image_load = cpu_to_le32((uint32_t)params->ep); +/* User can pass in text file with init list */ +if (strlen (params->imagename2)) +zynqimage_parse_initparams (zynqhdr, params->imagename2); + zynqhdr->checksum =zynqimage_checksum (zynqhdr); }tools/zynqmpimage.c +4
-0@@ -234,6 +234,30 @@ static int zynqmpimage_check_image_types(uint8_t type)return EXIT_FAILURE ; } +static void zynqmpimage_parse_initparams (struct zynqmp_header *zynqhdr, +const char *filename) +{ +/* Expect a table of register-value pairs, e.g. "0x12345678
0x4321" */tools/zynqmpimage.c +7
-0+FILE *fp =fopen (filename,"r" ); +struct zynqmp_reginit reginit; +unsigned int reg_count =0 ; +int r; + +if (!fp) { + fprintf(stderr, "Cannot open initparams file: %s\n",filename);
tools/zynqmpimage.c +17
-1+exit (1 ); + } +do { + r =fscanf (fp,"%x %x" , ®init.address, ®init.data); +if (r ==2 ) { + zynqhdr->register_init[reg_count] = reginit; + ++reg_count; + } + r =fscanf (fp,"%*[^\n]\n" );/* Skip to next line */ + }while ((r !=EOF ) && (reg_count <HEADER_REGINITS )); +fclose (fp); +} +static void zynqmpimage_set_header (void *ptr,struct stat *sbuf,int ifd,struct image_tool_params *params) {@@ -250,6 +274,10 @@ static void zynqmpimage_set_header(void *ptr, struct stat *sbuf, int ifd, if (params->eflag) zynqhdr->image_load = cpu_to_le32((uint32_t)params->ep); +/* User can pass in text file with init list */ +if (strlen (params->imagename2)) +zynqmpimage_parse_initparams (zynqhdr, params->imagename2); + zynqhdr->checksum =zynqmpimage_checksum (zynqhdr); } --1.9.1
Quoted 5 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Applied.
Thanks,
Michal
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/ Maintainer of Linux kernel - Xilinx Zynq ARM architecture Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform