From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27E57C433F5 for ; Mon, 8 Nov 2021 17:14:59 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9584A610A6 for ; Mon, 8 Nov 2021 17:14:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9584A610A6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0B0CD83922; Mon, 8 Nov 2021 18:13:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="FGbJD8WO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7F0818385E; Mon, 8 Nov 2021 18:13:38 +0100 (CET) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (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 7AB508390A for ; Mon, 8 Nov 2021 18:13:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kabel@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 534DA6108E; Mon, 8 Nov 2021 17:13:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636391588; bh=IOLY4bImlxwcLM34Cj7gS4uZQR+uXr9X9Ud5EYzOU8g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FGbJD8WOQ7Ze41CQe7RI/6o6NIZW7Z9hACmQ4YsVH6XbwNlsYH5LvQq5zcS+SoOzv NyoAtYALXzMhFJBe+vgB03mvL/lv6DtbqXxPOPD+onPUL1XdPt27LNSndT6pXNH1rn qHW7fOvYr9eMz0dPbyOsoK5NRHTer1gr0iShpvinbAbKCJOiRqCrHPH+NlI/8sTdO/ l6dRfHEksZ+K1wD60GqUe0y2Ve+s2COw3Cz7M566OuoyxboVN73fYVkUt77fWFQdGp ViWMlNHHnF93Dk/4u2D2QeTwvJ6OCnJ+EnGcdlMbwtwzJW6W3L/V8LMU4kcO7CIVOJ 5oAgp2uboi5Aw== From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: Stefan Roese Cc: u-boot@lists.denx.de, =?UTF-8?q?Pali=20Roh=C3=A1r?= , =?UTF-8?q?Marek=20Beh=C3=BAn?= Subject: [PATCH u-boot-marvell 11/11] tools: kwbimage: Properly set srcaddr in kwbimage v0 Date: Mon, 8 Nov 2021 18:12:51 +0100 Message-Id: <20211108171251.25382-12-kabel@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211108171251.25382-1-kabel@kernel.org> References: <20211108171251.25382-1-kabel@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Field srcaddr in kwbimage v0 needs to be adjusted similarly like in v1. Signed-off-by: Pali Rohár Signed-off-by: Marek Behún --- tools/kwbimage.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 952023c14c..875f636c7a 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -937,6 +937,28 @@ static void *image_create_v0(size_t *imagesz, struct image_tool_params *params, main_hdr->checksum = image_checksum8(image, sizeof(struct main_hdr_v0)); + /* + * 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); + /* Generate the ext header */ if (has_ext) { struct ext_hdr_v0 *ext_hdr; -- 2.32.0