How to Place a variable in custom location of MCU internal Flash Memory?
Now, it is getting interesting. We were able to place the RAM variables into the loctions we neded. We took help of scatter file which was generated by default. We then edited it. We informed Keil to use our own scater file. We partioned RAM into several blocks. We assigned RO data, ZI data of differect pbject files into each block of RAM. We tested it to make sure it works.
Now, I am trying to place a variable in custom Flash memory location. I want to know the exact location of the value in the flash memory. This has several appliaitons.
- I can take help of this information of the variable in the flash memory to decide what is the type of the software loaded
- Bootloader can make use of this information to understand whether there is a valid application code or not
- Bootloader can also use this information to decide which part of application to load ( ex.: if the MCU has too many applications in same package)
- I can also use this as a key to verify whether some operation was done on this product already or not. if the operation was done the code will erase the key and write a new value.
- and some more applications which are not listed here :)
I have declared two load region in the scatter file. The new load region is called LR_SECRET_IROM1.
I have declared the variable in a separate C file. That C file contains only the declaration of the variable. nothing else. Below pictures should help to understand what i am trying to do.
Header file: Project3.h |
Flash variable with the programmed address location and also the value now visible |
So, i was able t successfully place the variable in Internal flash memory in the region i wanted. We also placed the variables in RAM. That is different story. Placing variables in Flash was little challenging.
So, what next?
In the coming posts, i want to access this location in the code and try to read the value. If the value matches expected value, then i will write another value in another location. This is to learn run time flash memory access. it si helpful in the future for boot loader application.
I think, until now, scatter file has helped a lot. We will dig into accessing flash memory in coming posts. Also, we will look at MAP file once more with a simple MAP file viewer.
Hack Netflix account. now use Neflix account free for always.click to follow simple steps
ReplyDeleteGuaranteed Success.
Hack Netflix Account
Nice experiments. I read all of them and I can say for now they are the most straightforward you can find on the Internet to understand the bare basics on Keil, Scatter files and Map files. Almost all is focused on GNU compiler and Eclipse, not Keil... :(
ReplyDeleteGood job.