cancel
Showing results for 
Search instead for 
Did you mean: 

New STM32_ExtMem_Manager driver for STM32H7S7 won't erase/write sectors

nico23
Senior III

I'm using an STM32H7S78-DK board and I have a part of the firmware that, from the boot, updates the FLASH from a .bin inside an SD card

The code is pretty simple as I loop the FLASH comparing every sector with the one in the SD card and, if different I erase the internal flash sector and write the new one.

Everything was working correctly until a update the code via CubeMX

The read seems to still working

if (EXTMEM_Read(0, fw_offset, flash_buf, br) != 0)

but as soon as I do the

if (EXTMEM_EraseSector(0, fw_offset, FLASH_SECTOR_SIZE) != 0)

I got an error

The crash happens in

          if (EXTMEM_DRIVER_NOR_SFDP_OK != EXTMEM_DRIVER_NOR_SFDP_SectorErase(&extmem_list_config[MemId].NorSfdpObject,
                                                                              local_address, sector_type))
          {
            retr = EXTMEM_ERROR_DRIVER;
          }

I've rolled back just the driver in the STM32_ExtMem_Manager, and everything started working again

I've noticed that quite a few files have been changed, including the addition of #define EXTMEM_DRIVER_CUSTOM     0

In the conf_template, it could be helpful to understand what's changed. Everything else has stayed the same. Where should I look?

 
Another thing that has changed, if it is useful to understand the changes, is that in stm32_sfdp_driver.c the 
#define ERASE_COMMAND 0x60 has been deleted
 
What could be the issue?
 
I've just found out that I've updated from SLA0044 Rev5/February 2018 to SLA0044 Rev6/October 2025
2 REPLIES 2
Guenael Cadier
ST Employee

Hi @nico23 
I guess you are now using ExtMemManager v1.5.0 right ?
And that you were previously using v1.3.0 ?

The 1.5.0 version contains addition of a new driver inside EMM, called CUSTOM. It is fully separated from the NOR_SFDP driver, so should have no impact on the use of NOR_SFDP driver, as in your configuration.

ERASE_COMMAND define was removed in v1.4.0 and has been replaced by SFDP_DRIVER_ERASE_CHIP_COMMAND which is now located in stm32_sfdp_driver_type.h (same value).
(this define corresponds to the full chip erase instraction, so should not be used when performing EXTMEM_DRIVER_NOR_SFDP_SectorErase().)

If you debug inside EXTMEM_DRIVER_NOR_SFDP_SectorErase() what is the command and type of erase operation that will be executed ?
What is the error code returned by EXTMEM_DRIVER_NOR_SFDP_SectorErase() ?

Regards

Hi @Guenael Cadier ,

I can confirm

#define EXTMEM_VERSION 0x00010500 /* Version v1.5.0 */

I've done various test and at some point I'm seeing driver_check_FlagBUSY function return error EXTMEM_DRIVER_NOR_SFDP_ERROR_BUSY

This is the command I'm launching

EXTMEM_EraseSector(0, fw_offset, FLASH_SECTOR_SIZE); with fw_offset=0 e #define FLASH_SECTOR_SIZE               0x2000UL  /* 8 KB */

                EXTMEM_DRIVER_NOR_SFDP_SectorErase(&extmem_list_config[MemId].NorSfdpObject,
                                                   local_address, sector_type))

local_address=0x24004557
sector_type=EXTMEM_DRIVER_NOR_SFDP_SECTOR_TYPE1

Inside EXTMEM_DRIVER_NOR_SFDP_SectorErase it's executing

    case EXTMEM_DRIVER_NOR_SFDP_SECTOR_TYPE1:
      command = SFDPObject->sfdp_private.DriverInfo.EraseType1Command;
      size = SFDPObject->sfdp_private.DriverInfo.EraseType1Size;
      timeout = SFDPObject->sfdp_private.DriverInfo.EraseType1Timing;
      break;

I can't understand why  local_address hasn't an address of my external memory even if I pass 

EXTMEM_EraseSector(0, fw_offset

with fw_offset=0 (infact it fails at the very first iteration)

why is that?