cancel
Showing results for 
Search instead for 
Did you mean: 

Writing from Bootloader on STM32H735

HispaEmo
Associate III

Hello everyone,

I am currently working on a bootloader project for the STM32H735, using the pre-configured ExtMem_Boot project provided by the STM32CubeIDE. However, I am encountering an issue when trying to write to the external flash memory at address 0x90000000.

Problem Description

I am using the function BSP_OSPI_NOR_Write to write data to the external flash memory. Here is the code snippet that performs the write operation:

 

HispaEmo_0-1718294101014.png

Issue Encountered

When the code enters the function BSP_OSPI_NOR_Write, it fails at the following point within the HAL_OSPI_Transmit function:

 

/* Wait till transfer complete flag is set to go back in idle state */
status = OSPI_WaitFlagStateUntilTimeout(hospi, HAL_OSPI_FLAG_TC, SET, tickstart, Timeout);

 

This error occurs specifically during the execution of the MX25LM51245G_PageProgramDTR function call:


/* Issue page program command */ if (MX25LM51245G_PageProgramDTR(&hospi_nor[Instance], (uint8_t*)data_addr, current_addr, current_size) != MX25LM51245G_OK) { ret = BSP_ERROR_COMPONENT_FAILURE; }

 

Additional Information

Despite this error, the jumptoapp function seems to execute correctly. However, I am unable to determine the root cause of this issue.

Request for Help

I would greatly appreciate any insights or suggestions on what might be causing this issue. Has anyone encountered similar problems or have experience with writing to external flash memory on the STM32H735? Any tips or advice on how to resolve this would be extremely helpful.

Thank you in advance for your assistance!

Best regards,
Emilio

5 REPLIES 5
HispaEmo
Associate III

I want to provide a bit more context to help you understand my issue and offer some guidance.

Specifically, I'm trying to implement a function that reads a .bin file from the SD card and writes it to the address 0x90000000.

I am using the BSP_OSPI_NOR_Write function for this task. However, I encountered an issue when I comment out the MemoryMapped mode in OSPI_Startup:

 

HispaEmo_0-1718360518315.png

When this section is commented, the code does not get stuck at MX25LM51245G_AutoPollingMemReady, but I always encounter a timeout error with MX25LM51245G_PageProgram.

 

HispaEmo_1-1718360600836.png

 

Has anyone encountered a similar issue or have any suggestions on how to resolve this? Any advice on correctly writing the .bin file to 0x90000000 would be greatly appreciated.

Thank you!

 

 

 

Memory Mapped mode can't be used concurrently with command mode.

When not memory mapped, you can't access / see the memory content at 0x90000000

The OSPI Memory doesn't understand the mapping in the STM32, so it's address is zero based, so you'll want to mask the address passed in.

ie

.Address = address & 0x0FFFFFFF; // Mask to lower 28-bits

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

Thank you, I can run my code.

But Im trying to:

HispaEmo_1-1718370255471.png

with

uint8_t aTxBuffer[] = " ****Memory-mapped OSPI communication**** ****Memory-mapped OSPI communication**** ****Memory-mapped OSPI communication**** ****Memory-mapped OSPI communication**** ****Memory-mapped OSPI communication**** ****Memory-mapped OSPI communication**** ";

but:

 

HispaEmo_2-1718370327734.png

 

is something wrong?

I changed this as you say:

HispaEmo_3-1718370384452.png


many many thanks @Tesla DeLorean 

HispaEmo
Associate III

sorry i was comment BSP_OSPI_NOR_DisableMemoryMappedMode(0);

HispaEmo_4-1718370969338.png

 

MNapi
Senior III

You can always use this code to write then enable memory mapped mode later and read from 0x90000000

You write to address = 0

This code is working on me on H7 chip and same MX25LM5124

I had some problems too to write in mapped mode.

 

/* Configure the memory in octal mode ------------------------------------- */

OSPI_OctalModeCfg(&hospi1);

sCommand.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
sCommand.FlashId = HAL_OSPI_FLASH_ID_1;
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE;
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;

 

OSPI_WriteEnable(&hospi1);

/* Erasing Sequence -------------------------------------------------- */
sCommand.Instruction = OCTAL_SECTOR_ERASE_CMD;
sCommand.AddressMode = HAL_OSPI_ADDRESS_8_LINES;
sCommand.Address = address;
sCommand.DataMode = HAL_OSPI_DATA_NONE;
sCommand.DummyCycles = 0;

if (HAL_OSPI_Command_IT(&hospi1, &sCommand) != HAL_OK)
{

Error_Handler();
}

/* Configure automatic polling mode to wait for end of erase ------ */

OSPI_AutoPollingMemReady(&hospi1);

/* Enable write operations ---------------------------------------- */
OSPI_WriteEnable(&hospi1);

/* Writing Sequence ----------------------------------------------- */
sCommand.Instruction = OCTAL_PAGE_PROG_CMD;
sCommand.DataMode = HAL_OSPI_DATA_8_LINES;
sCommand.NbData = BUFFERSIZE;

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

Error_Handler();
}

if (HAL_OSPI_Transmit_IT(&hospi1, aTxBuffer) != HAL_OK)
{

Error_Handler();
}