cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H743 FLASH reprogramming

Handzic.Dirk
Associate III
Posted on June 01, 2018 at 12:10

Hi,

I am porting some firmware from STM32F2 to STM32H743 which is known working good on STM32F205.

I am trying to reprogram internal FLASH on BANK1 while executing code from internal RAM. All routines needed in flash.c and sflash.c are placed in section .fast which is located in AXISRAM and copied at startup from FLASH to RAM.

Reading from USB memory, writing to external serial FLASH (sflash routines in RAM) works fine. After erasing the first sector using flash_EraseSector() the system crashes. I can verify that the first sector is erased using the debug tool.

Can there be a problem with cache? I am a bit lost. I have used this methode on both STM32F2, F4 and F0. Any ideas what could be wrong?

Best regards

Dirk

Some update:

1) The main problem has been a debugger setting in Rowleys Crosswork, 'RAM Software Breakpoints' should be set to 'Disabled' for the STM32H743 specially when debugging code stored in RAM.

2) Since all code used during reprogramming FLASH is in RAM no calls to HAL routines can be used. (I know it could be solved more elegant and safe with switching between FLASH banks)

I attach some working files.

6 REPLIES 6
Nesrine M_O
Lead II
Posted on June 01, 2018 at 13:03

Hi

Handzic.Dirk

,

  • 'the system crashes.' Do you mean that your debug session is lost?

    avoid to read flash content at erase time

  • Could you please share with us a screen shot about the flash status registers?

-Nesrine-

Handzic.Dirk
Associate III
Posted on June 01, 2018 at 13:46

Hi Nesrine,

yes I am loosing the debug session and I have problems to single step or set breakpoints while executing from RAM (I have contacted Rowleys about that since I am using the Crossworks IDE).

What I can say is that basically execution from AXISRAM seems to work since I use serial FLASH access in other parts of the software and I can see in the disassembler field that code is executed at 0x240001A4 for sflash_Read() i e. Serial FLASH reading/writing works.

Since I can not single step while exuting from RAM I can not provide a screen dump right now, but I will as soon as I get a reply from Rowleys.

Dirk

Uwe Bonnes
Principal III
Posted on June 01, 2018 at 14:45

I have not read carefully the code. One question: You are aware that on H& flash is written in 256 bit chunks? One proposal: Try to write with your code on bank 2 with code running on bank 1 to see if parts of your code still are in bank1.

Handzic.Dirk
Associate III
Posted on June 01, 2018 at 14:54

Hi Uwe,

I have not come as far as writing to the FLASH. The crash happens already after erasing the first sector. Regarding the '256 bit chunks', I have read about it but find it confusing since PSIZE1/2 still can be set to 32 bit?

Posted on June 01, 2018 at 15:01

Bonnes.Uwe

+1

In fact regarding STM32H7 flash Programming/Erase:

Minimum granularity of Erase sector is 128Kbytes,

Programming granularity: 256 bits ,this constraint is due to Error Code Correction (ECC) that is always active and is made on a line of 256bits and we cannot do it with less bits else we will get an ECC error.

-Nesrine-

Posted on June 01, 2018 at 15:07

Argh, useing magic numbers is evil!

sector = (sect << 3) & 0x00000078;

Bits 10:8 SNB1: Bank 1 sector erase selection number

These bits are used to select the target sector for a sector erase operation. SNB1 can be

programmed only when LOCK1 is set to `0'.