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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8B924C433F5 for ; Wed, 24 Nov 2021 04:40:03 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E6BCA82FAB; Wed, 24 Nov 2021 05:40:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="e+NQMrzw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ED5BE82FAD; Wed, 24 Nov 2021 05:39:58 +0100 (CET) Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2291B80FAE for ; Wed, 24 Nov 2021 05:39:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x730.google.com with SMTP id q64so1533786qkd.5 for ; Tue, 23 Nov 2021 20:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=VtpKPtON5+PqSSjG3DVHLhTNouj93+OBypi/QuGytjU=; b=e+NQMrzwyz3txdI9SupJqRBA3hG8ay8vAl40TtdhhmEiBikOs280ZbyyHtDBW2uXM8 NlIaqrnF3eGhLDtcezO/jEIokyTLUU4wGWgoYKxAdfqyJqUu5WUH8p+vnGhAJBgfdvKf b2PtzrT7dmXr7JuYWSwWcUj3VVwFtuHBN8INWX7TZ95ds52cfR9CWy/rzyLStgCCFylZ UcMnCq8WAQxElOi6/sv9yIiCyHJffJW7hPEwjR6xIiDJh3OGrY2tkUYZzwjiGF8hDcZj ZvN/zH5eT5g/SSaMKBh/lUPfrRJD6Yy1lsZcZ6mAc5k0QTDDict5jMTPxR+r77DHjdCl 5W5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=VtpKPtON5+PqSSjG3DVHLhTNouj93+OBypi/QuGytjU=; b=7yd/D+t0WwY4kPr3Gu7aAa/MDkHZ2dnETbAFZBKbWLuDW8NuaELIBosFlaS4QbItH1 P3kIKV8XW1i4BVjWNL8bzqt7s1cWNRXRrUN8b9sz6L2TLTJ/eo6ftrzMdbGky3ddiXrD JwzpCArFPh/w69ECbCwEIbuNQII3YqzB1HYRO9QZelygRUzxdNac149HzYi/AI0evUxW QXIVrYcunempUoWWU918M903Sasjj7zpBQB+2ACVXnCMl6ISRo33NjFN/BP/AlNxP93n vePQWhz2QfpR9mEpjb/P5RB4foeCzw6MZliWVJHB5bqFpXbxPX74qEtnx/nsi5q5i8In s4cw== X-Gm-Message-State: AOAM533ACaB/MOKQJaogL69n24Qow/OQT9mNChoodzdBE4FknbsO31tR g2scaL4AMySAvV13yJFsUHc= X-Google-Smtp-Source: ABdhPJyZ0i1LSXONRPX+u6VtPD9gW0sOowxoGxmzWFqWIqRG/cr68sXnEwDB2wZf3ATT1JwEbGTbDQ== X-Received: by 2002:a05:620a:4312:: with SMTP id u18mr2813365qko.483.1637728794002; Tue, 23 Nov 2021 20:39:54 -0800 (PST) Received: from [192.168.1.201] (pool-108-18-207-184.washdc.fios.verizon.net. [108.18.207.184]) by smtp.googlemail.com with ESMTPSA id v15sm7808029qkl.91.2021.11.23.20.39.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Nov 2021 20:39:53 -0800 (PST) From: Sean Anderson Subject: Re: [PATCH v2 1/2] riscv: Support booting SiFive Unmatched from SPI. To: Thomas Skibo , u-boot@lists.denx.de Cc: ycliang@andestech.com References: <20211124042737.27974-1-thomas-git@skibo.net> <20211124042737.27974-2-thomas-git@skibo.net> Message-ID: <8f5993f7-cba9-aff6-c8f4-efb6eb8288a6@gmail.com> Date: Tue, 23 Nov 2021 23:39:53 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20211124042737.27974-2-thomas-git@skibo.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 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 On 11/23/21 11:27 PM, Thomas Skibo wrote: > Configure SPI flash devices into SPL. Add SPI boot option to spl.c. > Document how to format flash for booting. > > Signed-off-by: Thomas Skibo > --- > .../dts/hifive-unmatched-a00-u-boot.dtsi | 11 +++++++ > board/sifive/unmatched/spl.c | 3 ++ > configs/sifive_unmatched_defconfig | 6 ++++ > doc/board/sifive/unmatched.rst | 29 +++++++++++++++++++ > 4 files changed, 49 insertions(+) > > diff --git a/arch/riscv/dts/hifive-unmatched-a00-u-boot.dtsi b/arch/riscv/dts/hifive-unmatched-a00-u-boot.dtsi > index c5475aa149..1ee8ab1868 100644 > --- a/arch/riscv/dts/hifive-unmatched-a00-u-boot.dtsi > +++ b/arch/riscv/dts/hifive-unmatched-a00-u-boot.dtsi > @@ -16,6 +16,10 @@ > u-boot,dm-spl; > }; > > + config { > + u-boot,spl-payload-offset = <0x105000>; /* loader2 @1044KB */ > + }; > + > hfclk { > u-boot,dm-spl; > }; > @@ -30,6 +34,13 @@ > clocks = <&rtcclk>; > }; > > +&qspi0 { > + u-boot,dm-spl; > + flash@0 { > + u-boot,dm-spl; > + }; > +}; > + > &spi0 { > mmc@0 { > u-boot,dm-spl; > diff --git a/board/sifive/unmatched/spl.c b/board/sifive/unmatched/spl.c > index d5663274cd..7c0beedc08 100644 > --- a/board/sifive/unmatched/spl.c > +++ b/board/sifive/unmatched/spl.c > @@ -22,6 +22,7 @@ > #define GEM_PHY_RESET SIFIVE_GENERIC_GPIO_NR(0, 12) > > #define MODE_SELECT_REG 0x1000 > +#define MODE_SELECT_SPI 0x6 > #define MODE_SELECT_SD 0xb > #define MODE_SELECT_MASK GENMASK(3, 0) > > @@ -123,6 +124,8 @@ u32 spl_boot_device(void) > u32 boot_device = mode_select & MODE_SELECT_MASK; > > switch (boot_device) { > + case MODE_SELECT_SPI: > + return BOOT_DEVICE_SPI; > case MODE_SELECT_SD: > return BOOT_DEVICE_MMC1; > default: > diff --git a/configs/sifive_unmatched_defconfig b/configs/sifive_unmatched_defconfig > index 9cc18b029c..d400ed0b23 100644 > --- a/configs/sifive_unmatched_defconfig > +++ b/configs/sifive_unmatched_defconfig > @@ -8,6 +8,7 @@ CONFIG_SPL_DM_SPI=y > CONFIG_DEFAULT_DEVICE_TREE="hifive-unmatched-a00" > CONFIG_SPL_MMC=y > CONFIG_SPL=y > +CONFIG_SPL_SPI_FLASH_SUPPORT=y > CONFIG_SPL_SPI=y > CONFIG_AHCI=y > CONFIG_TARGET_SIFIVE_UNMATCHED=y > @@ -23,17 +24,22 @@ CONFIG_DISPLAY_BOARDINFO=y > CONFIG_DISPLAY_BOARDINFO_LATE=y > CONFIG_ID_EEPROM=y > CONFIG_SPL_SEPARATE_BSS=y > +CONFIG_SPL_DM_SPI_FLASH=y > CONFIG_SPL_DM_RESET=y > +CONFIG_SPL_SPI_LOAD=y > CONFIG_CMD_EEPROM=y > CONFIG_CMD_MEMINFO=y > CONFIG_CMD_PWM=y > CONFIG_CMD_GPT_RENAME=y > CONFIG_CMD_PCI=y > CONFIG_CMD_USB=y > +CONFIG_USE_ENV_SPI_BUS=y > +CONFIG_ENV_SPI_BUS=1 > CONFIG_SYS_RELOC_GD_ENV_ADDR=y > CONFIG_SCSI_AHCI=y > CONFIG_AHCI_PCI=y > CONFIG_SPL_CLK=y > +CONFIG_SPI_FLASH_ISSI=y > CONFIG_SYS_I2C_EEPROM_ADDR=0x54 > CONFIG_E1000=y > CONFIG_NVME=y > diff --git a/doc/board/sifive/unmatched.rst b/doc/board/sifive/unmatched.rst > index 6b024f07f6..387785d76b 100644 > --- a/doc/board/sifive/unmatched.rst > +++ b/doc/board/sifive/unmatched.rst > @@ -534,3 +534,32 @@ Sample boot log from HiFive Unmatched board > OpenEmbedded nodistro.0 unmatched ttySIF0 > > unmatched login: > + > + > +Booting from SPI > +---------------- > + > +Use Building steps from "Booting from uSD using U-Boot SPL" section. > + > +Partition the SPI in Linux via mtdblock. > + > +.. code-block:: none > + > + sgdisk --clear -a 1 \ > + --new=1:40:2087 --change-name=1:spl --typecode=1:5B193300-FC78-40CD-8002-E86C45580B47 \ > + --new=2:2088:10279 --change-name=2:uboot --typecode=2:2E54B353-1271-4842-806F-E436D6AF6985 \ > + --new=3:10280:10535 --change-name=3:env --typecode=3:0FC63DAF-8483-4772-8E79-3D69D8477DE4 \ nit: Please use hexcodes as printed with sgdisk -L. And also document what the type is. Documentation is for us humans after all :) --Sean > + /dev/mtdblock0 > + > +Write U-boot SPL and U-boot to their partitions. > + > +.. code-block:: none > + > + dd if=u-boot-spl.bin of=/dev/mtdblock0 bs=4096 seek=5 conv=sync > + dd if=u-boot.itb of=/dev/mtdblock0 bs=4096 seek=261 conv=sync > + > +Power off the board. > + > +Change DIP switches MSEL[3:0] to 0110. > + > +Power up the board. >