From patchwork Tue May 19 19:23:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1216 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 00CE03F086 for ; Tue, 19 May 2020 21:24:47 +0200 (CEST) Received: by mail-pg1-f198.google.com with SMTP id x132sf504573pgx.22 for ; Tue, 19 May 2020 12:24:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1589916285; cv=pass; d=google.com; s=arc-20160816; b=gzkoCTN7DIhJE4G164Um1MxSRfpxE8ISNaSZGyMOmsE47h9Hp1YOdUTFDwrxnWpMXS vcC2vFsGi2p2EJdL8DlOZRN5rekl7tjZMEhLSdVCFrEghe0NfXxENTZR2eRl/+9JDcHL XiGrC/y5/nZ40Y80XwTqXO8GdSifhl7gvZSp9rYviWo02LxSrFpeYWHC/faMiNa24yuf TSG6LRtecEaViKWOe5lStoGwanlpLBB3dBBjW/76ELRLvzf8fms1F/+MrQoBTYyfi1Ja 4+JY5qRuqWAMK2iem0HpIW18DU9ya/U0HQHxfVH8l5mK/KbEpyQa00J1Kw7d5njsZvPp Vy8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=7r08axu5GCbDc9lklonFahDhNhKI/mnOKE0+GX7d1j8=; b=u7q6Et6rIrZCg7mhrmiz++lIZ2PQR9o89F1Xe0nGxMtP5yiL0+nDBVLjxaV5wYAVv9 PEFZomRVy3ogZB0hrwulpGWSv6VwAwj2CodUxIPk/8SjMCYK0SWuvj7PRUKg2XGv+GxG pvZ//An1B6L81SNAU5L32DxMmFTmg0iTXV4uA5UcB28aYwuli6VSQTWMrOgefuN35yOP 0jtN/ogusxQoz4Azy4ZFR6C1rnPVFNEjJdkMINC+/kbD49eANc/HlYLMt2Tq8mVIAdtn N+SjxVvUUYW1TDdLeA8syHHPgU0ubLEUYUHO3axLNgy5auo03wUL1/LYcBXv1j3tVPXb nAzA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HTB14d5e; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=7r08axu5GCbDc9lklonFahDhNhKI/mnOKE0+GX7d1j8=; b=Y8RyNaXOwA5bHAe4r7Ai2VNgH7kKNSqx/LMkZkI21cA98YRYdCKuMwqobdfZsoDpLL 0RJecNPzoyRidpLgOtLVY2TLoVm7o15GXSLlyBs12EHiHu4QpIWreYZKJMo2RDEMTXOY 6ZBiXcmODTjlS4NQcOwBeuuT6LQUv/X3skqPw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=7r08axu5GCbDc9lklonFahDhNhKI/mnOKE0+GX7d1j8=; b=NR/dKLqaOWf2KAo+fO93/pJ+K1DXltRAmHtQSh5qV7PRe7n3jsmkfWx1PoLZY8wNhf TchJgQ2tQ0V30CYgf4POQsFn6jzOvFOW6gmL3kjgcj93hTooZq7bJjzLZGO0ntQ1iJDQ cADRr51EkIECV9/xXAoldKNOSFc+wqo1tdB9oWyo2wGIZLFtml4t/pg+cg+aujsITx1D qVrGQqyn8J6hMDTVdkYyP/ZGqHOyxS55bE3HtvPrz5r1A94UydXXYWD5RN+8e1g/g1fY AhS4u7/7pIoclwN3RyLMEJifoggptCuO/dt/Zj69reKue+NMZZlh1Zgk0EpsZtKAAqJD daFA== X-Gm-Message-State: AOAM532/9SUmlHPoiV5kIdsPD9f642jlNGcRLzYhP1JAwlH3ipXysLYh sJ+x6Ha2CP+JWbqEriBCL+PvD2id X-Google-Smtp-Source: ABdhPJzpVhwh5C/NLnU0nPZKH4H+qcJb7rLz+PFXzpt8V20kVfv4PLHr60KB1IX/Mzn8SdWXTaCFdQ== X-Received: by 2002:a62:168d:: with SMTP id 135mr558695pfw.239.1589916285740; Tue, 19 May 2020 12:24:45 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:e116:: with SMTP id z22ls156821pgh.9.gmail; Tue, 19 May 2020 12:24:45 -0700 (PDT) X-Received: by 2002:a63:f94f:: with SMTP id q15mr707685pgk.256.1589916285204; Tue, 19 May 2020 12:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589916285; cv=none; d=google.com; s=arc-20160816; b=arUR5a7kcBaUd7B6fv1Qeq1ypc3fljy8wKtmXp+ZIVhLNKLOxliGOjmXnedcJFR2Mq Kl5Ms2+zmbw5tGSGGA+uNAHgiL3YPDbA1Xk6Xuvp3zC6AB6vPBeTWEkZz+7eOrMlj+oD XiGMPlYywo/LYl8J5ItBkJ+RXonEgSS/5Qi16zWk3NqKJX6Y9YzuwxVW77UndPo2oP6u PxtkGtQudvcf3kTun3pbPObxaB5I/STYB8zPMrbXMJBaCZ5zxCy2yd2W/iCefH4KeQEQ 0UQw2wfJr71zAfjVbjLQLhsVIe447kbQLYS3gjPcEwpKgpQy19FhPyn1YIVTlZKMvTzj l0Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=09Qf1T+fvlhBfVx1TLgBZwQYUWr10jqdqIDeq0OFCJI=; b=L5Rq0ygDd93wKsuinEjrsddGlTEuXFmXtFLmDfGdvTiALXSimCm+qeDusLojZnlql8 E7Ihuh95rorDyorbqYF2viBP5rd9OPDHAxsg2LxoIhHuZ33YD++7/YSqseGnJnw++2ez s0TE5KpXJwmGM8bA7RV4qdTFIL3kee50zlZoHVNZHWRZ3fgF3PYsJIspyX77boNA7b5m kXhXD7mETWLFHf2xdzLdxvMWWGHxFNCkHEqfh6qMH9XXAgC6E3s1BvjAgwzYYfezZEf1 Tdq0Tf9+/xLOzs1ui9qe7wY30dpjYb+BNsrvcfMTMysTC9Hl7IAeuGLa5ytwgkgoaCQe 4hpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HTB14d5e; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g19sor430040plg.16.2020.05.19.12.24.45 for (Google Transport Security); Tue, 19 May 2020 12:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:8b82:: with SMTP id ay2mr973898plb.94.1589916284793; Tue, 19 May 2020 12:24:44 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:713c:4a0a:47eb:ffcd]) by smtp.gmail.com with ESMTPSA id w192sm222553pff.126.2020.05.19.12.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 12:24:44 -0700 (PDT) From: Jagan Teki To: Rick Chen , Atish Patra , Palmer Dabbelt , Bin Meng , Paul Walmsley , Anup Patel , Sagar Kadam Cc: u-boot@lists.denx.de, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v2 5/9] sifive: fu540: Add Booting from SPI Date: Wed, 20 May 2020 00:53:36 +0530 Message-Id: <20200519192340.16624-6-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519192340.16624-1-jagan@amarulasolutions.com> References: <20200519192340.16624-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HTB14d5e; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , U-Boot SPL 2020.07-rc2-00156-gb9abb0716a-dirty (May 19 2020 - 21:56:17 +0530) Trying to boot from SPI U-Boot 2020.07-rc2-00156-gb9abb0716a-dirty (May 19 2020 - 21:56:17 +0530) CPU: rv64imafdc Model: SiFive HiFive Unleashed A00 DRAM: 8 GiB No reserved memory region found in source FDT 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 Signed-off-by: Jagan Teki --- Changes for v2: - enable board driver - comment spl-payloade-offset - reference for SPI partition arch/riscv/cpu/fu540/Kconfig | 2 + .../dts/hifive-unleashed-a00-u-boot.dtsi | 12 ++++++ board/sifive/fu540/fu540.c | 12 ------ configs/sifive_fu540_defconfig | 4 ++ doc/board/sifive/fu540.rst | 41 +++++++++++++++++++ 5 files changed, 59 insertions(+), 12 deletions(-) diff --git a/arch/riscv/cpu/fu540/Kconfig b/arch/riscv/cpu/fu540/Kconfig index e9302e87c0..7a813a9ac8 100644 --- a/arch/riscv/cpu/fu540/Kconfig +++ b/arch/riscv/cpu/fu540/Kconfig @@ -5,6 +5,8 @@ config SIFIVE_FU540 bool select ARCH_EARLY_INIT_R + imply BOARD + imply BOARD_FU540 imply CPU imply CPU_RISCV imply RISCV_TIMER diff --git a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi index 303806454b..4b2b242deb 100644 --- a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +++ b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi @@ -12,6 +12,10 @@ spi2 = &qspi2; }; + config { + u-boot,spl-payload-offset = <0x105000>; /* loader2 @1044KB */ + }; + hfclk { u-boot,dm-spl; }; @@ -22,6 +26,14 @@ }; +&qspi0 { + u-boot,dm-spl; + + flash@0 { + u-boot,dm-spl; + }; +}; + &qspi2 { mmc@0 { u-boot,dm-spl; diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c index 535ab60aed..a7b530b281 100644 --- a/board/sifive/fu540/fu540.c +++ b/board/sifive/fu540/fu540.c @@ -116,18 +116,6 @@ int board_init(void) return 0; } -#ifdef CONFIG_SPL -u32 spl_boot_device(void) -{ -#ifdef CONFIG_SPL_MMC_SUPPORT - return BOOT_DEVICE_MMC1; -#else - puts("Unknown boot device\n"); - hang(); -#endif -} -#endif - #ifdef CONFIG_SPL_LOAD_FIT int board_fit_config_name_match(const char *name) { diff --git a/configs/sifive_fu540_defconfig b/configs/sifive_fu540_defconfig index 8d412f8d6a..551d4b04a5 100644 --- a/configs/sifive_fu540_defconfig +++ b/configs/sifive_fu540_defconfig @@ -2,9 +2,11 @@ CONFIG_RISCV=y CONFIG_SPL_GPIO_SUPPORT=y CONFIG_SYS_MALLOC_F_LEN=0x3000 CONFIG_ENV_SIZE=0x20000 +CONFIG_SPL_DM_SPI=y CONFIG_SPL_MMC_SUPPORT=y CONFIG_NR_DRAM_BANKS=1 CONFIG_SPL=y +CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI_SUPPORT=y CONFIG_TARGET_SIFIVE_FU540=y CONFIG_ARCH_RV64I=y @@ -15,9 +17,11 @@ CONFIG_MISC_INIT_R=y CONFIG_DISPLAY_CPUINFO=y CONFIG_DISPLAY_BOARDINFO=y CONFIG_SPL_SEPARATE_BSS=y +CONFIG_SPL_SPI_LOAD=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_DM_SEQ_ALIAS=y CONFIG_SPL_CLK=y CONFIG_DM_MTD=y diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst index 9e9ae98b64..d3d38eb966 100644 --- a/doc/board/sifive/fu540.rst +++ b/doc/board/sifive/fu540.rst @@ -541,3 +541,44 @@ Sample boot log from HiFive Unleashed board type: 0fc63daf-8483-4772-8e79-3d69d8477de4 type: linux guid: 9faa81b6-39b1-4418-af5e-89c48f29c20d + +Booting from SPI +---------------- + +Use Building steps from "Booting from MMC using U-Boot SPL" section. + +Partition the SPI in Linux via mtdblock. (Require to boot the board in +SD boot mode by enabling MTD block in Linux) + +Use prebuilt image from here [1], which support to partition the SPI flash. + +.. code-block:: none + + # sgdisk --clear \ + > --set-alignment=2 \ + > --new=1:40:2087 --change-name=1:loader1 --typecode=1:5B193300-FC78-40CD-8002-E86C45580B47 \ + > --new=2:2088:10279 --change-name=2:loader2 --typecode=2:2E54B353-1271-4842-806F-E436D6AF6985 \ + > --new=3:10536:65494 --change-name=3:rootfs --typecode=3:0FC63DAF-8483-4772-8E79-3D69D8477DE4 \ + > /dev/mtdblock0 + +Program the SPI (Require to boot the board in SD boot mode) + +Execute below steps on U-Boot proper, + +.. code-block:: none + + sf erase 0x5000 0x100000 + tftpboot $kernel_addr_r u-boot-spl.bin + sf write $kernel_addr_r 0x5000 $filesize + + sf erase 0x105000 0x100000 + tftpboot $kernel_addr_r u-boot.itb + sf write $kernel_addr_r 0x105000 $filesize + +Power off the board + +Change DIP switches MSEL[3:0] are set to 0110 + +Power up the board. + +[1] https://github.com/amarula/bsp-sifive