My board design is based on ls1021aiot board . I have ls1020a on board and with different qspi flash chip than on ls1021aiot board.
QSPI flash part on our board "s25fl164k" . WIth existing driver I was able to perform "Erase" operation . I am not sure about write but "READ" is deffinately not working as it crashes my system when I try to read a mtd partition. I have done following changes at driver and device tree to work for my "qspi " flash part.
Changes in device tree :
kernel/3.12/arch/arm/boot/dts/
&qspi {
num-cs = <2>;
bus-num = <0>;
fsl,spi-num-chipselects = <2>;
fsl,spi-flash-chipselects = <0>;
status = "okay";
qflash0: s25fl164k@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "spansion,s25fl164k", "jedec,spi-nor";
spi-max-frequency = <20000000>;
reg = <0>;
m25p,fast-read;
partition@0 {
label = "rcw";
reg = <0x0 0x1000>;
};
partition@1 {
label = "u-boot";
reg = <0x10000 0x100000>;
};
partition@3 {
label = "environment";
reg = <0x110000 0x600000>;
};
};
};
Changes in kernel driver
kernel/3.12/drivers/mtd/spi-nor/spi-nor.c I added following line of code in device list structure .
{ "s25fl164k", INFO(0x014017, 0, 64 * 1024, 128, SECT_4K) },
What else Do I need to do to make this qSPI flash work ? Am I missing something ? I habe my u-boot environment stored in qspi flash and I want to access them from linux using fw_printenv and fw_setenv . I will appreciate your help.
Thanks
Dhruval
Hello Dhruval,
We had a similar failure as indicated at bootup:
[ 2.260106] m25p80 spi0.0: found s25fl116k, expected s25fl164k <--- [ 2.266301] m25p80 spi0.0: s25fl116k (2048 Kbytes) <--- [ 2.271246] 3 ofpart partitions found on MTD device spi0.0 [ 2.276823] Creating 3 MTD partitions on "spi0.0": [ 2.281668] 0x000000000000-0x0000000c0000 : "U-Boot" [ 2.302309] 0x0000000c0000-0x0000000c2000 : "env" [ 2.321337] 0x0000000d0000-0x000000800000 : "Data0" [ 2.326397] mtd: partition "Data0" extends beyond the end of device "spi0.0" -- size truncated to 0x130000
One potential issue is that the Cypress S25FL164K device does not identify itself properly. I have seen some success by swapping its id 0x014017 with 0x014015 at spi-nor.c driver:
{ "s25fl116k", INFO(0x014017, 0, 64 * 1024, 32, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "s25fl132k", INFO(0x014016, 0, 64 * 1024, 64, SECT_4K) }, { "s25fl164k", INFO(0x014015, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "s25fl204k", INFO(0x014013, 0, 64 * 1024, 8, SECT_4K | SPI_NOR_DUAL_READ) },
It now reports the proper size:
[ 2.250171] m25p80 spi0.0: found s25fl164k [ 2.256368] m25p80 spi0.0: s25fl164k (8192 Kbytes) <--- woohoo!
Additional investigation and testing is need to verify that there is an issue with 8Mbyte device identification.
Good luck,
Andrew
Hello Dhruval,
Please try whether QSPI flash can be read/write under u-boot with the following commands first, they decide whether this is Kernel driver problem.
=> sf probe 0:0
SF: Detected S25FL128S_64K with page size 256 Bytes, erase size 64 KiB, total 16 MiB
=> sf erase 0 100000
SF: 1048576 bytes @ 0x0 Erased: OK
=> sf write 82000000 0 1000
SF: 4096 bytes @ 0x0 Written: OK
=> sf read 81100000 0 1000
SF: 4096 bytes @ 0x0 Read: OK
=> cm.b 81100000 82000000 1000
Total of 4096 byte(s) were the same
Have a great day,
Yiping
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks for Replying.
Firstly, I have u-boot and rcw stored in QSPI and I can access qspi flash from u-boot and currently I am booting(u-boot) from same QSPI flash.
Secondly I am using different QSPI flash part(s25fl164k), Dose the linux driver support this part? As mentioned earlier I have tried to add support as I learn but it didn't seem to work for me at linux. Can you please guide me here.
Thanks
Dhruval
Following changes in spi-nor.c solved my problem .
{ "s25fl164k", INFO(0x014017, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
Thanks
Dhruval