NanoPI R2S SPI NOR Flash

I have soldered Winbond W25Q128JVSIQ an SPI flash chip to the NanoPI R2S board and from last fiew days I'm trying boot OpenWRT from an SPI flash.
Does anyone have an idea how to make a working image or have one ?
Thx

You need to change the dts of the source code. Try asking friendlyarm people as well

What have I done to this time ?

  1. Patched rockchip.dts file with patch as below
                flash@0 {
                        #address-cells = <0x1>;
                        #size-cells = <0x1>;
                        compatible = "winbond,w25q128", "jedec,spi-nor";
                        reg = <0x0>;
                        spi-max-frequency = <0x7ed6b40>; /* 133 MHz */

                        partitions {
                                compatible = "fixed-partitions";
                                #address-cells = <0x1>;
                                #size-cells = <0x1>;

                                partition@0 {
                                        label = "uboot";
                                        reg = <0x0 0x100000>;
                                };

                                partition@100000 {
                                        label = "dtb";
                                        reg = <0x100000 0x10000>;
                                };

                                partition@110000 {
                                        compatible = "denx,uimage";
                                        label = "firmware";
                                        reg = <0x110000 0xef0000>;
                                };
                        };
                };

After these patch I have 3 mtd partitions

cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00100000 00010000 "uboot"
mtd1: 00010000 00010000 "dtb"
mtd2: 00ef0000 00010000 "firmware"
  1. Patched target/linux/rockchip/image/Makefile
### Devices ###
define Device/Default
  PROFILES := Default
  KERNEL := kernel-bin | lzma
  IMAGES := sysupgrade.bin
  SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
  DEVICE_DTS = rockchip/$$(SOC)-$(lastword $(subst _, ,$(1)))
  BLOCKSIZE := 64k
  IMAGE_SIZE := 15296k
  IMAGE/sysupgrade.bin = append-kernel | append-rootfs | pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE)

endef

With this patch I got small openwrt-rockchip-armv8-friendlyarm_nanopi-r2s-squashfs-sysupgrade.bin file

  1. With script as below created
./mkimage -v -n rk3328 -T rksd -d /home/openwrt/rk3328_ddr_333MHz_v1.13.bin idbloader.img
cat /home/openwrt/rk3328_miniloader_v2.46.bin >> idbloader.img

idbloader.img
  1. Makes few patches to handle SPI flash to U-Boot and OpenWRT kernel.

  2. Done

     mtd -e uboot write idbloader.img uboot
     mtd -e dtb write rockchip.dtb
     mtd -e firmware write openwrt-rockchip-armv8-friendlyarm_nanopi-r2s-squashfs-sysupgrade.bin firmware.
  1. After boot without SD card I have all times only
DDR version 1.13 20180428
ID:0x805 N
In
SRX
DDR4
333MHz
Bus Width=32 Col=10 Bank=4 Bank Group=2 Row=15 CS=1 Die Bus-Width=16 Size=1024MB
ddrconfig:14
OUT
Boot1 Release Time: Feb  2 2018 15:41:39, version: 2.46
ChipType = 0x11, 271
SdmmcInit=2 0
BootCapSize=0
UserCapSize=0MB
FwPartOffset=2000 , 0
SdmmcInit=0 2
powerOn 677887
Usb re Boot. 6677874
Usb re Boot. 12677875
Usb re Boot. 18677878
SoftReset
SoftReset, 19342397 us

DDR version 1.13 20180428
ID:0x805 N
In
SRX
DDR4
333MHz
Bus Width=32 Col=10 Bank=4 Bank Group=2 Row=15 CS=1 Die Bus-Width=16 Size=1024MB
ddrconfig:14
OUT
Boot1 Release Time: Feb  2 2018 15:41:39, version: 2.46
ChipType = 0x11, 273
SdmmcInit=2 0
BootCapSize=0
UserCapSize=0MB
FwPartOffset=2000 , 0
SdmmcInit=0 2
powerOn 677884
Usb re Boot. 6677870
Usb re Boot. 12677875
Usb re Boot. 18677878
SoftReset
SoftReset, 19342395 us
  1. When I put SD card the system is booting normaly
DDR version 1.13 20180428
ID:0x805 N
In
SRX
DDR4
333MHz
Bus Width=32 Col=10 Bank=4 Bank Group=2 Row=15 CS=1 Die Bus-Width=16 Size=1024MB
ddrconfig:14
OUT
Boot1 Release Time: Feb  2 2018 15:41:39, version: 2.46
ChipType = 0x11, 272
SdmmcInit=2 0
BootCapSize=0
UserCapSize=0MB
FwPartOffset=2000 , 0
SdmmcInit=0 0
BootCapSize=0
UserCapSize=59694MB
FwPartOffset=2000 , 0
StorageInit ok = 142122
Raw SecureMode = 0
SecureInit read PBA: 0x4
SecureInit read PBA: 0x404
SecureInit read PBA: 0x804
SecureInit read PBA: 0xc04
SecureInit read PBA: 0x1004
SecureInit ret = 0, SecureMode = 0
LoadTrustBL
No find bl30.bin
No find bl32.bin
Load uboot, ReadLba = 2000
hdr 0x0:0x1b,0xdb,0x90,0x4c,0xa5,0x44,0x65,0x0c,0xe4,0x54,0x1d,0xb8,0x2f,0xb1,0xa0,0xd9,

Load uboot, ReadLba = 2400
hdr 0x0:0x9f,0x56,0xd4,0xfa,0x50,0x1f,0x14,0x6e,0x70,0xdd,0x6e,0x0c,0x33,0x9e,0xc0,0xfa,

Load uboot, ReadLba = 2800
hdr 0x0:0xa6,0x07,0x1f,0x9a,0xf8,0x51,0x56,0x32,0xde,0x81,0x6e,0xe0,0xab,0xfe,0xf3,0x8f,

Load uboot, ReadLba = 2c00
hdr 0x0:0xfc,0x43,0x6e,0x28,0xff,0x8f,0x55,0x62,0xe9,0x80,0x76,0x10,0xf4,0x07,0x33,0xe8,

Load uboot, ReadLba = 3000
hdr 0x0:0xbc,0xcf,0x20,0x7a,0x1d,0x44,0x13,0x20,0x23,0x43,0x3f,0x02,0xc7,0xa5,0xa2,0x71,

Load uboot, ReadLba = 3400
hdr 0x0:0xc1,0xc2,0x32,0x79,0x0f,0x9f,0x6c,0x1b,0x2b,0x5c,0x47,0x55,0xf6,0x9e,0x86,0x41,

Load uboot, ReadLba = 3800
Load OK, addr=0x200000, size=0xb3308
RunBL31 0x40000
NOTICE:  BL31: v1.3(debug):403e0b816
NOTICE:  BL31: Built : 14:13:08, Aug 11 2020
NOTICE:  BL31:Rockchip release version: v1.3
INFO:    ARM GICv2 driver initialized
INFO:    Using opteed sec cpu_context!
INFO:    boot cpu mask: 1
INFO:    plat_rockchip_pmu_init: pd status 0xe
INFO:    BL31: Initializing runtime services
WARNING: No OPTEE provided by BL2 boot loader, Booting device without OPTEE initialization. SMC`s destined for OPTEE will return SMC_UNK
ERROR:   Error initializing runtime service opteed_fast
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x200000
INFO:    SPSR = 0x3c9


U-Boot 2022.07-armbian (Oct 18 2022 - 07:35:01 +0000)

Model: FriendlyElec NanoPi R2S
DRAM:  1022 MiB
PMIC:  RK8050 (on=0x40, off=0x00)
Core:  231 devices, 23 uclasses, devicetree: separate
MMC:   mmc@ff500000: 1
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial@ff130000
Out:   serial@ff130000
Err:   serial@ff130000

Does anybody have idea what I doing wrong ?
Thx

1 Like