From patchwork Mon Apr 20 14:05:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1096 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id C18723F086 for ; Mon, 20 Apr 2020 16:05:32 +0200 (CEST) Received: by mail-ot1-f70.google.com with SMTP id 41sf9504734otj.11 for ; Mon, 20 Apr 2020 07:05:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587391531; cv=pass; d=google.com; s=arc-20160816; b=X0QQvALjEDNJ9DVETKNFgwbz+587f6mJVwqXEx28ezSflHkTyexJmu7EILP/4S1jbi yyrrVanHRtjIdJphqiURNHyJbaDQhJseJ7jdcWkmA1VqdE+DxdoEcFIlB9rgdeCkLrEC JxDtkbAAvMJhcfDbagdBuxr0bIMkUFEJe4F1/nlUqdvPB9XL2vKkW1oZmGBYtl3413zn 2SQHKTeJ+4JVoI2sKBc0oFZuR6ynj4aUcnK8JAsG5MeNwR+MbD6N/OO0LJN06bt/L712 rerGed4xsrt3BXmd0bRG/gCVtZvi+G5DawniYenxNWTprYWE9IseLKnxEXqThLnIhPOK +w8Q== 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:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=8UfoAQRVovtlssiNyGDYKYVFlPuo689PTjon4mCx4Ak=; b=cK78cnuWgR4eYysqQ4SfWs6kmLoQ6N932d5McrPuHMLWN3k3AXWmGq4VJfSVpP5/Kw b55133SaJi30cLXhnUwzk3c/L9nPWbVsI0dhoyiGGvgqKeSVkhRwLrZ0ZjE/tEcr2SoQ k/sV8k27vpbrafWrBEXn9KOywGPY14rjqmAD6VvVdwbyYfao5+GG3FgoAqkCL4MbquVg aEXx0fheNbLm/fqawko1tFec4v5oBwFIjGCxPLKntDR3DTPiPxC0VTPqnTFeeya2llDQ +GAE6A5BV4Xas80bFOEanj0U/0bJU1332DTJ57U2qzJWU5MibS595iBe+Ymd6MylxAre Brng== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=a2ihE+RU; 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=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=8UfoAQRVovtlssiNyGDYKYVFlPuo689PTjon4mCx4Ak=; b=gt1UgAog0DLPPIvB0f4T7HPmiJbLnRnAim399ulyEpbDpJsdwSXm94SctGIoiwSVB6 u5bTnG7n9Sow0+lTdgVVNHOpnQutYY1k3YoTPblbGauYCvNuKIzR98J+gRe9rmQOI/fC OkwW2ODSY4aGhC42S/hGqJULs7ebUQS1D1Nkk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references: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=8UfoAQRVovtlssiNyGDYKYVFlPuo689PTjon4mCx4Ak=; b=m1UjpZiFN1wHmPf9C3TCbjjMamS26hn2aOzqaQJW0LeWw8Nz5JeH2HmyZd02rh8tlD YylWA0f3RXzmwfSyL/WbsKbaz4G6oGsExE9nqv6gEk8fwDZVKh978viw5dj1mK9DYKv4 lfvFP7GNKXe/zkPbfs7aYuot6JIrERAS9RPw3p+TuUzJJU+gbum3/iOGlR9wvlwKlMml Y9stWiavvxvgoCkqNKCWc2mDN8DBtoHhBlLsDr1Xx+6sXGc2DA7RBAap+qECKUhTvQ+k AW/2/wJro7cNCdWezO+Zk3/kb4MoXJHAGHYI9Md8MjRnT9UOVdHtaJF60+2bzgKbhdyt JeiQ== X-Gm-Message-State: AGi0PuZrAZRTCnnuIxP79xLkAEvsk33YRpCkN15P+78vIWbgCcHnEC5n VOEYScgJfNHVvdJRiZRdv0YkiIBX X-Google-Smtp-Source: APiQypKHNXePOQQglSvPVjtNgB5I5+Iv6dmYQFSTDLwQ2EdBWBgMr/Fg3fcIcrFxAjhjxCSCh8T9RA== X-Received: by 2002:aca:4e10:: with SMTP id c16mr10819919oib.140.1587391531135; Mon, 20 Apr 2020 07:05:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:aca:c748:: with SMTP id x69ls2339667oif.5.gmail; Mon, 20 Apr 2020 07:05:30 -0700 (PDT) X-Received: by 2002:aca:ed4b:: with SMTP id l72mr9929262oih.95.1587391530655; Mon, 20 Apr 2020 07:05:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587391530; cv=none; d=google.com; s=arc-20160816; b=GBlzY8rFgXhrEfvlcgMiGNI4o7Tplhp8oltjN42cBx6lcyesAvUJUl9Lotjtc5mql2 rGrqSahdTeEC1sAgOqAuHVx4RDrZ9Fqg0APaskPCPND9KxW97e2AGzX2jluVMw3GbRCZ /GbnHt2T7PobkRwvCO2DkgatglKTnH0oRkl7c2UhFCNa/iOlNWUVziJ2+8INDw/v4dFK FOIMIXN5rDoCbG827mSVQrvATCRP1SMu+kgzJVVsQ5XyK/jsREQf3q/9Fxg1cbwAfS8S uYwdWspVMNaOf++NAaf9AIpVGc77QcmSCYYEFbUhr4L5tFj9aeiD9qCt9L9V63y9alAq NKdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8p67pl63ubqMJy97Gt3C2W5p4scIwtMtW+dm1awXctE=; b=E8EZ5RycUej9fau39BiupvKR05uomJsLXzy7V9GaZZILJxob2542ufi0pDCfnSM7ad ena7i8K4pF1zAqwMljRJkppfMNJTZA6dM2Rbs0UrAXldyqQyWlqeGIybdl/hHXlzHFfC KSNS3htKwJDC4ro9x+b3lewvCqd+rUZhiZew9lzyn/it8lQ2IYzHvhm8RJ8jENpddEEa qMr6e9al5woWI/qFjjRlcbKiIchAHXU5T1FyLcVKoH9BLwafDrPoLECjQCXg4RDoapvZ 21XVVO24z/+BN2KZTrEivJQ7di2rr3mpr7NODWnvVge9AKG0Zt2F7y84NyCKCjrU8e7y rB0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=a2ihE+RU; 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 x10sor855156ote.50.2020.04.20.07.05.30 for (Google Transport Security); Mon, 20 Apr 2020 07:05:30 -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:b60d:: with SMTP id b13mr17540609pls.324.1587391530242; Mon, 20 Apr 2020 07:05:30 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:7ddc:e17b:a9b3:404]) by smtp.gmail.com with ESMTPSA id z23sm1197219pfr.136.2020.04.20.07.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2020 07:05:29 -0700 (PDT) From: Jagan Teki To: pragnesh.patel@sifive.com, rick@andestech.com, u-boot@lists.denx.de Cc: bmeng.cn@gmail.com, sagar.kadam@sifive.com, paul.walmsley@sifive.com, troy.benjegerdes@sifive.com, palmerdabbelt@google.com, anup.patel@wdc.com, atish.patra@wdc.com, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH 1/5] sifive: fu540: Add Booting from SPI Date: Mon, 20 Apr 2020 19:35:10 +0530 Message-Id: <20200420140514.25847-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420140514.25847-1-jagan@amarulasolutions.com> References: <20200420140514.25847-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=a2ihE+RU; 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.04-rc4-g0b8ed9b8b6 (Apr 20 2020 - 18:31:50 +0530) Trying to boot from MMC1 U-Boot 2020.04-rc4-g0b8ed9b8b6 (Apr 20 2020 - 18:31:50 +0530) CPU: rv64imafdc Model: SiFive HiFive Unleashed A00 DRAM: 8 GiB MMC: spi@10050000:mmc@0: 0 Loading Environment from SPI Flash... SF: Detected is25wp256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB *** Warning - bad CRC, using default environment 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 Reviewed-by: Bin Meng --- .../dts/hifive-unleashed-a00-u-boot.dtsi | 12 ++++++ board/sifive/fu540/fu540.c | 3 ++ configs/sifive_fu540_spi_defconfig | 26 +++++++++++ doc/board/sifive/fu540.rst | 43 +++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 configs/sifive_fu540_spi_defconfig diff --git a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi index 0162f59f60..f5a208398f 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>; /* @ 1044KB */ + }; + hfclk { u-boot,dm-spl; }; @@ -21,6 +25,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 131fee8898..84dd20e29d 100644 --- a/board/sifive/fu540/fu540.c +++ b/board/sifive/fu540/fu540.c @@ -129,6 +129,9 @@ void board_boot_order(u32 *spl_boot_list) u32 boot_devices[] = { #ifdef CONFIG_SPL_MMC_SUPPORT BOOT_DEVICE_MMC1, +#endif +#ifdef CONFIG_SPL_SPI_LOAD + BOOT_DEVICE_SPI, #endif }; diff --git a/configs/sifive_fu540_spi_defconfig b/configs/sifive_fu540_spi_defconfig new file mode 100644 index 0000000000..24d0a9338e --- /dev/null +++ b/configs/sifive_fu540_spi_defconfig @@ -0,0 +1,26 @@ +CONFIG_RISCV=y +CONFIG_ENV_SIZE=0x20000 +CONFIG_NR_DRAM_BANKS=1 +CONFIG_TARGET_SIFIVE_FU540=y +CONFIG_ARCH_RV64I=y +CONFIG_RISCV_SMODE=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_FIT=y +CONFIG_MISC_INIT_R=y +CONFIG_DISPLAY_CPUINFO=y +CONFIG_DISPLAY_BOARDINFO=y +CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00" +CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_DM_MTD=y +CONFIG_SPL_SEPARATE_BSS=y +CONFIG_SPL=y +CONFIG_SPL_DM_SEQ_ALIAS=y +CONFIG_SPL_DM_SPI=y +CONFIG_SPL_SPI_FLASH_SUPPORT=y +CONFIG_SPL_SPI_SUPPORT=y +CONFIG_SPL_SPI_LOAD=y +CONFIG_SPL_YMODEM_SUPPORT=y +CONFIG_SPL_CLK=y +CONFIG_SPL_GPIO_SUPPORT=y +CONFIG_SYS_MALLOC_F_LEN=0x3000 +CONFIG_SIFIVE_FU540_DDR=y diff --git a/doc/board/sifive/fu540.rst b/doc/board/sifive/fu540.rst index 691ef232e2..14323e0985 100644 --- a/doc/board/sifive/fu540.rst +++ b/doc/board/sifive/fu540.rst @@ -391,3 +391,46 @@ Program the SD card Change DIP switches MSEL[3:0] are set to 1011 Insert the SD card and power up the board. + +Booting from SPI +---------------- + +Use steps from "Building" section for building the U-Boot + +.. code-block:: none + + export ARCH=riscv + export CROSS_COMPILE= + make sifive_fu540_spi_defconfig + make + +Partition the SPI in Linux via mtdblock. (Require to boot +the board in SD boot mode by enabling MTD block in Linux) + +.. 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) +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.