STM32U5G9 OctoSPI Memory-Mapped Mode with MX35LF1G24AD NAND Flash
Hi everyone,
I'm working on a project using the STM32U5G9 microcontroller and trying to interface it with a Macronix MX35LF1G24AD NAND flash via the OctoSPI peripheral.
The goal is to enable memory-mapped mode so the external flash can be accessed as part of the MCU's address space. However, I'm facing some challenges and would appreciate any insights or examples from the community.
Here are my main questions:
- Is the MX35LF1G24AD NAND flash compatible with OctoSPI memory-mapped mode on the STM32U5G9? Most examples I’ve found are for NOR flash, and I’m unsure if NAND is fully supported in this mode.
- What are the key configuration steps in STM32CubeMX or HAL to properly set up OctoSPI for this device?
- Are there any specific limitations or considerations when using NAND flash in memory-mapped mode (e.g., ECC handling, bad block management, page/block alignment)?
Additional Doubt:
In most OctoSPI memory-mapped examples I’ve seen (typically with NOR flash), the flow looks something like this:
OSPI_RegularCmdTypeDef sCommand = {0};
sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
sCommand.Instruction = READ_CMD;
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
sCommand.AddressMode = HAL_OSPI_ADDRESS_1_LINE;
sCommand.DataMode = HAL_OSPI_DATA_1_LINE;
sCommand.DummyCycles = DUMMY_CYCLES;
HAL_OSPI_Command(&hospi, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);
HAL_OSPI_MemoryMapped(&hospi, &memMappedCfg);
However, with the MX35LF1G24AD, it seems that data cannot be read directly from the chip. Instead, you must first issue a Page Read command to transfer data from NAND to the internal cache, and then use a Read From Cache command to access the data. For example:
// Step 1: Page Read (transfer from NAND to cache)
SendCommand(PAGE_READ_CMD, block, page);
// Step 2: Read From Cache (read from internal buffer)
SendCommand(READ_FROM_CACHE_CMD, column_address);
This makes me wonder: Can memory-mapped mode even work with this kind of NAND architecture, where a two-step read process is required?
Any clarification on this behavior or suggestions on how to implement memory-mapped-like access with this flash would be greatly appreciated.
Thanks in advance!
