<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>In a scatter file explicitly place variable initializer values in a flash region</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/35203/in-a-scatter-file-explicitly-place-variable-initializer-values-in-a-flash-region</link><description> 
Hi, 

 
Is there a way to explicitly place variable initializer values in
a defined flash region using scatter files? 

 
For example, using the scatter file below, 

 
LOAD_ROM 0x0000 0x8000 ; Name of load region (LOAD_ROM),
 ; Start address for load</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: In a scatter file explicitly place variable initializer values in a flash region</title><link>https://community.arm.com/thread/70837?ContentTypeID=1</link><pubDate>Wed, 01 Aug 2018 01:15:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8384e3e9-5b1d-4954-9d3a-af642167e830</guid><dc:creator>Bolibe java</dc:creator><description>&lt;p&gt;&lt;p&gt;
Is the ultrasonic mouse repellent effective?&lt;/p&gt;

&lt;p&gt;
The ultrasonic mouse repellent device produce the ultrasound that
drives the mouse and most of the insect pests to hear the pain of the
mouse and most of the pests, the sound waves are forced to make the
headache uncomfortably, and the mice will have the symptoms of
anorexia, anorexia, twitching, and even the death of the mice. The
rodent can&amp;#39;t wait to escape the scene immediately; but because the
rodent has a living sex. They will not move easily and come back to
see if they are really unsuitable for a long time, so this product
must be used for a long period of at least ten and a half months to
achieve the purpose of long term repellent of mice.&lt;/p&gt;

&lt;p&gt;
The ultrasonic mouse repellent device also has a time of failure -
the deafness rats are invalid (the mouse is deaf because of the close
relatives, the gene mutation causes deafness); there are also a
slight difference in the degree of ultrasonic reflection in the mice
of different types or different regions.&lt;/p&gt;

&lt;p&gt;
According to the study of animal and entomologist, the frequency
range of the ears can be different in all kinds of animals, which is
basically the inverse ratio between the size of the body and the
frequency of hearing, that is, the less the hearing frequency is, the
higher the hearing frequency is.&lt;/p&gt;

&lt;p&gt;
&lt;a href="https://www.h-nec.com/"&gt;https://www.h-nec.com/&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In a scatter file explicitly place variable initializer values in a flash region</title><link>https://community.arm.com/thread/70836?ContentTypeID=1</link><pubDate>Wed, 01 Aug 2018 01:12:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:209ff3b1-0713-4e16-94d7-1347e4beffbc</guid><dc:creator>Bolibe java</dc:creator><description>&lt;p&gt;&lt;p&gt;
Can electronic mouse repellent device drive rats?&lt;br /&gt;
Answer: so far, there is no relevant literature or background
information in the scientific community and reports that electronic
mouse repellent device can stimulate the rats and achieve the goal of
driving. Instead of using electromagnetic waves will interfere with
household appliances, and the input of electromagnetic waves into the
power system for many electric equipment such as audio, television,
computer and other household appliances will have a certain
interference and damage, and the exposure to high frequency
electromagnetic wave radiation will also bring some harm to the human
body. Use this kind of product. This also explains why all relevant
departments of the world require all electrical appliances to be used
in the network to be used by EMI electromagnetic authentication. In
1998, the WHO survey showed that electromagnetic waves have five
major effects on human body: A and electromagnetic waves are the main
causes of cardiovascular disease, diabetes and cancer mutation; B and
electromagnetic waves cause direct injury to the human reproductive
system, the nervous system and the immune system; C and
electromagnetic waves are induced by abortion, infertility,
teratology and other pathological changes. Factors: D, excessive
electromagnetic wave radiation directly affect the development of
brain tissue, bone marrow development, vision decline, liver disease,
hematopoietic function decline, serious people can lead to retinal
detachment; E, electromagnetic wave radiation can make male sexual
function decline, female endocrine disorder, menstrual disorder.&lt;/p&gt;

&lt;p&gt;
However, can the IR mouse repellent device drive rats? A lot of
scientific experiments show that mice are color blindness, and
amblyopia animals, human beings are tricolor vision, red, blue, green
vision, and mice are two color vision can only distinguish the
ultraviolet light blue color wavelength of 359nm and green wavelength
510nm, the mouse&amp;#39;s visual 88% sense It should be green, and only 12%
can sense the color of ultraviolet light blue. Now on the market,
some merchants sell the repellent claims that there is no scientific
basis for infrared repellent function, because the infrared
wavelength is in the range of 800nm-1000nm, which is far away from
the color light that mice can see. It is absurd to use infrared rays
to remove mice.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In a scatter file explicitly place variable initializer values in a flash region</title><link>https://community.arm.com/thread/131688?ContentTypeID=1</link><pubDate>Sun, 29 Jul 2018 00:07:28 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a1a8edc2-8324-47c2-878a-04903ae358b5</guid><dc:creator>Dung Do Dang</dc:creator><description>&lt;p&gt;&lt;p&gt;
To explicitly place a variable into FLASH (or other valid
addresses) you can use a compiler-specific-feature; attribute
keyword.&lt;/p&gt;

&lt;p&gt;
To place your aGlobalVar at the absolute address 0x00021C00, you
can do this:&lt;/p&gt;

&lt;pre&gt;
int aGlobalVar __attribute__((at(0x00021C00))) = 0xDEADBEEF;
&lt;/pre&gt;

&lt;p&gt;
The ARM linker will place the value 0xDEADBEEF at the address
0x00021C00.&lt;br /&gt;
The value of aGlobalVar is 0xDEADBEEF.&lt;br /&gt;
The address of aGlobalVar is 0x00021C00.&lt;/p&gt;

&lt;p&gt;
As directed by Westonsupermare Pier:&lt;br /&gt;
Creating new ER region ER_BEACON_CONFIGURATION_DATA in the scatter
file and&lt;/p&gt;

&lt;pre&gt;
int aGlobalVar __attribute__((section(&amp;quot;ER_BEACON_CONFIGURATION_DATA&amp;quot;))) = 0xDEADBEEF;
&lt;/pre&gt;

&lt;p&gt;
will place the 0xDEADBEEF in the address defined for
ER_BEACON_CONFIGURATION_DATA in the scatter file. And, the compiler
will generate scatter load codes to copy the data in
ER_BEACON_CONFIGURATION_DATA to RAM to be called in __main().&lt;/p&gt;

&lt;p&gt;
One main difference between the two methods is where the
aGlobalVar is located in memory.&lt;br /&gt;
In the first method, every time you access aGlobalVar it will go to
0x00021C00 (FLASH?).&lt;br /&gt;
In the second method, every time you access aGlobalVar it will go to
RAM address assigned by the linker (you dont know it&amp;#39;s address before
the linker has done it work).&lt;/p&gt;

&lt;p&gt;
Obviously, the second method is faster if you run code from
flash.&lt;/p&gt;

&lt;p&gt;
Note1: to compile under ARMCC6, GNU GCC, IAR or other compilers,
you have to change the syntax for the __attribute__ keyword.&lt;/p&gt;

&lt;p&gt;
Note2:&lt;/p&gt;

&lt;pre&gt;
ER_BEACON_CONFIGURATION_DATA 0x00021C00 FIXED 0x400 { ; Beacon configuration
   beaconconfiguration.o (+RO +RW)
  }
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
The linker will place code and data (RO and RW) generated by the
compiled beaconconfiguration.c into this flash section.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In a scatter file explicitly place variable initializer values in a flash region</title><link>https://community.arm.com/thread/129556?ContentTypeID=1</link><pubDate>Thu, 26 Jul 2018 09:54:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7fd1e53a-b303-4a32-bc9f-e857d7683a38</guid><dc:creator>LJ Ye</dc:creator><description>&lt;p&gt;&lt;p&gt;
Please read the manual in progress. But yeah we understand initial values have to
live in FLASH, we were just confused about if we can control where
those values are placed.&lt;/p&gt;

&lt;p&gt;
Maybe our mistake was not realizing each execution block contains
a ROM and RAM block (ie as far as linker is concerned,
ER_BEACON_CONFIGURATION_DATA and RW_IRAM1 are the same execution
block), and any initial values used to initialize RAM variables
specified in the RAM block are placed in the corresponding ROM
block?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In a scatter file explicitly place variable initializer values in a flash region</title><link>https://community.arm.com/thread/121359?ContentTypeID=1</link><pubDate>Thu, 26 Jul 2018 09:22:47 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c34d684f-8eea-4740-a873-9cf30119b518</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;gt;&amp;gt;The reason we are asking is we are seeing unexpected
values getting placed in the last FLASH region we declared in the
scatter file, and the values match those used to initialize some
global variables.&lt;/p&gt;

&lt;p&gt;
See the reason you have this problem is that you believe these
things are there &amp;quot;unexpectedly&amp;quot;, when actually the linker&amp;#39;s doing its
job, and the values for your global variables, which are non-zero,
have to manifest from somewhere.&lt;/p&gt;

&lt;p&gt;
Linker packs initialization data beyond your code, loader unpacks
into volatile memory, because that like disappears when the power is
removed, and needs to come from some place that remembers it a tad
more permanently.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In a scatter file explicitly place variable initializer values in a flash region</title><link>https://community.arm.com/thread/149081?ContentTypeID=1</link><pubDate>Thu, 26 Jul 2018 08:50:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bb0ce182-a9fc-46b9-be13-4db499e812e6</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
The questioner there is using the load region entirely wrong.&lt;/p&gt;

&lt;p&gt;
Look it&amp;#39;s not my job to train you to do your job, or perform your
job.&lt;/p&gt;

&lt;p&gt;
If you don&amp;#39;t understand the concepts of the scatter file, and the
role of the linker, and startup code, it&amp;#39;s not really my problem.
Trying to point you in the right direction to find a solution to your
issue, but not paid enough to do it for you, and get you past the
mind-block where you insist it must do things a certain way without
understanding how the mechanics actually work and the degrees of
freedom you have to change things, or alter the outcome.&lt;/p&gt;

&lt;p&gt;
Feel free to Please read the manual, and understand it, and work with your Keil
account manager to resolve your support issues.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In a scatter file explicitly place variable initializer values in a flash region</title><link>https://community.arm.com/thread/129557?ContentTypeID=1</link><pubDate>Thu, 26 Jul 2018 08:29:22 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:74b65af6-78e1-4c7c-85b6-74212c7857a6</guid><dc:creator>LJ Ye</dc:creator><description>&lt;p&gt;&lt;p&gt;
I don&amp;#39;t feel like our questions are answered. We have the exact
same issue as described in here: &lt;a href="http://www.keil.com/forum/23430/scatter-files-and-initialization-of-ram-data/"&gt;
&lt;a href="http://www.keil.com/forum/23430/scatter-files-and-initialization-of-ram-data/"&gt;www.keil.com/.../&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In a scatter file explicitly place variable initializer values in a flash region</title><link>https://community.arm.com/thread/121357?ContentTypeID=1</link><pubDate>Wed, 25 Jul 2018 16:15:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bb7047b6-c189-489f-baf1-19397ae4625b</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
The Load Region describes where to store things, the link packs
things there, and the scatter loader (__main) unpack them.&lt;/p&gt;

&lt;p&gt;
Everything you describe in LR_IROM will be packed in there
end-to-end, along with a linker generated table describing where
things are, and where they go.&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.keil.com/support/man/docs/armlink/armlink_pge1362065953229.htm"&gt;
&lt;a href="http://www.keil.com/support/man/docs/armlink/armlink_pge1362065953229.htm"&gt;www.keil.com/.../armlink_pge1362065953229.htm&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.keil.com/support/docs/3629.htm"&gt;http://www.keil.com/support/docs/3629.htm&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In a scatter file explicitly place variable initializer values in a flash region</title><link>https://community.arm.com/thread/109538?ContentTypeID=1</link><pubDate>Wed, 25 Jul 2018 15:37:14 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6131df1c-878e-46d6-b334-63105be9f5ce</guid><dc:creator>LJ Ye</dc:creator><description>&lt;p&gt;&lt;p&gt;
We are not trying to store a const value in FLASH.&lt;/p&gt;

&lt;p&gt;
We are wondering where in FLASH are all the values used to
initialize RAM variables are stored, and if it is possible to
explicitly place those values in a known FLASH region.&lt;/p&gt;

&lt;p&gt;
The reason we are asking is we are seeing unexpected values
getting placed in the last FLASH region we declared in the scatter
file, and the values match those used to initialize some global
variables.&lt;/p&gt;

&lt;p&gt;
Attaching our scatter file:&lt;/p&gt;

&lt;pre&gt;
LR_IROM1 0x0001D000 0x00023000  {    ; load region size_region
  ER_IROM1 0x0001D000 0x00004000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot&amp;#36;&amp;#36;Sections)
   .ANY (+RO)
  }

  ER_BEACON_POWERSTATE_DATA 0x00021000 FIXED 0x400 { ; Power state data used by the beacon
   powerstate.o (+RO +RW)
  }

  ER_BEACON_TRANSMITLEVEL_DATA 0x00021400 FIXED 0x400 { ; Transmit power level of the beacon
   transmitpower.o (+RO +RW)
  }

  ER_BEACON_CONFIGURATION_DATA 0x00021C00 FIXED 0x400 { ; Beacon configuration
   beaconconfiguration.o (+RO +RW)
  }

  RW_IRAM1 0x20002200 0x00001E00  {  ; RW data
   .ANY (+RW +ZI)
  }
}
&lt;/pre&gt;

&lt;p&gt;
We are seeing unexpected values getting placed in
ER_BEACON_CONFIGURATION_DATA region that clearly do not belong to
beaconconfiguration.o. These values do not have an entry in the .map
file, and they match values we use to initialize some global
variables.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In a scatter file explicitly place variable initializer values in a flash region</title><link>https://community.arm.com/thread/94474?ContentTypeID=1</link><pubDate>Wed, 25 Jul 2018 14:56:10 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0d45dd2d-a448-40d3-9f21-e8ab317961d4</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
The linker builds it into a static initialization table that
unpacks the load region into volatile memories. The code doing the
static copy is in __main and once complete jumps to your main()
function.&lt;/p&gt;

&lt;p&gt;
To have a variable in ROM, that stays there, consider using
&amp;quot;static const&amp;quot;&lt;/p&gt;

&lt;p&gt;
Want it at some specific address? Consider making a different load
region where you shrink the current one slightly, and have the second
one at the end, and then direct specific content into sections
therein.&lt;/p&gt;

&lt;p&gt;
ie&lt;/p&gt;

&lt;pre&gt;
LOAD_ROM 0x0000 0x7F00
{
..
}
CONST_ROM 0x7F00 0x0100
{
..
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: In a scatter file explicitly place variable initializer values in a flash region</title><link>https://community.arm.com/thread/70835?ContentTypeID=1</link><pubDate>Wed, 25 Jul 2018 13:59:03 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5f2c4df0-6087-4285-8934-b560d3866868</guid><dc:creator>LJ Ye</dc:creator><description>&lt;p&gt;&lt;p&gt;
Just to add to the original question:&lt;br /&gt;
After the project is compiled, if I look at the .map file, I would
see an entry for aGlobalVar getting placed at some RAM address. But
there wouldn&amp;#39;t be any entry for placing 0xDEADBEEF in the flash
anywhere (although we know it must live somewhere in FLASH).&lt;/p&gt;

&lt;p&gt;
Am I not looking at the right places?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>