Greetings,
I have been trying to integrate file system into Winbond W25Q02 NOR storage, Initially I tested the hardware by interfacing SPI communication between nrf 5340 and winbond and I was able to read JEDEC id, write characters into various pages and read back from them, so hardware is NOT the problem. Now I saw that zephyr allows us to integrate file system and there is a library called SPI nor, which is heavily inspired by Winbond. Before jumping into my storage for testing file system, I tested a "Mass" sample which I found in nordic SDK. it follows QSPI protocol, and I was able to mount the mx25r64 storage, which is already present inside nrf dk. Now when I use the same code, with modifications for communication (instead of QSPI, I need SPI),I get the error saying JEDEC id 00 00 00 does not match my given id in the overlay i.e ef 70 22. I just edited prj.config and overlay file in the mass sample for this purpose and I am really not sure if I need to make any changes on main.c or spi-nor.c driver for this.
This is my overlay file
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
// / {
// aliases {
// spi-flash0 = &winbond;
// };
// };
/* Disable conflicting buttons and UART */
&button2 {
status = "disabled";
};
&button3 {
status = "disabled";
};
&gpio_fwd {
status = "disabled";
};
&pinctrl {
spi_master_default: spi_master_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 2)>,
<NRF_PSEL(SPIM_MOSI, 0, 9)>,
<NRF_PSEL(SPIM_MISO, 0, 3)>;
};
};
spi_master_sleep: spi_master_sleep {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 2)>,
<NRF_PSEL(SPIM_MOSI, 0, 9)>,
<NRF_PSEL(SPIM_MISO, 0, 3)>;
low-power-enable;
};
};
};
&spi4 {
compatible = "nordic,nrf-spim";
pinctrl-0 = <&spi_master_default>;
pinctrl-1 = <&spi_master_sleep>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
status = "okay";
winbond:winbondw25q02@0 {
compatible = "jedec,spi-nor";
reg = <0>;
// irq-gpios = <&gpio0 21 0>;
spi-max-frequency = <32000000>;
//label = "WINBOND";
jedec-id = [ ef 70 22 ];
size = < 0x10000000 >;
has-dpd;
// sfdp-bfp = [
// e5 20 f1 ff ff ff ff 03 44 eb 08 6b 08 3b 04 bb
// ee ff ff ff ff ff 00 ff ff ff 00 ff 0c 20 0f 52
// 10 d8 00 ff 23 72 f5 00 82 ed 04 cc 44 83 68 44
// 30 b0 30 b0 f7 c4 d5 5c 00 be 29 ff f0 d0 ff ff
// ];
};
};
/delete-node/ &storage_partition;
&winbond {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
storage_partition: partition@0 {
label = "storage";
reg = <0x00000000 0x00020000>;
};
};
};
/ {
msc_disk0 {
compatible = "zephyr,flash-disk";
partition = <&storage_partition>;
disk-name = "NAND";
cache-size = <4096>;
};
};
This is my prj.config file
CONFIG_STDOUT_CONSOLE=y #USB related configs CONFIG_USB_DEVICE_STACK=y CONFIG_USB_DEVICE_PRODUCT="Zephyr MSC sample" CONFIG_USB_DEVICE_PID=0x0008 CONFIG_LOG=y CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y CONFIG_USB_MASS_STORAGE=y CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y CONFIG_USB_MASS_STORAGE_LOG_LEVEL_ERR=y CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n CONFIG_APP_MSC_STORAGE_FLASH_FATFS=y CONFIG_MAIN_STACK_SIZE=2048 CONFIG_FILE_SYSTEM=y CONFIG_FILE_SYSTEM_LITTLEFS=n CONFIG_SPI=y CONFIG_SPI_NOR=y CONFIG_FLASH_PAGE_LAYOUT=y CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 CONFIG_FLASH_JESD216_API=y CONFIG_FLASH_LOG_LEVEL_DBG=y CONFIG_SPI_LOG_LEVEL_DBG=y CONFIG_SPI_NRFX=y CONFIG_SPI_ASYNC=y CONFIG_SPI_SLAVE=y CONFIG_SPI=y #CONFIG_SPI_4=y CONFIG_SPI_NOR=y CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096 CONFIG_SPI_NOR_IDLE_IN_DPD=y #FLASH Config ############################################## CONFIG_DISK_ACCESS=y CONFIG_FILE_SYSTEM=y CONFIG_FAT_FILESYSTEM_ELM=y CONFIG_FS_FATFS_LFN=y CONFIG_SETTINGS_FS=y CONFIG_FLASH=y CONFIG_FLASH_MAP=y CONFIG_FLASH_PAGE_LAYOUT=y CONFIG_FLASH_LOG_LEVEL_ERR=y CONFIG_MPU_ALLOW_FLASH_WRITE=y CONFIG_DISK_DRIVER_FLASH=y
This is my terminal
*** Booting Zephyr OS build 28a3fca7da5c *** [00:00:00.257,751] <err> flashdisk: Flash area 0 open error -19 [00:00:00.257,751] <err> usb_msc: Storage init ERROR !!!! - Aborting USB init [00:00:00.257,781] <err> os: ***** BUS FAULT ***** [00:00:00.257,812] <err> os: Precise data bus error [00:00:00.257,812] <err> os: BFAR Address: 0xef8008f3 [00:00:00.257,843] <err> os: r0/a1: 0x00000000 r1/a2: 0x00013384 r2/a3: 0x00000000 [00:00:00.257,843] <err> os: r3/a4: 0xef8008f3 r12/ip: 0xfffffffc r14/lr: 0x00000883 [00:00:00.257,873] <err> os: xpsr: 0x69000000 [00:00:00.257,873] <err> os: Faulting instruction address (r15/pc): 0x0000f6c0 [00:00:00.257,904] <err> os: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0 [00:00:00.257,965] <err> os: Current thread: 0x20000b30 (unknown) [00:00:00.257,110] <dbg> spi_nrfx_spim: spi_context_update_tx: tx buf/len (nil)/0 [00:00:00.257,110] <dbg> spi_nrfx_spim: finish_transaction: Transaction finished with status 0 --- 17 messages dropped --- [00:00:00.257,141] <dbg> spi_nrfx_spim: spi_context_buffers_setup: tx_bufs 0x20005418 - rx_bufs 0x20005420 - 1 [00:00:00.257,171] <dbg> spi_nrfx_spim: spi_context_buffers_setup: current_tx 0x20005428 (2), current_rx 0x20005428 (2), tx buf/len 0x20005410/1, rx buf/len 0x20005410/1 [00:00:00.257,171] <dbg> spi_nrfx_spim: spi_context_update_tx: tx buf/len 0x20005478/3 [00:00:00.257,202] <dbg> spi_nrfx_spim: spi_context_update_rx: rx buf/len 0x20005478/3 [00:00:00.257,232] <dbg> spi_nrfx_spim: spi_context_update_tx: tx buf/len (nil)/0 [00:00:00.257,232] <dbg> spi_nrfx_spim: spi_context_update_rx: rx buf/len (nil)/0 [00:00:00.257,263] <dbg> spi_nrfx_spim: finish_transaction: Transaction finished with status 0 [00:00:00.257,293] <dbg> spi_nrfx_spim: spi_context_buffers_setup: tx_bufs 0x200053f8 - rx_bufs (nil) - 1 [00:00:00.257,293] <dbg> spi_nrfx_spim: spi_context_buffers_setup: current_tx 0x20005408 (1), current_rx (nil) (0), tx buf/len 0x200053f0/1, rx buf/len (nil)/0 [00:00:00.257,324] <dbg> spi_nrfx_spim: spi_context_update_tx: tx buf/len (nil)/0 [00:00:00.257,354] <dbg> spi_nrfx_spim: finish_transaction: Transaction finished with status 0 [00:00:00.257,385] <err> spi_nor: Device id 00 00 00 does not match config ef 70 22
file:///C:/Users/DELL/Desktop/datasheet/W25Q02JV_DTR_RevB_04192021-2329042.pdf
This is the link to winbond datasheet that I am using. Any help would be much appreciated!
