<?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>Code compiled with GNU gives memory problem</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/20880/code-compiled-with-gnu-gives-memory-problem</link><description> 
Hi, 

 
Setup: 
- Keil MCB2103 Evaluation Kit 
- Keilmdk303j.exe installed 
- gccARM331.exe installed 

 
I did a little software with I2C, Timer, WD, etc. It compiled with
the Keil compiler. I tried the software on flash and ram and worked
as expected</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/152609?ContentTypeID=1</link><pubDate>Fri, 29 Dec 2006 06:55:30 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:cc746ac3-c8d7-48b6-95bd-fef46c72126d</guid><dc:creator>David Perreault</dc:creator><description>&lt;p&gt;&lt;p&gt;
I think you are right&lt;/p&gt;

&lt;p&gt;
Thanks for all the tips!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/151833?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2006 15:16:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6d4749e2-bdab-44e6-9678-5ad8d8c3f4d7</guid><dc:creator>Dan Henry</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;But I still want to know what is the difference between the
two syntax&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Isn&amp;#39;t it that &amp;quot;IRQ&amp;quot; is implicit with ((interrupt)) compared to the
explicit ((interrupt(&amp;quot;IRQ&amp;quot;))) and that ((interrupt(&amp;quot;???&amp;quot;))) supports
others like FIQ?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/147317?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2006 14:47:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0a550c2b-62ac-4846-89a0-f4df4d7ceff6</guid><dc:creator>David Perreault</dc:creator><description>&lt;p&gt;&lt;p&gt;
Looks like with:&lt;/p&gt;

&lt;pre&gt;
void timerInt(void) __attribute__ ((interrupt(&amp;quot;IRQ&amp;quot;)));
void i2cISR(void) __attribute__ ((interrupt(&amp;quot;IRQ&amp;quot;)));
&lt;/pre&gt;

&lt;p&gt;
it is working.&lt;/p&gt;

&lt;p&gt;
But I still want to know what is the difference between the two
syntax&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/146025?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2006 13:39:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:eaeb5b84-4341-4557-addf-3da09aca219f</guid><dc:creator>David Perreault</dc:creator><description>&lt;p&gt;&lt;p&gt;
Ok, here is the situation.&lt;/p&gt;

&lt;p&gt;
I set an interrupt TIMER0 and I2C0.&lt;/p&gt;

&lt;pre&gt;
// Initialise VIC for I2C use
VICIntSelect = 0x0;
VICVectAddr0 = (u32) i2cISR;
VICVectCntl0 = 0x20 | 9;// use it for I2C Interrupt
VICIntEnable = 0x200;   // Enabling I2C Channel (9)

// Initialise VIC for TIMER0 use
VICIntSelect = 0x0;
VICVectAddr1 = (u32)timerInt;
VICVectCntl1 = 0x20 | 4;  // use it for Timer 0
VICIntEnable = 0x10;      // Enable Timer0 Interrupt
&lt;/pre&gt;

&lt;p&gt;
Of course, there is other code around that&lt;/p&gt;

&lt;p&gt;
When I run the program, I never receive any I2C interrupt.&lt;/p&gt;

&lt;p&gt;
I tried to take out the TIMER0 interrupt, and nothing happened on
I2C.&lt;/p&gt;

&lt;p&gt;
I tried to take out the I2C module and confirmed that the timer
works.&lt;/p&gt;

&lt;p&gt;
So, why the I2C module does not work? Are those definition are
ok?&lt;/p&gt;

&lt;pre&gt;
void timerInt(void) __attribute__ ((interrupt));
void i2cISR(void) __attribute__ ((interrupt));
&lt;/pre&gt;

&lt;p&gt;
By the way, what is the difference between:&lt;/p&gt;

&lt;pre&gt;
void timerInt(void) __attribute__ ((interrupt));
and
void timerInt(void) __attribute__ ((interrupt(&amp;quot;IRQ&amp;quot;)));
&lt;/pre&gt;

&lt;p&gt;
Regards&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/144173?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2006 13:18:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ccf61693-114e-4ae8-8b1e-bb8b0502ea8e</guid><dc:creator>Dan Henry</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;Now, I need to know why my interrupts are not working
now.&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
What kind of trouble are you having?&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;You have some knowledge about interrupt with GNU?&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Enough to know that GCC provides special extension syntax for the
interrupt function attribute.&lt;/p&gt;

&lt;p&gt;
There should be interrupt examples in your directory tree
somewhere.&lt;/p&gt;

&lt;p&gt;
Also see:&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.hitex.co.uk/arm/lpc2000book/index.html"&gt;www.hitex.co.uk/.../index.html&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/141700?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2006 12:53:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:425a2aa0-7b88-432c-b3b9-f919426a00d5</guid><dc:creator>David Perreault</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi Dan,&lt;/p&gt;

&lt;p&gt;
Guess what?&lt;/p&gt;

&lt;p&gt;
I re-scan for the X times the Startup.s and I saw that:&lt;/p&gt;

&lt;pre&gt;
    .equ    Top_Stack,      0x40004000
&lt;/pre&gt;

&lt;p&gt;
I changed it for 0x40002000. No more &amp;quot;Data Abort&amp;quot; exception
error!&lt;/p&gt;

&lt;p&gt;
Now, I need to know why my interrupts are not working now. You
have some knowledge about interrupt with GNU?&lt;/p&gt;

&lt;p&gt;
By the way, thanks for all the help that you gave me.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/138336?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2006 10:49:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2c13309f-5e37-4089-ba27-f6fb09322aad</guid><dc:creator>Dan Henry</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;Any clue what it could write at that address?&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
I believe that the intent of the STMDB you mentioned above is to
set up a stack frame, but it must be within existing memory, hence
the data abort exception.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;How the Realview result is working and not the GNU
one?&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
You showed us above that the GNU version&amp;#39;s R13 = 0x40003F70 is
beyond the 8K SRAM space, whereas the other version&amp;#39;s R13 =
0x400004A8 is within the valid address range. The GNU version must
have the notion that the data space is bigger than it is and is
initializing SP up too high.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/134909?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2006 10:08:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:58aa8df0-c64d-4237-a298-9968bbb37b69</guid><dc:creator>David Perreault</dc:creator><description>&lt;p&gt;&lt;p&gt;
Any clue what it could write at that address? Even the basic
program that I did (see other post) has the same behavior and there
is nothing special in that code.&lt;/p&gt;

&lt;p&gt;
How the Realview result is working and not the GNU one? Ok, they
do not compile the same way, but still it is the same code.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/123579?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2006 10:04:40 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ed6b1908-0cd2-41e1-972f-f4c0163c1a8a</guid><dc:creator>Dan Henry</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;... your linker file has it set for 16K. That might be the
problem.&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
I see your subsequent .ld file edit, yet the R13 value at the
abort suggests that 16K is still being used for some reason.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/112553?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2006 10:01:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:305b9ae9-c7fd-4a40-9881-ec8a78330b93</guid><dc:creator>Dan Henry</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;I am a new with this kind of stuff, but should the stack
pointer initialize itself?&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
No, setting the initial SP usually occurs during post-reset
initialization or in the C runtime startup code.&lt;/p&gt;

&lt;p&gt;
Anyway, looking up your eval board, then looking the CPU used on
the board (LPC2103), I see that it only has 8K of internal SRAM, yet
your linker file has it set for 16K. That might be the problem.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/123592?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2006 09:52:39 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:dd4ebd27-ef8c-4bc5-8d13-d6382d544ff2</guid><dc:creator>David Perreault</dc:creator><description>&lt;p&gt;&lt;p&gt;
When I said that I used the Keil compiler I was in error. I am
using the Realview one.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/112569?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2006 09:48:30 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:11f62a46-8c63-486c-aa12-ebe9d67db031</guid><dc:creator>David Perreault</dc:creator><description>&lt;p&gt;&lt;p&gt;
I wrote a little dummy program and had the same problem (R13 was
set at 0x40003FFC:&lt;/p&gt;

&lt;pre&gt;
void test();

int main()
{
    int i = 0;
    int j = 1;

    i = i + 1;
    j = i;

    if (j == 1)
    {
        i = 1;
        test();
    }
}

void test()
{
    int i = 1;
    if (i == 1)
    {
        i++;
    }
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/98771?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2006 08:43:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1b379553-39c9-4aa2-ab7f-bace9f66f668</guid><dc:creator>David Perreault</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;b&gt;GNU version&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
At the beginning, R13 = 0x40003F70&lt;br /&gt;
Once the abort occurs, R13 = 0x40003FFC&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;Keil version&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
At the beginning, R13 = 0x400004A8&lt;/p&gt;

&lt;p&gt;
I am a new with this kind of stuff, but should the stack pointer
initialize itself?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/88092?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2006 08:37:11 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:28469590-aa08-4ece-b0d1-c5a0ddac17aa</guid><dc:creator>Dan Henry</dc:creator><description>&lt;p&gt;&lt;p&gt;
Is the C runtime startup somehow failing to initialize R13 for use
as the stack pointer?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code compiled with GNU gives memory problem</title><link>https://community.arm.com/thread/47488?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2006 07:15:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:255bf6af-221f-4c62-9495-d6f6d2d8b67f</guid><dc:creator>David Perreault</dc:creator><description>&lt;p&gt;&lt;p&gt;
I changed the size in &lt;b&gt;LinkerScript.ld&lt;/b&gt; for&lt;/p&gt;

&lt;pre&gt;
  CODE (rx) : ORIGIN = 0x00000000, LENGTH = 0x00008000
  DATA (rw) : ORIGIN = 0x40000000, LENGTH = 0x00002000
&lt;/pre&gt;

&lt;p&gt;
I also checked the &lt;b&gt;Run to main()&lt;/b&gt; in the &lt;b&gt;Options for
Target/Debug&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
I started the debugger again and instead to start from Vectors
line it started into my main().&lt;/p&gt;

&lt;pre&gt;
    69: {
0x00000828  E1A0C00D  MOV       R12,R13
0x0000082C  E92DD870  STMDB     R13!,{R4-R6,R11-R12,R14-PC}
0x00000830  E24CB004  SUB       R11,R12,#0x00000004
    70:         u32 i = 0;
    71: //      u32 j = 0;
&lt;/pre&gt;

&lt;p&gt;
But once the line STMDB is executed, it goes directly to:&lt;/p&gt;

&lt;pre&gt;
   123:                 LDR     PC, DAbt_Addr
0x00000010  E59FF018  LDR       PC,[PC,#0x0018]
&lt;/pre&gt;

&lt;p&gt;
Any clue?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>