From patchwork Thu Jun 4 20:39:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1334 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 1C4D53F086 for ; Thu, 4 Jun 2020 22:40:53 +0200 (CEST) Received: by mail-pf1-f198.google.com with SMTP id h137sf5654458pfe.18 for ; Thu, 04 Jun 2020 13:40:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1591303251; cv=pass; d=google.com; s=arc-20160816; b=Bln+zJsnNMaNBYf8QlpfQNgzA5lft+d41I8yFQJOrqBEMboQKRDfjMONH2fh1PEAMN kHIhN/rizDBIa/CgGggvcHdkVy3caUIPMuMBrbLgTsTAVSwYAO8OlJKwd6rjcCW01RXX 6Se5d9N4VKHDj6q1ofkPAfd04NgiZRFCWjjp70EkfAEsLXSvZZlkGdoqpZvW8/rKVKoy EuLQkDxj/x+1qCHale2L4bFQ2hryNcQOnUkAfn0wqFTOBXo3Rh/eM4IIIxKkpUgp7gXe ZUzcgahOZADM1Mk17s3lgurjMR8cmqRqmNez7q8bh14bAIx/uPXDvT13my/6ta+aPOs7 FfYQ== 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=eDjlUaM5J6ln60lXH7VEF/2awo5Ru5xATon20y8vgYc=; b=XcCDYDT4thy2cTW6aPaCzJRzfU9/sGG54aV6Pyou7OI2y4CpaiJHsuLJKpxIlSln7H 3prj1ATIUj2IC/BxtwuqvYbkpX7PEG3ZZZ41xh3LLYXl5Zqd1VQhZCDfkAhiucPS+c8j X0xDRx5Nl2xKKEh6OsyLg6/woHTQ0x8MFD6YqXDBEiU9xt0MXvd0kCFgNdYg3a4+V5g+ TJezKEUK6SGvbYfXwguElXOBcpgSOTRwFMnFEq6SA08iVRakYJ5LoxoK4OHGKJ+oD+QL +iT1NcWShV2xWdhVhGg+71VVhc3pxQCpUj749XhDC2CdI0/5qJNzH5AjRNMbJeE2bryf BghA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=LMpUhMpN; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 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=eDjlUaM5J6ln60lXH7VEF/2awo5Ru5xATon20y8vgYc=; b=WeHeNRFpRG+QRBPCaRbZxBDN6ksI7aApdtNIcA8f9//gQI/BaFLCpCG+IBctBOWNJg m3tOOAfwXrKtYB6uJKXnP4r75CtwVbv5Z0J4BgPRrjqkOqha9qPhOgtstAE5kQmMFQwQ t8SLGDjPZ8PoUbKAsupDgYLtwwVAj+jbaoCYg= 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=eDjlUaM5J6ln60lXH7VEF/2awo5Ru5xATon20y8vgYc=; b=XDhl1tXdR+EDBiV5hmXmpTIMCaWjK9tJkI/ZqgOUNW9X4NExesWH9QdE79m9oI11h2 QfolByrGyCnP7qlA+nMJUOYBOn1ZdcVqn3tIFzhnZi0yqnzflXDtzdmB5WVy0m5o0q9R wiDwMDQLyoJWAzq63R+F4ceuen2JVdrbON9Epc0JEheL8rDDXbRA24kZjMF9q9DEpq/6 4kH8QeoJL+U2mt4YdomVxIiVeaxhJsnMENhoui6NXzRnl/NHIWPuJ8z636+v7WYewErc MZdpSFb//9cAQPWNRSlxL5HeH/tWic0/YdG33U8u2Iuqd5BW80lXEBYBOXFLh/qpq7Jy YwEw== X-Gm-Message-State: AOAM530reKb51VzlVOXoGIkHRHKuXoLtfQTe/B2Cp8JkcMNloYClDYuL cAGpJYyscv+fmt7lxK3JMWuwlpl/ X-Google-Smtp-Source: ABdhPJxVCjvkojksNHP/s54JlXyD8wagkpo65R25Smt65ax+K28NfBRTtVdKXsOJJBe3aGHhwITw4A== X-Received: by 2002:a17:902:b682:: with SMTP id c2mr6440928pls.313.1591303251348; Thu, 04 Jun 2020 13:40:51 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:b702:: with SMTP id d2ls2536687pls.6.gmail; Thu, 04 Jun 2020 13:40:51 -0700 (PDT) X-Received: by 2002:a17:902:7c96:: with SMTP id y22mr6199428pll.293.1591303250835; Thu, 04 Jun 2020 13:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591303250; cv=none; d=google.com; s=arc-20160816; b=FUWkuZbOarPoReYGB2qHMdE8CgJTdZomvMdR4fDqt51JNAb6a3ogB7xM6ZQCHbOD0i 8901plGvW90GtCUjzeY/l92R7iVP225GXPG7OkW8vvmBYRQmHo9azLOjl+IgRwWGZdp9 OBVhh9UYkQin0E4PECS4lzmCf1w4Jn/6LcjQntkbzd7ZzygIxYF/W1gSP/MsuqnY/GVc u4SdAWdDpGo/SZJLr3FbQrwPdDdWyb5G69XwI+P5har/HvqBq0bgFo0nVz6Ywrn0zZAZ keF73seDlEuYB4pbLC9nm1W0RvZo6K3Y5dijsHNZOike8LpqErikblbv556eigIZKmxE Optg== 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=i1WUqe4LCCLsnKRCsVFitSemnpVj2WAMcsw8SmwLXzM=; b=NL+kbPQTQ0S/qe3vAtpak28ry1GCG2asD40ske3obp99fq6RCh9pA37FOqbL2xT9wq GZB82Vf0n3xGQab+8FivmIscAWSnJdYAXdFtrn0yUF4BIKlXsW90fnRWA9l1dXFSw4HT MFLaQWzwlrGIMtxhHIAAMJXHoigxWjw2ixNT7oaHdQAnU6i5KLVCLuQn1B5l9/soQzpU nblZfFmc7ESfHuZJcXFtIdNkMY84uQZ748ewpNFkOpuVvD/cp5SCUfVNLGwvfaAy3GKP VzjegF82GmELyhx1VhQumSlGceJkl2oqtL73z4+8cGEPKywP6sInE0fxBxlQ6Y6nPhEJ oUEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=LMpUhMpN; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id j16sor7549372pff.13.2020.06.04.13.40.50 for (Google Transport Security); Thu, 04 Jun 2020 13:40:50 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6a00:801:: with SMTP id m1mr6151883pfk.200.1591303250517; Thu, 04 Jun 2020 13:40:50 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:41f4:94a8:1af3:a574]) by smtp.gmail.com with ESMTPSA id cm13sm6463775pjb.5.2020.06.04.13.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 13:40:49 -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 v3 2/6] sifive: fu540: Add Booting from SPI Date: Fri, 5 Jun 2020 02:09:45 +0530 Message-Id: <20200604203949.550290-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200604203949.550290-1-jagan@amarulasolutions.com> References: <20200604203949.550290-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=LMpUhMpN; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.41 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: , Add booting from SPI for SiFive Unleashed board. Signed-off-by: Jagan Teki Reviewed-by: Bin Meng Tested-by: Bin Meng --- Changes for v3: - updated based on master arch/riscv/cpu/fu540/Kconfig | 2 + .../dts/hifive-unleashed-a00-u-boot.dtsi | 12 ++++++ configs/sifive_fu540_defconfig | 4 ++ doc/board/sifive/fu540.rst | 41 +++++++++++++++++++ 4 files changed, 59 insertions(+) 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/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 f7c2c9f5bd..7a4b208288 100644 --- a/doc/board/sifive/fu540.rst +++ b/doc/board/sifive/fu540.rst @@ -533,3 +533,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 + + tftpboot $kernel_addr_r u-boot-spl.bin + sf erase 0x5000 $filesize + sf write $kernel_addr_r 0x5000 $filesize + + tftpboot $kernel_addr_r u-boot.itb + sf erase 0x105000 $filesize + 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