<?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>string pointer and static address problem</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/41179/string-pointer-and-static-address-problem</link><description> 
Hello, 

 
My problem is as following. I have a string array, If I delete
last string of GprsErrors or pointer of GprsErrors, if I make const
pointer. I don&amp;#39;t get error. 

 
I&amp;#39;m using some static addresses(0x20000309, 0x20000308 .....), I
guess, Keil</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/157892?ContentTypeID=1</link><pubDate>Sat, 09 Jan 2016 03:36:30 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6da6d68b-6250-430e-9cc7-789fcf4131e4</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
But your processor is unlikely to have dual-port memory. So it&amp;#39;s
unlikely that some outside hardware can use a direct pointer to
access the memory.&lt;/p&gt;

&lt;p&gt;
So exactly how is that outside access performed?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/157857?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 22:14:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5bb471b5-7e90-4417-b967-0e7211c00e0a</guid><dc:creator>Kutay Eem</dc:creator><description>&lt;p&gt;&lt;p&gt;
I have decoded, access via fixed address from outside by RF or
gprs.&lt;/p&gt;

&lt;p&gt;
I will try to solve by scatter file,&lt;/p&gt;

&lt;p&gt;
Thanks a lot&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/151606?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 16:44:14 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:cebe8594-4c32-4386-bbea-57544cd6440d</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
Carve out a region for the static stuff in the scatter file, say
0x20000000..0x200003FF, and put your new stuff elsewhere.&lt;/p&gt;

&lt;p&gt;
You&amp;#39;d have to look at how exactly the other data is accessed via
address from outside. If it is through an interface you provide, then
couldn&amp;#39;t you just decode that appropriately?&lt;/p&gt;

&lt;p&gt;
Here we use a more considered command/response system to access
internal parameters, not absolute addresses within our firmware or
RAM footprint.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/147131?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 15:00:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f65e914b-0574-4fd9-a433-fccdf2c181c2</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Note that you can use a scatter file, allowing you to create
custom groups for variables from different modules. Then you can make
sure that the linker finds a solution where it doesn&amp;#39;t overlap
variables with the absolutely positioned variables.&lt;/p&gt;

&lt;p&gt;
With no custom configuration, the linker will think it&amp;#39;s ok to use
all the RAM - and then you or the linker will be unhappy when you add
enough variables that you get overlapping.&lt;/p&gt;

&lt;p&gt;
Another thing to consider is that the profit/value of the company
depends on the quality of the code. So it might be a reason to try to
ask for some time allocated to code architecture work - but it
requires that the company management must be convinced that it
represents a profitable investment.&lt;/p&gt;

&lt;p&gt;
Most code bases requires a not too insignificant percent of the
time on rework to better adapt the code to slowly changing
requirements or to take advantage of new knowledge or tool
improvements. It just isn&amp;#39;t competitive to design the same way today
as 10 years ago.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/145691?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 14:41:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9e8057df-229f-4db4-af68-5bb0debda869</guid><dc:creator>Kutay Eem</dc:creator><description>&lt;p&gt;&lt;p&gt;
Dear Per Westermark, thanks a lot for your valuable comments.&lt;/p&gt;

&lt;p&gt;
You&amp;#39;re right. I&amp;#39;m also agree. I don&amp;#39;t want to use static addresses
and I haven&amp;#39;t used them before but now I have to use because I have
been working for three months for new company.&lt;/p&gt;

&lt;p&gt;
So all of older devices(by older embedded engineers) had designed
at fixed addresses and new devices should support older devices.
There are 250K older devices.&lt;/p&gt;

&lt;p&gt;
What can I do? As an engineer, I&amp;#39;m trying to find a solution.&lt;/p&gt;

&lt;p&gt;
And there is an interesting case.I usually level 3 optimization
for my projects. Older engineers hadn&amp;#39;t used any optimization (namely
optimization level 0). while optimization level 1, devices don&amp;#39;t
work. :)&lt;/p&gt;

&lt;p&gt;
I think I have to work a lot&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/143655?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 08:24:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:90952353-2649-429f-a896-d5c8dbdcc82e</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
If you continue to place variables at fixed addresses, then you
will also have to live with the problems that introduces. Unlucky
designs are gifts that continues to give...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/132018?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 07:56:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f7ff6757-34be-461e-a358-39713e9cf808</guid><dc:creator>Kutay Eem</dc:creator><description>&lt;p&gt;&lt;p&gt;
Sorry again, but the problem still didn&amp;#39;t solve. I&amp;#39;m some
impatient&lt;/p&gt;

&lt;p&gt;
I have defined ram sectios as following&lt;br /&gt;
IRAM1=0xB000&lt;br /&gt;
IRAM2=0x0800 (for bootloader)&lt;/p&gt;

&lt;p&gt;
My compiler results ( with const pointer)&lt;/p&gt;

&lt;p&gt;
Program Size: Code=89900 RO-data=12144 RW-data=448
ZI-data=26176&lt;/p&gt;

&lt;p&gt;
I have made rebuild but I get the same error.&lt;/p&gt;

&lt;p&gt;
when I didn&amp;#39;t find the problem, I don&amp;#39;t trust that project.&lt;/p&gt;

&lt;p&gt;
I&amp;#39;m using AT commands but const data all of them, just pointer
isn&amp;#39;t const and I get error.&lt;/p&gt;

&lt;p&gt;
while const strings increase, as if pointer size increases&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/140923?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 07:51:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:131ae9fd-f8ac-4242-836e-8086adae491a</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
First off - try to avoid playing debugger, i.e. try to avoid raw
memory addresses used externally.&lt;/p&gt;

&lt;p&gt;
Next thing - if you really need to, you should build a table of
indices. So just store a single pointer to this table at a known, and
well selected, address - possibly first or last in RAM or last in
flash.&lt;/p&gt;

&lt;p&gt;
Then use this pointer to access the table of addresses to
important data structures you want to be able to remotely
retrieve.&lt;/p&gt;

&lt;p&gt;
But do not (!) do make this into a two-way interface. If you
really need to control something in your embedded device, then you
really should send _commands_ to it. Only then will your program be
able to decide on the best time to perform the commands. You might
like to pick up newpaper, letters, ... from the mailbox. But you
wouldn&amp;#39;t much like if unknown people walked into your home and placed
mail or boxes on a table or the floor somewhere just because they had
the access and felt that gave them the right...&lt;/p&gt;

&lt;p&gt;
In the end, raw accesses are really problematic and something to
avoid like the plague.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/131575?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 07:07:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:65d8e51a-c1bc-46c6-b427-eb17683ce45a</guid><dc:creator>Kutay Eem</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks for replies.&lt;/p&gt;

&lt;p&gt;
I found the problem, IRAM1 and IRAM2 values had defined as
false.(old micro 128Kb rom, 32kb ram)&lt;br /&gt;
Current Microcontroller is stm32l151 series, there is 48kb ram,&lt;/p&gt;

&lt;p&gt;
False values&lt;br /&gt;
IRAM1=0x6800&lt;br /&gt;
IRAM2=0x0800 (for bootloader)&lt;/p&gt;

&lt;p&gt;
IRAM1 and IRAM2 should have been 0xC000 totally&lt;/p&gt;

&lt;p&gt;
Dear Westonsupermare Pier,&lt;/p&gt;

&lt;p&gt;
I have to use static addresses because old devices had defined
static for remote reading. So I can&amp;#39;t change them.&lt;/p&gt;

&lt;p&gt;

//============================================================================================&lt;/p&gt;

&lt;p&gt;
I have another question about for remote accsess(RF/gsm etc)
registers of microcontroller,&lt;br /&gt;
I use packed structs which have dinamic address. when I access micro
registers, I send struct Id and struct member ID.&lt;/p&gt;

&lt;p&gt;
what about you? what is best method for you?&lt;/p&gt;

&lt;p&gt;
Kutay,&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/137308?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 06:00:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f290f4a0-567e-444c-9a8a-de4435c3bc4c</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
AT directives should really be used as little as possible. They
are there for solving very special problems - and being for advanced
programming, they also tends to bite.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/129142?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 05:25:14 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:474086be-2ec4-4316-a584-981055cf4576</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;I&amp;#39;m using some static addresses(0x20000309, 0x20000308
.....)&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Why are you doing that? You have some AT directive somewhere in
your code or scatter file, which conveniently isn&amp;#39;t shown?&lt;/p&gt;

&lt;p&gt;
Perhaps the problem is that when you add more data to the table
the data expands, and now your rigid AT definitions overlay data that
has already been committed to memory, and the linker complains.
Suggest you remove them, and look at the .MAP file to see where the
memory is now used on your bigger table.&lt;/p&gt;

&lt;p&gt;
If the strings are fixed, consider if &amp;quot;static const&amp;quot; would commit
them to ROM/FLASH&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/120723?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 04:45:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f9b2bf57-8a07-404e-8bd0-dabe1d3b9b36</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
OK - I didn&amp;#39;t realized you talked about deleting a string in the
editor before rebuilding.&lt;/p&gt;

&lt;p&gt;
That extra &amp;quot;const&amp;quot; changes which memory region that will be used
for the data. Const data can be stored in flash, while non-const
initialized data needs a copy in flash that will then be copied into
RW memory to allow you to modify the data during runtime. And the RW
data + ZI (zero-initialized) data must fit into the available RAM you
have configured for the processor.&lt;/p&gt;

&lt;p&gt;
Not sure what your project looks like when it comes to memory
regions, but maybe you overflow the available RAM regions with your
data. The extra &amp;#39;const&amp;#39;, means less data to store into RAM.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/108627?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 04:24:16 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8e394e44-8b58-417a-88ac-f8b928ff8339</guid><dc:creator>Kutay Eem</dc:creator><description>&lt;p&gt;&lt;p&gt;
And I&amp;#39;m using stm32. I have used about 30KB RAM but there is still
free 10KB ram.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/83004?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 04:15:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:776740a0-a20f-4d6f-8f4d-207487a9ae8f</guid><dc:creator>Kutay Eem</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks for repply, Sorry, I didn&amp;#39;t understand you exactly. I have
write my problem as step by step.&lt;/p&gt;

&lt;p&gt;
const char pointer is const char array? That points const char
data. When I added a string more, I&amp;#39;m thinking of change const data
size but not pointer size. So why get I ram overlap error?&lt;/p&gt;

&lt;p&gt;
//===================================================&lt;/p&gt;

&lt;p&gt;
1) when I compile following code. I don&amp;#39;t get any error &lt;b&gt;(no
const pointer, no string)&lt;/b&gt;&lt;/p&gt;

&lt;pre&gt;
char const * GprsErrors[]={
    &amp;quot;BAUDRATE&amp;quot;,
    &amp;quot;AT CMD&amp;quot;,
    &amp;quot;ATE0 CMD&amp;quot;,
    &amp;quot;BAT INIT&amp;quot;,
    &amp;quot;PIN CODE&amp;quot;,
};
&lt;/pre&gt;

&lt;p&gt;
//===================================================&lt;br /&gt;
2) when I compile following code. I get as following error &lt;b&gt;(no
const pointer but just added a string)&lt;/b&gt;&lt;/p&gt;

&lt;pre&gt;
char const * GprsErrors[]={
    &amp;quot;BAUDRATE&amp;quot;,
    &amp;quot;AT CMD&amp;quot;,
    &amp;quot;ATE0 CMD&amp;quot;,
    &amp;quot;BAT INIT&amp;quot;,
    &amp;quot;PIN CODE&amp;quot;,
 &lt;b&gt;&amp;quot;IMEI OK&amp;quot;,   // I added this string  &lt;/b&gt;
};
&lt;/pre&gt;

&lt;p&gt;
..\Output\Project.axf: Error: L6971E: fgetc_b.o(.data) type RW
incompatible with constants.o(.ARM.__AT_0x20000309) type ZI in er
RW_IRAM1.&lt;/p&gt;

&lt;p&gt;
//===================================================&lt;br /&gt;
3) when I compile following code. I don&amp;#39;t get any error again&lt;b&gt;(
added const pointer and string)&lt;/b&gt;&lt;/p&gt;

&lt;pre&gt;
char const * &lt;b&gt;const&lt;/b&gt; GprsErrors[]={
    &amp;quot;BAUDRATE&amp;quot;,
    &amp;quot;AT CMD&amp;quot;,
    &amp;quot;ATE0 CMD&amp;quot;,
    &amp;quot;BAT INIT&amp;quot;,
    &amp;quot;PIN CODE&amp;quot;,
 &lt;b&gt;&amp;quot;IMEI OK&amp;quot;,   // I added this string  &lt;/b&gt;
};
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
//===================================================&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: string pointer and static address problem</title><link>https://community.arm.com/thread/69470?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 03:22:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0c902ea5-114f-4c86-a20d-789bf4dcc9b9</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
First off - think about the difference between a pointer that is
const and may not have the pointer value changed, and a pointer that
points to const data that may not have individual characters
changed.&lt;/p&gt;

&lt;p&gt;
Secondly - you several times writes &amp;quot;deletes&amp;quot; but never show us
what code you have that tries to delete any string.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>