From patchwork Fri May 29 06:03:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pragnesh Patel X-Patchwork-Id: 1300387 X-Patchwork-Delegate: uboot@andestech.com 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; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=selector1 header.b=C0ZI2AvD; 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 49YDdw6BVsz9sSp for ; Fri, 29 May 2020 16:08:36 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AADEC81C80; Fri, 29 May 2020 08:06:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sifive.com 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; unprotected) header.d=sifive.com header.i=@sifive.com header.b="C0ZI2AvD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EE60A81C9C; Fri, 29 May 2020 08:05:35 +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=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2060d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::60d]) (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 EE18B812FF for ; Fri, 29 May 2020 08:05:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pragnesh.patel@sifive.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kN2Vj7nU4Ae3a/+E7F2S/PWMU7AvoWoZ87lu7wv4ahRzcrsYTIif4A/Ax+KTrwQ0qtYKoXCvBpb4iF12wcw2PsgM3IF7sycvvcTeQSM3TXdOZ6onm2sp4NxNPbmvOP0I9T+47ZcYNnvgCI4Z9u9VauupGDQYHrNQxXi4/JT77TlxjeOaZU0ubJOvYudYoD81NVI9ctCmnUj/yA8xbRnGXhjVch4ml+7iyLX9b+klTXUtzvGsk877b8pAzvHx25/Rxkef2wWn+kQSuqSEP7NdzFOe8xtpf2UJZ58PqgSG018BH3s7qvDzFw+2+kU86sfnqA7EGxYdGGae1Tk8njYj/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=poTE7KxOCUbSLBXKVVMOGaJ9hNDiIii1iCiqG+h71Qk=; b=crIwcIyZfmqHLKU5UviiPHejmacF6phZxgG5oMdjwIP6nRmly38xK9jAsmcUIS7TrV3x27JDGUVLZzPac3YsQWZpug45yBERl8XoO9z4cfSFfr6M/r/+PtBHn7ZoRD2cxhOqn2s17ozqtPrjrOlShQGTYfWNu3VHljqJgA4ckx5YcgAWPXhlFVWxuUdtKS0182TPqXjQZqTxZveh2BQSNLJVPCHVQ4wRoLbrhncjPc4ZUeqbyLcMfW3bFpc4m2PxpLgVa8btRBiKWxnz59I0uWD5UtF0esdBEwtTFtqmeBxb3gniqp5+CskvFS22ud95d069zNmiHVhdFlUe7PQSaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=sifive.com; dmarc=pass action=none header.from=sifive.com; dkim=pass header.d=sifive.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=poTE7KxOCUbSLBXKVVMOGaJ9hNDiIii1iCiqG+h71Qk=; b=C0ZI2AvDHcnuJv0HlV+4+buhITB5B3YF5SfkJD6NsxnxzyyXhfLWD1G/OT6DtDV3Kdn8UDbGA2Ir/Sbhaxs1Y68IIeyP8Vy22OLLCFzmrtBkjFUBcVZTyp7eC8pRdVNxEbngFW1RYBTnihgem+9SjQqxHQgfzIZN+br2Ndl1/lc= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=sifive.com; Received: from MN2PR13MB2797.namprd13.prod.outlook.com (2603:10b6:208:f2::30) by MN2PR13MB3135.namprd13.prod.outlook.com (2603:10b6:208:135::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.7; Fri, 29 May 2020 06:05:29 +0000 Received: from MN2PR13MB2797.namprd13.prod.outlook.com ([fe80::e50d:b981:362f:58ed]) by MN2PR13MB2797.namprd13.prod.outlook.com ([fe80::e50d:b981:362f:58ed%5]) with mapi id 15.20.3045.015; Fri, 29 May 2020 06:05:29 +0000 From: Pragnesh Patel To: u-boot@lists.denx.de Cc: atish.patra@wdc.com, palmerdabbelt@google.com, bmeng.cn@gmail.com, paul.walmsley@sifive.com, jagan@amarulasolutions.com, anup.patel@wdc.com, sagar.kadam@sifive.com, rick@andestech.com, Pragnesh Patel , Palmer Dabbelt Subject: [PATCH v13 18/19] configs: fu540: Add config options for U-Boot SPL Date: Fri, 29 May 2020 11:33:38 +0530 Message-Id: <20200529060340.26708-19-pragnesh.patel@sifive.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529060340.26708-1-pragnesh.patel@sifive.com> References: <20200529060340.26708-1-pragnesh.patel@sifive.com> X-ClientProxiedBy: LO2P265CA0079.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8::19) To MN2PR13MB2797.namprd13.prod.outlook.com (2603:10b6:208:f2::30) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sachinj2-OptiPlex-7010.open-silicon.com (114.143.65.226) by LO2P265CA0079.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.21 via Frontend Transport; Fri, 29 May 2020 06:05:26 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [114.143.65.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18fe2e98-cb74-45ae-ded2-08d8039649d9 X-MS-TrafficTypeDiagnostic: MN2PR13MB3135: X-LD-Processed: 22f88e9d-ae0d-4ed9-b984-cdc9be1529f1,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 04180B6720 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Swc+J/azcjFT/tLYQ7pbZnqG1MOl1UoaaH9J+Actga+EB7j/86clOaWo0uKvL7I1mo/XyUH62pKoyH1GZsACmavdc5ZAJ8envq+YNvWyd65LgIEDaliISjW+SyEhf/++0odYodTu2qQ1U9fONGHw6ZBbyaTyA/jZ7g1UCD2O+1REtTL2tJSOVyzIqUELaZ/lPc9qJ5diHnYoTEemTgyna03JSo+HqGuzkAn3w+gLzjdz4xjRee7uHeoFRzy4TovXr27qMsGgsTdUsmmewwoEJpQZ1itocHmJ1aYtK0+NJpcGo0cLS6nDpruQBJuEFL7laObKOROv1eQlUGObs/JHvgg5HuqKRM3HXx3ISAYxW1IPxxyLxdZFF5IHKMEGqhaBfeLDGOlRnoVr09sucZDpog== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR13MB2797.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(396003)(39850400004)(136003)(376002)(366004)(346002)(956004)(44832011)(26005)(6506007)(2906002)(52116002)(316002)(5660300002)(1006002)(6666004)(1076003)(54906003)(86362001)(36756003)(8676002)(66476007)(66556008)(2616005)(6916009)(966005)(16526019)(186003)(478600001)(8936002)(83380400001)(4326008)(66946007)(6512007)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: t14AUKux6FjLQt1dSD26tCNPHH5rM9MXUpPm8KPvTlESi/3DHJyt30073pBntcTx9Nx3ZbsMJ43w6ce2rBY92bQZweo8KG1/eMW6W2riPUGcRBZR38YuEtX+cB9gZ89GKXFsvPtV4kB4yxoaMgqCfv3ENOZ/fyLjAGPPbq2igjdRuhW2/W1gDKuWhNLxRnIT95ovJXVAW3j0r7EOpI8aO2PBEAM3T4vZlbRlow35hxdng+TRAHfvGrtNx5RDXFcD+TtfPn/+gs2HNUCOy3Xo821MLagmUkQA1XDg75ODl5yK8V4ZVLAFQv0/7QJanRugfforKw+lKRlhXGGrTLjOhwDGemtzXFIO5T6IkesWqIPxElmdHeqXQykm7XsM7pdZ2Sh3sNf50HWLUE+ZvVCgIeMe4jPhACWZHZXHGzYQyQ0wH9etuQbjVX3PpY8LcjdeLIS2dCKSk2lveCASm8HyI+WxKN49TmVnRK88Igb3D8M= X-OriginatorOrg: sifive.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18fe2e98-cb74-45ae-ded2-08d8039649d9 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2020 06:05:29.5356 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 22f88e9d-ae0d-4ed9-b984-cdc9be1529f1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MzlH4ltrcGTj12AL5D697YGtsUshoLw0QEwwFn+QlzKCvhDQc5w0A1MMgYT3v59ziw9oCClz5tFz0mSd2G5dCUm3YiUuO2EHTEnBuySfkLc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB3135 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean With sifive_fu540_defconfig: User can use FSBL or u-boot-spl.bin anyone at a time. For FSBL, fsbl->fw_payload.bin (opensbi + U-Boot) For u-boot-spl.bin, u-boot-spl.bin->FIT image (opensbi + U-Boot proper + dtb) U-Boot SPL will be loaded by ZSBL from SD card (replace fsbl.bin with u-boot-spl.bin) and runs in L2 LIM in machine mode and then load FIT image u-boot.itb from SD card into RAM. U-Boot SPL expects u-boot.itb FIT image at the starting of SD card sector number (0x822) of GUID type "2E54B353-1271-4842-806F-E436D6AF6985" Signed-off-by: Pragnesh Patel Signed-off-by: Jagan Teki Reviewed-by: Jagan Teki Reviewed-by: Bin Meng --- configs/sifive_fu540_defconfig | 8 +++ doc/board/sifive/fu540.rst | 124 +++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) diff --git a/configs/sifive_fu540_defconfig b/configs/sifive_fu540_defconfig index f805aacc7a..8d412f8d6a 100644 --- a/configs/sifive_fu540_defconfig +++ b/configs/sifive_fu540_defconfig @@ -1,6 +1,11 @@ CONFIG_RISCV=y +CONFIG_SPL_GPIO_SUPPORT=y +CONFIG_SYS_MALLOC_F_LEN=0x3000 CONFIG_ENV_SIZE=0x20000 +CONFIG_SPL_MMC_SUPPORT=y CONFIG_NR_DRAM_BANKS=1 +CONFIG_SPL=y +CONFIG_SPL_SPI_SUPPORT=y CONFIG_TARGET_SIFIVE_FU540=y CONFIG_ARCH_RV64I=y CONFIG_RISCV_SMODE=y @@ -9,7 +14,10 @@ CONFIG_FIT=y CONFIG_MISC_INIT_R=y CONFIG_DISPLAY_CPUINFO=y CONFIG_DISPLAY_BOARDINFO=y +CONFIG_SPL_SEPARATE_BSS=y +CONFIG_SPL_YMODEM_SUPPORT=y CONFIG_OF_BOARD_FIXUP=y CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00" CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_SPL_CLK=y CONFIG_DM_MTD=y diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst index 610ba87074..5a37e0021d 100644 --- a/doc/board/sifive/fu540.rst +++ b/doc/board/sifive/fu540.rst @@ -31,6 +31,9 @@ TODO: stdout-path = "/soc/serial@10010000:115200"; }; +Booting from MMC using FSBL +--------------------------- + Building -------- @@ -421,3 +424,124 @@ as well. Please press Enter to activate this console. / # + +Booting from MMC using U-Boot SPL +--------------------------------- + +Building +-------- + +Before building U-Boot SPL, OpenSBI must be built first. OpenSBI can be +cloned and built for FU540 as below: + +.. code-block:: console + + git clone https://github.com/riscv/opensbi.git + cd opensbi + make PLATFORM=generic + export OPENSBI= + +Now build the U-Boot SPL and U-Boot proper + +.. code-block:: console + + cd + make sifive_fu540_defconfig + make + +This will generate spl/u-boot-spl.bin and FIT image (u-boot.itb) + + +Flashing +-------- + +ZSBL loads the U-Boot SPL (u-boot-spl.bin) from a partition with GUID type +5B193300-FC78-40CD-8002-E86C45580B47 + +U-Boot SPL expects a U-Boot FIT image (u-boot.itb) from a partition with GUID +type 2E54B353-1271-4842-806F-E436D6AF6985 + +FIT image (u-boot.itb) is a combination of fw_dynamic.bin, u-boot-nodtb.bin and +device tree blob (hifive-unleashed-a00.dtb) + +Format the SD card (make sure the disk has GPT, otherwise use gdisk to switch) + +.. code-block:: none + + # sudo sgdisk --clear \ + > --set-alignment=2 \ + > --new=1:34:2081 --change-name=1:loader1 --typecode=1:5B193300-FC78-40CD-8002-E86C45580B47 \ + > --new=2:2082:10273 --change-name=2:loader2 --typecode=2:2E54B353-1271-4842-806F-E436D6AF6985 \ + > --new=3:10274: --change-name=3:rootfs --typecode=3:0FC63DAF-8483-4772-8E79-3D69D8477DE4 \ + > /dev/sda + +Program the SD card + +.. code-block:: none + + sudo dd if=spl/u-boot-spl.bin of=/dev/sda seek=34 + sudo dd if=u-boot.itb of=/dev/sda seek=2082 + +Booting +------- +Once you plugin the sdcard and power up, you should see the U-Boot prompt. + +Sample boot log from HiFive Unleashed board +------------------------------------------- + +.. code-block:: none + + U-Boot SPL 2020.04-rc2-00109-g63efc7e07e-dirty (Apr 30 2020 - 13:52:36 +0530) + Trying to boot from MMC1 + + + U-Boot 2020.04-rc2-00109-g63efc7e07e-dirty (Apr 30 2020 - 13:52:36 +0530) + + CPU: rv64imafdc + Model: SiFive HiFive Unleashed A00 + DRAM: 8 GiB + MMC: spi@10050000:mmc@0: 0 + In: serial@10010000 + Out: serial@10010000 + Err: serial@10010000 + Net: eth0: ethernet@10090000 + Hit any key to stop autoboot: 0 + => version + U-Boot 2020.04-rc2-00109-g63efc7e07e-dirty (Apr 30 2020 - 13:52:36 +0530) + + riscv64-unknown-linux-gnu-gcc (crosstool-NG 1.24.0.37-3f461da) 9.2.0 + GNU ld (crosstool-NG 1.24.0.37-3f461da) 2.32 + => mmc info + Device: spi@10050000:mmc@0 + Manufacturer ID: 3 + OEM: 5344 + Name: SC16G + Bus Speed: 20000000 + Mode: SD Legacy + Rd Block Len: 512 + SD version 2.0 + High Capacity: Yes + Capacity: 14.8 GiB + Bus Width: 1-bit + Erase Group Size: 512 Bytes + => mmc part + + Partition Map for MMC device 0 -- Partition Type: EFI + + Part Start LBA End LBA Name + Attributes + Type GUID + Partition GUID + 1 0x00000022 0x00000821 "loader1" + attrs: 0x0000000000000000 + type: 5b193300-fc78-40cd-8002-e86c45580b47 + guid: 66e2b5d2-74db-4df8-ad6f-694b3617f87f + 2 0x00000822 0x00002821 "loader2" + attrs: 0x0000000000000000 + type: 2e54b353-1271-4842-806f-e436d6af6985 + guid: 8befaeaf-bca0-435d-b002-e201f37c0a2f + 3 0x00002822 0x01dacbde "rootfs" + attrs: 0x0000000000000000 + type: 0fc63daf-8483-4772-8e79-3d69d8477de4 + type: linux + guid: 9faa81b6-39b1-4418-af5e-89c48f29c20d