I am using MX25 external flash with nRF9160. I am unable to find the configuration to use the Zephyr APIs to access the flash. I am able to access it when I am using
I am using MX25 external flash with nRF9160. I am unable to find the configuration to use the Zephyr APIs to access the flash. I am able to access it when I am using
Hi
You might want to look at Zephyr Flash sample that demonstrates the use of flash API:
I have checked this example but it didn't worked for me. When I was calling the flash_erase I was getting some wierd observation.
This functions calls the following code:
AKO said:I have checked this example but it didn't worked for me
What do you mean by "did not work"? Did it not compile well? Were you able to flash it? Did you get runtime error?
AKO said:but here I see that no function is assigned to api->erase
In the main, you will see that we are getting the flash device from the devicetree by calling DEVICE_DT_GET().
Therefore, the drivers configured for that device in the DTS would be used to connect to the flash api.
I have compiled the example for NRF52840, and I can see (in the DTS) that spi-flash0 is using QSPI-NOR driver from NORDIC (see compatible), and in the NRF_QSPI_NOR.C file we see that:
Hence the flash erase would eventually connect with qspi_nor_erase from this driver.
If you are unfamiliar with this then I would recommend you to go through the DevAcademy courses that would quickly ramp up expertise working with NCS/Zephyr.
Warm regards,
Naeem
There are no compilation error, and I am able to flash it. The example that you have shared worked fine with QSPI (where the Flash_Erase/Flash_Read API are connecting with Zephyr APIs) but I am using SPI-NOR where I am facing issue.
Also, I am able to get the flash device from the Device tree.
There are no compilation error, and I am able to flash it. The example that you have shared worked fine with QSPI (where the Flash_Erase/Flash_Read API are connecting with Zephyr APIs) but I am using SPI-NOR where I am facing issue.
Also, I am able to get the flash device from the Device tree.
I am using the following to the flash device from DT:
My Device Tree:
what error you are getting now?
defining aliases for instances is fine.
you can do the debugging to see what is causing the issue.
. You can see in the above image when I execute line 242, I am getting exceptions and that could be because of the erase is not pointing to any valid function (as seen in watch)
Hi Amit,
I have tested on nrf52840dk, and I do not get any problem
I can see the correct functionality as well.
Just for reference, I am putting the nrf52840DK overlay here which is based on your overlay, the sample output dts, and the information from the DK guide.
/delete-node/ &mx25r64; &qspi{ status = "disabled"; }; &spi3{ compatible = "nordic,nrf-spim"; status = "okay"; pinctrl-0 = < &spi3_default >; pinctrl-1 = < &spi3_sleep >; pinctrl-names = "default", "sleep"; cs-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>; /* D10 */ mx25r64: mx25r6435f@0 { compatible = "jedec,spi-nor"; reg = < 0x0 >; spi-max-frequency = < 8000000 >; status = "okay"; jedec-id = [ C2 28 17 ]; 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 ]; size = < 0x4000000 >; has-dpd; t-enter-dpd = < 0x2710 >; t-exit-dpd = < 0x88b8 >; }; }; &pinctrl{ spi3_default: spi3_default { group1 { psels = <NRF_PSEL(SPIM_SCK, 0, 19)>, <NRF_PSEL(SPIM_MISO, 0, 21)>, <NRF_PSEL(SPIM_MOSI, 0, 20)>; }; }; spi3_sleep: spi3_sleep { group1 { psels = <NRF_PSEL(SPIM_SCK, 0, 19)>, <NRF_PSEL(SPIM_MISO, 0, 21)>, <NRF_PSEL(SPIM_MOSI, 0, 20)>; low-power-enable; }; }; }; /{ aliases{ spi-flash0 = &mx25r64; }; };
I am using the exact sample without modifying anything in the main except including a header file for the spi.
In the project configurations, SPI is enabled and QSPI is disabled; similarly in the overlay.