NRF5340 Nor Flash SPI/QSPI Fat FS

I am having some issues with spi flash and current.  Currently I have the NOR Flash, W25Q128JVPIQ, set up on spi 4 with a FATFS and USB MSD as per customer request.  This is working but when idle I am seeing an extra 580uA of current in this configuration which seems odd.  Included is my project config and device tree.  I cant really figure out what is wrong other then there is a flaw that is keeping the interface up or not letting the chip idle.  I have also tried the below QSPI config and while it gets the JDEC ID and the fs code reports a file system was created it can not mount the FS.  In an ideal case I would like to move or configuration to QSPI and have it reach an appropriate idle power level.  Currently we are using 1.7.1 sdk and I am using a fluke 87 multimeter for current measurement and have the nrf5340 idle current at 3.8uA and with the FS enabled it is 580uA.  In the old nrf sdk I used chan fs and this spi flash and had no power issues so this seems to be zephyr config related.  Any help would be appreciated.

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
# CONFIG_FCB=y
# CONFIG_SETTINGS_FCB=y


CONFIG_DISK_FLASH_DEV_NAME="MX25L32"
CONFIG_DISK_FLASH_START=0x0
CONFIG_DISK_VOLUME_SIZE=0x1000000
CONFIG_DISK_FLASH_MAX_RW_SIZE=4096
CONFIG_DISK_FLASH_ERASE_ALIGNMENT=0x1000
CONFIG_DISK_ERASE_BLOCK_SIZE=0x1000

 &qspi {
// 	status = "okay";
// 	sck-pin = <17>;
// 	io-pins = <13>, <14>, <15>, <16>;
// 	csn-pins = <18>;
// 	mx25l32: mx25l3206E@0 {
// 		compatible = "nordic,qspi-nor";
// 		reg = <0>;
// 		/* MX25R64 supports only pp and pp4io */
// 		writeoc = "pp4io";
// 		/* MX25R64 supports all readoc options */
// 		readoc = "read4io";
// 		sck-frequency = <8000000>;
// 		label = "MX25L32";
// 		jedec-id = [ef 40 18];
// 		// 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 = <0x10000000>;
// 		has-dpd;
// 		t-enter-dpd = <10000>;
// 		t-exit-dpd = <35000>;
// 		rx-delay = <6>;
// 	};
// };

&spi4 {
	compatible = "nordic,nrf-spim";
	status = "okay";
	sck-pin = <17>;
	mosi-pin = <13>;
	miso-pin = <14>;
	cs-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
	mx25l32: mx25l3206E@0 {
		compatible = "jedec,spi-nor";
		label = "MX25L32";
		reg = <0>;
		spi-max-frequency = <32000000>;
		wp-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
		hold-gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
		size = <0x8000000>;
		has-dpd;
		t-enter-dpd = <10000>;
		t-exit-dpd = <35000>;
		jedec-id = [ef 40 18];
//		has-be32k;
	};
};

/delete-node/ &storage_partition;

&mx25l32 {
	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		partition@0 {
			label = "storage";
			reg = <0x00000000 0x01000000>;
		};
	};
};

Parents
  • This is not obvious from product specification, but there is a difference in hardware between spi3 and spi4, because spi4 support high-speed it uses a different regulator internally, which unfortunately cause higher current consumption. That said, it should be possible to handle this difference (in other words drastically reduce it) in the driver's power management of the spi4, but I can find this is currently not the case. We will need to create an internal case to look at the power management of spi4. 

    I am not sure why you are not getting qspi to work, I do believe there should be some examples you can use as reference. That said, I do believe also qspi also suffer from a power management handling in the driver, which cause it to have excessive current at the moment. I believe this is already in progress to be fixed, but you may need to switch to main branch of ncs.

    Best regards,
    Kenneth

  • Kenneth thanks for the update.  As for QSPI there is no example that uses qspi as a fatfs that i can see. I would have thought that i would simply replace the spi nor with qspi nor and that was that, but that does not seem to be the case.  I have done extensive debugging with this but it will not load the FS unless the FS already existed from previously using SPI mode.  When I don't have an FS the FS code responds that it has created the file system but fails to mount with error -19 device does not exist.  Could this be a driver issue in the FS code for qspi?

Reply
  • Kenneth thanks for the update.  As for QSPI there is no example that uses qspi as a fatfs that i can see. I would have thought that i would simply replace the spi nor with qspi nor and that was that, but that does not seem to be the case.  I have done extensive debugging with this but it will not load the FS unless the FS already existed from previously using SPI mode.  When I don't have an FS the FS code responds that it has created the file system but fails to mount with error -19 device does not exist.  Could this be a driver issue in the FS code for qspi?

Children
Related