From patchwork Fri Aug 7 14:43:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1342305 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=BjHE1qWm; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BNSpK6z0Qz9sTF for ; Sat, 8 Aug 2020 00:45:45 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 25E5E82228; Fri, 7 Aug 2020 16:44:01 +0200 (CEST) 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="BjHE1qWm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 79AC3821FC; Fri, 7 Aug 2020 16:43:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) (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 718F0821DF for ; Fri, 7 Aug 2020 16:43:43 +0200 (CEST) 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-x742.google.com with SMTP id h7so1905866qkk.7 for ; Fri, 07 Aug 2020 07:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7Nh192c1A02F96BWJuOVe1+ZNhtaeqBs0lgPj6NGHpg=; b=BjHE1qWmfbwHo45lW4f5lQgRHdBijzZl3rccRyseghBm8o1j3oqZBJAp5eNYoHIzNp a1/EfbRi2F68FatTIwDytSScJEcTkYMs27B/wYGNxtMoVFYoMVWEu7ziGasdjEpyzKjB SlU5y67WC2I1w+2ZZS0OZ79Qx+rcvloz4iIM6ET5GdTHoFE6rUCXvgdumaE+lEj4jNZE rMshGOVYz8whT9OMXVQdl0d737RioG6dqg/d3Cj93G5OMhUZVzDd982FoI3uyoSdYbff j7PcYgpOmD7+2CkNM26hugqoDm67v8DS6U2D+jhou5ND3kM+0qVloRSfYL4fNaBTE3uc 0luw== 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:content-transfer-encoding; bh=7Nh192c1A02F96BWJuOVe1+ZNhtaeqBs0lgPj6NGHpg=; b=qOgxr4nin11YQ2khHhsnEsWjZa62ig3k1lPwXK+OKjY6weNBTZIUr0xoSzWT7N4isD G9l/4aRpfeg/doxkqgfaIBQYnb1I9kTXK9XMPwwqXqhY4wghPo7F7fjW+dDvmSqq1gf3 VM4fvydfivJd/uIK1CwMlMG7h1kQQyTB6RXkAHXSrps2ReepOl5muZiC+I/ByjI+SudR 53NgFapygdlq+26MeIMyLHQ13VPpfusjk2C21nrbQW/2fFg4ODjzqQWEi0hd2t7TaRpE 8WjYjnPZx62jMUWNLzt1TeYW/fJ3S0bRWoMKEE0emAaDOtqTny5xpkuv3Ax22FNUQ8z7 wIfw== X-Gm-Message-State: AOAM531du8azXOujisym7J17JeXZKliJMhCGIGvQA3V3Of7yokZsvHJd robL3JO+6LUOe+UtC4CztfRTegWysQa5WQ== X-Google-Smtp-Source: ABdhPJzi3ILqfDIJFW4Y3PSom4RwyuHUBbEdw7JkeacUJlX+wmb+ICZu3wbnasIDYG5ev8oyyshFNw== X-Received: by 2002:a37:614a:: with SMTP id v71mr14086688qkb.31.1596811422061; Fri, 07 Aug 2020 07:43:42 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id k134sm6976538qke.60.2020.08.07.07.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 07:43:41 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de, uboot-snps-arc@synopsys.com Cc: Heinrich Schuchardt , Jagan Teki , Eugeniy Paltsev , Horatiu Vultur , Marek Vasut , Sean Anderson , Rick Chen Subject: [PATCH v2 10/10] riscv: Add support for SPI on Kendryte K210 Date: Fri, 7 Aug 2020 10:43:17 -0400 Message-Id: <20200807144317.282868-11-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200807144317.282868-1-seanga2@gmail.com> References: <20200807144317.282868-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean This patch enables configs necessary for using SPI. It also adds some documentation. Signed-off-by: Sean Anderson --- 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" +CONFIG_MTDIDS_DEFAULT="nor0=spi3.0" +CONFIG_MTDPARTS_DEFAULT="spi3.0:496k(u-boot),16k(env),5632k(kernel),10240k(data)" 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@53000000:slot@0: 0 In: serial@38000000 Out: serial@38000000 Err: serial@38000000 - => - -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] = "" 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 --------------