I use spi_write() and spi_read() API to read JEDEC ID of Winbond NOR flash. But results of spi_read() are always 0. Do you have any suggestions to debug this issue?
I use spi_write() and spi_read() API to read JEDEC ID of Winbond NOR flash. But results of spi_read() are always 0. Do you have any suggestions to debug this issue?
Hi
Have you set up your SPI to match the specs of the Winbond flash you're using in your project's overlay file? See the snippet below which is set up for the MX25R serial flash that's on the nRF52840 DK by default.
&spi2 { compatible = "nordic,nrf-spi"; status = "okay"; cs-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>; pinctrl-0 = <&spi2_default>; pinctrl-1 = <&spi2_sleep>; pinctrl-names = "default", "sleep"; mx25r64: mx25r6435f@0 { compatible = "jedec,spi-nor"; reg = <0>; spi-max-frequency = <8000000>; jedec-id = [c2 28 17]; size = <67108864>; wp-gpios = <&gpio0 22 GPIO_ACTIVE_LOW>; hold-gpios = <&gpio0 23 GPIO_ACTIVE_LOW>; }; };
Also, what SPI instance, and what pins are you using for SPI on your board? You can try using spi_nor_read_jedec_id from the spi_nor.c driver to see what that function returns.
Best regards,
Simon
Thanks for your reply!
&spi1 {
status = "okay";
cs-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
pinctrl-0 = <&spi1_default>;
pinctrl-1 = <&spi1_sleep>;
pinctrl-names = "default", "sleep";
w25q32: w25q32jv@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <8000000>;
jedec-id = [ef 40 16];
size = <0x400000>;
has-dpd;
t-enter-dpd = <3500>;
t-exit-dpd = <3500>;
};
w25q256: w25q256jv@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <8000000>;
jedec-id = [ef 40 19];
size = <0x2000000>;
has-dpd;
t-enter-dpd = <3500>;
t-exit-dpd = <3500>;
};
};
minimal_log_spi>west build -b custom_nrf52832
-- west build: generating a build system
...
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map
cmd.exe /C "cd . && D:\ncs\toolchains\v2.3.0\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -gdwarf-4 @CMakeFiles\zephyr_pre0.rsp -o zephyr\zephyr_pre0.elf && cmd.exe /C "cd /D D:\ncs\v2.3.0\nrf\samples\minimal_log_spi\build\zephyr && D:\ncs\toolchains\v2.3.0\opt\bin\cmake.exe -E echo ""
d:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(flash_nor.c.obj): in function `flashNorInit':
D:\ncs\v2.3.0\nrf\samples\minimal_log_spi\build/../src/flash_nor.c:45: undefined reference to `spi_nor_read_jedec_id'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'D:\ncs\toolchains\v2.3.0\opt\bin\cmake.EXE' --build 'D:\ncs\v2.3.0\nrf\samples\minimal_log_spi\build'