cancel
Showing results for 
Search instead for 
Did you mean: 

OCTOSPI with STM32H573 and ISSI external flash IS25LX064. Memory mapped write causes Hardfault

aco990
Associate III

Hi @Tesla DeLorean ,
I use the IS25LX064 OctoSPI Flash memory with the STM32H573 and i can write and read from memory using direct mode. In memory mapped mode i can read the flash correctly for 0x90000000 but writing at 0x90000000 using memory mapped mode causes a hard fault with precise error at 0x90000000.

Does that mean it's not possible to write to the flash in memory mapped mode? RM0481 says:

aco990_0-1723546812483.png

 

Line 44 fails. Line 34 and 35 are working fine. And if i write using line 34 and then enable the memory mapped mode the read sequence from line 54 works fine, which means the memory mapped mode configuration is ok.

 

int main(void) {

	/* USER CODE BEGIN 1 */
	__IO uint8_t *mem_addr;
	  uint32_t address = 0;
	/* USER CODE END 1 */

	/* MCU Configuration--------------------------------------------------------*/

	/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
	HAL_Init();

	/* USER CODE BEGIN Init */

	/* USER CODE END Init */

	/* Configure the system clock */
	SystemClock_Config();

	/* USER CODE BEGIN SysInit */

	/* USER CODE END SysInit */

	/* Initialize all configured peripherals */
	MX_GPIO_Init();
	MX_ICACHE_Init();
	MX_OCTOSPI1_Init();
	/* USER CODE BEGIN 2 */
	ResetMemory(&hospi1);
	OSPI_DummyCycles(&hospi1);
	OSPI_EraseSector(&hospi1, address);
	
        /*---- direct read and write works fine--------*/
          //OSPI_Write(&hospi1, aTxBuffer, address, BUFFERSIZE);
	  //OSPI_Read(&hospi1, aRxBuffer, address, BUFFERSIZE);

	OSPI_EnableMemoryMapped(&hospi1);

	/*It is not recommended to program the flash memory using the memory-mapped writes:
	the indirect-write mode fulfills this operation. See RM0481 Rev 2 section 23.4.15*/
	/* Writing Sequence ----------------------------------------------- */
	mem_addr = (uint8_t*) (OCTOSPI1_BASE + address);
	for (uint16_t index = 0; index < BUFFERSIZE; index++) {
		*mem_addr = aTxBuffer[index]; /*-------- bus fault here -----*/
		mem_addr++;
	}

	/* In memory-mapped mode, not possible to check if the memory is ready
	 after the programming. So a delay corresponding to max page programming
	 time is added */
	HAL_Delay(2);

	/* Reading Sequence ----------------------------------------------- */
	mem_addr = (uint8_t*) (OCTOSPI1_BASE);
	for (uint16_t index = 0; index < BUFFERSIZE; index++) {
		if (*mem_addr != aTxBuffer[index]) {
			Error_Handler();
		}
		mem_addr++;
	}
	/* USER CODE END 2 */

	/* Infinite loop */
	/* USER CODE BEGIN WHILE */
	while (1) {
		/* USER CODE END WHILE */

		/* USER CODE BEGIN 3 */
	}
	/* USER CODE END 3 */
}

 

 


Thank you




 

1 ACCEPTED SOLUTION

Accepted Solutions
KDJEM.1
ST Employee

Hello @aco990 ,

Is the DQS output is disabled? 

Could you please take a look at the errata sheet and precisely 2.5.1 Memory-mapped write error response when DQS output is disabled.

KDJEM1_0-1723553734166.png

 

May OSPI_NOR_MemoryMapped can help you. This example describes how to erase a part of an OSPI NOR memory, write data in memory-mapped mode and access to OSPI NOR memory in memory-mapped mode to check the data in an infinite loop and runs on STM32H573IIKxQ devices.

I hope this help you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3

I wouldn't anticipate this working, and I don't see a template setup for the write operation. Writes tending to have specific alignment and buffer size expectations, write enable prior, and waiting for completion after. The peripheral isn't that complex. 

RAM devices might have less limitations. 

Use HAL_xSPI_Abort() to terminate Memory Mapped operation. 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
KDJEM.1
ST Employee

Hello @aco990 ,

Is the DQS output is disabled? 

Could you please take a look at the errata sheet and precisely 2.5.1 Memory-mapped write error response when DQS output is disabled.

KDJEM1_0-1723553734166.png

 

May OSPI_NOR_MemoryMapped can help you. This example describes how to erase a part of an OSPI NOR memory, write data in memory-mapped mode and access to OSPI NOR memory in memory-mapped mode to check the data in an infinite loop and runs on STM32H573IIKxQ devices.

I hope this help you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello @KDJEM.1,
looking at the schematic the DQS Pin of the flash is not used. But enabling DSQ for write operations as explained in errata sheet 2.5.1 fixed the problem.  I can now write in memory mapped mode without any errors.

Thanks you!