External flash to sleep

My board (nrf52840 sense) has flash memory P25Q16H. When I put everything off, the board consumes 25uA. To save the last bit of current I would like to put the flash memory to deep sleep.

	spi_flash_dev = DEVICE_DT_GET(DT_ALIAS(spi_flash0));	
	if (!device_is_ready(spi_flash_dev)) {
		LOG_ERR("%s: device not ready.\n", spi_flash_dev->name);
		return ENODEV;
	}
	
	if(pm_device_action_run(spi_flash_dev, PM_DEVICE_ACTION_SUSPEND)) { //only consumes more power, 3mA ?!
		LOG_ERR("could not suspend qspi flash device %s", spi_flash_dev->name);
	}

In the debugger, eventually this function in file nrf_qspi_nor.c is executed:

#ifdef CONFIG_PM_DEVICE
static int enter_dpd(const struct device *const dev)
{
	if (IS_ENABLED(DT_INST_PROP(0, has_dpd))) {
		struct qspi_cmd cmd = {
			.op_code = SPI_NOR_CMD_DPD,
		};
		uint32_t t_enter_dpd = DT_INST_PROP_OR(0, t_enter_dpd, 0);
		int rc;

		rc = qspi_send_cmd(dev, &cmd, false);
		if (rc < 0) {
			return rc;
		}

		if (t_enter_dpd) {
			uint32_t t_enter_dpd_us =
				DIV_ROUND_UP(t_enter_dpd, NSEC_PER_USEC);

			k_busy_wait(t_enter_dpd_us);
		}
	}

	return 0;
}
#endif /* CONFIG_PM_DEVICE */

SPI_NOR_CMD_DPD is indeed to 0xB9, which is consistent with the datasheet.

Problem: after executing this command, the power rises to 3.94mA. I have no idea what is causing this.

I'm running zephyr 3.5.99 ncs 2.6.1

Parents
  • Hi,

    I am very interested in a fix for this issue as well.

    My situation is the same except I am using a non-Sense Xiao BLE: approximately 20uA if I do not do anything to power off the external flash, and 2mA if I use pm_device_action_run.

    I did stumble upon a partial solution in this message: https://forum.seeedstudio.com/t/low-power-with-xiao-nrf52840-on-zephyr-rtos/270491/6. By adding flash.* from the zip-file linked to in the message  to my project and executing da_flash_init(); da_flash_command(0xB9); da_flash_uninit();, the power consumption gets down to 2.5uA, which is in line with my expectations.

    So it is possible to get there, and I can use this solution in the short run since I do not need the external flash for my current project, but I would very much prefer a solution that uses Zephyr's power management module.

    Best Regards,

    Peder

Reply
  • Hi,

    I am very interested in a fix for this issue as well.

    My situation is the same except I am using a non-Sense Xiao BLE: approximately 20uA if I do not do anything to power off the external flash, and 2mA if I use pm_device_action_run.

    I did stumble upon a partial solution in this message: https://forum.seeedstudio.com/t/low-power-with-xiao-nrf52840-on-zephyr-rtos/270491/6. By adding flash.* from the zip-file linked to in the message  to my project and executing da_flash_init(); da_flash_command(0xB9); da_flash_uninit();, the power consumption gets down to 2.5uA, which is in line with my expectations.

    So it is possible to get there, and I can use this solution in the short run since I do not need the external flash for my current project, but I would very much prefer a solution that uses Zephyr's power management module.

    Best Regards,

    Peder

Children
Related