cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0x linker script Flash memory modification, dead after hardware reset

danielbathtub
Associate III

Hi, 

 

For my application I need the following, 

I want to store variables in Flash memory, in order to preserve the data after a Hardware reset. 

My approach is as follows: 

1.) Modify the linker script to keep a page of flash memory outside of the program memory. 

-> Outcome, This I did correctly as seen below, 

danielbathtub_0-1718101306401.png

My flash memory boundaries in the RM and Datasheet for my MCU is shown below: 

danielbathtub_1-1718101392705.png

So, we can see that I have 2 pages free (4 K), where the program will not be stored. 

[The RAM is in the SRAM, which is not in the flash segment of the memory , so this is leaved as is].

 

2.) Modify the Variable which loads the vector table into flash. 

-> Outcome: This is shown below ,found in the system_stm32g0xx.c file. 

danielbathtub_2-1718101598139.png

 

The questions:

With the above facts in mind. Without even  touching the empty blank flash pages. 

My application after a hardware reset does not run, my code does not run after the controller experienced a hardware reset.

Why is this happening, it does not make sense to me ?.   

With the default memory layout the code runs after a hardware reset. 

 

Thanks

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

The reset expects there to be a table at 0x08000000 not some place else. Put your user data slack pages at the END of FLASH by making the size visible to the Linker smaller.

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

View solution in original post

1 REPLY 1

The reset expects there to be a table at 0x08000000 not some place else. Put your user data slack pages at the END of FLASH by making the size visible to the Linker smaller.

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