sun20i_d1_spl
sun20i_d1_spl copied to clipboard
SPI NOR Flash responses 00 00 00 on spinor_read_id
Hi :) I am using the Lichee RV Dock board with Allwinner D1 SOC. I soldered an SPI nor flash modeled Winbond w25q128jvpiq on the dock and the XFEL can detect this flash successfully. I compile and flash the SPL using these command
make CROSS_COMPILE=riscv64-linux-gnu- p=sun20iw1p1 spinor
~/xfel/xfel spinor write 0x00000000 nboot/boot0_spinor_sun20iw1p1.bin
However, in the booting process, it failed on printing
[207]spinor init fail
To figure out what the problem is, I edited the code on drivers/spinor/spinor.c, tried to print the SPI nor's id before the SPL exits abnormally, then I get that the spi_init() and spinor_read_id(id) finished successfully, but the spi nor id obtained is 00 00 00.
After so much debugging effort, I found that I was unable to find out what is going wrong. Can someone help me please?
Thanks so much :D
The detailed startup log is here
[26]HELLO! BOOT0 is starting!
[29]BOOT0 commit : 0dcb25c-dirty
[32]set pll start
[34]periph0 has been enabled
[37]set pll end
[38]board init ok
[40]DRAM only have internal ZQ!!
[43]get_pmu_exist() = -1
[46]ddr_efuse_type: 0x0
[49][AUTO DEBUG] single rank and full DQ!
[53]ddr_efuse_type: 0x0
[56][AUTO DEBUG] rank 0 row = 15
[58][AUTO DEBUG] rank 0 bank = 8
[62][AUTO DEBUG] rank 0 page size = 2 KB
[65]DRAM BOOT DRIVE INFO: V0.24
[68]DRAM CLK = 792 MHz
[70]DRAM Type = 3 (2:DDR2,3:DDR3)
[74]DRAMC ZQ value: 0x7b7bfb
[76]DRAM ODT value: 0x42.
[79]ddr_efuse_type: 0x0
[82]DRAM SIZE =512 M
[85]DRAM simple test OK.
[87]dram size =512
[89]spi init complete
[91]spinor_read_id returns 0
[94]spinor id is: 00 00 00, read cmd: 0b
[97]spinor init fail
I read the code carefully today, does the code only work for mmc boot and not for spi nor and nand flash for now?
Personally, I have only used the code in this repository with MMC. It is based on what Allwinner included in the D1 Tina SDK, which I believe was used to build the images pre-installed in SPI NAND in some Nezha boards. So it should at least work with SPI NAND. As far as I am aware, you are the first person to try using this code with SPI NOR.
Two things I would suggest:
- Enable
SPI_DEBUG
indrivers/spi.c
. This will provide a better log of what is happening. - I am guessing your pin configuration is wrong. Looking at
sunxi_spi_gpio_init
, it uses thestorage_gpio
settings from the boot0 header if those are defined. But the boot0 header innboot/main/boot0_head.c
has pin configuration for MMC0 on PF0-PF6, not SPI. You can try changing the settings instorage_gpio
, or you can forcesunxi_spi_gpio_init
to take the "else" case and use the default configuration (which is inside theCONFIG_ARCH_SUN20IW1P1
check).
Thank you for the detailed answer :) I managed to get a Nezha board today which has a 2Gb MX35LF2GE4AD SPI NAND Flash. I am trying to make it able to boot from SPI NAND and SPI NOR Flash. Once I have made any progress, I will pull a request here.