From bfb05d0187d70274c77d02dc0de5e728e1f8be05 Mon Sep 17 00:00:00 2001 From: Siarhei Siamashka Date: Thu, 3 Sep 2015 02:36:39 +0300 Subject: sunxi: Ensure that 'mksunxiboot' tool produces deterministic output Currently some uninitialized padding bytes are written to the output file, as can be confirmed with valgrind: $ valgrind tools/mksunxiboot spl/u-boot-spl.bin spl/sunxi-spl.bin ==5581== Syscall param write(buf) points to uninitialised byte(s) ==5581== at 0x4F0F940: __write_nocancel (in /lib64/libc-2.20.so) ==5581== by 0x400839: main (in /tmp/u-boot/tools/mksunxiboot) ==5581== Address 0xffeff5d3c is on thread 1's stack ==5581== in frame #1, created by main (???) This patch fixes the problem by clearing the whole structure instead of just a portion of it. Signed-off-by: Siarhei Siamashka Acked-by: Hans de Goede Signed-off-by: Hans de Goede --- tools/mksunxiboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/mksunxiboot.c b/tools/mksunxiboot.c index 3361251c8e..676d392fb4 100644 --- a/tools/mksunxiboot.c +++ b/tools/mksunxiboot.c @@ -99,7 +99,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - memset(img.pad, 0, BLOCK_SIZE); + memset(&img, 0, sizeof(img)); /* get input file size */ file_size = lseek(fd_in, 0, SEEK_END); -- cgit From b5e7586a73d4eb7b0aa9c597f293a584a2a1800a Mon Sep 17 00:00:00 2001 From: Michael Heimpold Date: Tue, 1 Sep 2015 23:58:44 +0200 Subject: mxs: mxsboot: fix endianess for sd boot images Running mxsboot on a big-endian system produces a sd image which cannot be started by the i.MX28 ROM. It complains on the debug uart as following: 0x8020a009 0x80502008 0x8020a009 0x80502008 ... Enforcing all fields within the BCB to little-endian make the image bootable again. Signed-off-by: Michael Heimpold Acked-by: Stefano Babic Acked-by: Marek Vasut --- tools/mxsboot.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'tools') diff --git a/tools/mxsboot.c b/tools/mxsboot.c index 15eec9179d..3434c81792 100644 --- a/tools/mxsboot.c +++ b/tools/mxsboot.c @@ -7,6 +7,7 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#include #include #include #include @@ -556,15 +557,15 @@ static int mx28_create_sd_image(int infd, int outfd) cb = (struct mx28_sd_config_block *)buf; - cb->signature = 0x00112233; - cb->primary_boot_tag = 0x1; - cb->secondary_boot_tag = 0x1; - cb->num_copies = 1; - cb->drv_info[0].chip_num = 0x0; - cb->drv_info[0].drive_type = 0x0; - cb->drv_info[0].tag = 0x1; - cb->drv_info[0].first_sector_number = sd_sector + 4; - cb->drv_info[0].sector_count = (size - 4) / 512; + cb->signature = htole32(0x00112233); + cb->primary_boot_tag = htole32(0x1); + cb->secondary_boot_tag = htole32(0x1); + cb->num_copies = htole32(1); + cb->drv_info[0].chip_num = htole32(0x0); + cb->drv_info[0].drive_type = htole32(0x0); + cb->drv_info[0].tag = htole32(0x1); + cb->drv_info[0].first_sector_number = htole32(sd_sector + 4); + cb->drv_info[0].sector_count = htole32((size - 4) / 512); wr_size = write(outfd, buf, size); if (wr_size != size) { -- cgit From 3e4dad50320d20894710276eb09f2057c6985065 Mon Sep 17 00:00:00 2001 From: Josh Wu Date: Wed, 16 Sep 2015 18:21:04 +0800 Subject: tools: gen_eth_addr: add getpid() to time(0) to avoid duplicated seed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As 'time(0) | getpid()' will have a lot of duplicated value. It is not a expected behavior. We expect different value for the seed when when run it in many times. So this patch will left shift the getpid() and add to time(0). That avoid duplicated value. Test command is like: % RUN=0; while [ $RUN -lt 10000 ]; do tools/gen_eth_addr; RUN=$(($RUN+1)); done | sort | uniq | wc -l 10000 This patch is incorporated with suggestions made by Wolfgang Denk and Andreas Bießmann. Thanks them a lot. Signed-off-by: Josh Wu Acked-by: Andreas Bießmann Acked-by: Wolfgang Denk Tested-by: Wolfgang Denk --- tools/gen_eth_addr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/gen_eth_addr.c b/tools/gen_eth_addr.c index bf9d935efd..5fa3e0cf56 100644 --- a/tools/gen_eth_addr.c +++ b/tools/gen_eth_addr.c @@ -15,7 +15,7 @@ main(int argc, char *argv[]) { unsigned long ethaddr_low, ethaddr_high; - srand(time(0) | getpid()); + srand(time(0) + (getpid() << 8)); /* * setting the 2nd LSB in the most significant byte of -- cgit From 4440ececed2d7c7494e03e462b395bdf4e8a418c Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Fri, 25 Sep 2015 01:22:39 -0700 Subject: tools: moveconfig: Update the URL for nds32 toolchain Give a full URL for a working nds32 toolchain for U-Boot. Signed-off-by: Bin Meng Reviewed-by: Masahiro Yamada --- tools/moveconfig.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/moveconfig.py b/tools/moveconfig.py index 496c90a9dc..1b53f951a4 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -181,7 +181,7 @@ SLEEP_TIME=0.03 # (https://www.kernel.org/pub/tools/crosstool/files/bin/), except the followings: # arc: https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases # blackfin: http://sourceforge.net/projects/adi-toolchain/files/ -# nds32: http://osdk.andestech.com/packages/ +# nds32: http://osdk.andestech.com/packages/nds32le-linux-glibc-v1.tgz # nios2: https://sourcery.mentor.com/GNUToolchain/subscription42545 # sh: http://sourcery.mentor.com/public/gnu_toolchain/sh-linux-gnu CROSS_COMPILE = { -- cgit From e954eb8028d7085fc8d0737c8e637ab940f7f147 Mon Sep 17 00:00:00 2001 From: Bernhard Nortmann Date: Thu, 17 Sep 2015 18:52:50 +0200 Subject: sunxi: move SPL-related definitions to platform-specific include The sunxi platform currently doesn't seem to make any use of the asm/arch-sunxi/spl.h file. This patch moves some declarations from tools/mksunxiboot.c into it. This enables us to reuse those definitions when extending the sunxi board code (boards/sunxi/boards.c). Signed-off-by: Bernhard Nortmann Acked-by: Hans de Goede Signed-off-by: Hans de Goede --- tools/mksunxiboot.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'tools') diff --git a/tools/mksunxiboot.c b/tools/mksunxiboot.c index 676d392fb4..54f4d0564e 100644 --- a/tools/mksunxiboot.c +++ b/tools/mksunxiboot.c @@ -15,23 +15,8 @@ #include #include #include +#include "asm/arch/spl.h" -/* boot head definition from sun4i boot code */ -struct boot_file_head { - uint32_t b_instruction; /* one intruction jumping to real code */ - uint8_t magic[8]; /* ="eGON.BT0" or "eGON.BT1", not C-style str */ - uint32_t check_sum; /* generated by PC */ - uint32_t length; /* generated by PC */ - /* - * We use a simplified header, only filling in what is needed - * by the boot ROM. To be compatible with Allwinner tools we - * would need to implement the proper fields here instead of - * padding. - */ - uint8_t pad[12]; /* align to 32 bytes */ -}; - -#define BOOT0_MAGIC "eGON.BT0" #define STAMP_VALUE 0x5F0A6C39 /* check sum functon from sun4i boot code */ -- cgit From a188438175bd5fb4ef0440c9fdd0ded8b5640b3d Mon Sep 17 00:00:00 2001 From: Bernhard Nortmann Date: Thu, 17 Sep 2015 18:52:51 +0200 Subject: sunxi: (mksunxiboot) signature to indicate "sunxi" SPL variant This patch follows up on a discussion of ways to improve support for the sunxi FEL ("USB boot") mechanism, especially with regard to boot scripts, see: https://groups.google.com/d/msg/linux-sunxi/wBEGUoLNRro/rHGq6nSYCQAJ The idea is to convert the (currently unused) "pad" bytes in the SPL header into an area where data can be passed to U-Boot. To do this safely, we have to make sure that we're actually using our "sunxi" flavor of the SPL, and not the Allwinner boot0. The modified mksunxiboot introduces a special signature to the SPL header in place of the "pub_head_size" field. This can be used to reliably distinguish between compatible versions of sunxi SPL and anything else (older variants or Allwinner's boot0). Signed-off-by: Bernhard Nortmann Acked-by: Siarhei Siamashka Acked-by: Hans de Goede Signed-off-by: Hans de Goede --- tools/mksunxiboot.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tools') diff --git a/tools/mksunxiboot.c b/tools/mksunxiboot.c index 54f4d0564e..9c1c5b7cee 100644 --- a/tools/mksunxiboot.c +++ b/tools/mksunxiboot.c @@ -118,6 +118,10 @@ int main(int argc, char *argv[]) ALIGN(file_size + sizeof(struct boot_file_head), BLOCK_SIZE); img.header.b_instruction = cpu_to_le32(img.header.b_instruction); img.header.length = cpu_to_le32(img.header.length); + + memcpy(img.header.spl_signature, SPL_SIGNATURE, 3); /* "sunxi" marker */ + img.header.spl_signature[3] = SPL_HEADER_VERSION; + gen_check_sum(&img.header); count = write(fd_out, &img, le32_to_cpu(img.header.length)); -- cgit From e29f1db3dd96901fb54d8faefed8cd2987704b68 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Tue, 29 Sep 2015 09:19:59 +0200 Subject: tools: kwboot: Add support for UART boot mode patching for Armada XP/38x Currently, kwboot only allows dynamic UART boot mode patching for SoCs with header version 0 (Orion, Kirkwood). This patch now enables this "-p" feature also for SoCs with header version 1 (Armada XP / 38x etc). With this its possible now to use the UART boot mode without on images that are generated for other boot devices, like SPI. So no need to change BOOT_FROM to "uart" for UART xmodem booting any more. Signed-off-by: Stefan Roese Tested-by: Kevin Smith Cc: Luka Perkov Cc: Dirk Eibach --- tools/kwbimage.c | 94 --------------------------------------- tools/kwbimage.h | 133 ++++++++++++++++++++++++++++++++++++++++--------------- tools/kwboot.c | 37 +++++++++++----- 3 files changed, 125 insertions(+), 139 deletions(-) (limited to 'tools') diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 3fa90d3a75..5e62d08a80 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -17,89 +17,6 @@ #include #include "kwbimage.h" -#define ALIGN_SUP(x, a) (((x) + (a - 1)) & ~(a - 1)) - -/* Structure of the main header, version 0 (Kirkwood, Dove) */ -struct main_hdr_v0 { - uint8_t blockid; /*0 */ - uint8_t nandeccmode; /*1 */ - uint16_t nandpagesize; /*2-3 */ - uint32_t blocksize; /*4-7 */ - uint32_t rsvd1; /*8-11 */ - uint32_t srcaddr; /*12-15 */ - uint32_t destaddr; /*16-19 */ - uint32_t execaddr; /*20-23 */ - uint8_t satapiomode; /*24 */ - uint8_t rsvd3; /*25 */ - uint16_t ddrinitdelay; /*26-27 */ - uint16_t rsvd2; /*28-29 */ - uint8_t ext; /*30 */ - uint8_t checksum; /*31 */ -}; - -struct ext_hdr_v0_reg { - uint32_t raddr; - uint32_t rdata; -}; - -#define EXT_HDR_V0_REG_COUNT ((0x1dc - 0x20) / sizeof(struct ext_hdr_v0_reg)) - -struct ext_hdr_v0 { - uint32_t offset; - uint8_t reserved[0x20 - sizeof(uint32_t)]; - struct ext_hdr_v0_reg rcfg[EXT_HDR_V0_REG_COUNT]; - uint8_t reserved2[7]; - uint8_t checksum; -}; - -/* Structure of the main header, version 1 (Armada 370, Armada XP) */ -struct main_hdr_v1 { - uint8_t blockid; /* 0 */ - uint8_t reserved1; /* 1 */ - uint16_t reserved2; /* 2-3 */ - uint32_t blocksize; /* 4-7 */ - uint8_t version; /* 8 */ - uint8_t headersz_msb; /* 9 */ - uint16_t headersz_lsb; /* A-B */ - uint32_t srcaddr; /* C-F */ - uint32_t destaddr; /* 10-13 */ - uint32_t execaddr; /* 14-17 */ - uint8_t reserved3; /* 18 */ - uint8_t nandblocksize; /* 19 */ - uint8_t nandbadblklocation; /* 1A */ - uint8_t reserved4; /* 1B */ - uint16_t reserved5; /* 1C-1D */ - uint8_t ext; /* 1E */ - uint8_t checksum; /* 1F */ -}; - -/* - * Header for the optional headers, version 1 (Armada 370, Armada XP) - */ -struct opt_hdr_v1 { - uint8_t headertype; - uint8_t headersz_msb; - uint16_t headersz_lsb; - char data[0]; -}; - -/* - * Various values for the opt_hdr_v1->headertype field, describing the - * different types of optional headers. The "secure" header contains - * informations related to secure boot (encryption keys, etc.). The - * "binary" header contains ARM binary code to be executed prior to - * executing the main payload (usually the bootloader). This is - * typically used to execute DDR3 training code. The "register" header - * allows to describe a set of (address, value) tuples that are - * generally used to configure the DRAM controller. - */ -#define OPT_HDR_V1_SECURE_TYPE 0x1 -#define OPT_HDR_V1_BINARY_TYPE 0x2 -#define OPT_HDR_V1_REGISTER_TYPE 0x3 - -#define KWBHEADER_V1_SIZE(hdr) \ - (((hdr)->headersz_msb << 16) | (hdr)->headersz_lsb) - static struct image_cfg_element *image_cfg; static int cfgn; @@ -173,17 +90,6 @@ struct image_cfg_element { #define IMAGE_CFG_ELEMENT_MAX 256 -/* - * Byte 8 of the image header contains the version number. In the v0 - * header, byte 8 was reserved, and always set to 0. In the v1 header, - * byte 8 has been changed to a proper field, set to 1. - */ -static unsigned int image_version(void *header) -{ - unsigned char *ptr = header; - return ptr[8]; -} - /* * Utility functions to manipulate boot mode and ecc modes (convert * them back and forth between description strings and the diff --git a/tools/kwbimage.h b/tools/kwbimage.h index 8e4a4e2810..9d2585c0e7 100644 --- a/tools/kwbimage.h +++ b/tools/kwbimage.h @@ -29,57 +29,109 @@ #define IBR_HDR_UART_ID 0x69 #define IBR_DEF_ATTRIB 0x00 -enum kwbimage_cmd { - CMD_INVALID, - CMD_BOOT_FROM, - CMD_NAND_ECC_MODE, - CMD_NAND_PAGE_SIZE, - CMD_SATA_PIO_MODE, - CMD_DDR_INIT_DELAY, - CMD_DATA -}; +#define ALIGN_SUP(x, a) (((x) + (a - 1)) & ~(a - 1)) -enum kwbimage_cmd_types { - CFG_INVALID = -1, - CFG_COMMAND, - CFG_DATA0, - CFG_DATA1 -}; - -/* typedefs */ -typedef struct bhr_t { - uint8_t blockid; /*0 */ - uint8_t nandeccmode; /*1 */ +/* Structure of the main header, version 0 (Kirkwood, Dove) */ +struct main_hdr_v0 { + uint8_t blockid; /*0 */ + uint8_t nandeccmode; /*1 */ uint16_t nandpagesize; /*2-3 */ uint32_t blocksize; /*4-7 */ uint32_t rsvd1; /*8-11 */ uint32_t srcaddr; /*12-15 */ uint32_t destaddr; /*16-19 */ uint32_t execaddr; /*20-23 */ - uint8_t satapiomode; /*24 */ - uint8_t rsvd3; /*25 */ + uint8_t satapiomode; /*24 */ + uint8_t rsvd3; /*25 */ uint16_t ddrinitdelay; /*26-27 */ uint16_t rsvd2; /*28-29 */ - uint8_t ext; /*30 */ - uint8_t checkSum; /*31 */ -} bhr_t, *pbhr_t; + uint8_t ext; /*30 */ + uint8_t checksum; /*31 */ +}; -struct reg_config { +struct ext_hdr_v0_reg { uint32_t raddr; uint32_t rdata; }; -typedef struct extbhr_t { - uint32_t dramregsoffs; - uint8_t rsrvd1[0x20 - sizeof(uint32_t)]; - struct reg_config rcfg[KWBIMAGE_MAX_CONFIG]; - uint8_t rsrvd2[7]; - uint8_t checkSum; -} extbhr_t, *pextbhr_t; +#define EXT_HDR_V0_REG_COUNT ((0x1dc - 0x20) / sizeof(struct ext_hdr_v0_reg)) + +struct ext_hdr_v0 { + uint32_t offset; + uint8_t reserved[0x20 - sizeof(uint32_t)]; + struct ext_hdr_v0_reg rcfg[EXT_HDR_V0_REG_COUNT]; + uint8_t reserved2[7]; + uint8_t checksum; +}; struct kwb_header { - bhr_t kwb_hdr; - extbhr_t kwb_exthdr; + struct main_hdr_v0 kwb_hdr; + struct ext_hdr_v0 kwb_exthdr; +}; + +/* Structure of the main header, version 1 (Armada 370, Armada XP) */ +struct main_hdr_v1 { + uint8_t blockid; /* 0 */ + uint8_t reserved1; /* 1 */ + uint16_t reserved2; /* 2-3 */ + uint32_t blocksize; /* 4-7 */ + uint8_t version; /* 8 */ + uint8_t headersz_msb; /* 9 */ + uint16_t headersz_lsb; /* A-B */ + uint32_t srcaddr; /* C-F */ + uint32_t destaddr; /* 10-13 */ + uint32_t execaddr; /* 14-17 */ + uint8_t reserved3; /* 18 */ + uint8_t nandblocksize; /* 19 */ + uint8_t nandbadblklocation; /* 1A */ + uint8_t reserved4; /* 1B */ + uint16_t reserved5; /* 1C-1D */ + uint8_t ext; /* 1E */ + uint8_t checksum; /* 1F */ +}; + +/* + * Header for the optional headers, version 1 (Armada 370, Armada XP) + */ +struct opt_hdr_v1 { + uint8_t headertype; + uint8_t headersz_msb; + uint16_t headersz_lsb; + char data[0]; +}; + +/* + * Various values for the opt_hdr_v1->headertype field, describing the + * different types of optional headers. The "secure" header contains + * informations related to secure boot (encryption keys, etc.). The + * "binary" header contains ARM binary code to be executed prior to + * executing the main payload (usually the bootloader). This is + * typically used to execute DDR3 training code. The "register" header + * allows to describe a set of (address, value) tuples that are + * generally used to configure the DRAM controller. + */ +#define OPT_HDR_V1_SECURE_TYPE 0x1 +#define OPT_HDR_V1_BINARY_TYPE 0x2 +#define OPT_HDR_V1_REGISTER_TYPE 0x3 + +#define KWBHEADER_V1_SIZE(hdr) \ + (((hdr)->headersz_msb << 16) | (hdr)->headersz_lsb) + +enum kwbimage_cmd { + CMD_INVALID, + CMD_BOOT_FROM, + CMD_NAND_ECC_MODE, + CMD_NAND_PAGE_SIZE, + CMD_SATA_PIO_MODE, + CMD_DDR_INIT_DELAY, + CMD_DATA +}; + +enum kwbimage_cmd_types { + CFG_INVALID = -1, + CFG_COMMAND, + CFG_DATA0, + CFG_DATA1 }; /* @@ -87,4 +139,15 @@ struct kwb_header { */ void init_kwb_image_type (void); +/* + * Byte 8 of the image header contains the version number. In the v0 + * header, byte 8 was reserved, and always set to 0. In the v1 header, + * byte 8 has been changed to a proper field, set to 1. + */ +static inline unsigned int image_version(void *header) +{ + unsigned char *ptr = header; + return ptr[8]; +} + #endif /* _KWBIMAGE_H_ */ diff --git a/tools/kwboot.c b/tools/kwboot.c index af7a6ee3f6..c5f4492b5f 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -614,9 +614,10 @@ static int kwboot_img_patch_hdr(void *img, size_t size) { int rc; - bhr_t *hdr; + struct main_hdr_v1 *hdr; uint8_t csum; - const size_t hdrsz = sizeof(*hdr); + size_t hdrsz = sizeof(*hdr); + int image_ver; rc = -1; hdr = img; @@ -626,8 +627,20 @@ kwboot_img_patch_hdr(void *img, size_t size) goto out; } - csum = kwboot_img_csum8(hdr, hdrsz) - hdr->checkSum; - if (csum != hdr->checkSum) { + image_ver = image_version(img); + if (image_ver < 0) { + fprintf(stderr, "Invalid image header version\n"); + errno = EINVAL; + goto out; + } + + if (image_ver == 0) + hdrsz = sizeof(*hdr); + else + hdrsz = KWBHEADER_V1_SIZE(hdr); + + csum = kwboot_img_csum8(hdr, hdrsz) - hdr->checksum; + if (csum != hdr->checksum) { errno = EINVAL; goto out; } @@ -639,14 +652,18 @@ kwboot_img_patch_hdr(void *img, size_t size) hdr->blockid = IBR_HDR_UART_ID; - hdr->nandeccmode = IBR_HDR_ECC_DISABLED; - hdr->nandpagesize = 0; + if (image_ver == 0) { + struct main_hdr_v0 *hdr_v0 = img; - hdr->srcaddr = hdr->ext - ? sizeof(struct kwb_header) - : sizeof(*hdr); + hdr_v0->nandeccmode = IBR_HDR_ECC_DISABLED; + hdr_v0->nandpagesize = 0; + + hdr_v0->srcaddr = hdr_v0->ext + ? sizeof(struct kwb_header) + : sizeof(*hdr_v0); + } - hdr->checkSum = kwboot_img_csum8(hdr, hdrsz) - csum; + hdr->checksum = kwboot_img_csum8(hdr, hdrsz) - csum; rc = 0; out: -- cgit From 835c30e368e9661a6d99179d948f64efebf5d1de Mon Sep 17 00:00:00 2001 From: Troy Kisky Date: Mon, 21 Sep 2015 14:02:48 -0700 Subject: imximage: header.length of 4 is valid Signed-off-by: Troy Kisky --- tools/imximage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/imximage.c b/tools/imximage.c index 0da48a733d..7e60bf5d39 100644 --- a/tools/imximage.c +++ b/tools/imximage.c @@ -361,8 +361,8 @@ static void print_hdr_v2(struct imx_header *imx_hdr) dcd_v2_t *dcd_v2 = &hdr_v2->dcd_table; uint32_t size, version; - size = be16_to_cpu(dcd_v2->header.length) - 8; - if (size > (MAX_HW_CFG_SIZE_V2 * sizeof(dcd_addr_data_t))) { + size = be16_to_cpu(dcd_v2->header.length); + if (size > (MAX_HW_CFG_SIZE_V2 * sizeof(dcd_addr_data_t)) + 8) { fprintf(stderr, "Error: Image corrupt DCD size %d exceed maximum %d\n", (uint32_t)(size / sizeof(dcd_addr_data_t)), -- cgit From 61903b759aa336d798da49d884467219796817ff Mon Sep 17 00:00:00 2001 From: Troy Kisky Date: Mon, 14 Sep 2015 18:06:31 -0700 Subject: imximage: fix commands other than write_data When CHECK_BITS_SET was added, they forgot to add a new command table, and instead overwrote the previous table. Signed-off-by: Troy Kisky Tested-by: Fabio Estevam --- tools/imximage.c | 77 ++++++++++++++++++++++++++++++++++++++++---------------- tools/imximage.h | 8 ++++-- 2 files changed, 62 insertions(+), 23 deletions(-) (limited to 'tools') diff --git a/tools/imximage.c b/tools/imximage.c index 7e60bf5d39..7c219222e9 100644 --- a/tools/imximage.c +++ b/tools/imximage.c @@ -160,54 +160,80 @@ static void set_dcd_val_v1(struct imx_header *imxhdr, char *name, int lineno, } } +static struct dcd_v2_cmd *gd_last_cmd; + static void set_dcd_param_v2(struct imx_header *imxhdr, uint32_t dcd_len, int32_t cmd) { dcd_v2_t *dcd_v2 = &imxhdr->header.hdr_v2.dcd_table; + struct dcd_v2_cmd *d = gd_last_cmd; + struct dcd_v2_cmd *d2; + int len; + + if (!d) + d = &dcd_v2->dcd_cmd; + d2 = d; + len = be16_to_cpu(d->write_dcd_command.length); + if (len > 4) + d2 = (struct dcd_v2_cmd *)(((char *)d) + len); switch (cmd) { case CMD_WRITE_DATA: - dcd_v2->write_dcd_command.tag = DCD_WRITE_DATA_COMMAND_TAG; - dcd_v2->write_dcd_command.length = cpu_to_be16( - dcd_len * sizeof(dcd_addr_data_t) + 4); - dcd_v2->write_dcd_command.param = DCD_WRITE_DATA_PARAM; + if ((d->write_dcd_command.tag == DCD_WRITE_DATA_COMMAND_TAG) && + (d->write_dcd_command.param == DCD_WRITE_DATA_PARAM)) + break; + d = d2; + d->write_dcd_command.tag = DCD_WRITE_DATA_COMMAND_TAG; + d->write_dcd_command.length = cpu_to_be16(4); + d->write_dcd_command.param = DCD_WRITE_DATA_PARAM; break; case CMD_WRITE_CLR_BIT: - dcd_v2->write_dcd_command.tag = DCD_WRITE_DATA_COMMAND_TAG; - dcd_v2->write_dcd_command.length = cpu_to_be16( - dcd_len * sizeof(dcd_addr_data_t) + 4); - dcd_v2->write_dcd_command.param = DCD_WRITE_CLR_BIT_PARAM; + if ((d->write_dcd_command.tag == DCD_WRITE_DATA_COMMAND_TAG) && + (d->write_dcd_command.param == DCD_WRITE_CLR_BIT_PARAM)) + break; + d = d2; + d->write_dcd_command.tag = DCD_WRITE_DATA_COMMAND_TAG; + d->write_dcd_command.length = cpu_to_be16(4); + d->write_dcd_command.param = DCD_WRITE_CLR_BIT_PARAM; break; /* * Check data command only supports one entry, - * so use 0xC = size(address + value + command). */ case CMD_CHECK_BITS_SET: - dcd_v2->write_dcd_command.tag = DCD_CHECK_DATA_COMMAND_TAG; - dcd_v2->write_dcd_command.length = cpu_to_be16(0xC); - dcd_v2->write_dcd_command.param = DCD_CHECK_BITS_SET_PARAM; + d = d2; + d->write_dcd_command.tag = DCD_CHECK_DATA_COMMAND_TAG; + d->write_dcd_command.length = cpu_to_be16(4); + d->write_dcd_command.param = DCD_CHECK_BITS_SET_PARAM; break; case CMD_CHECK_BITS_CLR: - dcd_v2->write_dcd_command.tag = DCD_CHECK_DATA_COMMAND_TAG; - dcd_v2->write_dcd_command.length = cpu_to_be16(0xC); - dcd_v2->write_dcd_command.param = DCD_CHECK_BITS_SET_PARAM; + d = d2; + d->write_dcd_command.tag = DCD_CHECK_DATA_COMMAND_TAG; + d->write_dcd_command.length = cpu_to_be16(4); + d->write_dcd_command.param = DCD_CHECK_BITS_SET_PARAM; break; default: break; } + gd_last_cmd = d; } static void set_dcd_val_v2(struct imx_header *imxhdr, char *name, int lineno, int fld, uint32_t value, uint32_t off) { - dcd_v2_t *dcd_v2 = &imxhdr->header.hdr_v2.dcd_table; + struct dcd_v2_cmd *d = gd_last_cmd; + int len; + + len = be16_to_cpu(d->write_dcd_command.length); + off = (len - 4) >> 3; switch (fld) { case CFG_REG_ADDRESS: - dcd_v2->addr_data[off].addr = cpu_to_be32(value); + d->addr_data[off].addr = cpu_to_be32(value); break; case CFG_REG_VALUE: - dcd_v2->addr_data[off].value = cpu_to_be32(value); + d->addr_data[off].value = cpu_to_be32(value); + off++; + d->write_dcd_command.length = cpu_to_be16((off << 3) + 4); break; default: break; @@ -236,12 +262,20 @@ static void set_dcd_rst_v2(struct imx_header *imxhdr, uint32_t dcd_len, char *name, int lineno) { dcd_v2_t *dcd_v2 = &imxhdr->header.hdr_v2.dcd_table; + struct dcd_v2_cmd *d = gd_last_cmd; + int len; + + if (!d) + d = &dcd_v2->dcd_cmd; + len = be16_to_cpu(d->write_dcd_command.length); + if (len > 4) + d = (struct dcd_v2_cmd *)(((char *)d) + len); + + len = (char *)d - (char *)&dcd_v2->header; dcd_v2->header.tag = DCD_HEADER_TAG; - dcd_v2->header.length = cpu_to_be16( - dcd_len * sizeof(dcd_addr_data_t) + 8); + dcd_v2->header.length = cpu_to_be16(len); dcd_v2->header.version = DCD_VERSION; - set_dcd_param_v2(imxhdr, dcd_len, CMD_WRITE_DATA); } static void set_imx_hdr_v1(struct imx_header *imxhdr, uint32_t dcd_len, @@ -314,6 +348,7 @@ static void set_hdr_func(void) max_dcd_entries = MAX_HW_CFG_SIZE_V1; break; case IMXIMAGE_V2: + gd_last_cmd = NULL; set_dcd_val = set_dcd_val_v2; set_dcd_param = set_dcd_param_v2; set_dcd_rst = set_dcd_rst_v2; diff --git a/tools/imximage.h b/tools/imximage.h index d41c74f327..c7b9b5c8cc 100644 --- a/tools/imximage.h +++ b/tools/imximage.h @@ -133,10 +133,14 @@ typedef struct { uint8_t param; } __attribute__((packed)) write_dcd_command_t; -typedef struct { - ivt_header_t header; +struct dcd_v2_cmd { write_dcd_command_t write_dcd_command; dcd_addr_data_t addr_data[MAX_HW_CFG_SIZE_V2]; +}; + +typedef struct { + ivt_header_t header; + struct dcd_v2_cmd dcd_cmd; uint32_t padding[1]; /* end up on an 8-byte boundary */ } dcd_v2_t; -- cgit From 354973076af744882f10311faa6dc0c1ca09d16b Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Wed, 26 Aug 2015 15:21:23 -0400 Subject: tools/mkimage.c: Clarify help text for -D slightly Try and make it clear that -D will replace all arguments passed to dtc and is not appending them. Signed-off-by: Tom Rini --- tools/mkimage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/mkimage.c b/tools/mkimage.c index c50af0510d..8af9d50e2c 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -595,7 +595,7 @@ static void usage(void) params.cmdname); fprintf(stderr, " %s [-D dtc_options] [-f fit-image.its|-F] fit-image\n", params.cmdname); - fprintf(stderr, " -D => set options for device tree compiler\n" + fprintf(stderr, " -D => set all options for device tree compiler\n" " -f => input filename for FIT source\n"); #ifdef CONFIG_FIT_SIGNATURE fprintf(stderr, "Signing / verified boot options: [-k keydir] [-K dtb] [ -c ] [-r]\n" -- cgit From 0219e4bfb4d31aed8bbbcf36b00b92844b9b5eb9 Mon Sep 17 00:00:00 2001 From: Vagrant Cascadian Date: Fri, 2 Oct 2015 09:11:51 -0700 Subject: Fix variation in timestamps caused by timezone differences. When building with SOURCE_DATE_EPOCH set, avoid use of mktime in default_image.c, which converts the timestamp into localtime. This causes variation based on timezone when building u-boot.img and u-boot-sunxi-with-spl.bin targets. Signed-off-by: Vagrant Cascadian Tested-by: Paul Kocialkowski Acked-by: Paul Kocialkowski --- tools/default_image.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'tools') diff --git a/tools/default_image.c b/tools/default_image.c index 18940af5b5..3ed7014147 100644 --- a/tools/default_image.c +++ b/tools/default_image.c @@ -89,7 +89,6 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd, { uint32_t checksum; char *source_date_epoch; - struct tm *time_universal; time_t time; image_header_t * hdr = (image_header_t *)ptr; @@ -103,13 +102,10 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd, if (source_date_epoch != NULL) { time = (time_t) strtol(source_date_epoch, NULL, 10); - time_universal = gmtime(&time); - if (time_universal == NULL) { + if (gmtime(&time) == NULL) { fprintf(stderr, "%s: SOURCE_DATE_EPOCH is not valid\n", __func__); time = 0; - } else { - time = mktime(time_universal); } } else { time = sbuf->st_mtime; -- cgit