public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 10/10] riscv: Add support for SPI on Kendryte K210
Date: Sat, 8 Aug 2020 07:15:51 -0400	[thread overview]
Message-ID: <d3dae360-a56f-13ac-45fb-3d47a26969cc@gmail.com> (raw)
In-Reply-To: <d5e6708e-6156-1c41-3db8-22ab970f5ba7@gmx.de>

On 8/8/20 1:48 AM, Heinrich Schuchardt wrote:
> On 8/7/20 4:43 PM, Sean Anderson wrote:
>> This patch enables configs necessary for using SPI. It also adds some
>> documentation.
>>
>> Signed-off-by: Sean Anderson <seanga2@gmail.com>
>> ---
>>
>> Changes in v2:
>> - Add Gigadevice SPI chips to dependencies
>>
>>  board/sipeed/maix/Kconfig          | 11 ++++
>>  configs/sipeed_maix_bitm_defconfig |  8 +++
>>  doc/board/sipeed/maix.rst          | 94 +++++++++++++++++++-----------
>>  3 files changed, 80 insertions(+), 33 deletions(-)
>>
>> diff --git a/board/sipeed/maix/Kconfig b/board/sipeed/maix/Kconfig
>> index 4c42dd2087..48a4e9dc1a 100644
>> --- a/board/sipeed/maix/Kconfig
>> +++ b/board/sipeed/maix/Kconfig
>> @@ -53,4 +53,15 @@ config BOARD_SPECIFIC_OPTIONS
>>  	imply CMD_GPIO
>>  	imply LED
>>  	imply LED_GPIO
>> +	imply SPI
>> +	imply DESIGNWARE_SPI
>> +	imply SPI_FLASH_GIGADEVICE
>> +	imply SPI_FLASH_WINBOND
>> +	imply DM_MTD
>> +	imply SPI_FLASH_MTD
>> +	imply CMD_MTD
>> +	imply ENV_IS_IN_SPI_FLASH
>> +	imply MMC
>> +	imply MMC_BROKEN_CD
>> +	imply MMC_SPI
>>  endif
>> diff --git a/configs/sipeed_maix_bitm_defconfig b/configs/sipeed_maix_bitm_defconfig
>> index f48f7f06e9..7f644e7a37 100644
>> --- a/configs/sipeed_maix_bitm_defconfig
>> +++ b/configs/sipeed_maix_bitm_defconfig
>> @@ -1,6 +1,14 @@
>>  CONFIG_RISCV=y
>> +CONFIG_ENV_SIZE=0x2000
>> +CONFIG_ENV_SECT_SIZE=0x1000
>> +CONFIG_ENV_OFFSET=0x7C000
>> +CONFIG_ENV_OFFSET_REDUND=0x7E000
>>  CONFIG_TARGET_SIPEED_MAIX=y
>>  CONFIG_ARCH_RV64I=y
>> +CONFIG_USE_BOOTCOMMAND=y
>> +CONFIG_BOOTCOMMAND="sf probe;mtd read kernel 80000000;go 80000000"
> 
> If no kernel is present, this will let your system hang.
> 
> "go" does not check that whatever you loaded from mtd is a kernel. That
> is why we have commands like bootm.

I think originally I was having problems with bootm because the *addr
variables were not set, so I used go and not bootm. I will try again
with your patch for those variables.

>> +CONFIG_MTDIDS_DEFAULT="nor0=spi3.0"
>> +CONFIG_MTDPARTS_DEFAULT="spi3.0:496k(u-boot),16k(env),5632k(kernel),10240k(data)"
> 
> The size of u-boot.bin may exceed 496 KiB depending on the options
> selected. Mine is currently 543589 bytes. When starting with OpenSBI
> another 70+ KiB will be needed.

Huh. I had only seen U-Boot with size in the 200-300M range. We can
definitely increase this. Again, this is effectively arbitrary, and I'm
still not sure if doing partitions like this is the best approach.
Perhaps we should be using UBI here? I wasn't able to figure out what
the "best practice" is for this sort of board.

> If we overwrite 5632 KiB from the kernel partition, this may overwrite
> the relocated U-Boot.
> 
> When an SD-card is worn out I can replace it. When the SPI flash is worn
> out I have to replace the device.

Yeah, I would like to be booting off the SD card here as well, but I
haven't gotten it working yet.

> We can put the kernel and the environment onto the SD card. I would
> suggest to use SPI only for OpenSBI and U-Boot. Please, use
> CONFIG_DISTRO_BOOT.

Ok.

>>  CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
>>  # CONFIG_NET is not set
>>  # CONFIG_INPUT is not set
>> diff --git a/doc/board/sipeed/maix.rst b/doc/board/sipeed/maix.rst
>> index 1865e2adfb..fa78bcd51c 100644
>> --- a/doc/board/sipeed/maix.rst
>> +++ b/doc/board/sipeed/maix.rst
>> @@ -46,42 +46,14 @@ Boot output should look like the following:
>>      U-Boot 2020.04-rc2-00087-g2221cc09c1-dirty (Feb 28 2020 - 13:53:09 -0500)
>>
>>      DRAM:  8 MiB
>> +    MMC:   spi at 53000000:slot at 0: 0
> 
> Actual output is
> 
> MMC:   regs=0000000053000000 max-frequency=25000000

Ok, I will update that.

>>      In:    serial at 38000000
>>      Out:   serial at 38000000
>>      Err:   serial at 38000000
> 
> As we do not check if a kernel is available:
> 
> MTD device kernel not found, ret -19
> ## Starting application at 0x80000000 ...
> 
> And then hanging.
> 
> Best regards
> 
> Heinrich
> 
>> -    =>
>> -
>> -Loading Images
>> -^^^^^^^^^^^^^^
>> -
>> -To load a kernel, transfer it over serial.
>> -
>> -.. code-block:: none
>> -
>> -    => loady 80000000 1500000
>> -    ## Switch baudrate to 1500000 bps and press ENTER ...
>> -
>> -    *** baud: 1500000
>> -
>> -    *** baud: 1500000 ***
>> -    ## Ready for binary (ymodem) download to 0x80000000 at 1500000 bps...
>> -    C
>> -    *** file: loader.bin
>> -    $ sz -vv loader.bin
>> -    Sending: loader.bin
>> -    Bytes Sent:2478208   BPS:72937
>> -    Sending:
>> -    Ymodem sectors/kbytes sent:   0/ 0k
>> -    Transfer complete
>> -
>> -    *** exit status: 0 ***
>> -    ## Total Size      = 0x0025d052 = 2478162 Bytes
>> -    ## Switch baudrate to 115200 bps and press ESC ...
>> -
>> -    *** baud: 115200
>> -
>> -    *** baud: 115200 ***
>> -    =>
>> +    Hit any key to stop autoboot:  0
>> +    SF: Detected w25q128fw with page size 256 Bytes, erase size 4 KiB, total 16 MiB
>> +    Reading 5242880 byte(s) at offset 0x00000000
>> +    ## Starting application at 0x80000000 ...
>>
>>  Running Programs
>>  ^^^^^^^^^^^^^^^^
>> @@ -163,6 +135,62 @@ To run legacy images, use the ``bootm`` command:
>>      argv[0] = "<NULL>"
>>      Hit any key to exit ...
>>
>> +Flashing Images
>> +---------------
>> +
>> +To flash a kernel, transfer it over serial, then write it to the kernel
>> +partition.
>> +
>> +.. code-block:: none
>> +
>> +    => loady 80000000 1500000
>> +    ## Switch baudrate to 1500000 bps and press ENTER ...
>> +
>> +    *** baud: 1500000
>> +
>> +    *** baud: 1500000 ***
>> +    ## Ready for binary (ymodem) download to 0x80000000 at 1500000 bps...
>> +    C
>> +    *** file: loader.bin
>> +    $ sz -vv loader.bin
>> +    Sending: loader.bin
>> +    Bytes Sent:2478208   BPS:72937
>> +    Sending:
>> +    Ymodem sectors/kbytes sent:   0/ 0k
>> +    Transfer complete
>> +
>> +    *** exit status: 0 ***
>> +    ## Total Size      = 0x0025d052 = 2478162 Bytes
>> +    ## Switch baudrate to 115200 bps and press ESC ...
>> +
>> +    *** baud: 115200
>> +
>> +    *** baud: 115200 ***
>> +    => sf probe
>> +    SF: Detected w25q128fw with page size 256 Bytes, erase size 4 KiB, total 16 MiB
>> +    => mtd write kernel 80000000 0 25d052
>> +    Writing 2478162 byte(s) at offset 0x00000000
>> +
>> +Partition Scheme
>> +^^^^^^^^^^^^^^^^
>> +
>> +There is no partition scheme specified by the manufacturer. The only requirement
>> +imposed by the firmware is that offset 0 will be loaded and ran. The default
>> +partition scheme is
>> +
>> +========= ======== ======
>> +Partition Offset   Size
>> +========= ======== ======
>> +u-boot    0x000000 496k
>> +env       0x07C000 16k
>> +kernel    0x080000 5M
>> +data      0x580000 10.5M
>> +========= ======== ======
>> +
>> +**NB:** kflash adds a 5-byte header to payloads (and a 32-byte trailer) to all
>> +payloads it flashes. If you use kflash to flash your payload, you will need to
>> +account for this header when specifying what offset in spi flash to load from.
>> +
>>  Pin Assignment
>>  --------------
>>
>>
> 

  reply	other threads:[~2020-08-08 11:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07 14:43 [PATCH v2 00/10] riscv: Add SPI support for Kendryte K210 Sean Anderson
2020-08-07 14:43 ` [PATCH v2 01/10] spi: dw: Convert calls to debug to log_* Sean Anderson
2020-08-07 14:49   ` Marek Vasut
2020-08-07 14:55     ` Sean Anderson
2020-08-08  5:14   ` Heinrich Schuchardt
2020-08-08 11:07     ` Sean Anderson
2020-08-08 14:11       ` Heinrich Schuchardt
2020-08-20 13:26   ` Simon Glass
2020-08-20 13:36     ` Marek Vasut
2020-08-21  0:08       ` Tom Rini
2020-08-21  1:08         ` Marek Vasut
2020-08-07 14:43 ` [PATCH v2 02/10] spi: dw: Rename "cs-gpio" to "cs-gpios" Sean Anderson
2020-08-07 14:43 ` [PATCH v2 03/10] spi: dw: Use generic function to read reg address Sean Anderson
2020-08-07 14:43 ` [PATCH v2 04/10] spi: dw: Rearrange struct dw_spi_priv Sean Anderson
2020-08-07 14:43 ` [PATCH v2 05/10] spi: dw: Add SoC-specific compatible strings Sean Anderson
2020-08-07 14:43 ` [PATCH v2 06/10] spi: dw: Configure ctrlr0 layout based on compatible string Sean Anderson
2020-08-07 14:43 ` [PATCH v2 07/10] spi: dw: Document devicetree binding Sean Anderson
2020-08-07 14:43 ` [PATCH v2 08/10] spi: dw: Add mem_ops Sean Anderson
2020-08-08 11:36   ` Sean Anderson
2020-08-07 14:43 ` [PATCH v2 09/10] riscv: Add device tree bindings for SPI Sean Anderson
2020-08-12  1:49   ` Rick Chen
2020-08-07 14:43 ` [PATCH v2 10/10] riscv: Add support for SPI on Kendryte K210 Sean Anderson
2020-08-08  5:48   ` Heinrich Schuchardt
2020-08-08 11:15     ` Sean Anderson [this message]
2020-08-10 10:49 ` [PATCH v2 00/10] riscv: Add SPI support for " Eugeniy Paltsev
2020-08-10 11:13   ` Sean Anderson
2020-08-10 15:32     ` Eugeniy Paltsev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d3dae360-a56f-13ac-45fb-3d47a26969cc@gmail.com \
    --to=seanga2@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox