Skip to content

Add support for memory mapping mode on STM32 QSPI without XIP #95926

@legoabram

Description

@legoabram

Summary

We use the settings API with an NVS partition on an external QSPI NOR flash chip. The internal flash on the STM32H753 we use really isn't an option for this since it's smallest erase operation is 128kb. The problem is that when you accumulate enough entries in your NVS, load times get LONG due to the number of reads required to traverse the whole partition when loading settings. But enabling memory mapped mode dramatically reduces this time. In my testing with a device with the worst load times, it went from 9 seconds to 2. Of course, we are working on optimizing the partition sizes for how much data we actually need to store, but I'd like the option for using memory mapped mode.

Describe the solution you'd like

Unfortunately, enabling memory mapped mode "officially" requires enabling XIP, which doesn't really apply to our device since we are running out of the internal flash. Just enabling XIP would probably break way more than it fixes.

But I found that just two changes are needed to make memory mapped mode work for generic partitions:

  1. Manually #define CONFIG_STM32_MEMMAP at the top of flash_stm32_qspi.c
  2. Modify ext_memory in device tree to be ATTR_MPU_IO
&ext_memory {
	zephyr,memory-attr = <( DT_MEM_ARM(ATTR_MPU_IO) )>;
};

There is likely a better mode/attribute for that memory section, but I lack the MPU knowledge to figure that out quickly. But that aside, it seemed to work perfectly including writing and erasing.

So ideally, I'd like a way to enable/invoke this mode of operation either via device tree attributes, KConfig, etc.

Alternatives

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

EnhancementChanges/Updates/Additions to existing featuresplatform: STM32ST Micro STM32

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions