From patchwork Fri Jul 23 09:13:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509047 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=xsPVil2D; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNvR2h4sz9sRN for ; Fri, 23 Jul 2021 19:15:15 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E6E8682D3C; Fri, 23 Jul 2021 11:14:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="xsPVil2D"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 277ED82CDE; Fri, 23 Jul 2021 11:14:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1E18182CDA for ; Fri, 23 Jul 2021 11:14:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id A4AFF1409F3; Fri, 23 Jul 2021 11:14:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031677; bh=rbRtvyLAEupUzTCK25Co5S3MFdlh4uYSa/Q730DslR8=; h=From:To:Date; b=xsPVil2DdTLfXPA+huR5hQn03huJ6J/eBBkjGD02bNXlPgSmZ1X781ZFPc0tePi1X p5xrkAXbjYqThqumFit3et465heJyi3I0gNxD3ToIFvtssuU6HtmDkK3SKiCTh4BGI Dk4UEXApb05u59RME+J57vhG37EtLbzfZ2tbdJ50= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 01/41] tools: kwbimage: Fix compilation without CONFIG_SYS_U_BOOT_OFFS Date: Fri, 23 Jul 2021 11:13:55 +0200 Message-Id: <20210723091435.20388-2-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The CONFIG_SYS_U_BOOT_OFFS option may be defined as empty string. In this case it causes compilation error: tools/kwbimage.c: In function ‘image_headersz_v1’: tools/kwbimage.c:1002:39: error: expected expression before ‘)’ token if (headersz > CONFIG_SYS_U_BOOT_OFFS) { ^ tools/kwbimage.c:1006:41: error: expected expression before ‘)’ token (int)headersz, CONFIG_SYS_U_BOOT_OFFS); ^ tools/kwbimage.c:1011:35: error: expected expression before ‘;’ token headersz = CONFIG_SYS_U_BOOT_OFFS; ^ make[1]: *** [scripts/Makefile.host:112: tools/kwbimage.o] Error 1 make: *** [Makefile:1822: tools] Error 2 Check whether the value of CONFIG_SYS_U_BOOT_OFFS is really set. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/Makefile b/tools/Makefile index bae3f95c49..9517f203fd 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -169,7 +169,7 @@ HOST_EXTRACFLAGS += -DCONFIG_FIT_SIGNATURE_MAX_SIZE=0xffffffff HOST_EXTRACFLAGS += -DCONFIG_FIT_CIPHER endif -ifdef CONFIG_SYS_U_BOOT_OFFS +ifneq ($(CONFIG_SYS_U_BOOT_OFFS),) HOSTCFLAGS_kwbimage.o += -DCONFIG_SYS_U_BOOT_OFFS=$(CONFIG_SYS_U_BOOT_OFFS) endif From patchwork Fri Jul 23 09:13:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509057 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=YQs9A3MA; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNxT3L8Dz9sXM for ; Fri, 23 Jul 2021 19:17:01 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A1B7582E32; Fri, 23 Jul 2021 11:15:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="YQs9A3MA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A53E682D73; Fri, 23 Jul 2021 11:14:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7A6E382D72 for ; Fri, 23 Jul 2021 11:14:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id E56831408AE; Fri, 23 Jul 2021 11:14:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031679; bh=UV1FfhT7zWHJElPMYLsivio1DQpyKBItoqxzmWYO53M=; h=From:To:Date; b=YQs9A3MAWsgp018fJULThVJU6+7Q0c4SryuVnGmkkPM4bHdxsgD2UyyfJPkUrmJEL ExZxahmddlmGMImHipp2QvG399Xw0JSpSYGiF2IHwa4IfVk5t5uh6VxmK7a6e1ayIA FVpvTY49eYfFDLrOoZCnioZgj2WFk9OCR0dP60Po= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 02/41] tools: kwbimage: Simplify aligning and calculating checksum Date: Fri, 23 Jul 2021 11:13:56 +0200 Message-Id: <20210723091435.20388-3-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The return value of kwbimage_generate() is used for aligning the data part of kwbimage. Use it for calculating proper 4 byte alignment as is required by BootROM and also use it for allocating additional 4 bytes for the 32-bit data checksum. This simplifies the alignment code to be only at one place (in function kwbimage_generate) and also simplifies setting checksum as it can be directly updated in memory. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwbimage.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 02fd0c949f..c775abf0e3 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -891,7 +891,7 @@ static void *image_create_v0(size_t *imagesz, struct image_tool_params *params, /* Fill in the main header */ main_hdr->blocksize = - cpu_to_le32(payloadsz + sizeof(uint32_t) - headersz); + cpu_to_le32(payloadsz - headersz); main_hdr->srcaddr = cpu_to_le32(headersz); main_hdr->ext = has_ext; main_hdr->destaddr = cpu_to_le32(params->addr); @@ -1249,7 +1249,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, /* Fill the main header */ main_hdr->blocksize = - cpu_to_le32(payloadsz - headersz + sizeof(uint32_t)); + cpu_to_le32(payloadsz - headersz); main_hdr->headersz_lsb = cpu_to_le16(headersz & 0xFFFF); main_hdr->headersz_msb = (headersz & 0xFFFF0000) >> 16; main_hdr->destaddr = cpu_to_le32(params->addr) @@ -1519,7 +1519,6 @@ static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd, size_t headersz = 0; uint32_t checksum; int ret; - int size; fcfg = fopen(params->imagename, "r"); if (!fcfg) { @@ -1547,9 +1546,6 @@ static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd, exit(EXIT_FAILURE); } - /* The MVEBU BootROM does not allow non word aligned payloads */ - sbuf->st_size = ALIGN(sbuf->st_size, 4); - version = image_get_version(); switch (version) { /* @@ -1580,16 +1576,10 @@ static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd, free(image_cfg); /* Build and add image checksum header */ - checksum = - cpu_to_le32(image_checksum32((uint32_t *)ptr, sbuf->st_size)); - size = write(ifd, &checksum, sizeof(uint32_t)); - if (size != sizeof(uint32_t)) { - fprintf(stderr, "Error:%s - Checksum write %d bytes %s\n", - params->cmdname, size, params->imagefile); - exit(EXIT_FAILURE); - } - - sbuf->st_size += sizeof(uint32_t); + checksum = cpu_to_le32(image_checksum32((uint8_t *)ptr + headersz, + sbuf->st_size - headersz - sizeof(uint32_t))); + memcpy((uint8_t *)ptr + sbuf->st_size - sizeof(uint32_t), &checksum, + sizeof(uint32_t)); /* Finally copy the header into the image area */ memcpy(ptr, image, headersz); @@ -1650,6 +1640,7 @@ static int kwbimage_generate(struct image_tool_params *params, struct image_type_params *tparams) { FILE *fcfg; + struct stat s; int alloc_len; int version; void *hdr; @@ -1662,6 +1653,12 @@ static int kwbimage_generate(struct image_tool_params *params, exit(EXIT_FAILURE); } + if (stat(params->datafile, &s)) { + fprintf(stderr, "Could not stat data file %s: %s\n", + params->datafile, strerror(errno)); + exit(EXIT_FAILURE); + } + image_cfg = malloc(IMAGE_CFG_ELEMENT_MAX * sizeof(struct image_cfg_element)); if (!image_cfg) { @@ -1719,12 +1716,9 @@ static int kwbimage_generate(struct image_tool_params *params, /* * The resulting image needs to be 4-byte aligned. At least * the Marvell hdrparser tool complains if its unaligned. - * By returning 1 here in this function, called via - * tparams->vrec_header() in mkimage.c, mkimage will - * automatically pad the the resulting image to a 4-byte - * size if necessary. + * After the image data is stored 4-byte checksum. */ - return 1; + return 4 + (4 - s.st_size % 4) % 4; } /* From patchwork Fri Jul 23 09:13:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509046 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=pAQ/X94r; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNvK0FCfz9sRN for ; Fri, 23 Jul 2021 19:15:08 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C806182D7E; Fri, 23 Jul 2021 11:14:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="pAQ/X94r"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2DF0B82D6F; Fri, 23 Jul 2021 11:14:44 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9F66882CDE for ; Fri, 23 Jul 2021 11:14:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 32B25140952; Fri, 23 Jul 2021 11:14:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031680; bh=A7li9QhScmBNZbq5cr7m+AqckvdOxzW6xn8O3wJ8Ih4=; h=From:To:Date; b=pAQ/X94r66NHk+VVdz90FAdamfuelWqrhSbStCWKlowkLgdICC+WY2KgBUQ/3S+HJ dEnkBf2HtPIwyupv/5lh/5gD7RFZHPfKgrrhDzVhYYdeFjdw/FyowuYlvG5ld0cZzF ophbRKUey9mNeyWZH2/ce6IqjRoCHyjq887khBjw= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 03/41] tools: kwbimage: Align SPI and NAND images to 256 bytes Date: Fri, 23 Jul 2021 11:13:57 +0200 Message-Id: <20210723091435.20388-4-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Writing into SPI NOR and NAND memory can be done only in 256 bytes long blocks. Align final image size so that when it is burned into SPI NOR or NAND memory via U-Boot's commands (sf or mtd), we can use the $filesize variable directly as the length argument. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwbimage.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index c775abf0e3..f40ba0994d 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1510,6 +1510,17 @@ static int image_get_version(void) return e->version; } +static int image_get_bootfrom(void) +{ + struct image_cfg_element *e; + + e = image_find_option(IMAGE_CFG_BOOT_FROM); + if (!e) + return -1; + + return e->bootfrom; +} + static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd, struct image_tool_params *params) { @@ -1642,6 +1653,7 @@ static int kwbimage_generate(struct image_tool_params *params, FILE *fcfg; struct stat s; int alloc_len; + int bootfrom; int version; void *hdr; int ret; @@ -1678,6 +1690,7 @@ static int kwbimage_generate(struct image_tool_params *params, exit(EXIT_FAILURE); } + bootfrom = image_get_bootfrom(); version = image_get_version(); switch (version) { /* @@ -1717,8 +1730,12 @@ static int kwbimage_generate(struct image_tool_params *params, * The resulting image needs to be 4-byte aligned. At least * the Marvell hdrparser tool complains if its unaligned. * After the image data is stored 4-byte checksum. + * Final SPI and NAND images must be aligned to 256 bytes. */ - return 4 + (4 - s.st_size % 4) % 4; + if (bootfrom == IBR_HDR_SPI_ID || bootfrom == IBR_HDR_NAND_ID) + return 4 + (256 - (alloc_len + s.st_size + 4) % 256) % 256; + else + return 4 + (4 - s.st_size % 4) % 4; } /* From patchwork Fri Jul 23 09:13:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509048 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=W6GaTMYs; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNvd5qljz9sRN for ; Fri, 23 Jul 2021 19:15:25 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5508582D83; Fri, 23 Jul 2021 11:14:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="W6GaTMYs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1456582D5E; Fri, 23 Jul 2021 11:14:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CCB5F8060B for ; Fri, 23 Jul 2021 11:14:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 6F0B91409FA; Fri, 23 Jul 2021 11:14:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031681; bh=3ng0B4x8/Burqk5hoIBmoSdKKFVs6EZfNqEAOinnnjs=; h=From:To:Date; b=W6GaTMYsnjHtpTIrnVHJBEbsttV/CRcaRU6+dfRmgRdwPA7NZ1aIi8CjSN0R338vQ Rmfb+FFzF2/YDLrpLfu6RgWMR1q1QeFR8eMwrWjRMGT0gMt1jEEZQuY4MY/TPpoj8R ygTg/EyK0SLbVfh4lYvH4Gbbs3kEDmp7xJXLEk7s= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 04/41] tools: kwbimage: Add constant for SDIO bootfrom Date: Fri, 23 Jul 2021 11:13:58 +0200 Message-Id: <20210723091435.20388-5-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Add constant for SDIO value of the bootfrom header field. Signed-off-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwbimage.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/kwbimage.h b/tools/kwbimage.h index 0b6d05bef1..9856b44536 100644 --- a/tools/kwbimage.h +++ b/tools/kwbimage.h @@ -27,6 +27,7 @@ #define IBR_HDR_SATA_ID 0x78 #define IBR_HDR_PEX_ID 0x9C #define IBR_HDR_UART_ID 0x69 +#define IBR_HDR_SDIO_ID 0xAE #define IBR_DEF_ATTRIB 0x00 /* Structure of the main header, version 0 (Kirkwood, Dove) */ From patchwork Fri Jul 23 09:13:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509049 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=KMAGKAXN; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNvs54hNz9sRN for ; Fri, 23 Jul 2021 19:15:37 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4A4DE82D94; Fri, 23 Jul 2021 11:15:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="KMAGKAXN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0E58482D80; Fri, 23 Jul 2021 11:14:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1E9A082D22 for ; Fri, 23 Jul 2021 11:14:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 9FFBA140A03; Fri, 23 Jul 2021 11:14:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031682; bh=apl7S4htRbecIAqbYVifh85AIsHIsIpn6qj29rK1Z8o=; h=From:To:Date; b=KMAGKAXNZxB9CJH8/ftxYBDLl1cPrzYK+q+NrYMyZvNvA2LA2D7ShRKz+CVV+ibHw ozIkHQCtAUUW7Y2+XIemd9cLCN9QRTrbWZgYvUA4WTzNgy6x1pCPMzHnW9u160vnA+ ZU5gscF5ApstTpcjeHUJ0XtYbsCegW+ROny+Imv4= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 05/41] tools: kwbimage: Fix generation of SATA, SDIO and PCIe images Date: Fri, 23 Jul 2021 11:13:59 +0200 Message-Id: <20210723091435.20388-6-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár SATA and SDIO images must be aligned to sector size (which in most cases is 512 bytes) and Source Address in main header is stored in number of sectors from the beginning of the drive. SATA image must be stored at sector 1 and SDIO image at sector 0. Source Address for PCIe image is not used and must be set to 0xFFFFFFFF. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwbimage.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index f40ba0994d..c65a40ecb7 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1281,6 +1281,28 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, main_hdr->destaddr = cpu_to_le32(params->addr); } + /* + * For SATA srcaddr is specified in number of sectors starting from + * sector 0. The main header is stored at sector number 1. + * This expects the sector size to be 512 bytes. + * Header size is already aligned. + */ + if (main_hdr->blockid == IBR_HDR_SATA_ID) + main_hdr->srcaddr = cpu_to_le32(headersz / 512 + 1); + + /* + * For SDIO srcaddr is specified in number of sectors starting from + * sector 0. The main header is stored at sector number 0. + * This expects sector size to be 512 bytes. + * Header size is already aligned. + */ + if (main_hdr->blockid == IBR_HDR_SDIO_ID) + main_hdr->srcaddr = cpu_to_le32(headersz / 512); + + /* For PCIe srcaddr is not used and must be set to 0xFFFFFFFF. */ + if (main_hdr->blockid == IBR_HDR_PEX_ID) + main_hdr->srcaddr = cpu_to_le32(0xFFFFFFFF); + #if defined(CONFIG_KWB_SECURE) if (image_get_csk_index() >= 0) { /* @@ -1731,9 +1753,12 @@ static int kwbimage_generate(struct image_tool_params *params, * the Marvell hdrparser tool complains if its unaligned. * After the image data is stored 4-byte checksum. * Final SPI and NAND images must be aligned to 256 bytes. + * Final SATA and SDIO images must be aligned to 512 bytes. */ if (bootfrom == IBR_HDR_SPI_ID || bootfrom == IBR_HDR_NAND_ID) return 4 + (256 - (alloc_len + s.st_size + 4) % 256) % 256; + else if (bootfrom == IBR_HDR_SATA_ID || bootfrom == IBR_HDR_SDIO_ID) + return 4 + (512 - (alloc_len + s.st_size + 4) % 512) % 512; else return 4 + (4 - s.st_size % 4) % 4; } From patchwork Fri Jul 23 09:14:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509051 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=c9hkU5oX; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNw52x35z9sXM for ; Fri, 23 Jul 2021 19:15:49 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0D41382DE8; Fri, 23 Jul 2021 11:15:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="c9hkU5oX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8D7E982D87; Fri, 23 Jul 2021 11:14:50 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 552EA82D5B for ; Fri, 23 Jul 2021 11:14:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id DD0C3140A0A; Fri, 23 Jul 2021 11:14:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031684; bh=cXRag3ipUn+f2PzfDD7uY2LUtodFGKp1MK1MQTpP/2o=; h=From:To:Date; b=c9hkU5oXYOqmONppULRiU4O0YJSzqN7E3SxH9ybNxPTazCYG61gg4a/GWj61QDwVi PcfUHY3+cEiaQM/nzSjDCCcJ756AXvF4wQ6w60SEj20vGAxyJ6o8x7iDyUKWaGWHWW wYhbdzzwMWrvJ18HOSI+Y40jabkZXq42OieXT7P4= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 06/41] tools: kwbimage: Don't crash when binary file name does not contain '/' Date: Fri, 23 Jul 2021 11:14:00 +0200 Message-Id: <20210723091435.20388-7-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár In the case when the file name is specified relative to the current working directory, it does not contain '/' character and strrchr() returns NULL. The following strcmp() function then crashes on NULL pointer dereference. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwbimage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index c65a40ecb7..724459fb8e 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1277,7 +1277,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, if (e) { char *s = strrchr(e->binary.file, '/'); - if (strcmp(s, "/binary.0") == 0) + if (s && strcmp(s, "/binary.0") == 0) main_hdr->destaddr = cpu_to_le32(params->addr); } From patchwork Fri Jul 23 09:14:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509052 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=cK9be7X1; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNwK10mmz9sXb for ; Fri, 23 Jul 2021 19:16:00 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6E97182DF3; Fri, 23 Jul 2021 11:15:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="cK9be7X1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 76B5982CDE; Fri, 23 Jul 2021 11:14:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 868D98164D for ; Fri, 23 Jul 2021 11:14:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 23424140A24; Fri, 23 Jul 2021 11:14:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031685; bh=xJAy0+uLxcuQeGAMVmCBrpMWQrWCv4c4GKnmJO0mxtk=; h=From:To:Date; b=cK9be7X1rnLP2iOB++WQC5yqarhG42RxWZ3MSXY+2u01yKIVnHE0PyJDI7KZ/0Fya EG9JOJKLW1KDekLG5xEm1A18bDHgn8Th4CNv+jLZ712welQ5j1gjZjEORWSi61yJk6 BZse3I3PxkejxT0v/4GSMxIwjOevEjHG30mnCiYQ= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 07/41] tools: kwbimage: Fix check for v0 extended header checksum Date: Fri, 23 Jul 2021 11:14:01 +0200 Message-Id: <20210723091435.20388-8-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Extended header checksum for v0 image is present only in the case when extended header is present. Skip checksum validation if extended header is not present. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwbimage.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 724459fb8e..4d9d818538 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1655,15 +1655,19 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, /* Only version 0 extended header has checksum */ if (image_version((void *)ptr) == 0) { - struct ext_hdr_v0 *ext_hdr; + struct main_hdr_v0 *mhdr = (struct main_hdr_v0 *)ptr; - ext_hdr = (struct ext_hdr_v0 *) + if (mhdr->ext & 0x1) { + struct ext_hdr_v0 *ext_hdr; + + ext_hdr = (struct ext_hdr_v0 *) (ptr + sizeof(struct main_hdr_v0)); - checksum = image_checksum8(ext_hdr, - sizeof(struct ext_hdr_v0) - - sizeof(uint8_t)); - if (checksum != ext_hdr->checksum) - return -FDT_ERR_BADSTRUCTURE; + checksum = image_checksum8(ext_hdr, + sizeof(struct ext_hdr_v0) + - sizeof(uint8_t)); + if (checksum != ext_hdr->checksum) + return -FDT_ERR_BADSTRUCTURE; + } } return 0; From patchwork Fri Jul 23 09:14:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509053 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=nmI+UgkR; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNwY6VbSz9sRN for ; Fri, 23 Jul 2021 19:16:13 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8D48782D7E; Fri, 23 Jul 2021 11:15:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="nmI+UgkR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4B9B982D80; Fri, 23 Jul 2021 11:14:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D008482D7C for ; Fri, 23 Jul 2021 11:14:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 61B5A140952; Fri, 23 Jul 2021 11:14:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031686; bh=rA9mTSn9rCWl2Fo1RLxFPQwyV1pnxS2BZ/Jb81QBNmQ=; h=From:To:Date; b=nmI+UgkRU+swR88HuzYTJUOPUnzBWvKYbhvK7Yog1/5WAtV5O/c9Jj/2yfIW5eeXG ZSaOGLvLBATl1HJbrayKWCxnS7lGYJ83N47O81yj01vi0JXFlF2f8X1EycUnPOKrKT Q2FppxrMDRuCgC+Pu+fa2vfwjbzHCgsuIaQbLCXg= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 08/41] tools: kwbimage: Validate extended headers of v1 images Date: Fri, 23 Jul 2021 11:14:02 +0200 Message-Id: <20210723091435.20388-9-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Add basic checks for extended headers of v1 images. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwbimage.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 4d9d818538..5d017dd5ac 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1670,6 +1670,35 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, } } + if (image_version((void *)ptr) == 1) { + struct main_hdr_v1 *mhdr = (struct main_hdr_v1 *)ptr; + + if (mhdr->ext & 0x1) { + uint32_t ohdr_size; + struct opt_hdr_v1 *ohdr = (struct opt_hdr_v1 *) + (ptr + sizeof(*mhdr)); + + while (1) { + if ((uint8_t *)ohdr + sizeof(*ohdr) > + (uint8_t *)mhdr + header_size) + return -FDT_ERR_BADSTRUCTURE; + + ohdr_size = (ohdr->headersz_msb << 16) | + le16_to_cpu(ohdr->headersz_lsb); + + if (ohdr_size < 8 || + (uint8_t *)ohdr + ohdr_size > + (uint8_t *)mhdr + header_size) + return -FDT_ERR_BADSTRUCTURE; + + if (!(*((uint8_t *)ohdr + ohdr_size - 4) & 0x1)) + break; + ohdr = (struct opt_hdr_v1 *)((uint8_t *)ohdr + + ohdr_size); + } + } + } + return 0; } From patchwork Fri Jul 23 09:14:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509054 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=c3BBQCFG; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNwn4cnPz9sV8 for ; Fri, 23 Jul 2021 19:16:25 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 344AA82DFE; Fri, 23 Jul 2021 11:15:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="c3BBQCFG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6EEC482CDE; Fri, 23 Jul 2021 11:14:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1289282D22 for ; Fri, 23 Jul 2021 11:14:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 9D4CF1409F0; Fri, 23 Jul 2021 11:14:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031687; bh=zqaOwTqnc2OaHmnaW3n8pEDI1VryMnmzIFEiUA3UQUE=; h=From:To:Date; b=c3BBQCFGWkpa+e30Mgnl+F8gpMAOh+6EiT8dKVzx6IwZbuMK3u+VZhtH4HUXcwFFi ozf2b8HVBcqm2j/XRTjI64PihclqtGeyyX93X1wIt19tUXBd9zT44rIIfCo8TJafHI sInb/P7TxUHLqRTymogFhV1ON/xEwzcLRWWa1t9g= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 09/41] tools: kwbimage: Validate data checksum of v1 images Date: Fri, 23 Jul 2021 11:14:03 +0200 Message-Id: <20210723091435.20388-10-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The data part of v1 images contains 32-bit checksum after the data. Validate whether this checksum is correct. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwbimage.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 5d017dd5ac..edda0ce7aa 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1672,6 +1672,8 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, if (image_version((void *)ptr) == 1) { struct main_hdr_v1 *mhdr = (struct main_hdr_v1 *)ptr; + uint32_t offset; + uint32_t size; if (mhdr->ext & 0x1) { uint32_t ohdr_size; @@ -1697,6 +1699,47 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, ohdr_size); } } + + offset = le32_to_cpu(mhdr->srcaddr); + + /* + * For SATA srcaddr is specified in number of sectors. + * The main header is must be stored at sector number 1. + * This expects that sector size is 512 bytes and recalculates + * data offset to bytes relative to the main header. + */ + if (mhdr->blockid == IBR_HDR_SATA_ID) { + if (offset < 1) + return -FDT_ERR_BADSTRUCTURE; + offset -= 1; + offset *= 512; + } + + /* + * For SDIO srcaddr is specified in number of sectors. + * This expects that sector size is 512 bytes and recalculates + * data offset to bytes. + */ + if (mhdr->blockid == IBR_HDR_SDIO_ID) + offset *= 512; + + /* + * For PCIe srcaddr is always set to 0xFFFFFFFF. + * This expects that data starts after all headers. + */ + if (mhdr->blockid == IBR_HDR_PEX_ID && offset == 0xFFFFFFFF) + offset = header_size; + + if (offset > image_size || offset % 4 != 0) + return -FDT_ERR_BADSTRUCTURE; + + size = le32_to_cpu(mhdr->blocksize); + if (offset + size > image_size || size % 4 != 0) + return -FDT_ERR_BADSTRUCTURE; + + if (image_checksum32(ptr + offset, size - 4) != + *(uint32_t *)(ptr + offset + size - 4)) + return -FDT_ERR_BADSTRUCTURE; } return 0; From patchwork Fri Jul 23 09:14:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509055 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=el4rxxEQ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNx12G9Lz9sRN for ; Fri, 23 Jul 2021 19:16:37 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B2C7782E0D; Fri, 23 Jul 2021 11:15:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="el4rxxEQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 26FD782D9C; Fri, 23 Jul 2021 11:14:59 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 34DF182D7F for ; Fri, 23 Jul 2021 11:14:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id DAA4D1409F3; Fri, 23 Jul 2021 11:14:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031689; bh=7sJiKhx+PkYpDJ04kAH72xxdaVssfMsI0deXIso88mA=; h=From:To:Date; b=el4rxxEQ0g0Ghi8tJxqrdHkIDIxU0rwERdfAUUfGo9lVrYlBzXmbyHPVv75Malu8H AWA0EWc3z/TK850Wanp9adYNJMV0pMaoZHIdpMg+qlf9sOtwLbE1YX5GSWksNVhDo6 cPVqf+iqvwH07FRNyfVTHX4J75EbYYKxNiwqeW7M= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 10/41] tools: kwbimage: Print size of binary header in kwbimage_print_header() Date: Fri, 23 Jul 2021 11:14:04 +0200 Message-Id: <20210723091435.20388-11-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The binary header in kwbimage contains executable SPL code. Print information about this binary header and not only information about it's data part. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwbimage.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index edda0ce7aa..bc30233871 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1627,6 +1627,30 @@ static void kwbimage_print_header(const void *ptr) printf("Image Type: MVEBU Boot from %s Image\n", image_boot_mode_name(mhdr->blockid)); printf("Image version:%d\n", image_version((void *)ptr)); + if (image_version((void *)ptr) == 1) { + struct main_hdr_v1 *mhdr = (struct main_hdr_v1 *)ptr; + + if (mhdr->ext & 0x1) { + struct opt_hdr_v1 *ohdr = (struct opt_hdr_v1 *) + ((uint8_t *)ptr + + sizeof(*mhdr)); + + while (1) { + uint32_t ohdr_size; + + ohdr_size = (ohdr->headersz_msb << 16) | + le16_to_cpu(ohdr->headersz_lsb); + if (ohdr->headertype == OPT_HDR_V1_BINARY_TYPE) { + printf("BIN Hdr Size: "); + genimg_print_size(ohdr_size - 12 - 4 * ohdr->data[0]); + } + if (!(*((uint8_t *)ohdr + ohdr_size - 4) & 0x1)) + break; + ohdr = (struct opt_hdr_v1 *)((uint8_t *)ohdr + + ohdr_size); + } + } + } printf("Data Size: "); genimg_print_size(mhdr->blocksize - sizeof(uint32_t)); printf("Load Address: %08x\n", mhdr->destaddr); From patchwork Fri Jul 23 09:14:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509056 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=OfXnwMp6; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNxF2H0Lz9sRN for ; Fri, 23 Jul 2021 19:16:49 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2218C82E16; Fri, 23 Jul 2021 11:15:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="OfXnwMp6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EA67882D94; Fri, 23 Jul 2021 11:14:59 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8433F82D85 for ; Fri, 23 Jul 2021 11:14:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 171AE1409FA; Fri, 23 Jul 2021 11:14:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031690; bh=BU4r0BypM2jg12pB1aPkg/WQwPwEzmTh0Bk9HrSl1aA=; h=From:To:Date; b=OfXnwMp6aKZwTJI7U9ZT67TeTi2i74MuLzS9XdKdq1QG6oc+G1rC8ImgLRknuTwe1 TpOeObLreKc5VQayeIKknAIfLFMN8qfNb/ikAGojnrlKaxtHZDQW3iH8R2qKmj+IUa cU5dMzOvyhZNLr8TkYdnRemdFFccE4H+MN566eiY= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 11/41] tools: kwbimage: Cosmetic fix - remove redundant space character Date: Fri, 23 Jul 2021 11:14:05 +0200 Message-Id: <20210723091435.20388-12-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Remove this space, since the constants are indented by tabs. Signed-off-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwbimage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/kwbimage.h b/tools/kwbimage.h index 9856b44536..cab3d95d13 100644 --- a/tools/kwbimage.h +++ b/tools/kwbimage.h @@ -28,7 +28,7 @@ #define IBR_HDR_PEX_ID 0x9C #define IBR_HDR_UART_ID 0x69 #define IBR_HDR_SDIO_ID 0xAE -#define IBR_DEF_ATTRIB 0x00 +#define IBR_DEF_ATTRIB 0x00 /* Structure of the main header, version 0 (Kirkwood, Dove) */ struct main_hdr_v0 { From patchwork Fri Jul 23 09:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509058 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=XzjT28DJ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNxj3GTKz9sRN for ; Fri, 23 Jul 2021 19:17:13 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 39D1382E67; Fri, 23 Jul 2021 11:15:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="XzjT28DJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0709782D8B; Fri, 23 Jul 2021 11:15:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9C7C382D8B for ; Fri, 23 Jul 2021 11:14:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 41F31140A03; Fri, 23 Jul 2021 11:14:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031691; bh=rs/+8xRBpvqnsn1D4dJ7nMNohO8SrHp0sMe+vAKqvpE=; h=From:To:Date; b=XzjT28DJ5cfFYGc68nw4zDn36OkHkZVXIFRWXx2t2E7MMvOkSuy4EmhRNbf6nhuOC DOkfgSP9VYLkA/KR2ERUwck51Dr7SxVDVclijFfvOHYMGg7urFdRJ8efiLVQJ1sHNl K6JOaPb5RgnLfbjCsY7dikYCc1b4cV0Yn3teIgTA= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 12/41] tools: kwbimage: Use -a parameter (load address) for v1 images Date: Fri, 23 Jul 2021 11:14:06 +0200 Message-Id: <20210723091435.20388-13-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The data part of v1 kwbimage currently contains U-Boot binary prepended by 64 bytes long Legacy U-Boot image header. This means that the load address is currently substracted by 64 bytes to ensure that U-Boot's entry point is at specified execution address. As mkimage has already separate arguments for load (-a) and execution (-e) address, there is no need to derive fixed load address from execution address. Therefore remove this load address hack from the kwbimage tool and support generating v1 kwbimage with arbitrary addresses for load and execution. Finally, calculate correct load address by caller for mkimage tool in Makefile. File u-boot-spl.kwb is always a v1 kwbimage and it is the only v1 kwbimage which U-Boot's build system generates. Remove also useless overwriting of destaddr for /binary.0 to the value which is already set on previous lines. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- Makefile | 2 +- tools/kwbimage.c | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index ca2432c8ce..c6de6393cb 100644 --- a/Makefile +++ b/Makefile @@ -1398,7 +1398,7 @@ MKIMAGEFLAGS_u-boot.kwb = -n $(KWD_CONFIG_FILE) \ -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) MKIMAGEFLAGS_u-boot-spl.kwb = -n $(KWD_CONFIG_FILE) \ - -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) \ + -T kwbimage -a $(shell printf "0x%x" $$(($(CONFIG_SYS_TEXT_BASE)-64))) -e $(CONFIG_SYS_TEXT_BASE) \ $(if $(KEYDIR),-k $(KEYDIR)) MKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \ diff --git a/tools/kwbimage.c b/tools/kwbimage.c index bc30233871..76c25628d4 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1252,8 +1252,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, cpu_to_le32(payloadsz - headersz); main_hdr->headersz_lsb = cpu_to_le16(headersz & 0xFFFF); main_hdr->headersz_msb = (headersz & 0xFFFF0000) >> 16; - main_hdr->destaddr = cpu_to_le32(params->addr) - - sizeof(image_header_t); + main_hdr->destaddr = cpu_to_le32(params->addr); main_hdr->execaddr = cpu_to_le32(params->ep); main_hdr->srcaddr = cpu_to_le32(headersz); main_hdr->ext = hasext; @@ -1273,13 +1272,6 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, e = image_find_option(IMAGE_CFG_DEBUG); if (e) main_hdr->flags = e->debug ? 0x1 : 0; - e = image_find_option(IMAGE_CFG_BINARY); - if (e) { - char *s = strrchr(e->binary.file, '/'); - - if (s && strcmp(s, "/binary.0") == 0) - main_hdr->destaddr = cpu_to_le32(params->addr); - } /* * For SATA srcaddr is specified in number of sectors starting from From patchwork Fri Jul 23 09:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509059 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=i52n/KXI; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNxw3HZvz9sRN for ; Fri, 23 Jul 2021 19:17:24 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ED90582E88; Fri, 23 Jul 2021 11:15:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="i52n/KXI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 39C6A82D72; Fri, 23 Jul 2021 11:15:10 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E436582D5B for ; Fri, 23 Jul 2021 11:14:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 7CC1A140952; Fri, 23 Jul 2021 11:14:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031692; bh=dM2aiR3Vsx/sZWscolu4bLq8P6e9uZhK4RwtPlPdtlA=; h=From:To:Date; b=i52n/KXIZdT5YDG3xCW0zMBKTNr5zq0cdqRWlm9Jli8Zk1N8r4p9HHRAG/USwzof5 +0abaLnc1kLTtIl+qZdmdL1QoM51+xEtq09xBMzPjk1BA0VKUhDLEKg3kaE8WybLnY ZX2kqVG3lDB9776krQ2kt0NDomLtvcYesaDSlJqw= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 13/41] tools: kwbimage: Change maximum number of arguments in binary header to 256 Date: Fri, 23 Jul 2021 11:14:07 +0200 Message-Id: <20210723091435.20388-14-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The number is stored in one byte, so the maximum should be 255. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- tools/kwbimage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 76c25628d4..2d4574af7d 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -89,7 +89,7 @@ struct nand_ecc_mode nand_ecc_modes[] = { /* Used to identify an undefined execution or destination address */ #define ADDR_INVALID ((uint32_t)-1) -#define BINARY_MAX_ARGS 8 +#define BINARY_MAX_ARGS 255 /* In-memory representation of a line of the configuration file */ From patchwork Fri Jul 23 09:14:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509060 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=AEde8N5I; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNy66z5xz9sRN for ; Fri, 23 Jul 2021 19:17:34 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8B92882E8D; Fri, 23 Jul 2021 11:16:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="AEde8N5I"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 69F9382D82; Fri, 23 Jul 2021 11:15:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 121E782D86 for ; Fri, 23 Jul 2021 11:14:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id AE3FA1409F3; Fri, 23 Jul 2021 11:14:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031693; bh=4POc8uD/w8GtQXakN6gl58NSqREQxdAMRp7QPvdVwfs=; h=From:To:Date; b=AEde8N5IWBBTULICSxFk6+b2vEpd+IJqBS3Janyr6LXipDx2LhgbiMmVbSnkGjSXs YzwNQA07whx2yhghwLQD5jeuEKly9bVOa6byK5gEROSrjFQPC5hD3cBI+hzmSmrWP/ wYtJ6MaOeWTjzSC3ZG9TixGcVLI/rQXxVP6LkgSc= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 14/41] tools: kwbimage: Fix calculating size of binary header Date: Fri, 23 Jul 2021 11:14:08 +0200 Message-Id: <20210723091435.20388-15-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Binary header consist of: * 1 byte for header type * 3 bytes for header size * 1 byte for number of arguments * 3 reserved bytes * N*4 bytes for arguments * M bytes (aligned to 4 bytes) for executable data * 1 byte for information about next header * 3 reserved bytes The first four bytes are specified as sizeof(struct opt_hdr_v1) and the remaining bytes as ALIGN(s.st_size, 4) + (binarye->binary.nargs + 2) * sizeof(uint32_t) Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- tools/kwbimage.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 2d4574af7d..6c9f93ae8b 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -984,7 +984,7 @@ static size_t image_headersz_v1(int *hasext) } headersz += sizeof(struct opt_hdr_v1) + - s.st_size + + ALIGN(s.st_size, 4) + (binarye->binary.nargs + 2) * sizeof(uint32_t); if (hasext) *hasext = 1; @@ -1051,14 +1051,7 @@ int add_binary_header_v1(uint8_t *cur) binhdrsz = sizeof(struct opt_hdr_v1) + (binarye->binary.nargs + 2) * sizeof(uint32_t) + - s.st_size; - - /* - * The size includes the binary image size, rounded - * up to a 4-byte boundary. Plus 4 bytes for the - * next-header byte and 3-byte alignment at the end. - */ - binhdrsz = ALIGN(binhdrsz, 4) + 4; + ALIGN(s.st_size, 4); hdr->headersz_lsb = cpu_to_le16(binhdrsz & 0xFFFF); hdr->headersz_msb = (binhdrsz & 0xFFFF0000) >> 16; From patchwork Fri Jul 23 09:14:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509085 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=WjwUQ3n5; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP9M5tBMz9sRN for ; Fri, 23 Jul 2021 19:27:19 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7485E82E05; Fri, 23 Jul 2021 11:25:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="WjwUQ3n5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0FECC82D81; Fri, 23 Jul 2021 11:25:15 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 63CED82D7C for ; Fri, 23 Jul 2021 11:14:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id DEC481408AE; Fri, 23 Jul 2021 11:14:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031695; bh=/7JipegSuL7P8p2lOPZcjNdIIa87dO0sDwLbRfScWU4=; h=From:To:Date; b=WjwUQ3n5IAPBefhmvquGRucYlJs6jyPsAaziH8QFlDvtP9V6nBz49VYM27cU3zvZU piSczZTJvf8HtN2HtKiw2eaQD9w72gHuRKxQtlw2Ki2bBt7QC/mUA2B9iv16wV9i4c BvD/DaDHMG2hJt3bciu4SRbSL9/M/FJlxz7/v9uw= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 15/41] tools: kwbimage: Add support for more BINARY headers Date: Fri, 23 Jul 2021 11:14:09 +0200 Message-Id: <20210723091435.20388-16-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The kwbimage v1 format supports multiple BINARY executable headers. Add support for it into mkimage/kwbimage tool. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Chris Packham Reviewed-by: Stefan Roese Tested-by: Chris Packham --- tools/kwbimage.c | 59 +++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 6c9f93ae8b..1bfc524424 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -942,6 +942,7 @@ static size_t image_headersz_v1(int *hasext) { struct image_cfg_element *binarye; size_t headersz; + int cfgi; /* * Calculate the size of the header and the size of the @@ -949,21 +950,19 @@ static size_t image_headersz_v1(int *hasext) */ headersz = sizeof(struct main_hdr_v1); - if (image_count_options(IMAGE_CFG_BINARY) > 1) { - fprintf(stderr, "More than one binary blob, not supported\n"); - return 0; - } - if (image_count_options(IMAGE_CFG_PAYLOAD) > 1) { fprintf(stderr, "More than one payload, not possible\n"); return 0; } - binarye = image_find_option(IMAGE_CFG_BINARY); - if (binarye) { + for (cfgi = 0; cfgi < cfgn; cfgi++) { int ret; struct stat s; + binarye = &image_cfg[cfgi]; + if (binarye->type != IMAGE_CFG_BINARY) + continue; + ret = stat(binarye->binary.file, &s); if (ret < 0) { char cwd[PATH_MAX]; @@ -1018,10 +1017,10 @@ static size_t image_headersz_v1(int *hasext) return ALIGN(headersz, 4096); } -int add_binary_header_v1(uint8_t *cur) +int add_binary_header_v1(uint8_t **cur, uint8_t **next_ext, + struct image_cfg_element *binarye) { - struct image_cfg_element *binarye; - struct opt_hdr_v1 *hdr = (struct opt_hdr_v1 *)cur; + struct opt_hdr_v1 *hdr = (struct opt_hdr_v1 *)*cur; uint32_t *args; size_t binhdrsz; struct stat s; @@ -1029,11 +1028,6 @@ int add_binary_header_v1(uint8_t *cur) FILE *bin; int ret; - binarye = image_find_option(IMAGE_CFG_BINARY); - - if (!binarye) - return 0; - hdr->headertype = OPT_HDR_V1_BINARY_TYPE; bin = fopen(binarye->binary.file, "r"); @@ -1055,17 +1049,17 @@ int add_binary_header_v1(uint8_t *cur) hdr->headersz_lsb = cpu_to_le16(binhdrsz & 0xFFFF); hdr->headersz_msb = (binhdrsz & 0xFFFF0000) >> 16; - cur += sizeof(struct opt_hdr_v1); + *cur += sizeof(struct opt_hdr_v1); - args = (uint32_t *)cur; + args = (uint32_t *)*cur; *args = cpu_to_le32(binarye->binary.nargs); args++; for (argi = 0; argi < binarye->binary.nargs; argi++) args[argi] = cpu_to_le32(binarye->binary.args[argi]); - cur += (binarye->binary.nargs + 1) * sizeof(uint32_t); + *cur += (binarye->binary.nargs + 1) * sizeof(uint32_t); - ret = fread(cur, s.st_size, 1, bin); + ret = fread(*cur, s.st_size, 1, bin); if (ret != 1) { fprintf(stderr, "Could not read binary image %s\n", @@ -1075,17 +1069,13 @@ int add_binary_header_v1(uint8_t *cur) fclose(bin); - cur += ALIGN(s.st_size, 4); + *cur += ALIGN(s.st_size, 4); - /* - * For now, we don't support more than one binary - * header, and no other header types are - * supported. So, the binary header is necessarily the - * last one - */ - *((uint32_t *)cur) = 0x00000000; + *((uint32_t *)*cur) = 0x00000000; + **next_ext = 1; + *next_ext = *cur; - cur += sizeof(uint32_t); + *cur += sizeof(uint32_t); return 0; @@ -1218,6 +1208,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, uint8_t *image, *cur; int hasext = 0; uint8_t *next_ext = NULL; + int cfgi; /* * Calculate the size of the header and the size of the @@ -1296,13 +1287,19 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, */ secure_hdr = (struct secure_hdr_v1 *)cur; cur += sizeof(struct secure_hdr_v1); + *next_ext = 1; next_ext = &secure_hdr->next; } #endif - *next_ext = 1; - if (add_binary_header_v1(cur)) - return NULL; + for (cfgi = 0; cfgi < cfgn; cfgi++) { + e = &image_cfg[cfgi]; + if (e->type != IMAGE_CFG_BINARY) + continue; + + if (add_binary_header_v1(&cur, &next_ext, e)) + return NULL; + } #if defined(CONFIG_KWB_SECURE) if (secure_hdr && add_secure_header_v1(params, ptr, payloadsz, From patchwork Fri Jul 23 09:14:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509077 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=Ol5WImMG; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP7m4lqxz9sRN for ; Fri, 23 Jul 2021 19:25:56 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 03AA782D96; Fri, 23 Jul 2021 11:25:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="Ol5WImMG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2BD4A82D93; Fri, 23 Jul 2021 11:24:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9517A82D96 for ; Fri, 23 Jul 2021 11:14:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 291B2140952; Fri, 23 Jul 2021 11:14:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031696; bh=U4tdsYoLiVm734CzY41rr5LX12RbAaBLvBmwBeyh7xE=; h=From:To:Date; b=Ol5WImMGDFyCTJvdGkDg8aKFdDUdb8DjNxU9wJIkpvPD8c+2lGGear7mLxI3K05K1 yWsDULktexyELan6iU0OXF+L/xV3PwHr90oMLzRREjqZ4RsshSaLFTA/wI7evi9LX6 yF+y1j1OCewGhY6ob/Ng39jVOm2K9uQvhDgV77Yc= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 16/41] tools: kwbimage: Don't parse PAYLOAD keyword Date: Fri, 23 Jul 2021 11:14:10 +0200 Message-Id: <20210723091435.20388-17-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The PAYLOAD keyword does nothing. No code is using it and both mkimage and kwbimage completely ignore it. It looks like a relict from the past. The payload image itself can be specified only via -d parameter to mkimage. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Chris Packham Reviewed-by: Stefan Roese Tested-by: Chris Packham --- tools/kwbimage.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 1bfc524424..74a77412d7 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -103,7 +103,6 @@ enum image_cfg_type { IMAGE_CFG_NAND_ECC_MODE, IMAGE_CFG_NAND_PAGESZ, IMAGE_CFG_BINARY, - IMAGE_CFG_PAYLOAD, IMAGE_CFG_DATA, IMAGE_CFG_BAUDRATE, IMAGE_CFG_DEBUG, @@ -131,7 +130,6 @@ static const char * const id_strs[] = { [IMAGE_CFG_NAND_ECC_MODE] = "NAND_ECC_MODE", [IMAGE_CFG_NAND_PAGESZ] = "NAND_PAGE_SIZE", [IMAGE_CFG_BINARY] = "BINARY", - [IMAGE_CFG_PAYLOAD] = "PAYLOAD", [IMAGE_CFG_DATA] = "DATA", [IMAGE_CFG_BAUDRATE] = "BAUDRATE", [IMAGE_CFG_DEBUG] = "DEBUG", @@ -157,7 +155,6 @@ struct image_cfg_element { unsigned int args[BINARY_MAX_ARGS]; unsigned int nargs; } binary; - const char *payload; unsigned int dstaddr; unsigned int execaddr; unsigned int nandblksz; @@ -874,11 +871,6 @@ static void *image_create_v0(size_t *imagesz, struct image_tool_params *params, headersz += sizeof(struct ext_hdr_v0); } - if (image_count_options(IMAGE_CFG_PAYLOAD) > 1) { - fprintf(stderr, "More than one payload, not possible\n"); - return NULL; - } - image = malloc(headersz); if (!image) { fprintf(stderr, "Cannot allocate memory for image\n"); @@ -950,11 +942,6 @@ static size_t image_headersz_v1(int *hasext) */ headersz = sizeof(struct main_hdr_v1); - if (image_count_options(IMAGE_CFG_PAYLOAD) > 1) { - fprintf(stderr, "More than one payload, not possible\n"); - return 0; - } - for (cfgi = 0; cfgi < cfgn; cfgi++) { int ret; struct stat s; From patchwork Fri Jul 23 09:14:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509081 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=UKCdhHxq; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP8Y6xsbz9sRN for ; Fri, 23 Jul 2021 19:26:37 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 951F382DD4; Fri, 23 Jul 2021 11:25:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="UKCdhHxq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F389E82D72; Fri, 23 Jul 2021 11:25:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C52058164D for ; Fri, 23 Jul 2021 11:14:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 6235B1409F3; Fri, 23 Jul 2021 11:14:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031697; bh=cLj8tfFKI3nZOybV+E4HLqg+fEfXE7mLCJU1pjwrOfk=; h=From:To:Date; b=UKCdhHxqXHaINQ4Sy4fMfdfStGPukNVBAxtGqzwXKBdGwnTpiGOTur1UvWQTS5kZY D4T44Rsj/gEb1oEB8K1aOdx3VUXVAvftfHeauMiKrSO3LXAV8aX8QK/nS9FFEzrZzl mSOJ5DV8TWwUBFluMgtxxwOBhACQJN6PVf9R87oE= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 17/41] tools: kwbimage: Add support for DATA command also for v1 images Date: Fri, 23 Jul 2021 11:14:11 +0200 Message-Id: <20210723091435.20388-18-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The DATA command is already supported by mkimage for v0 images, but not for v1 images. BootROM code which executes v1 images also supports DATA command via an optional extended v1 header OPT_HDR_V1_REGISTER_TYPE. Implement support for DATA command for v1 images. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Chris Packham Reviewed-by: Stefan Roese Tested-by: Chris Packham --- tools/kwbimage.c | 32 +++++++++++++++++++++++++++++++- tools/kwbimage.h | 27 +++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 74a77412d7..b585f49180 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -933,6 +933,7 @@ static void *image_create_v0(size_t *imagesz, struct image_tool_params *params, static size_t image_headersz_v1(int *hasext) { struct image_cfg_element *binarye; + unsigned int count; size_t headersz; int cfgi; @@ -942,6 +943,10 @@ static size_t image_headersz_v1(int *hasext) */ headersz = sizeof(struct main_hdr_v1); + count = image_count_options(IMAGE_CFG_DATA); + if (count > 0) + headersz += sizeof(struct register_set_hdr_v1) + 8 * count + 4; + for (cfgi = 0; cfgi < cfgn; cfgi++) { int ret; struct stat s; @@ -1188,6 +1193,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, { struct image_cfg_element *e; struct main_hdr_v1 *main_hdr; + struct register_set_hdr_v1 *register_set_hdr; #if defined(CONFIG_KWB_SECURE) struct secure_hdr_v1 *secure_hdr = NULL; #endif @@ -1195,7 +1201,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, uint8_t *image, *cur; int hasext = 0; uint8_t *next_ext = NULL; - int cfgi; + int cfgi, datai, size; /* * Calculate the size of the header and the size of the @@ -1279,6 +1285,30 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, } #endif + datai = 0; + register_set_hdr = (struct register_set_hdr_v1 *)cur; + for (cfgi = 0; cfgi < cfgn; cfgi++) { + e = &image_cfg[cfgi]; + if (e->type != IMAGE_CFG_DATA) + continue; + register_set_hdr->data[datai].entry.address = + cpu_to_le32(e->regdata.raddr); + register_set_hdr->data[datai].entry.value = + cpu_to_le32(e->regdata.rdata); + datai++; + } + if (datai != 0) { + size = sizeof(struct register_set_hdr_v1) + 8 * datai + 4; + register_set_hdr->headertype = OPT_HDR_V1_REGISTER_TYPE; + register_set_hdr->headersz_lsb = cpu_to_le16(size & 0xFFFF); + register_set_hdr->headersz_msb = size >> 16; + /* Set delay to the smallest possible value 1ms. */ + register_set_hdr->data[datai].last_entry.delay = 1; + cur += size; + *next_ext = 1; + next_ext = ®ister_set_hdr->data[datai].last_entry.next; + } + for (cfgi = 0; cfgi < cfgn; cfgi++) { e = &image_cfg[cfgi]; if (e->type != IMAGE_CFG_BINARY) diff --git a/tools/kwbimage.h b/tools/kwbimage.h index cab3d95d13..9f86da46e8 100644 --- a/tools/kwbimage.h +++ b/tools/kwbimage.h @@ -148,6 +148,33 @@ struct secure_hdr_v1 { uint16_t reserved5; /* 0x25E2 - 0x25E3 */ }; +/* + * Structure of register set + */ +struct register_set_hdr_v1 { + uint8_t headertype; /* 0x0 */ + uint8_t headersz_msb; /* 0x1 */ + uint16_t headersz_lsb; /* 0x2 - 0x3 */ + union { + struct { + uint32_t address; /* 0x4+8*N - 0x7+8*N */ + uint32_t value; /* 0x8+8*N - 0xB+8*N */ + } entry; + struct { + uint8_t next; /* 0xC+8*N */ + uint8_t delay; /* 0xD+8*N */ + uint16_t reserved; /* 0xE+8*N - 0xF+8*N */ + } last_entry; + } data[]; +}; + +/* + * Value 0 in register_set_hdr_v1 delay field is special. + * Instead of delay it setup SDRAM Controller. + */ +#define REGISTER_SET_HDR_OPT_DELAY_SDRAM_SETUP 0 +#define REGISTER_SET_HDR_OPT_DELAY_MS(val) ((val) ?: 1) + /* * Various values for the opt_hdr_v1->headertype field, describing the * different types of optional headers. The "secure" header contains From patchwork Fri Jul 23 09:14:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509075 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=eIiVlemu; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP7H6z99z9sRN for ; Fri, 23 Jul 2021 19:25:31 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DB9B082DB0; Fri, 23 Jul 2021 11:25:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="eIiVlemu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9BA4082DB6; Fri, 23 Jul 2021 11:24:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1E18582CDE for ; Fri, 23 Jul 2021 11:14:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id A1D071408AE; Fri, 23 Jul 2021 11:14:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031698; bh=tF43hJyYt8y7g3YNG1DczLqzvlLC6OvRRiru+gCNMus=; h=From:To:Date; b=eIiVlemufW24WKJrpP6B0uFKyGTBMBAblc/QZhqnJElHzgLaUcjppmtTLLOKND0FV DEgUa3XZy3Mz8LHCccYzcnQDSVwCZMjCmJDBk/jwVtE1EygRAYLu5feIQp4eQLbwGi OZSO3PEZfEmc7UotS8dasAsXnt0/xOw4IJ2XbZsQ= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 18/41] tools: kwbimage: Add support for a new DATA_DELAY command Date: Fri, 23 Jul 2021 11:14:12 +0200 Message-Id: <20210723091435.20388-19-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár This command is supported only by v1 images and specifies a milliseconds delay after executing some set of DATA commands. The special string value SDRAM_SETUP instructs BootROM to setup SDRAM controller instead of executing delay. SDRAM_SETUP may be specified only once and after the last DATA command. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Chris Packham Reviewed-by: Stefan Roese Tested-by: Chris Packham --- tools/kwbimage.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index b585f49180..469e5b55f2 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -104,6 +104,7 @@ enum image_cfg_type { IMAGE_CFG_NAND_PAGESZ, IMAGE_CFG_BINARY, IMAGE_CFG_DATA, + IMAGE_CFG_DATA_DELAY, IMAGE_CFG_BAUDRATE, IMAGE_CFG_DEBUG, IMAGE_CFG_KAK, @@ -131,6 +132,7 @@ static const char * const id_strs[] = { [IMAGE_CFG_NAND_PAGESZ] = "NAND_PAGE_SIZE", [IMAGE_CFG_BINARY] = "BINARY", [IMAGE_CFG_DATA] = "DATA", + [IMAGE_CFG_DATA_DELAY] = "DATA_DELAY", [IMAGE_CFG_BAUDRATE] = "BAUDRATE", [IMAGE_CFG_DEBUG] = "DEBUG", [IMAGE_CFG_KAK] = "KAK", @@ -162,6 +164,7 @@ struct image_cfg_element { unsigned int nandeccmode; unsigned int nandpagesz; struct ext_hdr_v0_reg regdata; + unsigned int regdata_delay; unsigned int baudrate; unsigned int debug; const char *key_name; @@ -1289,8 +1292,21 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, register_set_hdr = (struct register_set_hdr_v1 *)cur; for (cfgi = 0; cfgi < cfgn; cfgi++) { e = &image_cfg[cfgi]; - if (e->type != IMAGE_CFG_DATA) + if (e->type != IMAGE_CFG_DATA && + e->type != IMAGE_CFG_DATA_DELAY) continue; + if (e->type == IMAGE_CFG_DATA_DELAY) { + size = sizeof(struct register_set_hdr_v1) + 8 * datai + 4; + register_set_hdr->headertype = OPT_HDR_V1_REGISTER_TYPE; + register_set_hdr->headersz_lsb = cpu_to_le16(size & 0xFFFF); + register_set_hdr->headersz_msb = size >> 16; + register_set_hdr->data[datai].last_entry.delay = e->regdata_delay; + cur += size; + *next_ext = 1; + next_ext = ®ister_set_hdr->data[datai].last_entry.next; + datai = 0; + continue; + } register_set_hdr->data[datai].entry.address = cpu_to_le32(e->regdata.raddr); register_set_hdr->data[datai].entry.value = @@ -1429,6 +1445,12 @@ static int image_create_config_parse_oneline(char *line, el->regdata.raddr = strtoul(value1, NULL, 16); el->regdata.rdata = strtoul(value2, NULL, 16); break; + case IMAGE_CFG_DATA_DELAY: + if (!strcmp(value1, "SDRAM_SETUP")) + el->regdata_delay = REGISTER_SET_HDR_OPT_DELAY_SDRAM_SETUP; + else + el->regdata_delay = REGISTER_SET_HDR_OPT_DELAY_MS(strtoul(value1, NULL, 10)); + break; case IMAGE_CFG_BAUDRATE: el->baudrate = strtoul(value1, NULL, 10); break; From patchwork Fri Jul 23 09:14:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509079 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=UYG+mL7G; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP8B30h0z9sV8 for ; Fri, 23 Jul 2021 19:26:18 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CBC1182DA5; Fri, 23 Jul 2021 11:25:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="UYG+mL7G"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F3C9E82DBF; Fri, 23 Jul 2021 11:24:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5295C82D9C for ; Fri, 23 Jul 2021 11:15:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id DB950140952; Fri, 23 Jul 2021 11:14:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031700; bh=qA2YOdWRGX+DyxjPLO/ZpufAUkZUTD5mrxgHtbl7bVM=; h=From:To:Date; b=UYG+mL7GhWigO0EG1BVf82AUUXSnjt5kqID4YY5AkvIpiWgdUaV4o/SSyHb5sxXQu wliPmkI+AHModS2HuVUK10Vumqmhd9yR6/5kuTuZyOXvhdAUsjwG7BnfOHoz/TZFyl SxilGwi/rZfIz7cUiHpyqHaodU3Hpo0fZFKKQJ7U= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 19/41] tools: kwbimage: Do not hide usage of secure header under CONFIG_ARMADA_38X Date: Fri, 23 Jul 2021 11:14:13 +0200 Message-Id: <20210723091435.20388-20-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The mkimage host tool can be used to generate kwbimage v1 image with secure header on host system for A38x plaform also when U-Boot is being compiled for different platform. So there is no reason to not allow compiling of mkimage/kwbimage with secure header support for e.g. x86-64 host. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Chris Packham Reviewed-by: Stefan Roese Tested-by: Chris Packham --- tools/Makefile | 4 ---- tools/kwbimage.c | 22 ---------------------- 2 files changed, 26 deletions(-) diff --git a/tools/Makefile b/tools/Makefile index 9517f203fd..35aefc207c 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -173,10 +173,6 @@ ifneq ($(CONFIG_SYS_U_BOOT_OFFS),) HOSTCFLAGS_kwbimage.o += -DCONFIG_SYS_U_BOOT_OFFS=$(CONFIG_SYS_U_BOOT_OFFS) endif -ifneq ($(CONFIG_ARMADA_38X),) -HOSTCFLAGS_kwbimage.o += -DCONFIG_KWB_SECURE -endif - # MXSImage needs LibSSL ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_ARMADA_38X)$(CONFIG_TOOLS_LIBCRYPTO),) HOSTCFLAGS_kwbimage.o += \ diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 469e5b55f2..f3b16d94ad 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -16,7 +16,6 @@ #include #include "kwbimage.h" -#ifdef CONFIG_KWB_SECURE #include #include #include @@ -42,13 +41,10 @@ void EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) EVP_MD_CTX_reset(ctx); } #endif -#endif static struct image_cfg_element *image_cfg; static int cfgn; -#ifdef CONFIG_KWB_SECURE static int verbose_mode; -#endif struct boot_mode { unsigned int id; @@ -243,8 +239,6 @@ image_count_options(unsigned int optiontype) return count; } -#if defined(CONFIG_KWB_SECURE) - static int image_get_csk_index(void) { struct image_cfg_element *e; @@ -267,8 +261,6 @@ static bool image_get_spezialized_img(void) return e->sec_specialized_img; } -#endif - /* * Compute a 8-bit checksum of a memory area. This algorithm follows * the requirements of the Marvell SoC BootROM specifications. @@ -363,7 +355,6 @@ static uint8_t baudrate_to_option(unsigned int baudrate) } } -#if defined(CONFIG_KWB_SECURE) static void kwb_msg(const char *fmt, ...) { if (verbose_mode) { @@ -852,8 +843,6 @@ done: return ret; } -#endif - static void *image_create_v0(size_t *imagesz, struct image_tool_params *params, int payloadsz) { @@ -984,13 +973,11 @@ static size_t image_headersz_v1(int *hasext) *hasext = 1; } -#if defined(CONFIG_KWB_SECURE) if (image_get_csk_index() >= 0) { headersz += sizeof(struct secure_hdr_v1); if (hasext) *hasext = 1; } -#endif #if defined(CONFIG_SYS_U_BOOT_OFFS) if (headersz > CONFIG_SYS_U_BOOT_OFFS) { @@ -1080,8 +1067,6 @@ err_close: return -1; } -#if defined(CONFIG_KWB_SECURE) - int export_pub_kak_hash(RSA *kak, struct secure_hdr_v1 *secure_hdr) { FILE *hashf; @@ -1189,7 +1174,6 @@ int add_secure_header_v1(struct image_tool_params *params, uint8_t *ptr, return 0; } -#endif static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, uint8_t *ptr, int payloadsz) @@ -1197,9 +1181,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, struct image_cfg_element *e; struct main_hdr_v1 *main_hdr; struct register_set_hdr_v1 *register_set_hdr; -#if defined(CONFIG_KWB_SECURE) struct secure_hdr_v1 *secure_hdr = NULL; -#endif size_t headersz; uint8_t *image, *cur; int hasext = 0; @@ -1275,7 +1257,6 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, if (main_hdr->blockid == IBR_HDR_PEX_ID) main_hdr->srcaddr = cpu_to_le32(0xFFFFFFFF); -#if defined(CONFIG_KWB_SECURE) if (image_get_csk_index() >= 0) { /* * only reserve the space here; we fill the header later since @@ -1286,7 +1267,6 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, *next_ext = 1; next_ext = &secure_hdr->next; } -#endif datai = 0; register_set_hdr = (struct register_set_hdr_v1 *)cur; @@ -1334,11 +1314,9 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, return NULL; } -#if defined(CONFIG_KWB_SECURE) if (secure_hdr && add_secure_header_v1(params, ptr, payloadsz, headersz, image, secure_hdr)) return NULL; -#endif /* Calculate and set the header checksum */ main_hdr->checksum = image_checksum8(main_hdr, headersz); From patchwork Fri Jul 23 09:14:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509062 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=DgeCLk8y; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNyX74DVz9sRN for ; Fri, 23 Jul 2021 19:17:56 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1FFC082DC3; Fri, 23 Jul 2021 11:16:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="DgeCLk8y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 43D6182E7D; Fri, 23 Jul 2021 11:15:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8621E82DA3 for ; Fri, 23 Jul 2021 11:15:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 2199F1409F3; Fri, 23 Jul 2021 11:15:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031701; bh=x5aBxW5G4dCJkN9/7NGihKl/LDngwWe1fFdcDwGpLw4=; h=From:To:Date; b=DgeCLk8yGjZcXP5nq45D8C93ek/zzloQUmfiX+2HMRLolLkB9o+F1t0HxTJSjIgzP DoKBn+nSXkWpF3cUs4+4Tvb5UN9cKOENq+1f5M5WsixqAA/02ml/IfR06HImclgVBL HTW5z6TF/5VGTiKP6PWe1fuW5d9SXy+VyZfJeCMs= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 20/41] tools: kwbimage: Mark all BootROM structures __packed Date: Fri, 23 Jul 2021 11:14:14 +0200 Message-Id: <20210723091435.20388-21-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár These structures must have specific size without padding, so mark them as packed via the de-facto standard macro __packed. Also replace PACKED macro. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- tools/kwbimage.h | 30 ++++++++++++++++++------------ tools/kwboot.c | 8 +------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tools/kwbimage.h b/tools/kwbimage.h index 9f86da46e8..e063e3e41e 100644 --- a/tools/kwbimage.h +++ b/tools/kwbimage.h @@ -11,6 +11,12 @@ #include #include +#ifdef __GNUC__ +#define __packed __attribute((packed)) +#else +#define __packed +#endif + #define KWBIMAGE_MAX_CONFIG ((0x1dc - 0x20)/sizeof(struct reg_config)) #define MAX_TEMPBUF_LEN 32 @@ -46,12 +52,12 @@ struct main_hdr_v0 { uint16_t rsvd2; /* 0x1C-0x1D */ uint8_t ext; /* 0x1E */ uint8_t checksum; /* 0x1F */ -}; +} __packed; struct ext_hdr_v0_reg { uint32_t raddr; uint32_t rdata; -}; +} __packed; #define EXT_HDR_V0_REG_COUNT ((0x1dc - 0x20) / sizeof(struct ext_hdr_v0_reg)) @@ -61,12 +67,12 @@ struct ext_hdr_v0 { struct ext_hdr_v0_reg rcfg[EXT_HDR_V0_REG_COUNT]; uint8_t reserved2[7]; uint8_t checksum; -}; +} __packed; struct kwb_header { struct main_hdr_v0 kwb_hdr; struct ext_hdr_v0 kwb_exthdr; -}; +} __packed; /* Structure of the main header, version 1 (Armada 370/38x/XP) */ struct main_hdr_v1 { @@ -87,7 +93,7 @@ struct main_hdr_v1 { uint16_t reserved5; /* 0x1C-0x1D */ uint8_t ext; /* 0x1E */ uint8_t checksum; /* 0x1F */ -}; +} __packed; /* * Main header options @@ -109,21 +115,21 @@ struct opt_hdr_v1 { uint8_t headersz_msb; uint16_t headersz_lsb; char data[0]; -}; +} __packed; /* * Public Key data in DER format */ struct pubkey_der_v1 { uint8_t key[524]; -}; +} __packed; /* * Signature (RSA 2048) */ struct sig_v1 { uint8_t sig[256]; -}; +} __packed; /* * Structure of secure header (Armada 38x) @@ -146,7 +152,7 @@ struct secure_hdr_v1 { uint8_t next; /* 0x25E0 */ uint8_t reserved4; /* 0x25E1 */ uint16_t reserved5; /* 0x25E2 - 0x25E3 */ -}; +} __packed; /* * Structure of register set @@ -159,14 +165,14 @@ struct register_set_hdr_v1 { struct { uint32_t address; /* 0x4+8*N - 0x7+8*N */ uint32_t value; /* 0x8+8*N - 0xB+8*N */ - } entry; + } __packed entry; struct { uint8_t next; /* 0xC+8*N */ uint8_t delay; /* 0xD+8*N */ uint16_t reserved; /* 0xE+8*N - 0xF+8*N */ - } last_entry; + } __packed last_entry; } data[]; -}; +} __packed; /* * Value 0 in register_set_hdr_v1 delay field is special. diff --git a/tools/kwboot.c b/tools/kwboot.c index 4be094c9c8..2683e5360c 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -26,12 +26,6 @@ #include #include -#ifdef __GNUC__ -#define PACKED __attribute((packed)) -#else -#define PACKED -#endif - /* * Marvell BootROM UART Sensing */ @@ -68,7 +62,7 @@ struct kwboot_block { uint8_t _pnum; uint8_t data[128]; uint8_t csum; -} PACKED; +} __packed; #define KWBOOT_BLK_RSP_TIMEO 1000 /* ms */ From patchwork Fri Jul 23 09:14:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509078 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=TKltJNV9; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP7z20Ygz9sV8 for ; Fri, 23 Jul 2021 19:26:07 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2893B82D86; Fri, 23 Jul 2021 11:25:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="TKltJNV9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 63ADD82DAB; Fri, 23 Jul 2021 11:24:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EAF6182DB2 for ; Fri, 23 Jul 2021 11:15:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 5B99A1409FA; Fri, 23 Jul 2021 11:15:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031702; bh=YmlLRnDG8LvasPrs8XstvBk49Ws4VyNnCfkp+n8S8Dw=; h=From:To:Date; b=TKltJNV9a/1IW3JPkJ+46kAQ+ls6B/QMG9/u5MQl2nrdqvMZ1dc3imCCV8ea0xomU 4AIZLb7Y9YXeP4PJfITa+BO5VX5tAJsT3flXwG7Ae4yvROyWe5sM7FnyV8B/PdbIH6 TVxMuBdvKtMMtZ/EnSUwH8V8kFqc8QGGla3ojxQE= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 21/41] tools: dumpimage: Fix crashing when trying to extract data from kwbimage Date: Fri, 23 Jul 2021 11:14:15 +0200 Message-Id: <20210723091435.20388-22-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Trying to call the following command causes NULL pointer dereference in strlen(): ./tools/dumpimage -T kwbimage -o /tmp/out u-boot-spl.kwb Fix it by checking whether params->imagename is non-NULL before calling strlen(). Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- tools/kwbimage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index f3b16d94ad..5410df63f5 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1867,7 +1867,7 @@ static int kwbimage_generate(struct image_tool_params *params, */ static int kwbimage_check_params(struct image_tool_params *params) { - if (!strlen(params->imagename)) { + if (!params->imagename || !strlen(params->imagename)) { char *msg = "Configuration file for kwbimage creation omitted"; fprintf(stderr, "Error:%s - %s\n", params->cmdname, msg); From patchwork Fri Jul 23 09:14:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509080 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=ZUeo2hEg; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP8N3nqjz9sRN for ; Fri, 23 Jul 2021 19:26:28 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B948F82DC4; Fri, 23 Jul 2021 11:25:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="ZUeo2hEg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 58ADB82DA5; Fri, 23 Jul 2021 11:25:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 570A582DB0 for ; Fri, 23 Jul 2021 11:15:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 9667D1408AE; Fri, 23 Jul 2021 11:15:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031703; bh=X3o5HCjOYUcnrD4PWwqDA9h86uvL4+hUl6rNpSSE2qA=; h=From:To:Date; b=ZUeo2hEgc2oe4d2j2+sE2vDKyoqtypuZzRFDoCC4PcOyZ00LwBIKw36sqH0VpLXTe EVPvC4x8TO33Ar7dRUUEb21w/SKdfy4AzsEC12REv3p266IvUH/5c0tR21eYyabSg+ oGxiYqSEmgm4kMpwSJroB11Azc48GunwfTtH/Lxw= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 22/41] tools: dumpimage: Show error message when trying to extract data from kwbimage Date: Fri, 23 Jul 2021 11:14:16 +0200 Message-Id: <20210723091435.20388-23-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár There is no code for extracting data from kwbimage, so show an error message when user tries this via e.g. dumpimage call: ./tools/dumpimage -T kwbimage -o /tmp/out u-boot-spl.kwb Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- tools/kwbimage.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 5410df63f5..9ecda861e4 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1867,6 +1867,11 @@ static int kwbimage_generate(struct image_tool_params *params, */ static int kwbimage_check_params(struct image_tool_params *params) { + if (params->iflag) { + fprintf(stderr, "%s: kwbimage does not support extract operation\n", params->cmdname); + return CFG_INVALID; + } + if (!params->imagename || !strlen(params->imagename)) { char *msg = "Configuration file for kwbimage creation omitted"; From patchwork Fri Jul 23 09:14:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509088 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=jbIU8wb1; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP9y3vlBz9sRN for ; Fri, 23 Jul 2021 19:27:50 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BFA9C82E02; Fri, 23 Jul 2021 11:26:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="jbIU8wb1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C33C182D7C; Fri, 23 Jul 2021 11:25:17 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3703782DA2 for ; Fri, 23 Jul 2021 11:15:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id D04AE1409F3; Fri, 23 Jul 2021 11:15:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031705; bh=sV3a+c9C8fi6/NUVdHkWxlLEXHzXe4tQcdxja1h6L5Q=; h=From:To:Date; b=jbIU8wb1mbd8+61uFKq4mLFQ8iWpc96nUwKheI6iKz2dZZedxLTgtgGgMaB8X1CpT oSZrWotOgtX0GBn7bQVoDs+L9ZePdMmPdEbDT9pUuB+PotKu01bKK4mqzGQGu74YyI MBeJrmFr2JNzHsi0OC7vR0lgl3I9IvVfmNoMwtG8= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 23/41] tools: kwboot: Fix wrong parameter passed to read() Date: Fri, 23 Jul 2021 11:14:17 +0200 Message-Id: <20210723091435.20388-24-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The 'buf' variable is a pointer and '_buf' is the array itself. Therefore we should pass sizeof(_buf) instead of sizeof(buf) to read(). Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/kwboot.c b/tools/kwboot.c index 2683e5360c..1ba5ded5d3 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -465,7 +465,7 @@ kwboot_term_pipe(int in, int out, char *quit, int *s) ssize_t nin, nout; char _buf[128], *buf = _buf; - nin = read(in, buf, sizeof(buf)); + nin = read(in, buf, sizeof(_buf)); if (nin <= 0) return -1; From patchwork Fri Jul 23 09:14:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509074 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=Ug9XmxJZ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP74188Hz9sRN for ; Fri, 23 Jul 2021 19:25:20 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 63EA682DBE; Fri, 23 Jul 2021 11:24:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="Ug9XmxJZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DBD6E82DAC; Fri, 23 Jul 2021 11:24:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9A1ED82DAD for ; Fri, 23 Jul 2021 11:15:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 14D0D140952; Fri, 23 Jul 2021 11:15:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031706; bh=vs6GvBH2KcDRfabGa1fKLAnzYmF5YST1VppBSFGmwwk=; h=From:To:Date; b=Ug9XmxJZV+dGytTEQsvKDoA7wBy8BxVHGAAb42XZPvOXx5Nx9YGOAYCYDbn1PYyrT 9JEErPozwInY3yQmoKmD4+eDagTtj2arfDcLPuAObgZ9jI9qDMdGTlUvkqvKonB0BW YZpGuGBDrFsDYzqlUSNmryogMZx5jDBItxL7RFxQ= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 24/41] tools: kwboot: Fix restoring terminal Date: Fri, 23 Jul 2021 11:14:18 +0200 Message-Id: <20210723091435.20388-25-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Call tcsetattr() only if the file descriptor is valid. It may be invalidated by previous lines (if it is not a tty descriptor). Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwboot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/kwboot.c b/tools/kwboot.c index 1ba5ded5d3..7fa742d84c 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -558,7 +558,8 @@ kwboot_terminal(int tty) } } while (quit[s] != 0); - tcsetattr(in, TCSANOW, &otio); + if (in >= 0) + tcsetattr(in, TCSANOW, &otio); out: return rc; } From patchwork Fri Jul 23 09:14:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509086 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=kDEAfno3; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP9Y4Dcvz9sRN for ; Fri, 23 Jul 2021 19:27:29 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 218D382DFE; Fri, 23 Jul 2021 11:26:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="kDEAfno3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 03D5C82D81; Fri, 23 Jul 2021 11:25:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 30F5A82D86 for ; Fri, 23 Jul 2021 11:15:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 5EAB0140A28; Fri, 23 Jul 2021 11:15:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031708; bh=AzucOn2x46tcw8TfE7hPscKKc+4Obhxw2TFE68towQs=; h=From:To:Date; b=kDEAfno3JYzQmRb4qTqSdsCv0KRFkFZyO1jz93X4W5+7/IK1Cfd+seYFhTFXQjA8V t/gwHJWw1bkFFNMNx9DEGTnFwx6WaBb+YXcYX1S7/u8VtN2xux/oPV8aX5dH4L3Ln5 b16zCN63hePHeyfOLVbn20ZnUWtP+QmQkVWrkAq4= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 25/41] tools: kwboot: Print trailing newline after terminal is terminated Date: Fri, 23 Jul 2021 11:14:19 +0200 Message-Id: <20210723091435.20388-26-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Print trailing newline as the last printed byte can be something different. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwboot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/kwboot.c b/tools/kwboot.c index 7fa742d84c..941f4228f9 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -560,6 +560,7 @@ kwboot_terminal(int tty) if (in >= 0) tcsetattr(in, TCSANOW, &otio); + printf("\n"); out: return rc; } From patchwork Fri Jul 23 09:14:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509071 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=SbCdD1N8; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP6S3dj9z9sV8 for ; Fri, 23 Jul 2021 19:24:48 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CC4B482D5B; Fri, 23 Jul 2021 11:24:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="SbCdD1N8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1BB2982D83; Fri, 23 Jul 2021 11:24:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4FA5A82D5B for ; Fri, 23 Jul 2021 11:15:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id D2D5C1408AE; Fri, 23 Jul 2021 11:15:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031710; bh=VwrIyavfetKZEr8955beMqs+o9VCDdU6tzLZTR10Qig=; h=From:To:Date; b=SbCdD1N85ejGFg96VFd1yNaD0Dd67OJuCWNNTAWqaKbm7vSpCEszbjtoVogIGSrFz pYppD0OLR9GrTZzrAet3n14ZBssCPN7m0u33Ia8JtkvEnBRkx4pYTP3wbRznCR6H9b vrV/VRG1M/DJbGjHVvZPmzKDVnWe/0KTMMKI66wo= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 26/41] tools: kwboot: Cosmetic fix - add missing curly brackets Date: Fri, 23 Jul 2021 11:14:20 +0200 Message-Id: <20210723091435.20388-27-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Add missing curly brackets for this else statement. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwboot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/kwboot.c b/tools/kwboot.c index 941f4228f9..c0ac4ce19e 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -479,13 +479,14 @@ kwboot_term_pipe(int in, int out, char *quit, int *s) return 0; buf++; nin--; - } else + } else { while (*s > 0) { nout = write(out, quit, *s); if (nout <= 0) return -1; (*s) -= nout; } + } } } From patchwork Fri Jul 23 09:14:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509073 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=aACwcZfw; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP6s13qJz9sRN for ; Fri, 23 Jul 2021 19:25:09 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4F39F82D83; Fri, 23 Jul 2021 11:24:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="aACwcZfw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BEDCB82D94; Fri, 23 Jul 2021 11:24:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 89A2882DB6 for ; Fri, 23 Jul 2021 11:15:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 199921409FA; Fri, 23 Jul 2021 11:15:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031711; bh=Pgv+eXskFNQBBjh07TcJwZ6JcyX/5fJgFeBiF92uswU=; h=From:To:Date; b=aACwcZfwJulu45CDes/Qd3sQcLa3lHT/qHIbedUrmnIyWq9648u2gk+V4+W0UigNL 66g/WvLj15xI4KMD3pnDbAv4SKLzKWVloXYtknnfi9V6URNXPiW9g6jMkUVGG/7Hyt /IEnXMeCLW90YtWxsB1UMVRgTCvnhmLzumzGYjIs= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 27/41] tools: kwboot: Check for v1 header size Date: Fri, 23 Jul 2021 11:14:21 +0200 Message-Id: <20210723091435.20388-28-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Too small invalid headers may cause kwboot to crash. Check for header size of v1 images. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- tools/kwboot.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/kwboot.c b/tools/kwboot.c index c0ac4ce19e..1d32c1b7ad 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -645,6 +645,11 @@ kwboot_img_patch_hdr(void *img, size_t size) else hdrsz = KWBHEADER_V1_SIZE(hdr); + if (size < hdrsz) { + errno = EINVAL; + goto out; + } + csum = kwboot_img_csum8(hdr, hdrsz) - hdr->checksum; if (csum != hdr->checksum) { errno = EINVAL; From patchwork Fri Jul 23 09:14:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509083 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=cs4H0KGW; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP8z4vpVz9sRN for ; Fri, 23 Jul 2021 19:26:59 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3EF7982DE4; Fri, 23 Jul 2021 11:25:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="cs4H0KGW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7646282D9A; Fri, 23 Jul 2021 11:25:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A5CC382D72 for ; Fri, 23 Jul 2021 11:15:12 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 53B1B140A03; Fri, 23 Jul 2021 11:15:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031712; bh=OJyPM+I1dqkWY/Yut9G+lzXNe6STEQ87IgKawZGN1Gg=; h=From:To:Date; b=cs4H0KGWfWp/8bGA9aykxRoo1A5EBb/SiNWYZMxISpA8ZSB9jqeBdnbC0KhNuyVJT /IwumWYfdYF7A0C1rnIgYNOu3r7IZSLzDWgkMfheQKQ6/YdQd7iXCA/lUkkapz2LIs VHY40XMoxBgcGanvtmzcUzMbA/Q8S7NUkNvTD6B4= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 28/41] tools: kwboot: Fix checking image header version Date: Fri, 23 Jul 2021 11:14:22 +0200 Message-Id: <20210723091435.20388-29-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Function image_version() returns unsigned value, so it can never be negative. Explicitly check for two supported image versions: v0 and v1. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- tools/kwboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/kwboot.c b/tools/kwboot.c index 1d32c1b7ad..7feeaa45a2 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -634,7 +634,7 @@ kwboot_img_patch_hdr(void *img, size_t size) } image_ver = image_version(img); - if (image_ver < 0) { + if (image_ver != 0 && image_ver != 1) { fprintf(stderr, "Invalid image header version\n"); errno = EINVAL; goto out; From patchwork Fri Jul 23 09:14:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509076 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=xA1khfTP; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP7Y5R3Nz9sRN for ; Fri, 23 Jul 2021 19:25:45 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 726BD82D5B; Fri, 23 Jul 2021 11:25:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="xA1khfTP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 047EC82DAC; Fri, 23 Jul 2021 11:24:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EDAA182D84 for ; Fri, 23 Jul 2021 11:15:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 84A4F1408AE; Fri, 23 Jul 2021 11:15:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031713; bh=NuWcyguOE7SeA9CEjhp+YJCdRs/i5+NXvYVQy7jiBhA=; h=From:To:Date; b=xA1khfTPuxGe8VxwbrkHyFCFytwYekZ0JV//Tz/XalFbtM2nFlNWGtb8h56veE7pg aQFBfOvoZYpDI2bAMcfhc9FeN7oIUKMv98tKvZ4z8W55VesJ4SzwJHmAfMIsyTYWs6 erFAsRtezdPDty7/dsCt5j3Rl73EnKn6zENsY8yE= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 29/41] arm: mvebu: Fix return_to_bootrom() Date: Fri, 23 Jul 2021 11:14:23 +0200 Message-Id: <20210723091435.20388-30-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Register r0 should be set to return value 0x0 - NO_ERR. Set r0 with return value after all registers are restored from the stack, so that the return value is always correct. Signed-off-by: Pali Rohár Fixes: 944c7a317675 ("arm: mvebu: Add option to use UART xmodem protocol via kwboot") Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- arch/arm/mach-mvebu/lowlevel_spl.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-mvebu/lowlevel_spl.S b/arch/arm/mach-mvebu/lowlevel_spl.S index 8718d7a43e..dde77b7652 100644 --- a/arch/arm/mach-mvebu/lowlevel_spl.S +++ b/arch/arm/mach-mvebu/lowlevel_spl.S @@ -13,8 +13,9 @@ ENDPROC(save_boot_params) ENTRY(return_to_bootrom) ldr r12, =CONFIG_SPL_BOOTROM_SAVE ldr sp, [r12] + ldmfd sp!, {r0 - r12, lr} /* @ restore registers from stack */ mov r0, #0x0 /* @ return value: 0x0 NO_ERR */ - ldmfd sp!, {r0 - r12, pc} /* @ restore regs and return */ + bx lr /* @ return to bootrom */ ENDPROC(return_to_bootrom) /* From patchwork Fri Jul 23 09:14:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509072 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=jW4Kgemp; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP6d2Q5Mz9sRN for ; Fri, 23 Jul 2021 19:24:57 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0130782D87; Fri, 23 Jul 2021 11:24:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="jW4Kgemp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F073E82DAC; Fri, 23 Jul 2021 11:24:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4090582DBF for ; Fri, 23 Jul 2021 11:15:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id C22BF140952; Fri, 23 Jul 2021 11:15:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031714; bh=b3SqoEoixHgV+lz4457wjhSCuweh91lpstuWWIPwTGU=; h=From:To:Date; b=jW4KgempjsbOV0EtcfYdg/LiotZWXhfKySSh5LY8dsC/38AlWWpuoJsjELO49345i rL664mg+LfuWPWhAwvFK0Q3vt+xsDn40691m9xHfHzVT3WmoRlD9B7n7UDEh4kBOv5 qVbIvAgAPikJlKG4c6FqYqEI4Dh0nFNDLUSi81HA= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 30/41] arm: mvebu: Mark return_to_bootrom() as a noreturn function Date: Fri, 23 Jul 2021 11:14:24 +0200 Message-Id: <20210723091435.20388-31-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár This function does not return, so add the appropriate compiler flag. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- arch/arm/mach-mvebu/include/mach/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h b/arch/arm/mach-mvebu/include/mach/cpu.h index 52473ade7a..79858858c2 100644 --- a/arch/arm/mach-mvebu/include/mach/cpu.h +++ b/arch/arm/mach-mvebu/include/mach/cpu.h @@ -142,7 +142,7 @@ int mvebu_mbus_probe(struct mbus_win windows[], int count); int mvebu_soc_family(void); u32 mvebu_get_nand_clock(void); -void return_to_bootrom(void); +void __noreturn return_to_bootrom(void); #ifndef CONFIG_DM_MMC int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks); From patchwork Fri Jul 23 09:14:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509084 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=S42EOXIk; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP994N00z9sRN for ; Fri, 23 Jul 2021 19:27:09 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 575F482DF1; Fri, 23 Jul 2021 11:25:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="S42EOXIk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0144A82D80; Fri, 23 Jul 2021 11:25:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6626282DC0 for ; Fri, 23 Jul 2021 11:15:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 0A7551409F6; Fri, 23 Jul 2021 11:15:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031716; bh=81IH5Lw06Qbbrw0mnuhqq07FgRIOeOMiwqRCmROl/6Q=; h=From:To:Date; b=S42EOXIkQqKR/vF2YOnk9Wx/VN2fhPt8jUiobZdcJVstmP7REyJzDW2HBoHjp/x1M h9d2G7QsnhFGX+HG3K6UedZc0Gpie+AXo6goUeowRjunr3tMQHInjAjknP+5Xj70aq QuTqcU/l9nkIY68DDymocX9fZqyHG24RU71iE31k= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 31/41] arm: mvebu: Implement return_to_bootrom() via U-Boot's SPL framework Date: Fri, 23 Jul 2021 11:14:25 +0200 Message-Id: <20210723091435.20388-32-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár U-Boot's SPL framework already has an API for loading U-Boot via BootROM. Implement the function board_return_to_bootrom() for mvebu SPL code. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- arch/arm/mach-mvebu/Kconfig | 4 ++++ arch/arm/mach-mvebu/spl.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig index cda65f7478..2133d9a172 100644 --- a/arch/arm/mach-mvebu/Kconfig +++ b/arch/arm/mach-mvebu/Kconfig @@ -257,6 +257,7 @@ config MVEBU_SPL_BOOT_DEVICE_SPI select SPL_SPI_FLASH_SUPPORT select SPL_SPI_LOAD select SPL_SPI_SUPPORT + select SPL_BOOTROM_SUPPORT config MVEBU_SPL_BOOT_DEVICE_MMC bool "SDIO/MMC card" @@ -267,14 +268,17 @@ config MVEBU_SPL_BOOT_DEVICE_MMC select SPL_GPIO_SUPPORT select SPL_LIBDISK_SUPPORT select SPL_MMC_SUPPORT + select SPL_BOOTROM_SUPPORT config MVEBU_SPL_BOOT_DEVICE_SATA bool "SATA" select SPL_SATA_SUPPORT select SPL_LIBDISK_SUPPORT + select SPL_BOOTROM_SUPPORT config MVEBU_SPL_BOOT_DEVICE_UART bool "UART" + select SPL_BOOTROM_SUPPORT endchoice diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c index 16ebb7a59e..836eb18889 100644 --- a/arch/arm/mach-mvebu/spl.c +++ b/arch/arm/mach-mvebu/spl.c @@ -79,6 +79,18 @@ u32 spl_boot_device(void) return get_boot_device(); } +int board_return_to_bootrom(struct spl_image_info *spl_image, + struct spl_boot_device *bootdev) +{ + u32 *regs = *(u32 **)CONFIG_SPL_BOOTROM_SAVE; + + printf("Returning to BootROM (return address 0x%08x)...\n", regs[13]); + return_to_bootrom(); + + /* NOTREACHED - return_to_bootrom() does not return */ + hang(); +} + void board_init_f(ulong dummy) { int ret; From patchwork Fri Jul 23 09:14:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509082 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=IopBvsMn; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP8m49vSz9sRN for ; Fri, 23 Jul 2021 19:26:48 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5CF3B82DBF; Fri, 23 Jul 2021 11:25:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="IopBvsMn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CEF6682D84; Fri, 23 Jul 2021 11:25:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B7DAA82DC2 for ; Fri, 23 Jul 2021 11:15:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 47BCD1408AE; Fri, 23 Jul 2021 11:15:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031717; bh=vx73fi6pB0vk9K+4LVdKOgI63R9AuHJVh/DXeOsDPmY=; h=From:To:Date; b=IopBvsMnf+uUI8ga7YqVSvgyJ2HlN3t8fP+ZOMwlPcCdRhHsO/vkdoGaQ19ohYCEB qod1+AykOylDoM9dOIS4EWZD0xg/IhqZnO4xVGsrUWBAyi49XaL4P2aEqSQCUwdoj6 Hg+16xrioNjh1CwksER90P1JJFkwUwG9J4vd0L9A= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 32/41] arm: mvebu: Use U-Boot's SPL BootROM framework for booting from NAND/UART Date: Fri, 23 Jul 2021 11:14:26 +0200 Message-Id: <20210723091435.20388-33-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Current code uses hack in board_init_f() which calls return_to_bootrom() to skip U-Boot SPL code and return back to BootROM to load U-Boot via UART or from NAND. This change migrates that hack from the board_init_f() function and changes it to return BOOT_DEVICE_BOOTROM instead of returning to BootROM directly, so that U-Boot's SPL framework is used for returning to BootROM. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Chris Packham Tested-by: Chris Packham --- arch/arm/mach-mvebu/spl.c | 47 ++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c index 836eb18889..5c3d959bff 100644 --- a/arch/arm/mach-mvebu/spl.c +++ b/arch/arm/mach-mvebu/spl.c @@ -76,7 +76,30 @@ static u32 get_boot_device(void) u32 spl_boot_device(void) { - return get_boot_device(); + u32 boot_device = get_boot_device(); + + /* + * Return to the BootROM to continue the Marvell xmodem + * UART boot protocol. As initiated by the kwboot tool. + * + * This can only be done by the BootROM since the beginning + * of the image is already read and interpreted by the BootROM. + * SPL has no chance to receive this information. So we + * need to return to the BootROM to enable this xmodem + * UART download. Use SPL infrastructure to return to BootROM. + * + * If booting from NAND lets let the BootROM load the + * rest of the bootloader. + */ + switch (boot_device) { + case BOOT_DEVICE_UART: +#if defined(CONFIG_ARMADA_38X) + case BOOT_DEVICE_NAND: +#endif + return BOOT_DEVICE_BOOTROM; + default: + return boot_device; + } } int board_return_to_bootrom(struct spl_image_info *spl_image, @@ -147,26 +170,4 @@ void board_init_f(ulong dummy) /* Update read timing control for PCIe */ mv_rtc_config(); - - /* - * Return to the BootROM to continue the Marvell xmodem - * UART boot protocol. As initiated by the kwboot tool. - * - * This can only be done by the BootROM and not by the - * U-Boot SPL infrastructure, since the beginning of the - * image is already read and interpreted by the BootROM. - * SPL has no chance to receive this information. So we - * need to return to the BootROM to enable this xmodem - * UART download. - * - * If booting from NAND lets let the BootROM load the - * rest of the bootloader. - */ - switch (get_boot_device()) { - case BOOT_DEVICE_UART: -#if defined(CONFIG_ARMADA_38X) - case BOOT_DEVICE_NAND: -#endif - return_to_bootrom(); - } } From patchwork Fri Jul 23 09:14:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509064 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=RhhRBdGg; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNyx5nj1z9sRN for ; Fri, 23 Jul 2021 19:18:17 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6648282DD6; Fri, 23 Jul 2021 11:16:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="RhhRBdGg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9C5E882DBA; Fri, 23 Jul 2021 11:16:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1074682DC3 for ; Fri, 23 Jul 2021 11:15:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 845D8140952; Fri, 23 Jul 2021 11:15:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031718; bh=n5GUYhdNpxmkhdH419hf6yJzmZxq28gDajpyQ4g3QiQ=; h=From:To:Date; b=RhhRBdGgPYD69qedmGWlcm5oR/+sPuUHezvPKwh4uSXAJvsKpLo6E0XVZd7QilShA aA/xYepAMmkT4Uf3PMYejJPZRiIbHjuKYrNEGTSB89HR6H8GlqM/fTprJOoqgw9QyD qhFCytWLso9ipIB56n7vq/1AWJPC9Fq0WPf0WVF4= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 33/41] SPL: Add support for specifying offset between header and image Date: Fri, 23 Jul 2021 11:14:27 +0200 Message-Id: <20210723091435.20388-34-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Some image types (e.g. kwbimage v1) store the offset to SPL binary and offset to U-Boot proper binary in their headers. To avoid reading SPL binary when loading U-Boot proper, add support for specifying offset in struct spl_image_info, which defines the offset from the beginning of the header and the beginning of the executable data. Initial support is added only for SPI, MMC and SATA code. We can extend it later if needed. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- common/spl/spl_mmc.c | 16 +++++++++++++++- common/spl/spl_sata.c | 12 +++++++++++- common/spl/spl_spi.c | 2 +- include/spl.h | 1 + 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 2377d0937d..9f9a87afcf 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -20,26 +20,40 @@ static int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc, ulong sector, struct image_header *header) { + u32 image_offset_sectors; u32 image_size_sectors; unsigned long count; + u32 image_offset; int ret; ret = spl_parse_image_header(spl_image, header); if (ret) return ret; + /* convert offset to sectors - round down */ + image_offset_sectors = spl_image->offset / mmc->read_bl_len; + /* calculate remaining offset */ + image_offset = spl_image->offset % mmc->read_bl_len; + /* convert size to sectors - round up */ image_size_sectors = (spl_image->size + mmc->read_bl_len - 1) / mmc->read_bl_len; /* Read the header too to avoid extra memcpy */ - count = blk_dread(mmc_get_blk_desc(mmc), sector, image_size_sectors, + count = blk_dread(mmc_get_blk_desc(mmc), + sector + image_offset_sectors, + image_size_sectors, (void *)(ulong)spl_image->load_addr); debug("read %x sectors to %lx\n", image_size_sectors, spl_image->load_addr); if (count != image_size_sectors) return -EIO; + if (image_offset) + memmove((void *)(ulong)spl_image->load_addr, + (void *)(ulong)spl_image->load_addr + image_offset, + spl_image->size); + return 0; } diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c index e108af0576..535a9219ef 100644 --- a/common/spl/spl_sata.c +++ b/common/spl/spl_sata.c @@ -36,6 +36,8 @@ static int spl_sata_load_image_raw(struct spl_image_info *spl_image, struct image_header *header; unsigned long count; u32 image_size_sectors; + u32 image_offset_sectors; + u32 image_offset; int ret; header = spl_get_load_buffer(-sizeof(*header), stor_dev->blksz); @@ -48,11 +50,19 @@ static int spl_sata_load_image_raw(struct spl_image_info *spl_image, return ret; image_size_sectors = DIV_ROUND_UP(spl_image->size, stor_dev->blksz); - count = blk_dread(stor_dev, sector, image_size_sectors, + image_offset_sectors = spl_image->offset / stor_dev->blksz; + image_offset = spl_image->offset % stor_dev->blksz; + count = blk_dread(stor_dev, sector + image_offset_sectors, + image_size_sectors, (void *)spl_image->load_addr); if (count != image_size_sectors) return -EIO; + if (image_offset) + memmove((void *)spl_image->load_addr, + (void *)spl_image->load_addr + image_offset, + spl_image->size); + return 0; } diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c index 6a4e033287..9884e7c185 100644 --- a/common/spl/spl_spi.c +++ b/common/spl/spl_spi.c @@ -159,7 +159,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, err = spl_parse_image_header(spl_image, header); if (err) return err; - err = spi_flash_read(flash, payload_offs, + err = spi_flash_read(flash, payload_offs + spl_image->offset, spl_image->size, (void *)spl_image->load_addr); } diff --git a/include/spl.h b/include/spl.h index 74a1939452..d1a903fef7 100644 --- a/include/spl.h +++ b/include/spl.h @@ -219,6 +219,7 @@ struct spl_image_info { void *fdt_addr; #endif u32 boot_device; + u32 offset; u32 size; u32 flags; void *arg; From patchwork Fri Jul 23 09:14:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509087 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=PpWlcG5P; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWP9l5KBGz9sRN for ; Fri, 23 Jul 2021 19:27:39 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 105B182D72; Fri, 23 Jul 2021 11:26:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="PpWlcG5P"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E837A82D73; Fri, 23 Jul 2021 11:25:17 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3F27882C92 for ; Fri, 23 Jul 2021 11:15:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id C2C161409FA; Fri, 23 Jul 2021 11:15:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031719; bh=znHrXvrM2Lk0OUfJ0ncRpNl3+ROTBZGAQ0prSRokYFY=; h=From:To:Date; b=PpWlcG5PIn2P+/vVBDk0H6N+ChlQxQmj7DugaSoQcwkomEnDJqiZ6EdN5Lc0mSVaL 09CqdQJPDwRqN1z0bH0/EcPzJFso8WKZBynF5bWihRHO74G6Rux83zWCOdOihtFhfG QZvJVKhcjnUm2D5mkX1ctsrHx13NIQIHKsHqGU2Y= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 34/41] SPL: Add support for parsing board / BootROM specific image types Date: Fri, 23 Jul 2021 11:14:28 +0200 Message-Id: <20210723091435.20388-35-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Platform specific BootROM may use its own image type for loading SPL or U-Boot proper. In some cases it makes sense to not use BootROM supplied code for booting U-Boot proper but rather to use U-Boot SPL for this, e.g. when U-Boot SPL can load U-Boot proper faster than BootROM. In this case it is required for platform board code to parse and load U-Boot in BootROM specific image type. This change adds support for parsing platform / board / BootROM specific image types via weak function spl_parse_board_header() which is called before marking boot image as a raw. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- common/spl/spl.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/spl/spl.c b/common/spl/spl.c index 3b96f2fc31..1df31de5b3 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -296,6 +296,12 @@ static int spl_load_fit_image(struct spl_image_info *spl_image, } #endif +__weak int spl_parse_board_header(struct spl_image_info *spl_image, + const void *image_header, size_t size) +{ + return -EINVAL; +} + __weak int spl_parse_legacy_header(struct spl_image_info *spl_image, const struct image_header *header) { @@ -348,6 +354,9 @@ int spl_parse_image_header(struct spl_image_info *spl_image, } #endif + if (!spl_parse_board_header(spl_image, (const void *)header, sizeof(*header))) + return 0; + #ifdef CONFIG_SPL_RAW_IMAGE_SUPPORT /* Signature not found - assume u-boot.bin */ debug("mkimage signature not found - ih_magic = %x\n", From patchwork Fri Jul 23 09:14:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509063 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=mi35K5JI; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNyk3LPzz9sRN for ; Fri, 23 Jul 2021 19:18:06 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DD81882DE7; Fri, 23 Jul 2021 11:16:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="mi35K5JI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 141E482E8E; Fri, 23 Jul 2021 11:16:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 86DAF82DCF for ; Fri, 23 Jul 2021 11:15:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 091721408AE; Fri, 23 Jul 2021 11:15:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031721; bh=WqIqSQ+v7aOgsc0xrXGgg+5Y9NKDrkRMl/sbFUXBXhA=; h=From:To:Date; b=mi35K5JIfVM2sHPZhGvEjElj+f4LdzCzFG0kquU4Sa68LsbA6zMCH+tHp6IcG07ZY YVmkn2jF976xJ0PoNNXcINUMX7wlFLCJqPWvO78T0Yp/dqiD5oQTCW4TahiscGu3cw hiX8WPT1LsBPy5SDnCkfPordw0gEI4TRR9kCjoX4= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 35/41] arm: mvebu: Load U-Boot proper binary in SPL code based on kwbimage header Date: Fri, 23 Jul 2021 11:14:29 +0200 Message-Id: <20210723091435.20388-36-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Now that proper load and execution addresses are set in v1 kwbimage we can use it for loading and booting U-Boot proper. Use the new spl_parse_board_header() function to implement parsing the kwbimage v1 header. Use information from this header to locate offset and size of the U-Boot proper binary, instead of using the legacy U-Boot header which is prepended to the U-Boot proper binary stored at fixed offset. This has the advantage that we do not need to relay on legacy U-Boot header anymore and therefore U-Boot proper binary can be stored at any offset, as is the case when loading & booting U-Boot proper by BootROM. The CONFIG_SYS_U_BOOT_OFFS option is therefore not used by SPL code anymore. Also allow to compile U-Boot SPL without CONFIG_SPL_SPI_FLASH_SUPPORT, CONFIG_SPL_MMC_SUPPORT or CONFIG_SPL_SATA_SUPPORT set. In this case BootROM is used for loading and executing U-Boot proper. This reduces the size of U-Boot's SPL image. By default these config options are enabled and so BootROM loading is not used. In some cases BootROM reads from SPI NOR at lower speed than U-Boot SPL. So people can decide whether they want to have smaller SPL binary at the cost of slower boot. Therefore dependency on CONFIG_SPL_DM_SPI, CONFIG_SPL_SPI_FLASH_SUPPORT, CONFIG_SPL_SPI_LOAD, CONFIG_SPL_SPI_SUPPORT, CONFIG_SPL_DM_GPIO, CONFIG_SPL_DM_MMC, CONFIG_SPL_GPIO_SUPPORT, CONFIG_SPL_LIBDISK_SUPPORT, CONFIG_SPL_MMC_SUPPORT, CONFIG_SPL_SATA_SUPPORT and CONFIG_SPL_LIBDISK_SUPPORT is changed from strict to related "imply" (which can be selectivelly turned off and causes booting via BootROM). Options CONFIG_SYS_SPI_U_BOOT_OFFS, CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR and CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET have to to be set to zero as they define the location where kwbimage header starts. It is the location where BootROM expects start of the kwbimage from which it reads, parses and executes SPL part. The same applies to option CONFIG_SPL_SATA_RAW_U_BOOT_SECTOR, which has to be set to one. Update all config files to set correct values of these options and set CONFIG_SYS_U_BOOT_OFFS to the correct value - the offset where U-Boot proper starts. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- arch/arm/mach-mvebu/Kconfig | 22 +-- arch/arm/mach-mvebu/spl.c | 205 ++++++++++++++++++++++++++-- board/kobol/helios4/Kconfig | 5 - board/solidrun/clearfog/Kconfig | 5 - common/spl/Kconfig | 4 +- configs/clearfog_defconfig | 1 - configs/controlcenterdc_defconfig | 1 - configs/db-88f6720_defconfig | 1 - configs/db-88f6820-amc_defconfig | 1 - configs/db-88f6820-gp_defconfig | 2 - configs/db-mv784mp-gp_defconfig | 1 - configs/ds414_defconfig | 1 - configs/helios4_defconfig | 1 - configs/maxbcm_defconfig | 1 - configs/theadorable_debug_defconfig | 1 - configs/turris_omnia_defconfig | 1 - configs/x530_defconfig | 1 - include/configs/clearfog.h | 5 +- include/configs/controlcenterdc.h | 7 +- include/configs/db-88f6720.h | 2 +- include/configs/db-88f6820-amc.h | 2 +- include/configs/db-88f6820-gp.h | 5 +- include/configs/db-mv784mp-gp.h | 2 +- include/configs/ds414.h | 2 +- include/configs/helios4.h | 5 +- include/configs/theadorable.h | 2 +- include/configs/turris_omnia.h | 5 +- include/configs/x530.h | 2 +- 28 files changed, 224 insertions(+), 69 deletions(-) diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig index 2133d9a172..140c4199a2 100644 --- a/arch/arm/mach-mvebu/Kconfig +++ b/arch/arm/mach-mvebu/Kconfig @@ -253,27 +253,27 @@ choice config MVEBU_SPL_BOOT_DEVICE_SPI bool "SPI NOR flash" imply ENV_IS_IN_SPI_FLASH - select SPL_DM_SPI - select SPL_SPI_FLASH_SUPPORT - select SPL_SPI_LOAD - select SPL_SPI_SUPPORT + imply SPL_DM_SPI + imply SPL_SPI_FLASH_SUPPORT + imply SPL_SPI_LOAD + imply SPL_SPI_SUPPORT select SPL_BOOTROM_SUPPORT config MVEBU_SPL_BOOT_DEVICE_MMC bool "SDIO/MMC card" imply ENV_IS_IN_MMC # GPIO needed for eMMC/SD card presence detection - select SPL_DM_GPIO - select SPL_DM_MMC - select SPL_GPIO_SUPPORT - select SPL_LIBDISK_SUPPORT - select SPL_MMC_SUPPORT + imply SPL_DM_GPIO + imply SPL_DM_MMC + imply SPL_GPIO_SUPPORT + imply SPL_LIBDISK_SUPPORT + imply SPL_MMC_SUPPORT select SPL_BOOTROM_SUPPORT config MVEBU_SPL_BOOT_DEVICE_SATA bool "SATA" - select SPL_SATA_SUPPORT - select SPL_LIBDISK_SUPPORT + imply SPL_SATA_SUPPORT + imply SPL_LIBDISK_SUPPORT select SPL_BOOTROM_SUPPORT config MVEBU_SPL_BOOT_DEVICE_UART diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c index 5c3d959bff..3b6bc38970 100644 --- a/arch/arm/mach-mvebu/spl.c +++ b/arch/arm/mach-mvebu/spl.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -16,6 +17,160 @@ #include #include +#if defined(CONFIG_SPL_SPI_FLASH_SUPPORT) || defined(CONFIG_SPL_MMC_SUPPORT) || defined(CONFIG_SPL_SATA_SUPPORT) + +/* + * When loading U-Boot via SPL from SPI NOR, CONFIG_SYS_SPI_U_BOOT_OFFS must + * point to the offset of kwbimage main header which is always at offset zero + * (defined by BootROM). Therefore other values of CONFIG_SYS_SPI_U_BOOT_OFFS + * makes U-Boot non-bootable. + */ +#ifdef CONFIG_SPL_SPI_FLASH_SUPPORT +#if defined(CONFIG_SYS_SPI_U_BOOT_OFFS) && CONFIG_SYS_SPI_U_BOOT_OFFS != 0 +#error CONFIG_SYS_SPI_U_BOOT_OFFS must be set to 0 +#endif +#endif + +/* + * When loading U-Boot via SPL from eMMC (in Marvell terminology SDIO), the + * kwbimage main header is stored at sector 0. U-Boot SPL needs to parse this + * header and figure out at which sector the U-Boot proper binary is stored. + * Partition booting is therefore not supported and CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR + * and CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET need to point to the + * kwbimage main header. + */ +#ifdef CONFIG_SPL_MMC_SUPPORT +#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION +#error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION is unsupported +#endif +#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR) && CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR != 0 +#error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR must be set to 0 +#endif +#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET) && CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 0 +#error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET must be set to 0 +#endif +#endif + +/* + * When loading U-Boot via SPL from SATA disk, the kwbimage main header is + * stored at sector 1. Therefore CONFIG_SPL_SATA_RAW_U_BOOT_SECTOR must be + * set to 1. Otherwise U-Boot SPL would not be able to load U-Boot proper. + */ +#ifdef CONFIG_SPL_SATA_SUPPORT +#if !defined(CONFIG_SPL_SATA_RAW_U_BOOT_USE_SECTOR) || !defined(CONFIG_SPL_SATA_RAW_U_BOOT_SECTOR) || CONFIG_SPL_SATA_RAW_U_BOOT_SECTOR != 1 +#error CONFIG_SPL_SATA_RAW_U_BOOT_SECTOR must be set to 1 +#endif +#endif + +/* Boot Type - block ID */ +#define IBR_HDR_I2C_ID 0x4D +#define IBR_HDR_SPI_ID 0x5A +#define IBR_HDR_NAND_ID 0x8B +#define IBR_HDR_SATA_ID 0x78 +#define IBR_HDR_PEX_ID 0x9C +#define IBR_HDR_UART_ID 0x69 +#define IBR_HDR_SDIO_ID 0xAE + +/* Structure of the main header, version 1 (Armada 370/38x/XP) */ +struct kwbimage_main_hdr_v1 { + uint8_t blockid; /* 0x0 */ + uint8_t flags; /* 0x1 */ + uint16_t reserved2; /* 0x2-0x3 */ + uint32_t blocksize; /* 0x4-0x7 */ + uint8_t version; /* 0x8 */ + uint8_t headersz_msb; /* 0x9 */ + uint16_t headersz_lsb; /* 0xA-0xB */ + uint32_t srcaddr; /* 0xC-0xF */ + uint32_t destaddr; /* 0x10-0x13 */ + uint32_t execaddr; /* 0x14-0x17 */ + uint8_t options; /* 0x18 */ + uint8_t nandblocksize; /* 0x19 */ + uint8_t nandbadblklocation; /* 0x1A */ + uint8_t reserved4; /* 0x1B */ + uint16_t reserved5; /* 0x1C-0x1D */ + uint8_t ext; /* 0x1E */ + uint8_t checksum; /* 0x1F */ +} __packed; + +#ifdef CONFIG_SPL_MMC_SUPPORT +u32 spl_mmc_boot_mode(const u32 boot_device) +{ + return MMCSD_MODE_RAW; +} +#endif + +int spl_parse_board_header(struct spl_image_info *spl_image, + const void *image_header, size_t size) +{ + const struct kwbimage_main_hdr_v1 *mhdr = image_header; + + if (size < sizeof(*mhdr)) { + /* This should be compile time assert */ + printf("FATAL ERROR: Image header size is too small\n"); + hang(); + } + + /* + * Very basic check for image validity. We cannot check mhdr->checksum + * as it is calculated also from variable length extended headers + * (including SPL content) which is not included in U-Boot image_header. + */ + if (mhdr->version != 1 || + ((mhdr->headersz_msb << 16) | mhdr->headersz_lsb) < sizeof(*mhdr) || + ( +#ifdef CONFIG_SPL_SPI_FLASH_SUPPORT + mhdr->blockid != IBR_HDR_SPI_ID && +#endif +#ifdef CONFIG_SPL_SATA_SUPPORT + mhdr->blockid != IBR_HDR_SATA_ID && +#endif +#ifdef CONFIG_SPL_MMC_SUPPORT + mhdr->blockid != IBR_HDR_SDIO_ID && +#endif + 1 + )) { + printf("ERROR: Not valid SPI/NAND/SATA/SDIO kwbimage v1\n"); + return -EINVAL; + } + + spl_image->offset = mhdr->srcaddr; + +#ifdef CONFIG_SPL_SATA_SUPPORT + /* + * For SATA srcaddr is specified in number of sectors. + * The main header is must be stored at sector number 1. + * This expects that sector size is 512 bytes and recalculates + * data offset to bytes relative to the main header. + */ + if (mhdr->blockid == IBR_HDR_SATA_ID) { + if (spl_image->offset < 1) { + printf("ERROR: Wrong SATA srcaddr in kwbimage\n"); + return -EINVAL; + } + spl_image->offset -= 1; + spl_image->offset *= 512; + } +#endif + +#ifdef CONFIG_SPL_MMC_SUPPORT + /* + * For SDIO (eMMC) srcaddr is specified in number of sectors. + * This expects that sector size is 512 bytes and recalculates + * data offset to bytes. + */ + if (mhdr->blockid == IBR_HDR_SDIO_ID) + spl_image->offset *= 512; +#endif + + spl_image->size = mhdr->blocksize; + spl_image->entry_point = mhdr->execaddr; + spl_image->load_addr = mhdr->destaddr; + spl_image->os = IH_OS_U_BOOT; + spl_image->name = "U-Boot"; + + return 0; +} + static u32 get_boot_device(void) { u32 val; @@ -49,11 +204,11 @@ static u32 get_boot_device(void) boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS; debug("SAR_REG=0x%08x boot_device=0x%x\n", val, boot_device); switch (boot_device) { -#if defined(CONFIG_ARMADA_38X) +#ifdef BOOT_FROM_NAND case BOOT_FROM_NAND: return BOOT_DEVICE_NAND; #endif -#ifdef CONFIG_SPL_MMC_SUPPORT +#ifdef BOOT_FROM_MMC case BOOT_FROM_MMC: case BOOT_FROM_MMC_ALT: return BOOT_DEVICE_MMC1; @@ -69,15 +224,26 @@ static u32 get_boot_device(void) return BOOT_DEVICE_SATA; #endif case BOOT_FROM_SPI: - default: return BOOT_DEVICE_SPI; + default: + return BOOT_DEVICE_BOOTROM; }; } +#else + +static u32 get_boot_device(void) +{ + return BOOT_DEVICE_BOOTROM; +} + +#endif + u32 spl_boot_device(void) { u32 boot_device = get_boot_device(); + switch (boot_device) { /* * Return to the BootROM to continue the Marvell xmodem * UART boot protocol. As initiated by the kwboot tool. @@ -87,18 +253,35 @@ u32 spl_boot_device(void) * SPL has no chance to receive this information. So we * need to return to the BootROM to enable this xmodem * UART download. Use SPL infrastructure to return to BootROM. - * - * If booting from NAND lets let the BootROM load the - * rest of the bootloader. */ - switch (boot_device) { case BOOT_DEVICE_UART: -#if defined(CONFIG_ARMADA_38X) - case BOOT_DEVICE_NAND: -#endif return BOOT_DEVICE_BOOTROM; + + /* + * If SPL is compiled with chosen boot_device support + * then use SPL driver for loading U-Boot proper. + */ +#ifdef CONFIG_SPL_MMC_SUPPORT + case BOOT_DEVICE_MMC1: + return BOOT_DEVICE_MMC1; +#endif +#ifdef CONFIG_SPL_SATA_SUPPORT + case BOOT_FROM_SATA: + return BOOT_FROM_SATA; +#endif +#ifdef CONFIG_SPL_SPI_FLASH_SUPPORT + case BOOT_DEVICE_SPI: + return BOOT_DEVICE_SPI; +#endif + + /* + * If SPL is not compiled with chosen boot_device support + * then return to the BootROM. BootROM supports loading + * U-Boot proper from any valid boot_device present in SAR + * register. + */ default: - return boot_device; + return BOOT_DEVICE_BOOTROM; } } diff --git a/board/kobol/helios4/Kconfig b/board/kobol/helios4/Kconfig index cad51c1cf0..81a2199ae5 100644 --- a/board/kobol/helios4/Kconfig +++ b/board/kobol/helios4/Kconfig @@ -16,9 +16,4 @@ config ENV_SECT_SIZE # Use optimistic 64 KiB erase block, will vary between actual media default 0x10000 if MVEBU_SPL_BOOT_DEVICE_MMC || MVEBU_SPL_BOOT_DEVICE_UART -config SYS_SPI_U_BOOT_OFFS - hex "address of u-boot payload in SPI flash" - default 0x20000 - depends on MVEBU_SPL_BOOT_DEVICE_SPI - endmenu diff --git a/board/solidrun/clearfog/Kconfig b/board/solidrun/clearfog/Kconfig index cf95258090..60d3921307 100644 --- a/board/solidrun/clearfog/Kconfig +++ b/board/solidrun/clearfog/Kconfig @@ -54,9 +54,4 @@ config ENV_SECT_SIZE # Use optimistic 64 KiB erase block, will vary between actual media default 0x10000 if MVEBU_SPL_BOOT_DEVICE_MMC || MVEBU_SPL_BOOT_DEVICE_UART -config SYS_SPI_U_BOOT_OFFS - hex "address of u-boot payload in SPI flash" - default 0x20000 - depends on MVEBU_SPL_BOOT_DEVICE_SPI - endmenu diff --git a/common/spl/Kconfig b/common/spl/Kconfig index c0183521d2..cf8e898224 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -344,7 +344,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR default 0x75 if ARCH_DAVINCI default 0x8a if ARCH_MX6 || ARCH_MX7 default 0x100 if ARCH_UNIPHIER - default 0x140 if ARCH_MVEBU + default 0x0 if ARCH_MVEBU default 0x200 if ARCH_SOCFPGA || ARCH_AT91 default 0x300 if ARCH_ZYNQ || ARCH_KEYSTONE || OMAP34XX || OMAP44XX || \ OMAP54XX || AM33XX || AM43XX || ARCH_K3 @@ -1099,6 +1099,7 @@ config SPL_SATA_SUPPORT config SPL_SATA_RAW_U_BOOT_USE_SECTOR bool "SATA raw mode: by sector" depends on SPL_SATA_SUPPORT + default y if ARCH_MVEBU help Use sector number for specifying U-Boot location on SATA disk in raw mode. @@ -1106,6 +1107,7 @@ config SPL_SATA_RAW_U_BOOT_USE_SECTOR config SPL_SATA_RAW_U_BOOT_SECTOR hex "Sector on the SATA disk to load U-Boot from" depends on SPL_SATA_RAW_U_BOOT_USE_SECTOR + default 0x1 if ARCH_MVEBU help Sector on the SATA disk to load U-Boot from, when the SATA disk is being used in raw mode. Units: SATA disk sectors (1 sector = 512 bytes). diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig index 4702cf2df1..4ece79fe7e 100644 --- a/configs/clearfog_defconfig +++ b/configs/clearfog_defconfig @@ -24,7 +24,6 @@ CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET=0x1 CONFIG_SPL_I2C_SUPPORT=y CONFIG_CMD_TLV_EEPROM=y CONFIG_SPL_CMD_TLV_EEPROM=y diff --git a/configs/controlcenterdc_defconfig b/configs/controlcenterdc_defconfig index a8d961a7c5..eccc1d7dfc 100644 --- a/configs/controlcenterdc_defconfig +++ b/configs/controlcenterdc_defconfig @@ -9,7 +9,6 @@ CONFIG_TARGET_CONTROLCENTERDC=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x100000 CONFIG_ENV_SECT_SIZE=0x40000 -CONFIG_SYS_SPI_U_BOOT_OFFS=0x30000 CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="armada-38x-controlcenterdc" CONFIG_SPL_TEXT_BASE=0x40000030 diff --git a/configs/db-88f6720_defconfig b/configs/db-88f6720_defconfig index bb73635d92..479a110252 100644 --- a/configs/db-88f6720_defconfig +++ b/configs/db-88f6720_defconfig @@ -10,7 +10,6 @@ CONFIG_TARGET_DB_88F6720=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x100000 CONFIG_ENV_SECT_SIZE=0x10000 -CONFIG_SYS_SPI_U_BOOT_OFFS=0x20000 CONFIG_DEFAULT_DEVICE_TREE="armada-375-db" CONFIG_SPL_TEXT_BASE=0x40004030 CONFIG_SPL_SERIAL_SUPPORT=y diff --git a/configs/db-88f6820-amc_defconfig b/configs/db-88f6820-amc_defconfig index a7c8498599..7cc838a148 100644 --- a/configs/db-88f6820-amc_defconfig +++ b/configs/db-88f6820-amc_defconfig @@ -10,7 +10,6 @@ CONFIG_TARGET_DB_88F6820_AMC=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x100000 CONFIG_ENV_SECT_SIZE=0x40000 -CONFIG_SYS_SPI_U_BOOT_OFFS=0x24000 CONFIG_DEFAULT_DEVICE_TREE="armada-385-db-88f6820-amc" CONFIG_SPL_TEXT_BASE=0x40000030 CONFIG_SPL_SERIAL_SUPPORT=y diff --git a/configs/db-88f6820-gp_defconfig b/configs/db-88f6820-gp_defconfig index 6fa00d1a17..cdc6cabaf6 100644 --- a/configs/db-88f6820-gp_defconfig +++ b/configs/db-88f6820-gp_defconfig @@ -10,7 +10,6 @@ CONFIG_TARGET_DB_88F6820_GP=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x100000 CONFIG_ENV_SECT_SIZE=0x40000 -CONFIG_SYS_SPI_U_BOOT_OFFS=0x24000 CONFIG_DEFAULT_DEVICE_TREE="armada-388-gp" CONFIG_SPL_TEXT_BASE=0x40000030 CONFIG_SPL_SERIAL_SUPPORT=y @@ -24,7 +23,6 @@ CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y diff --git a/configs/db-mv784mp-gp_defconfig b/configs/db-mv784mp-gp_defconfig index e1f6aff8f5..1f5c987cfd 100644 --- a/configs/db-mv784mp-gp_defconfig +++ b/configs/db-mv784mp-gp_defconfig @@ -10,7 +10,6 @@ CONFIG_TARGET_DB_MV784MP_GP=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x100000 CONFIG_ENV_SECT_SIZE=0x10000 -CONFIG_SYS_SPI_U_BOOT_OFFS=0x20000 CONFIG_DEFAULT_DEVICE_TREE="armada-xp-gp" CONFIG_SPL_TEXT_BASE=0x40004030 CONFIG_SPL_SERIAL_SUPPORT=y diff --git a/configs/ds414_defconfig b/configs/ds414_defconfig index b8a0bd09d4..cf0d937295 100644 --- a/configs/ds414_defconfig +++ b/configs/ds414_defconfig @@ -10,7 +10,6 @@ CONFIG_TARGET_DS414=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x7E0000 CONFIG_ENV_SECT_SIZE=0x10000 -CONFIG_SYS_SPI_U_BOOT_OFFS=0x24000 CONFIG_DEFAULT_DEVICE_TREE="armada-xp-synology-ds414" CONFIG_SPL_TEXT_BASE=0x40004030 CONFIG_SPL_SERIAL_SUPPORT=y diff --git a/configs/helios4_defconfig b/configs/helios4_defconfig index 202e57344d..4026dd4b89 100644 --- a/configs/helios4_defconfig +++ b/configs/helios4_defconfig @@ -24,7 +24,6 @@ CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET=0x1 CONFIG_SPL_I2C_SUPPORT=y CONFIG_CMD_TLV_EEPROM=y CONFIG_SPL_CMD_TLV_EEPROM=y diff --git a/configs/maxbcm_defconfig b/configs/maxbcm_defconfig index e754108b73..4bcac91057 100644 --- a/configs/maxbcm_defconfig +++ b/configs/maxbcm_defconfig @@ -10,7 +10,6 @@ CONFIG_TARGET_MAXBCM=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x100000 CONFIG_ENV_SECT_SIZE=0x10000 -CONFIG_SYS_SPI_U_BOOT_OFFS=0x20000 CONFIG_DEFAULT_DEVICE_TREE="armada-xp-maxbcm" CONFIG_SPL_TEXT_BASE=0x40004030 CONFIG_SPL_SERIAL_SUPPORT=y diff --git a/configs/theadorable_debug_defconfig b/configs/theadorable_debug_defconfig index 6d32e6c5be..a479ac7748 100644 --- a/configs/theadorable_debug_defconfig +++ b/configs/theadorable_debug_defconfig @@ -10,7 +10,6 @@ CONFIG_TARGET_THEADORABLE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x100000 CONFIG_ENV_SECT_SIZE=0x40000 -CONFIG_SYS_SPI_U_BOOT_OFFS=0x1a000 CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="armada-xp-theadorable" CONFIG_SPL_TEXT_BASE=0x40004030 diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig index 5f7b1a67a2..9eec70e8a8 100644 --- a/configs/turris_omnia_defconfig +++ b/configs/turris_omnia_defconfig @@ -14,7 +14,6 @@ CONFIG_TARGET_TURRIS_OMNIA=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0xF0000 CONFIG_ENV_SECT_SIZE=0x10000 -CONFIG_SYS_SPI_U_BOOT_OFFS=0x24000 CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="armada-385-turris-omnia" CONFIG_SPL_TEXT_BASE=0x40000030 diff --git a/configs/x530_defconfig b/configs/x530_defconfig index dbde392374..49610eda24 100644 --- a/configs/x530_defconfig +++ b/configs/x530_defconfig @@ -10,7 +10,6 @@ CONFIG_TARGET_X530=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x100000 CONFIG_ENV_SECT_SIZE=0x40000 -CONFIG_SYS_SPI_U_BOOT_OFFS=0x24000 CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="armada-385-atl-x530" CONFIG_SPL_TEXT_BASE=0x40000030 diff --git a/include/configs/clearfog.h b/include/configs/clearfog.h index c9852a72b9..255b147945 100644 --- a/include/configs/clearfog.h +++ b/include/configs/clearfog.h @@ -71,11 +71,10 @@ #if defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI) /* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_SPI_U_BOOT_OFFS +#define CONFIG_SYS_U_BOOT_OFFS 0x20000 #elif defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC) || defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA) /* SPL related MMC defines */ -#define CONFIG_SYS_MMC_U_BOOT_OFFS (160 << 10) -#define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_MMC_U_BOOT_OFFS +#define CONFIG_SYS_U_BOOT_OFFS (160 << 10) #ifdef CONFIG_SPL_BUILD #define CONFIG_FIXED_SDHCI_ALIGNED_BUFFER 0x00180000 /* in SDRAM */ #endif diff --git a/include/configs/controlcenterdc.h b/include/configs/controlcenterdc.h index 869b94bc9b..fffc372872 100644 --- a/include/configs/controlcenterdc.h +++ b/include/configs/controlcenterdc.h @@ -87,16 +87,13 @@ #if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SPI_NOR_FLASH /* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_SPI_U_BOOT_OFFS +#define CONFIG_SYS_U_BOOT_OFFS 0x30000 #endif #if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SDIO_MMC_CARD /* SPL related MMC defines */ #define CONFIG_SPL_MMC_SUPPORT -#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION 1 -#define CONFIG_SYS_MMC_U_BOOT_OFFS (168 << 10) -#define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_MMC_U_BOOT_OFFS -#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR (CONFIG_SYS_U_BOOT_OFFS / 512) +#define CONFIG_SYS_U_BOOT_OFFS (168 << 10) #ifdef CONFIG_SPL_BUILD #define CONFIG_FIXED_SDHCI_ALIGNED_BUFFER 0x00180000 /* in SDRAM */ #endif diff --git a/include/configs/db-88f6720.h b/include/configs/db-88f6720.h index 213883ef0f..14c0190375 100644 --- a/include/configs/db-88f6720.h +++ b/include/configs/db-88f6720.h @@ -66,6 +66,6 @@ #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) /* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_SPI_U_BOOT_OFFS +#define CONFIG_SYS_U_BOOT_OFFS 0x20000 #endif /* _CONFIG_DB_88F6720_H */ diff --git a/include/configs/db-88f6820-amc.h b/include/configs/db-88f6820-amc.h index fe9a7ab563..3cd1ff899a 100644 --- a/include/configs/db-88f6820-amc.h +++ b/include/configs/db-88f6820-amc.h @@ -61,7 +61,7 @@ #if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SPI_NOR_FLASH /* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_SPI_U_BOOT_OFFS +#define CONFIG_SYS_U_BOOT_OFFS 0x24000 #endif /* diff --git a/include/configs/db-88f6820-gp.h b/include/configs/db-88f6820-gp.h index ed851bc670..5e43191e8e 100644 --- a/include/configs/db-88f6820-gp.h +++ b/include/configs/db-88f6820-gp.h @@ -73,13 +73,12 @@ #if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SPI_NOR_FLASH /* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_SPI_U_BOOT_OFFS +#define CONFIG_SYS_U_BOOT_OFFS 0x24000 #endif #if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SDIO_MMC_CARD /* SPL related MMC defines */ -#define CONFIG_SYS_MMC_U_BOOT_OFFS (160 << 10) -#define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_MMC_U_BOOT_OFFS +#define CONFIG_SYS_U_BOOT_OFFS (160 << 10) #ifdef CONFIG_SPL_BUILD #define CONFIG_FIXED_SDHCI_ALIGNED_BUFFER 0x00180000 /* in SDRAM */ #endif diff --git a/include/configs/db-mv784mp-gp.h b/include/configs/db-mv784mp-gp.h index 3e20516e94..990fcec129 100644 --- a/include/configs/db-mv784mp-gp.h +++ b/include/configs/db-mv784mp-gp.h @@ -79,7 +79,7 @@ #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) /* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_SPI_U_BOOT_OFFS +#define CONFIG_SYS_U_BOOT_OFFS 0x20000 /* Enable DDR support in SPL (DDR3 training from Marvell bin_hdr) */ #define CONFIG_SPD_EEPROM 0x4e diff --git a/include/configs/ds414.h b/include/configs/ds414.h index c8b45066cc..b34da334e2 100644 --- a/include/configs/ds414.h +++ b/include/configs/ds414.h @@ -70,7 +70,7 @@ #if defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI) /* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_SPI_U_BOOT_OFFS +#define CONFIG_SYS_U_BOOT_OFFS 0x24000 #endif /* DS414 bus width is 32bits */ diff --git a/include/configs/helios4.h b/include/configs/helios4.h index 2cda05c85a..3875377971 100644 --- a/include/configs/helios4.h +++ b/include/configs/helios4.h @@ -71,11 +71,10 @@ #if defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI) /* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_SPI_U_BOOT_OFFS +#define CONFIG_SYS_U_BOOT_OFFS 0x20000 #elif defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC) || defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA) /* SPL related MMC defines */ -#define CONFIG_SYS_MMC_U_BOOT_OFFS (160 << 10) -#define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_MMC_U_BOOT_OFFS +#define CONFIG_SYS_U_BOOT_OFFS (160 << 10) #ifdef CONFIG_SPL_BUILD #define CONFIG_FIXED_SDHCI_ALIGNED_BUFFER 0x00180000 /* in SDRAM */ #endif diff --git a/include/configs/theadorable.h b/include/configs/theadorable.h index 587b134a1b..bfe135da6b 100644 --- a/include/configs/theadorable.h +++ b/include/configs/theadorable.h @@ -94,7 +94,7 @@ #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) /* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_SPI_U_BOOT_OFFS +#define CONFIG_SYS_U_BOOT_OFFS 0x1a000 /* Enable DDR support in SPL (DDR3 training from Marvell bin_hdr) */ #define CONFIG_DDR_FIXED_SIZE (2 << 20) /* 2GiB */ diff --git a/include/configs/turris_omnia.h b/include/configs/turris_omnia.h index 7da18f97db..49ee7a7af5 100644 --- a/include/configs/turris_omnia.h +++ b/include/configs/turris_omnia.h @@ -47,13 +47,12 @@ #ifdef CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI /* SPL related SPI defines */ -# define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_SPI_U_BOOT_OFFS +# define CONFIG_SYS_U_BOOT_OFFS 0x24000 #endif #ifdef CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC /* SPL related MMC defines */ -# define CONFIG_SYS_MMC_U_BOOT_OFFS (160 << 10) -# define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_MMC_U_BOOT_OFFS +# define CONFIG_SYS_U_BOOT_OFFS (160 << 10) # ifdef CONFIG_SPL_BUILD # define CONFIG_FIXED_SDHCI_ALIGNED_BUFFER 0x00180000 /* in SDRAM */ # endif diff --git a/include/configs/x530.h b/include/configs/x530.h index 4446510df4..25b259832a 100644 --- a/include/configs/x530.h +++ b/include/configs/x530.h @@ -98,6 +98,6 @@ #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) /* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_SPI_U_BOOT_OFFS +#define CONFIG_SYS_U_BOOT_OFFS 0x24000 #endif /* _CONFIG_X530_H */ From patchwork Fri Jul 23 09:14:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509061 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=mmpXCKOo; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNyL42Gzz9sRN for ; Fri, 23 Jul 2021 19:17:46 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D9BC582D3C; Fri, 23 Jul 2021 11:16:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="mmpXCKOo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A2A2D82E8E; Fri, 23 Jul 2021 11:15:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A8F7B82DC8 for ; Fri, 23 Jul 2021 11:15:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 4ED6A140952; Fri, 23 Jul 2021 11:15:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031722; bh=2s9uMX4EDo9ejr4MpHHYKlPlRljpyKa6+VZiSCYXsk8=; h=From:To:Date; b=mmpXCKOoB01j7pG10Q1BPCJJiEDhQaHwM3VHC1s7I/kPQ2FBN2arlXgPkpzsaLQXJ +8fZ8bA+lYsOosl/+HVoXKqu62FewuWyjZMWi6YDpruJP9vsSs8gVOhdm+XB5RlBqJ vIR019UXZXlgOEvyJI0tBaBzwrc/1p8cyS7P5zgA= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 36/41] arm: mvebu: Remove legacy U-Boot header from kwbimage v1 files Date: Fri, 23 Jul 2021 11:14:30 +0200 Message-Id: <20210723091435.20388-37-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The SPL code now already parses kwbimage v1 headers where all necessary information about how to load and execute U-Boot proper is present. The legacy 64-byte U-Boot header is not used anymore. Remove this 64-byte header by putting u-boot.bin binary (instead of u-boot.img) into kwbimage v1 and let SPL code or BootROM to load U-Boot directly at its execution address. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Chris Packham Reviewed-by: Stefan Roese --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c6de6393cb..26999fb2ab 100644 --- a/Makefile +++ b/Makefile @@ -1398,7 +1398,7 @@ MKIMAGEFLAGS_u-boot.kwb = -n $(KWD_CONFIG_FILE) \ -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) MKIMAGEFLAGS_u-boot-spl.kwb = -n $(KWD_CONFIG_FILE) \ - -T kwbimage -a $(shell printf "0x%x" $$(($(CONFIG_SYS_TEXT_BASE)-64))) -e $(CONFIG_SYS_TEXT_BASE) \ + -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) \ $(if $(KEYDIR),-k $(KEYDIR)) MKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \ @@ -1441,7 +1441,7 @@ u-boot.itb: u-boot-nodtb.bin \ $(BOARD_SIZE_CHECK) endif -u-boot-spl.kwb: u-boot.img spl/u-boot-spl.bin FORCE +u-boot-spl.kwb: u-boot.bin spl/u-boot-spl.bin FORCE $(call if_changed,mkimage) u-boot.sha1: u-boot.bin From patchwork Fri Jul 23 09:14:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509065 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=MLE0pkbu; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNz73JjMz9sV8 for ; Fri, 23 Jul 2021 19:18:27 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 14CDB82E4A; Fri, 23 Jul 2021 11:16:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="MLE0pkbu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 41FA982E8E; Fri, 23 Jul 2021 11:16:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E470182DD4 for ; Fri, 23 Jul 2021 11:15:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 88ACC1409F6; Fri, 23 Jul 2021 11:15:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031723; bh=7VRZZKCgkKH/h8Iu8RvL8MMoJXjdFIfIybPdgcfbgh8=; h=From:To:Date; b=MLE0pkbuK1MOqm24p3R7lBj00p8nnr2xc7GBFuIH71UuDdh9lr5lCouyHIybd7u94 37dJQAJs0Kcm1EAfAM4HK9yQqVbhUTxzswA3o47XQyDvfDdgu/wFY2OdaOs19Uub6g wRFxiSZaJaalufkRtmA6v6OBWM40Xdo8E/w4Mhow= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 37/41] tools: kwbimage: Remove v1 kwbimage SPL padding to CONFIG_SYS_U_BOOT_OFFS bytes Date: Fri, 23 Jul 2021 11:14:31 +0200 Message-Id: <20210723091435.20388-38-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár This padding depends on board config file and therefore it makes the mkimage binary tool board specific, which is not correct. One cannot use mkimage tool built as a result for board A to generate images for board B, even if both A and B are on the same platform. This CONFIG_SYS_U_BOOT_OFFS padding was needed when kwbimage v1 contained SPL code which loaded U-Boot proper based on CONFIG_SYS_U_BOOT_OFFS, instead of reading correct offset from kwbimage header. Now that SPL code parses kwbimage header and deterinate correct offset, there is no need for this CONFIG_SYS_U_BOOT_OFFS padding anymore. By removing it we also reduce the size of SPL code and therefore also decrease the final size of v1 kwbimage. This means there is more space for U-Boot proper binary. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Chris Packham Reviewed-by: Stefan Roese --- tools/Makefile | 4 ---- tools/kwbimage.c | 13 ------------- 2 files changed, 17 deletions(-) diff --git a/tools/Makefile b/tools/Makefile index 35aefc207c..4a86321f64 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -169,10 +169,6 @@ HOST_EXTRACFLAGS += -DCONFIG_FIT_SIGNATURE_MAX_SIZE=0xffffffff HOST_EXTRACFLAGS += -DCONFIG_FIT_CIPHER endif -ifneq ($(CONFIG_SYS_U_BOOT_OFFS),) -HOSTCFLAGS_kwbimage.o += -DCONFIG_SYS_U_BOOT_OFFS=$(CONFIG_SYS_U_BOOT_OFFS) -endif - # MXSImage needs LibSSL ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_ARMADA_38X)$(CONFIG_TOOLS_LIBCRYPTO),) HOSTCFLAGS_kwbimage.o += \ diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 9ecda861e4..ccb0b92266 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -979,19 +979,6 @@ static size_t image_headersz_v1(int *hasext) *hasext = 1; } -#if defined(CONFIG_SYS_U_BOOT_OFFS) - if (headersz > CONFIG_SYS_U_BOOT_OFFS) { - fprintf(stderr, - "Error: Image header (incl. SPL image) too big!\n"); - fprintf(stderr, "header=0x%x CONFIG_SYS_U_BOOT_OFFS=0x%x!\n", - (int)headersz, CONFIG_SYS_U_BOOT_OFFS); - fprintf(stderr, "Increase CONFIG_SYS_U_BOOT_OFFS!\n"); - return 0; - } - - headersz = CONFIG_SYS_U_BOOT_OFFS; -#endif - /* * The payload should be aligned on some reasonable * boundary From patchwork Fri Jul 23 09:14:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509067 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=uAqr2xET; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNzX18Gjz9sRN for ; Fri, 23 Jul 2021 19:18:48 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 895E782E6A; Fri, 23 Jul 2021 11:16:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="uAqr2xET"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 596CE82DDE; Fri, 23 Jul 2021 11:16:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2CC8682DC1 for ; Fri, 23 Jul 2021 11:15:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id C57EE1408AE; Fri, 23 Jul 2021 11:15:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031724; bh=biKV81vQDJJChb9GA0PSy3r5oiF4XWSYpiu+uW57H+I=; h=From:To:Date; b=uAqr2xETfQwOJnHSCxUyHNIdUo4DCSqqkVJforvjIkQGHex5HfbNwlzlnjk/thUGB d2g8bHobR8BEm1lkYUm3VTEJqLuG7JeDoQFJEeRLRjA8/xf6ne4IRjqzpM9LN8EQyh Mdy6R/gHzaZH29JOZ9bvKDCUvtxFqQC/3Llvlmtk= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 38/41] arm: mvebu: Remove unused macro CONFIG_SYS_U_BOOT_OFFS Date: Fri, 23 Jul 2021 11:14:32 +0200 Message-Id: <20210723091435.20388-39-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Macro CONFIG_SYS_U_BOOT_OFFS is set but not used anymore. Remove it. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Chris Packham Reviewed-by: Stefan Roese --- include/configs/clearfog.h | 6 +----- include/configs/controlcenterdc.h | 6 ------ include/configs/db-88f6720.h | 3 --- include/configs/db-88f6820-amc.h | 5 ----- include/configs/db-88f6820-gp.h | 6 ------ include/configs/db-mv784mp-gp.h | 3 --- include/configs/ds414.h | 5 ----- include/configs/helios4.h | 6 +----- include/configs/theadorable.h | 3 --- include/configs/turris_omnia.h | 6 ------ include/configs/x530.h | 3 --- scripts/config_whitelist.txt | 1 - 12 files changed, 2 insertions(+), 51 deletions(-) diff --git a/include/configs/clearfog.h b/include/configs/clearfog.h index 255b147945..fbdd2f0a24 100644 --- a/include/configs/clearfog.h +++ b/include/configs/clearfog.h @@ -69,12 +69,8 @@ #define CONFIG_SPL_STACK (0x40000000 + ((192 - 16) << 10)) #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) -#if defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI) -/* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS 0x20000 -#elif defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC) || defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA) +#if defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC) || defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA) /* SPL related MMC defines */ -#define CONFIG_SYS_U_BOOT_OFFS (160 << 10) #ifdef CONFIG_SPL_BUILD #define CONFIG_FIXED_SDHCI_ALIGNED_BUFFER 0x00180000 /* in SDRAM */ #endif diff --git a/include/configs/controlcenterdc.h b/include/configs/controlcenterdc.h index fffc372872..e81d05aa2e 100644 --- a/include/configs/controlcenterdc.h +++ b/include/configs/controlcenterdc.h @@ -85,15 +85,9 @@ #define CONFIG_SPL_LIBGENERIC_SUPPORT #define CONFIG_SPL_I2C_SUPPORT -#if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SPI_NOR_FLASH -/* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS 0x30000 -#endif - #if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SDIO_MMC_CARD /* SPL related MMC defines */ #define CONFIG_SPL_MMC_SUPPORT -#define CONFIG_SYS_U_BOOT_OFFS (168 << 10) #ifdef CONFIG_SPL_BUILD #define CONFIG_FIXED_SDHCI_ALIGNED_BUFFER 0x00180000 /* in SDRAM */ #endif diff --git a/include/configs/db-88f6720.h b/include/configs/db-88f6720.h index 14c0190375..cbb9270f93 100644 --- a/include/configs/db-88f6720.h +++ b/include/configs/db-88f6720.h @@ -65,7 +65,4 @@ #define CONFIG_SPL_STACK (0x40000000 + ((192 - 16) << 10)) #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) -/* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS 0x20000 - #endif /* _CONFIG_DB_88F6720_H */ diff --git a/include/configs/db-88f6820-amc.h b/include/configs/db-88f6820-amc.h index 3cd1ff899a..757fbc0b9b 100644 --- a/include/configs/db-88f6820-amc.h +++ b/include/configs/db-88f6820-amc.h @@ -59,11 +59,6 @@ #define CONFIG_SPL_STACK (0x40000000 + ((192 - 16) << 10)) #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) -#if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SPI_NOR_FLASH -/* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS 0x24000 -#endif - /* * mv-common.h should be defined after CMD configs since it used them * to enable certain macros diff --git a/include/configs/db-88f6820-gp.h b/include/configs/db-88f6820-gp.h index 5e43191e8e..d50eb2c120 100644 --- a/include/configs/db-88f6820-gp.h +++ b/include/configs/db-88f6820-gp.h @@ -71,14 +71,8 @@ #define CONFIG_SPL_STACK (0x40000000 + ((192 - 16) << 10)) #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) -#if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SPI_NOR_FLASH -/* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS 0x24000 -#endif - #if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SDIO_MMC_CARD /* SPL related MMC defines */ -#define CONFIG_SYS_U_BOOT_OFFS (160 << 10) #ifdef CONFIG_SPL_BUILD #define CONFIG_FIXED_SDHCI_ALIGNED_BUFFER 0x00180000 /* in SDRAM */ #endif diff --git a/include/configs/db-mv784mp-gp.h b/include/configs/db-mv784mp-gp.h index 990fcec129..ef7eebd081 100644 --- a/include/configs/db-mv784mp-gp.h +++ b/include/configs/db-mv784mp-gp.h @@ -78,9 +78,6 @@ #define CONFIG_SPL_STACK (0x40000000 + ((192 - 16) << 10)) #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) -/* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS 0x20000 - /* Enable DDR support in SPL (DDR3 training from Marvell bin_hdr) */ #define CONFIG_SPD_EEPROM 0x4e #define CONFIG_BOARD_ECC_SUPPORT /* this board supports ECC */ diff --git a/include/configs/ds414.h b/include/configs/ds414.h index b34da334e2..4bbb244fa2 100644 --- a/include/configs/ds414.h +++ b/include/configs/ds414.h @@ -68,11 +68,6 @@ #define CONFIG_SPL_STACK (0x40000000 + ((192 - 16) << 10)) #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) -#if defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI) -/* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS 0x24000 -#endif - /* DS414 bus width is 32bits */ #define CONFIG_DDR_32BIT diff --git a/include/configs/helios4.h b/include/configs/helios4.h index 3875377971..1368080f03 100644 --- a/include/configs/helios4.h +++ b/include/configs/helios4.h @@ -69,12 +69,8 @@ #define CONFIG_SPL_STACK (0x40000000 + ((192 - 16) << 10)) #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) -#if defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI) -/* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS 0x20000 -#elif defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC) || defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA) +#if defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC) || defined(CONFIG_MVEBU_SPL_BOOT_DEVICE_SATA) /* SPL related MMC defines */ -#define CONFIG_SYS_U_BOOT_OFFS (160 << 10) #ifdef CONFIG_SPL_BUILD #define CONFIG_FIXED_SDHCI_ALIGNED_BUFFER 0x00180000 /* in SDRAM */ #endif diff --git a/include/configs/theadorable.h b/include/configs/theadorable.h index bfe135da6b..31852fb248 100644 --- a/include/configs/theadorable.h +++ b/include/configs/theadorable.h @@ -93,9 +93,6 @@ #define CONFIG_SPL_STACK (0x40000000 + ((192 - 16) << 10)) #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) -/* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS 0x1a000 - /* Enable DDR support in SPL (DDR3 training from Marvell bin_hdr) */ #define CONFIG_DDR_FIXED_SIZE (2 << 20) /* 2GiB */ diff --git a/include/configs/turris_omnia.h b/include/configs/turris_omnia.h index 49ee7a7af5..0a824b7939 100644 --- a/include/configs/turris_omnia.h +++ b/include/configs/turris_omnia.h @@ -45,14 +45,8 @@ #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) #define CONFIG_SPL_DRIVERS_MISC_SUPPORT -#ifdef CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI -/* SPL related SPI defines */ -# define CONFIG_SYS_U_BOOT_OFFS 0x24000 -#endif - #ifdef CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC /* SPL related MMC defines */ -# define CONFIG_SYS_U_BOOT_OFFS (160 << 10) # ifdef CONFIG_SPL_BUILD # define CONFIG_FIXED_SDHCI_ALIGNED_BUFFER 0x00180000 /* in SDRAM */ # endif diff --git a/include/configs/x530.h b/include/configs/x530.h index 25b259832a..515c6e7ff4 100644 --- a/include/configs/x530.h +++ b/include/configs/x530.h @@ -97,7 +97,4 @@ #define CONFIG_SPL_STACK (0x40000000 + ((192 - 16) << 10)) #define CONFIG_SPL_BOOTROM_SAVE (CONFIG_SPL_STACK + 4) -/* SPL related SPI defines */ -#define CONFIG_SYS_U_BOOT_OFFS 0x24000 - #endif /* _CONFIG_X530_H */ diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 042ca116e9..1f88212625 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -3301,7 +3301,6 @@ CONFIG_SYS_USE_NAND CONFIG_SYS_USE_NANDFLASH CONFIG_SYS_USE_NORFLASH CONFIG_SYS_USR_EXCEP -CONFIG_SYS_U_BOOT_OFFS CONFIG_SYS_VCXK_ACKNOWLEDGE_DDR CONFIG_SYS_VCXK_ACKNOWLEDGE_PIN CONFIG_SYS_VCXK_ACKNOWLEDGE_PORT From patchwork Fri Jul 23 09:14:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509066 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=N48W3udn; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNzK3dVDz9sRN for ; Fri, 23 Jul 2021 19:18:37 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6658182E10; Fri, 23 Jul 2021 11:16:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="N48W3udn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7CB9282D94; Fri, 23 Jul 2021 11:16:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7988882DDE for ; Fri, 23 Jul 2021 11:15:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 092C71409FA; Fri, 23 Jul 2021 11:15:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031726; bh=TMcHKVZmWw3wAsi0DANV4MK0s3qVnRTiKqsXtmjweTs=; h=From:To:Date; b=N48W3udnF6P//kmIEx0FqFvFaEVZxcHlEj0YabN2+PMzaMNVZntfme7Lqnpzm2oUK 2GF/3HU5k7+Rp1xpo4NFl2lVloKAyndpl9c+YAdM/hKR4vhepWdt1PlBvu6jvPhAF+ gNUaeTzsJVdwct4GKo9LdFada3bQJdTVUnevYkgQ= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 39/41] arm: mvebu: gdsys: Remove custom spl_board_init() Date: Fri, 23 Jul 2021 11:14:33 +0200 Message-Id: <20210723091435.20388-40-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The gdsys a38x config file (controlcenterdc_defconfig) uses BootROM to load U-Boot proper. Since it is now possible to do this via U-Boot SPL framework, we do not need to provide custom spl_board_init() which calls return_to_bootrom(). Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Chris Packham Reviewed-by: Stefan Roese --- board/gdsys/a38x/Makefile | 2 +- board/gdsys/a38x/spl.c | 20 -------------------- configs/controlcenterdc_defconfig | 1 - 3 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 board/gdsys/a38x/spl.c diff --git a/board/gdsys/a38x/Makefile b/board/gdsys/a38x/Makefile index 32fffab467..4b13859fed 100644 --- a/board/gdsys/a38x/Makefile +++ b/board/gdsys/a38x/Makefile @@ -4,7 +4,7 @@ # Copyright (C) 2015 Reinhard Pfau # Copyright (C) 2016 Mario Six -obj-$(CONFIG_TARGET_CONTROLCENTERDC) += controlcenterdc.o hre.o spl.o keyprogram.o dt_helpers.o +obj-$(CONFIG_TARGET_CONTROLCENTERDC) += controlcenterdc.o hre.o keyprogram.o dt_helpers.o ifeq ($(CONFIG_SPL_BUILD),) obj-$(CONFIG_TARGET_CONTROLCENTERDC) += hydra.o ihs_phys.o diff --git a/board/gdsys/a38x/spl.c b/board/gdsys/a38x/spl.c deleted file mode 100644 index 84864d1974..0000000000 --- a/board/gdsys/a38x/spl.c +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * (C) Copyright 2016 - * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc - */ - -#include -#include -#include - -void spl_board_init(void) -{ -#if CONFIG_SPL_BOOT_DEVICE == SPL_BOOT_SPI_NOR_FLASH - u32 *bootrom_save = (u32 *)CONFIG_SPL_BOOTROM_SAVE; - u32 *regs = (u32 *)(*bootrom_save); - - printf("Returning to BootROM (return address %08x)...\n", regs[13]); - return_to_bootrom(); -#endif -} diff --git a/configs/controlcenterdc_defconfig b/configs/controlcenterdc_defconfig index eccc1d7dfc..89cc579261 100644 --- a/configs/controlcenterdc_defconfig +++ b/configs/controlcenterdc_defconfig @@ -27,7 +27,6 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_BOARD_LATE_INIT=y CONFIG_LAST_STAGE_INIT=y -CONFIG_SPL_BOARD_INIT=y CONFIG_SPL_SYS_MALLOC_SIMPLE=y CONFIG_HUSH_PARSER=y # CONFIG_CMD_ELF is not set From patchwork Fri Jul 23 09:14:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509068 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=AHC55efK; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNzj6kC4z9sRN for ; Fri, 23 Jul 2021 19:18:57 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7C09F82EA7; Fri, 23 Jul 2021 11:16:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="AHC55efK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5D84182DC3; Fri, 23 Jul 2021 11:16:10 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9403682DE7 for ; Fri, 23 Jul 2021 11:15:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 44A8D1409F6; Fri, 23 Jul 2021 11:15:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031727; bh=13wQtlq5uIw7dNH8+6yAnGCm/EApmZxItzQb9CfPXc4=; h=From:To:Date; b=AHC55efKBEsBwSqfeM//KtYZONskoi+vbjRAe/GC3tPuv/aaTPAzzI3BlwPo4TvSY 4JyhQUcVQLISyrTuD7f3hvcninHUyCZSnoLUNNZWdDcza9L1FY41hl24A7UvfM9Gg0 yGCYVMq3b4CLkJcjwfGpv5XC+QOvcZaDMvNSv94Y= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 40/41] kwbimage: Add support for extracting images via dumpimage tool Date: Fri, 23 Jul 2021 11:14:34 +0200 Message-Id: <20210723091435.20388-41-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár The kwbimage library does not support extracting subimages. Implement it. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- tools/kwbimage.c | 72 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 64 insertions(+), 8 deletions(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index ccb0b92266..5665198db0 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1849,17 +1849,73 @@ static int kwbimage_generate(struct image_tool_params *params, return 4 + (4 - s.st_size % 4) % 4; } +static int kwbimage_extract_subimage(void *ptr, struct image_tool_params *params) +{ + struct main_hdr_v1 *mhdr = (struct main_hdr_v1 *)ptr; + size_t header_size = kwbimage_header_size(ptr); + int idx = params->pflag; + int cur_idx = 0; + uint32_t offset; + ulong image; + ulong size; + + if (image_version((void *)ptr) == 1 && (mhdr->ext & 0x1)) { + struct opt_hdr_v1 *ohdr = (struct opt_hdr_v1 *) + ((uint8_t *)ptr + + sizeof(*mhdr)); + + while (1) { + uint32_t ohdr_size = (ohdr->headersz_msb << 16) | + le16_to_cpu(ohdr->headersz_lsb); + + if (ohdr->headertype == OPT_HDR_V1_BINARY_TYPE) { + if (idx == cur_idx) { + image = (ulong)&ohdr->data[4 + + 4 * ohdr->data[0]]; + size = ohdr_size - 12 - + 4 * ohdr->data[0]; + goto extract; + } + ++cur_idx; + } + if (!(*((uint8_t *)ohdr + ohdr_size - 4) & 0x1)) + break; + ohdr = (struct opt_hdr_v1 *)((uint8_t *)ohdr + + ohdr_size); + } + } + + if (idx != cur_idx) { + printf("Image %d is not present\n", idx); + return -1; + } + + offset = le32_to_cpu(mhdr->srcaddr); + + if (mhdr->blockid == IBR_HDR_SATA_ID) { + offset -= 1; + offset *= 512; + } + + if (mhdr->blockid == IBR_HDR_SDIO_ID) + offset *= 512; + + if (mhdr->blockid == IBR_HDR_PEX_ID && offset == 0xFFFFFFFF) + offset = header_size; + + image = (ulong)((uint8_t *)ptr + offset); + size = le32_to_cpu(mhdr->blocksize) - 4; + +extract: + return imagetool_save_subimage(params->outfile, image, size); +} + /* * Report Error if xflag is set in addition to default */ static int kwbimage_check_params(struct image_tool_params *params) { - if (params->iflag) { - fprintf(stderr, "%s: kwbimage does not support extract operation\n", params->cmdname); - return CFG_INVALID; - } - - if (!params->imagename || !strlen(params->imagename)) { + if (!params->iflag && (!params->imagename || !strlen(params->imagename))) { char *msg = "Configuration file for kwbimage creation omitted"; fprintf(stderr, "Error:%s - %s\n", params->cmdname, msg); @@ -1869,7 +1925,7 @@ static int kwbimage_check_params(struct image_tool_params *params) return (params->dflag && (params->fflag || params->lflag)) || (params->fflag && (params->dflag || params->lflag)) || (params->lflag && (params->dflag || params->fflag)) || - (params->xflag) || !(strlen(params->imagename)); + (params->xflag); } /* @@ -1884,7 +1940,7 @@ U_BOOT_IMAGE_TYPE( kwbimage_verify_header, kwbimage_print_header, kwbimage_set_header, - NULL, + kwbimage_extract_subimage, kwbimage_check_image_types, NULL, kwbimage_generate From patchwork Fri Jul 23 09:14:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1509069 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=Sl1/JoQ6; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GWNzw0bHfz9sV8 for ; Fri, 23 Jul 2021 19:19:08 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B4E7682DFE; Fri, 23 Jul 2021 11:16:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="Sl1/JoQ6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E5E5482DC1; Fri, 23 Jul 2021 11:16:12 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3EE3E82DEF for ; Fri, 23 Jul 2021 11:15:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8747:7254:5571:3010]) by mail.nic.cz (Postfix) with ESMTPSA id 73A031408AE; Fri, 23 Jul 2021 11:15:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1627031729; bh=UnK+XC6rR3F+ToN+zaAk+MzLDDDvBpIcoVF7hDdA1i4=; h=From:To:Date; b=Sl1/JoQ6j59HkJ2WXsVMNtl3R/r2qzeXQHf43akwxqRleXSErCkEzjX0Q+HmCw0di 5BqseQrQGL1luNk4e7e7/idakA9+7SDWc4iHtca74tU4jPbX94/WrpqRQPlPWOgC4T 4ngKaBv6PJG610e1XDKdbBLSwL0J4J28eSg8sC4E= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de, Chris Packham , Stefan Roese , Baruch Siach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-mvebu v3 41/41] kwbimage: Update help message about how to extract from an existing image Date: Fri, 23 Jul 2021 11:14:35 +0200 Message-Id: <20210723091435.20388-42-marek.behun@nic.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210723091435.20388-1-marek.behun@nic.cz> References: <20210723091435.20388-1-marek.behun@nic.cz> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean From: Pali Rohár Extracting is now supported by dumpimage, so mention it in help instead of `kwbimage -x`. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- tools/kwbimage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 5665198db0..00cb338d64 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -961,7 +961,7 @@ static size_t image_headersz_v1(int *hasext) fprintf(stderr, "Didn't find the file '%s' in '%s' which is mandatory to generate the image\n" "This file generally contains the DDR3 training code, and should be extracted from an existing bootable\n" - "image for your board. See 'kwbimage -x' to extract it from an existing image.\n", + "image for your board. Use 'dumpimage -T kwbimage -p 0' to extract it from an existing image.\n", binarye->binary.file, dir); return 0; }