there is one startup file (which we will learn for sure, Pakka, line to line) and other library files. Now linker has many files and the objects to handle. SO, have to be very careful while handling scatter file, and objects and variables in it. What I wanted to tell is that scatter file is blindly followed by linker.
#Rom memory variable in keil mdk arm code
When it boots, the startup code tries to access the illegal location and fails doing nothing. It maps all your variables (RW data, ZI data, for example) to that location. You can tell, your RAM address starts from 0x10000000 and it will believe. Linker abides by the rule of the scatter file. Scatter file is like guideline for the linker. Was i fast anywhere, by the way? nope :)Ī little modified scatter file - another view
![rom memory variable in keil mdk arm rom memory variable in keil mdk arm](https://img.yumpu.com/5336521/1/500x640/using-the-mcbstm32c-evaluation-board-keil.jpg)
Here are the changes i have done in our custom scatter file ( sounds like a pro) Second one i have modified Small things only. first image is as is right after renaming it. Both are contents of our scatter file only. Observe the difference between two images. memory area in flash where you like to monitor the value using third party tool etc.
![rom memory variable in keil mdk arm rom memory variable in keil mdk arm](https://blog.st.com/wp-content/uploads/arm-keil-1280x720.jpg)
memory area shared by multiple resources.saving important variables in memory area where you can protect.I do not know much use cases but a few are but there are n number of use cases where you have to keep things in order. If i am the programmer, and i do not have any problem with memory allocation of the variable by Keil default scatter file and linker, it is okay. The variables have taken locations as they wish. I am not Lazy but i am in energy save mode :) The addresses of variables in second file we can see in the image right? i am not typing again. Memory addresses of variables in source file project2.c Step 4: Scatter file Syntax from ARM linker file Right Side there is 0x0800 0000 and maximum allocated is 1 MB (0x0010 0000) We will see the startup file too in detail but for the moment, let us focus only on the scatter file. it is because, it has kept 512 (0x200) bytes of memory to Stack i guess. The scatter file stops the RAM at 0x18000.The RAM in STM32L467RG which is on this particular Nucleo board is 128 KBytes (0x20000) RW_IRAM1 is just a label, 0x2000000 is the location where the RAM region starts. RAM is where variables are placed during code execution.So, our execution region will be from 0x08000000 and can be upto 0x08100000. 0x00100000 corresponds to 1 MegaByte of memory location, which is true for the STM32 Nucleo board we have.0x08000000 is the start address of Flash Memory in STM32L476 MCU ( See Pic Below).
![rom memory variable in keil mdk arm rom memory variable in keil mdk arm](http://www.emprog.com/emprog/images/keil-arm-mdk-1.jpg)