cancel
Showing results for 
Search instead for 
Did you mean: 

Memory writing problem of STM32L452RE

Raycooldes
Associate II

Hello fellow seniors:
I am still in the learning stage and currently use the part of writing to the memory (Flash Memory). I have encountered a problem and would like to ask for advice:
From the picture (instruction manual) of [[Figure 1]], we can see that the blocks that can be written in the memory are 0x08000000~0x08080000螢幕擷取畫面 2024-05-08 163233.png

For the following questions, please refer to [https://youtu.be/iMChxrvMNG0]

Because I opened the memory to see that some user variables used the previous memory. I was afraid of being overwritten and changed it to 0x8020000 to start writing. However, after writing, I found that the memory will be cleared as long as it is restarted. Have you tried it? I tried to set the Initial break point, but found that it will be cleared as soon as the computer is turned on.
If it is written to 0x0807F800 (the last segment), the memory will not be cleared. However, I looked through the manual and did not see which memory block will be used by the system. I would like to ask why this is?

 

4 REPLIES 4

How does that write data to the memory?

You'd need to select the write tab, and write a .BIN file to a specific address

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

Hello 

Tesla DeLorean:
Sorry for my poor english
Before I test writing memory via CubeProgrammer,I had written memory use
HAL_FLASH_Unlock();
HAL_FLASHEx_Erase();
HAL_FLASH_Lock();

HAL_FLASH_Program(

FLASH_TYPEPROGRAM_DOUBLEWORD, 0x08020000 + (sizeof(test_flash_data) * (flash_cnt1/2)),

test_flash_data);

...etc via Stm32CubeIDE,It's all work fine,and i can see the written memory on 0x08020000

But after soft reset or power reset,the memory that i had written will be returned to 0xFFFFFFFF

 

So i changed my mind to test write memory via CubeProgrammer,After testing,I figured that if i write memory on

0x08020000,the memory block will be reset after disconnect and reconnect.

But if i write memory block at 0x0807F800(the end of memory that can be written),the data that i wrote will

not be format...

 

I'm used to be wondered if that problem is about the mode of power on(0x08000000->0x00000000),

but it's not seems to be this reason.

20240508_STM32L4記憶體被清除的影片.gif

Need to be unlocked to program, so move the lock until afterward

HAL_FLASH_Program(..);

HAL_FLASH_Lock();

 

Your animation shows you edit the PC side memory, it does not illustrate you writing than content on to the STM32 Flash, which is why it disappears after you reconnect.

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

Thanks to the reply of Tesla DeLorean:

On the top was my error type on this website,i was able to write memory into flash successfully.

During these hours,i found that if i entering debugging mode,Cubeide will do a full chip erase.

I surveyed some solution(like modify flash.ld),here is the code in flash.ld that i modify:

/*----------------------------------------------*/

/* Memories definition */

MEMORY

{

RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 160K

RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 32K

/*Total 512K*/

FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 82K(I'm wondering if it is right,the default was 512K)

RAY_DATA (xrw) : ORIGIN = 0x8050000, LENGTH = 50K

/*Total 512K*/

}

/*----------------------------------------------*/

After declaration of RAY_DATA that the address is where i want to put,i adding a section into section below:

/*----------------------------------------------*/

/* Sections */

SECTIONS

{

/* RAY_DATA_KEEP */

.RAY_DATA (NOLOAD) :

{

. = ALIGN(4);

KEEP (*(.RAY_DATA))

. = ALIGN(4);

} >RAY_DATA

/*----------------------------------------------*/

After modified these codes,i did flash function and checked if it is written ok even if i do hardware or software reset

All is fine due to next debugging mode.. If i terminated this session and relaunch, it will do full erase again..

is there somewhere wrong that i didn't noticed?

Thanks...Here is my operation video uploaded on Youtube below.

https://youtu.be/4_NOoPEGdSk