2025-08-07 7:47 PM - last edited on 2025-08-27 6:56 AM by Amel NASRI
I'm trying unsuccessfully to erase a 4K sector at 0x73ff0000 using STM32CubeIDE code, but the STM32CubeProgrammer works fine. I've tried using BSP_OSPI_NOR_Erase_Block() and MX25LM51245G_BlockErase() with no luck.
My code base is the HTTP_IOT_WebServer example. My basic code is (where addr=0x73FF0000 and EFLASH_SECTOR_MASK=0x03FFF000)
-------------------------------------------
BSP_OSPI_NOR_DisableMemoryMappedMode(0);
rc = MX25LM51245G_BlockErase(&hospi_nor[0], MX25LM51245G_SPI_MODE, MX25LM51245G_STR_TRANSFER,
HAL_OSPI_ADDRESS_32_BITS, addr & EFLASH_SECTOR_MASK,
MX25LM51245G_ERASE_4K);
BSP_OSPI_NOR_DisableMemoryMappedMode(0);
-------------------------------------------
Any idea why this doesn't work? Is the Programmer doing anything I'm not doing?
-Marty
2025-08-07 10:21 PM
Read the Status Register, and check the BPB (Block Protection Bits)
2025-08-10 6:54 PM
Status Reg = 0x00 before and after attempt to erase. The BP0-BP3 bits are zero, no protection.
-Marty
2025-08-10 7:14 PM
>>Any idea why this doesn't work? Is the Programmer doing anything I'm not doing?
The memory is not in the mode you think it is?
ie Not in SPI mode, not in 32-bit mode
Look at what exactly is being sent. Describe the nature of the failure. Does it complete immediately? Ignore the command? Not erase? Not respond to other commands?
You've sent a Write Enable? It spends some time in Wait for Complete? A 64KB sector erase at a 64 KB boundary? Zero-Basis address?