Skip to main content
Graduate
October 5, 2023
Solved

STM32H7B0RBT6 with QSPI PSRAM APS6404L-3SQR

  • October 5, 2023
  • 5 replies
  • 9185 views

Hi Community,

During a project we are using the microcontroller STM32H7B0RBT6 with QSPI PSRAM APS6404L-3SQR , it works fine in indirect mode either in quad read and quad write, but the issue is with the write in memory mapped mode when trying to write less than 8 byte, one for example (*((uint8_t*) (0x90000010))=0x55;) the 7 others  bytes are zeroed it seems that the write accept only 8 bytes if the data is less than 8 the other bytes are zeroed as you can see :

ALAMI_Othmane_0-1696536469785.png

instead written 8 bytes (*((uint64_t*) (0x90000010))=0xA5A5A5A5A5A5A5A5ULL;) works fine !!

Did someone face a similar problem could please provide some suggestions to do, thanks,

 

Here I share the code that  I have used to  enable the memory mapped mode

 

OSPI_MemoryMappedTypeDef sMemMappedCfg = {0};
OSPI_RegularCmdTypeDef sCommand = {0};

/* set command to write to qspi ram */

sCommand.OperationType = HAL_OSPI_OPTYPE_WRITE_CFG;
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_4_LINES;
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS;
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
sCommand.AddressMode = HAL_OSPI_ADDRESS_4_LINES;
sCommand.AddressSize = HAL_OSPI_ADDRESS_24_BITS;
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
sCommand.DataMode = HAL_OSPI_DATA_4_LINES;
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
sCommand.DQSMode = HAL_OSPI_DQS_ENABLE; /* Memory-mapped write error response when DQS output is disabled */
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
sCommand.Instruction = QUAD_WRITE_DATA_CMD;
sCommand.Address = 0;
sCommand.NbData = 0;
sCommand.DummyCycles = 0;

 

if (HAL_OSPI_Command(&hospi1, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE)  != HAL_OK)

{

Error_Handler();

}

/* set command to read from spi ram */

sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
sCommand.OperationType = HAL_OSPI_OPTYPE_READ_CFG;
sCommand.Instruction = FAST_READ_QUAD_DATA_CMD;
sCommand.DummyCycles = 6;

if (HAL_OSPI_Command(&hospi1, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE)  != HAL_OK)

{

Error_Handler();

}

/* set up memory mapping */

/* release nCS after access, else no refresh */
sMemMappedCfg.TimeOutActivation = HAL_OSPI_TIMEOUT_COUNTER_ENABLE;
sMemMappedCfg.TimeOutPeriod = 1;

if (HAL_OSPI_MemoryMapped(&hospi1, &sMemMappedCfg) != HAL_OK)

{

Error_Handler();

}

 

    This topic has been closed for replies.
    Best answer by ALAMI_Othmane

    This memory require a specific refresh value that resolve the issue, now it's working fine and stable with the memory mapped mode, we have actually used as a heap for our application contain the frame buffer and all others data

    to make it work, you need to:
    - Configure the MPU for the specific mapped addresses area

    - Pay attention to the refresh value ( should equal 241)  when initializing the octospi interface to have better stability for values stored in this ram

    5 replies

    Graduate
    October 9, 2023

    MPU is reconfigured to :

    MPU_InitStruct.Enable = MPU_REGION_ENABLE;

    MPU_InitStruct.Number = MPU_REGION_NUMBER5;

    MPU_InitStruct.BaseAddress = 0x90000000;

    MPU_InitStruct.Size = MPU_REGION_SIZE_8MB;

    MPU_InitStruct.SubRegionDisable = 0x0;

    MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;

    MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;

    MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;

    MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;

    MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;

    MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;

     

    this handle this issue and we can now do software write in one byte, but the issue is still exist when you write by debugger .

    Technical Moderator
    October 6, 2023

    Hello @ALAMI_Othmane,

    First let me thank you for posting.

    A similar question is posted here.

    There is an errata "Memory-mapped write error response when DQS output is disabled". So with this errata we need to enable the DQS when doing memory mapped writes even if the memory do not support DQS. This is the workaround as you did.

    So when you do a 8-16-32 bit write , the OCTOSPI will output 64-bit and mask the rest using DQS pin. The problem is if the memory do not support DQS (which is in our case), the rest of the AXI data will be written to the memory. so if you write : (*((uint8_t*) (0x90000000))=0x55;) 0x90000000 will be written correctly but the data from address 0x90000001-0x90000007 will be corrupted. 

    Kaouthar

     

    Graduate
    October 6, 2023

    Hello KDJEM.1

    Thanks for your answer,

    So you confirm there is no way to write less than 8 bytes with memory mapped mode activated, 

    We need this info cause this memory will be used as heap in a project where we will allocate  different sizes of Data .

    Best Regards

    Explorer
    October 9, 2023

    Hi, 

    There is a Memory Mapped Write limitation with QSPI SDR on STMH7A/B. If possible you  might want to consider OPI PSRAM (11 pin instead of 6, but up to x4 bandwith). The OPI version of APS6404L-3SQR is APS6408L-3OBM-BA (3V also available in 128Mb APS12808L-3OBM- BA)

    Alex

    Graduate
    October 9, 2023

    Hi Alex,

    Thanks for your Answer,

    For the specific version of MCU used there is no OPI, do you confirm we can't allocate the heap in this QSPI memory ? 

    Best,

    Othmane

    Explorer
    October 10, 2023

    Hi, 

    This MCU is supporting Octal PSRAM (x2), or do you mean it's not available on your board ?

    If you wish to stay with lowest pincount, QSPI DDR is also supported, such as APS12808O-DQ-WA

    With QSPI SDR, Memory mapped write is not supported

    Alex

    ALAMI_OthmaneAuthorAnswer
    Graduate
    June 22, 2024

    This memory require a specific refresh value that resolve the issue, now it's working fine and stable with the memory mapped mode, we have actually used as a heap for our application contain the frame buffer and all others data

    to make it work, you need to:
    - Configure the MPU for the specific mapped addresses area

    - Pay attention to the refresh value ( should equal 241)  when initializing the octospi interface to have better stability for values stored in this ram

    Explorer
    September 23, 2024

    Hi :

    Can you share the settings of MPU with me(it will be better if you can give the source code)?

    I want to use memory map with this IC too.

    Explorer
    September 23, 2024

    Hi, 

    which memory PN are you looking for ?

    Let me just remind that STM32H7B0 supports OPI (APS6408L)... and QSPI DDR (APS12808O-DQ) full spec but have a memory mapped write limitation for QSPI SDR (APS6404L...)

    Thanks

    Alex 

    PS: Overview of IoT RAM (QSPI, OPI  & HPI PSRAM) support

    AlexAPMemory_1-1727083721592.png

    STM32 MCU familyHPI/OPIOPIQSPI SDRQSPI DDRComment
    STM32L4Rx-✓*--*avoid odd address write issue - ADMUX recommended
    STM32L5
    STM32L4P5/Q5
    STM32U575/585
    STM32H5
    - 
    STM32H7A3/B3
    STM32H72x/3x
    -✓** doesn't support QSPI SDR Memory mapped Write mode
    STM32U59x/U5Ax, STM32U5Fx/U5Gx
    STM32H7Rx/Sx
     
    All STM32 supporting NOR QSPI--✓*-* doesn't support QSPI SDR Memory mapped Write mode
    APMemory device256Mb~512Mb
    1.8V
    BGA24/WLCSP
    APS256XXN-OBR/OB9-...
    APS512XXN-OBR/OB9-...
    64Mb~512Mb
    1.8V ~3V
    BGA24/WLCSP
    APS6408L-xOBM-...
    APS12808L-xOBM-BA
    APS12808O-OBR-WB
    APS25608N-OBR-BD
    APS51208N-OBR-BD
    16Mb~128Mb
    1.8V ~3V
    SOP8/USON8/WLCSP
    APS1604M-xSQR-…
    APS6404L-xSQR-...
    APS12808O-SQRH-WA
    128Mb
    1.8V
    WLCSP
    APS12808O-DQ-WA
     

     

    Explorer
    July 25, 2024

    can you give me the the source file pls?