Skip to main content
Mayank1
Associate II
January 28, 2021
Question

Hard Fault while accessing external flash memory configured in memory mapped mode

  • January 28, 2021
  • 7 replies
  • 5503 views

Hi,

I have been working on implementing external flash driver integration with TouchGFX on STM32G474-eval board, in memory mapped mode.

I have configured the QSPI in Bank 1 with Single/Dual lines. I have attached an image of my CubeMx configuration.

I am getting hard fault while accessing any memory area of external flash. But, while in debug mode, I am able to access the memory address, for example: 0x90000000.

Below are my QSPI initialisation sequence :

uint8_t CSP_QUADSPI_Init(void) {

if(CSP_QSPI_Erase_Chip() != HAL_OK)

{

return HAL_ERROR;

}

if (QSPI_AutoPollingMemReady(HAL_QSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {

return HAL_ERROR;

}

if (QSPI_WriteEnable() != HAL_OK) {

return HAL_ERROR;

}

if (QSPI_Configuration() != HAL_OK) {

return HAL_ERROR;

}

if (QSPI_AutoPollingMemReady(HAL_QSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {

return HAL_ERROR;

}

return HAL_OK;

}

uint8_t CSP_QSPI_EnableMemoryMappedMode(void) {

QSPI_CommandTypeDef sCommand;

QSPI_MemoryMappedTypeDef sMemMappedCfg;

/* Enable Memory-Mapped mode-------------------------------------------------- */

sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;

sCommand.AddressSize = QSPI_ADDRESS_32_BITS;

sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;

sCommand.DdrMode = QSPI_DDR_MODE_DISABLE;

sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;

sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;

sCommand.AddressMode = QSPI_ADDRESS_1_LINE;

sCommand.DataMode = QSPI_DATA_1_LINE;

sCommand.NbData = 0;

sCommand.Address = 0;

sCommand.Instruction = 0x0BU;

sCommand.DummyCycles = 4;

sMemMappedCfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE;

if (HAL_QSPI_MemoryMapped(&hqspi1, &sCommand, &sMemMappedCfg) != HAL_OK) {

return HAL_ERROR;

}

return HAL_OK;

}0693W000007D2OTQA0.png

This topic has been closed for replies.

7 replies

Romain DIELEMAN
ST Employee
January 28, 2021

Hi,

Could you provide some screenshots of the error ? Have you started your project from scratch ?

This is not a TouchGFX related question, could you edit and add the corresponding "Topic" tags (like QSPI and your mcu) ? This will help increasing this post's visibility and getting the right help/knowledgeable people .

/Romain

Tesla DeLorean
Guru
January 28, 2021

What make/model of flash part?

Whilst executing code or moving data?

Show a register dump and code at fault.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Mayank1
Mayank1Author
Associate II
February 9, 2021

External flash model is MT25QL512ABB-Micron. I want to configure QSPI in single/Dual mode, not in Quad mode.

0693W000007ES7aQAG.png

Tesla DeLorean
Guru
February 9, 2021

Ok, but that's the Hard Fault Handler, not the site of the fault itself.

You need to go unpack what was happening in the getTextureMapperDrawScanLine()

Why do you erase the memory in the initialization code, won't that break things? ie pointers loading as 0xFFFFFFFF ?

The initialization code makes little sense. You shouldn't need to write enable

Look at the STM32G474-EVAL BSP code

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..