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 047FEC4167B for ; Fri, 30 Dec 2022 09:35:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C59E485452; Fri, 30 Dec 2022 10:35:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id F29E3854EC; Fri, 30 Dec 2022 10:35:36 +0100 (CET) Received: from mail-m11873.qiye.163.com (mail-m11873.qiye.163.com [115.236.118.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4B882849C0 for ; Fri, 30 Dec 2022 10:35:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=rock-chips.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kever.yang@rock-chips.com Received: from [192.168.0.116] (unknown [112.49.5.234]) by mail-m11873.qiye.163.com (Hmail) with ESMTPA id 45810900470; Fri, 30 Dec 2022 17:35:18 +0800 (CST) Message-ID: <699b40c4-9bc2-7951-ba90-1d85a4fee91c@rock-chips.com> Date: Fri, 30 Dec 2022 17:35:17 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: Rockchip RK3328 4-byte addressing problem in SPI Content-Language: en-US To: Simon Glass , =?UTF-8?Q?Marcin_Wo=c5=baniak?= Cc: u-boot@lists.denx.de References: From: Kever Yang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlCS0pDVkgaHR5KGkNCQ0xLQ1UTARMWGhIXJBQOD1 lXWRgSC1lBWUpKSVVPQlVOVUlIT1lXWRYaDxIVHRRZQVlPS0hVSkpLSEpMVUpLS1VLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NiI6Nzo6Kz0oHRoWKCwTTg48 LAEwCklVSlVKTUxJSEJJQkpDQ0tDVTMWGhIXVRAeDR4JVQIaFRw7CRQYEFYYExILCFUYFBZFWVdZ EgtZQVlKSklVT0JVTlVJSE9ZV1kIAVlBT0hKQjcG X-HM-Tid: 0a856262c56c2eafkusn45810900470 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean Hi Macin, On 2022/12/30 06:39, Simon Glass wrote: > +Kever Yang > > On Thu, 22 Dec 2022 at 18:30, Marcin Woźniak wrote: >> Hello, >> >> I would like to let you know how i've lost about 2 weeks because of lack >> of Rockchip BOOTROM documentation. >> >> I tried to use Mainline Uboot to Boot NanoPI R2S using soldered SPI >> Winbond 25Q256 chip. >> >> I had to make some patches in Uboot core files to make it work. I didn't look into SPI boot flow, but there have many boards working with SPI including rk3399, rk3328 and other SoCs. It should be work to sync with those boards. >> >> First one adds SPI boot device. File >> |arch/arm/mach-rockchip/rk3328/rk3328.c with adding: | >> >> |[BROM_BOOTSOURCE_SPINOR] "/spi@ff190000", |const char * const >> boot_devices || >> >> Second was |arch/arm/mach-rockchip/spl-boot-order.c and last if statement:| >> >> |if (!uclass_get_device_by_of_offset(UCLASS_SPI, node, &parent)) return >> BOOT_DEVICE_SPI;| >> >> || >> >> This patch is added because RockChip SPI driver is using UCLASS_SPI >> instead of SPI_FLASH so boot device wasn't connecting with right DM >> Driver rk_spi.c >> >> Third one fixed SPL and it was added at the end: |drivers/spi/rk_spi.c >> | >> >> |DM_DRIVER_ALIAS(rockchip_rk3288_spi, rockchip_rk3328_spi);| >> >> After that board booted successfully. Second bigger problem was a >> mistake and lack of RockChip Bootrom documentation. >> >> I've soldered 32Mbyte Flash and didn't know that U-Boot in SPL was >> switching it's 3-byte address mode to 4-byte one to gain access to full >> 32 Mbytes. >> >> The problem was that board booted in cold-start but after issuing >> "reset" - it was going to MASKROM mode like no SPI was soldered or empty. >> >> After loosing two weeks i figured that RockChip bootrom talks to SPI >> using only 3-byte addressing. >> >> So leaving 4-byte switched by UBoot SPI chip made it unusable to >> RockChip Bootrom. I found this by dumping Bootrom and decompiling it. Sync with engineer working on these area, and get below: Yes, this "4-byte addressing problem in SPI" issue is in SoCs including rk3328, this only happen on SPI NOR size at least 32MB, most of customers only use smaller size SPI NOR. If 32MB+ SPI NOR is  needed for the project, them we would suggest to use those SPI  flash with 3&4 byte command set support; or else workaround to do the snor_deinit and exit_4byte_address_mode will needed before every reboot/hot reset in the system. Thanks, - Kever >> I don't know if it's enough information to make a patch to MainLine (at >> least for SPI boot in RK3328). >> >> Problem with 3-byte addressing is a complete different story. >> >> Sorry for my "unproffesional" mail. I am writing this type of message >> for a first time. >> >> Marcin >> >> >> >> || >> >> |||||||| >> >> ||