<?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>Malloc returns NULL</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/35138/malloc-returns-null</link><description> 
Setup 

 
Keil: uVision 5.17.0.0 
ARM: LPC1768 
A standard project with some UARTS and I2C 
&amp;quot;Use memory Layout form target&amp;quot; is checked (using the standard
scatter file) 
&amp;quot;Use MicroLIB&amp;quot; is not checked 

 
from startup_LPC17xx.s 
Heap_Size EQU 0x00002000</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/155600?ContentTypeID=1</link><pubDate>Tue, 01 Mar 2016 04:07:59 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:41796feb-5d1d-412d-9a3d-0084424bc04a</guid><dc:creator>Stefan Olsson</dc:creator><description>&lt;p&gt;&lt;p&gt;
It works now as expected, it was all related to one of all of the
added lines at the top of startup_LPC..&lt;/p&gt;

&lt;pre&gt;
                EXPORT  __initial_sp
                EXPORT  __heap_base
                EXPORT  __heap_limit
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
If any of them, even if the program only have &amp;quot;EXPORT __initial_sp&amp;quot;
(and not the other two) the heap dont get initalized. If none of them
are exported then the runtime library will call
__user_initial_stackheap as expected.&lt;/p&gt;

&lt;p&gt;
&lt;br /&gt;
It is neccessary to export a new/seperate variabel if the stack top
is going to be used&lt;br /&gt;
somewhere else, like this&lt;/p&gt;

&lt;pre&gt;
                EXPORT  &lt;b&gt;__initial_stack_top&lt;/b&gt;


Stack_Size      EQU     0x00000800

                AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem       SPACE   Stack_Size
__initial_sp
&lt;b&gt;__initial_stack_top&lt;/b&gt;
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
One interesting observation was that if the program had&lt;/p&gt;

&lt;pre&gt;
                EXPORT  __initial_sp
                EXPORT  __heap_base
                EXPORT  __heap_limit

The map file will contain
__rtentry4.o(.ARM.Collect&amp;#36;&amp;#36;rtentry&amp;#36;&amp;#36;00000004) refers to sys_stackheap_outer.o(.text) for __user_setup_stackheap
sys_stackheap_outer.o(.text) refers to startup_lpc17xx.o(.text) for __user_initial_stackheap

But they was never called
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
&lt;br /&gt;
Conclusive:&lt;br /&gt;
Dont export any of __initial_sp, __heap_base or __heap_limit form the
startup_XXXX.s&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/155265?ContentTypeID=1</link><pubDate>Mon, 29 Feb 2016 09:44:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8983828d-6017-4c22-a8be-83e1bb8f45b2</guid><dc:creator>Robert McNamara</dc:creator><description>&lt;p&gt;&lt;p&gt;
1) Stop making any calls to _init_alloc.&lt;/p&gt;

&lt;p&gt;
2) You should be getting a link error on TEST2, no compile error.
See #4 below. This would only seem to be if you exported
__heap_limit, __heap_base and __initial_sp. If you export these, it
will compile and link fine using both microlib and standardlib, but
will not actually work in standardlib mode. Did you somehow change
the standard code in a way that these variables were exported when
not using the microlib? You may notice in the map file that
sys_stackheap_outer.o references a __user_inital_stackheap that
resides in sys_stackheap_outer.o when these are exported. If you do
not export these variables, it will reference the
__user_initial_stackheap in YOUR startup.s file. This is why your
__user_initial_stackheap is not being called. i.e. You are not using
the &amp;quot;standard&amp;quot; code at all, you have modified it to not work and then
complained about it not working.&lt;/p&gt;

&lt;p&gt;
3) Look at your map file&lt;/p&gt;

&lt;pre&gt;
USING:__user_setup_stackheap,

your map file should show __rtentry4.o referencing __user_setup_stackheap in your startup.s file.  There is no reference to __user_initial_stackheap.
&lt;/pre&gt;
&lt;pre&gt;
USING: __user_initial_stackheap

your mapfile should show sys_stackheap_outer.o referenceing __user_initial_stackheap in your startup.s file.  You will also see __user_setup_stackheap referenceing sys_stackheap_outer.o
&lt;/pre&gt;

&lt;p&gt;
4) I have never seen __heap_limit defined as a variable when not
using the microlib. I think the &amp;quot;standard&amp;quot; startup code is very
specific in NOT creating a __heap_limit or __heap_base variable when
not using the microlib. Don&amp;#39;t define this as a variable.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/154869?ContentTypeID=1</link><pubDate>Mon, 29 Feb 2016 02:36:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:74c2394e-f023-4f55-8d6c-e249f04ea638</guid><dc:creator>Stefan Olsson</dc:creator><description>&lt;p&gt;&lt;p&gt;
I am using Keil: uVision 5.17.0.0&lt;br /&gt;
&lt;br /&gt;
But ARM says that __user_initial_stackheap is a legacy thingy&lt;br /&gt;

&lt;a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0492c/Cihhdahf.html"&gt;infocenter.arm.com/.../index.jsp&lt;/a&gt;&lt;br /&gt;

and the, nowdays, the proper function should be
__user_setup_stackheap()&lt;br /&gt;
&lt;br /&gt;
I gues the Keil runtime library get messaed up if it see the
__user_initial_stackheap() and does not initilize heap (internally)
nor does it call __user_initial_stackheap.&lt;/p&gt;

&lt;p&gt;
It seems that the only way is to hide __user_initial_stackheap
from Keil so it does not see it and assume it have to initilize the
heap itself.&lt;br /&gt;
Note, if __user_initial_stackheap is comment out, it is neccessary as
well to do the following at the begining of startup_LPC17xx.s&lt;/p&gt;

&lt;pre&gt;
                EXPORT  __heap_base
                EXPORT  __heap_limit
&lt;/pre&gt;

&lt;p&gt;
Regards Stefan&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/154367?ContentTypeID=1</link><pubDate>Mon, 29 Feb 2016 02:06:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:90415ef9-2a1c-499a-9587-22e7379a9d07</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;That really seems like the way you would allocate a heap in
previous versions, but not in any recent.&amp;quot;&lt;/p&gt;

&lt;p&gt;
So maybe you got two separate functions that tries to initialize
the heap.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/153806?ContentTypeID=1</link><pubDate>Sun, 28 Feb 2016 22:51:37 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:dfa4dc16-ddf5-47f4-a534-edc4fb5b7e3c</guid><dc:creator>Stefan Olsson</dc:creator><description>&lt;p&gt;&lt;p&gt;
Test1&lt;/p&gt;

&lt;pre&gt;
Heap_Size       EQU     0x00000000

Result:
No compilation error
It hangs inside _init_alloc call in the main function
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
&lt;br /&gt;
Test2&lt;/p&gt;

&lt;pre&gt;
Heap_Size       EQU     0x00000000
;                EXPORT  __user_initial_stackheap
//  _init_alloc((uintptr_t)&amp;amp;__heap_base, (uintptr_t)&amp;amp;__heap_limit);
Result:
No compilation error
It never reach the main() function
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
&lt;br /&gt;
Test3:&lt;/p&gt;

&lt;pre&gt;
Heap_Size       EQU     0x00000800
;                EXPORT  __user_initial_stackheap
//  _init_alloc((uintptr_t)&amp;amp;__heap_base, (uintptr_t)&amp;amp;__heap_limit);
Result:
No compilation error
It reach the main() function
&lt;b&gt;and malloc returns a valid pointer (that is, it points into the right area)&lt;/b&gt;
&lt;/pre&gt;

&lt;p&gt;
wtf, why would it work corretly with &amp;quot;standard&amp;quot; code comment
out?&lt;/p&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: Malloc returns NULL</title><link>https://community.arm.com/thread/153134?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2016 10:25:38 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a8a968dc-dac9-4ff0-bec7-8e8d29ffcb11</guid><dc:creator>Robert McNamara</dc:creator><description>&lt;p&gt;&lt;p&gt;
heap test of 0?&lt;/p&gt;

&lt;p&gt;
Try removing __user_initialize_stackheap and the EXPORT of it from
the startup file. Do you get a link error?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/152408?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2016 06:25:52 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f048021c-c999-4290-a39f-10214f7e452e</guid><dc:creator>Stefan Olsson</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;br /&gt;
startup_LPC17xx.s&lt;/p&gt;

&lt;pre&gt;
Stack_Size      EQU     0x00000800

                AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem       SPACE   Stack_Size
__initial_sp


; &amp;lt;h&amp;gt; Heap Configuration
;   &amp;lt;o&amp;gt;  Heap Size (in Bytes) &amp;lt;0x0-0xFFFFFFFF:8&amp;gt;
; &amp;lt;/h&amp;gt;

Heap_Size       EQU     0x00000800

                AREA    HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem        SPACE   Heap_Size
__heap_limit
&lt;/pre&gt;

&lt;p&gt;
Scatter file&lt;/p&gt;

&lt;pre&gt;

LR_IROM1 0x00000000 0x00080000  {    ; load region size_region
  ER_IROM1 0x00000000 0x00080000  {  ; load address = execution address
    *.o (RESET, +First)
    *(InRoot&amp;#36;&amp;#36;Sections)
    .ANY (+RO)
  }

  RW_IRAM_STACK 0x10000000 0x2000  {  ; RW data
    .ANY (STACK)
  }

  LO_ARM_TEST 0x10002000 UNINIT 0x20 {  ; RW data
    .ANY (__LO_ARM_TEST_RAM_AREA)
  }

  RW_IRAM1 0x10002020 0x3FE0  {  ; RW data
    .ANY (+RW +ZI)
  }

  RW_IRAM_HEAP 0x10006000 0x2000 {  ; RW data
    .ANY (HEAP)
  }
}
&lt;/pre&gt;

&lt;p&gt;
yes, i have the assembler view up as awell, i have a break point
at __user_inital_stackheap and the main function&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The execution do&lt;/p&gt;

&lt;pre&gt;

                LDR     R0, =SystemInit
                BLX     R0
                LDR     R0, =__main
                BX      R0
&lt;/pre&gt;

&lt;p&gt;
And then it will hit the main function without hitting
__user_inital_stackheap.&lt;br /&gt;
&lt;br /&gt;
If i do&lt;br /&gt;
v = malloc(0x10);&lt;br /&gt;
&lt;br /&gt;
it will return NULL&lt;br /&gt;
but if i have called _init_alloc((uintptr_t)&amp;amp;__heap_base,
(uintptr_t)&amp;amp;__heap_limit); before the malloc it will not return a
NULL pointer and the pointer is in &amp;quot;right area&amp;quot;&lt;/p&gt;

&lt;p&gt;
&amp;quot;use microlib&amp;quot; is unchecked, my main function look like
this&lt;/p&gt;

&lt;pre&gt;
int main(int argc, char **argv)
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
I have not tested to set &amp;quot;If you make the heap 0 in size, does it
crash before main?&amp;quot;&lt;/p&gt;

&lt;p&gt;
&lt;br /&gt;
&lt;br /&gt;
Regards Stefan&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/151611?ContentTypeID=1</link><pubDate>Thu, 25 Feb 2016 09:24:25 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:264a6fed-19d0-437e-96fb-3ebe113183f2</guid><dc:creator>Robert McNamara</dc:creator><description>&lt;p&gt;&lt;p&gt;
What size is your heap?&lt;/p&gt;

&lt;p&gt;
How much are you trying to allocate in your main?&lt;/p&gt;

&lt;p&gt;
If you make the heap 0 in size, does it crash before main?&lt;/p&gt;

&lt;p&gt;
If you make the heap larger does it eventually work?&lt;/p&gt;

&lt;p&gt;
When you set your breakpoint in __user_initial_stackheap, make
sure you also right click and then left click &amp;quot;show disassembly at
###&amp;quot; Then see if it stops in your __user_inital_stackheap.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/150915?ContentTypeID=1</link><pubDate>Wed, 24 Feb 2016 23:07:41 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8babd66a-ffd7-4a95-8a37-542bb876bb63</guid><dc:creator>Stefan Olsson</dc:creator><description>&lt;p&gt;&lt;p&gt;
No, it is pure C, one single main function&lt;br /&gt;
&lt;br /&gt;
I even recreated an empty project (&amp;quot;use microlib&amp;quot; unchecked) to test
it again.&lt;br /&gt;
When i step into the malloc function i can see that the malloc
function consider the heap to be full and it wont call the
__user_initial_stackheap&lt;br /&gt;
&lt;br /&gt;
In the map file the following exists so something is going on&lt;br /&gt;
&lt;br /&gt;
__user_initial_stackheap 0x000002cd Thumb Code 0
startup_lpc17xx.o(.text)&lt;br /&gt;
__use_two_region_memory 0x000002f1 Thumb Code 2 heapauxi.o(.text)&lt;br /&gt;
__rt_heap_escrow 0x000002f3 Thumb Code 2 heapauxi.o(.text)&lt;br /&gt;
__rt_heap_expand 0x000002f5 Thumb Code 2 heapauxi.o(.text)&lt;br /&gt;
__use_no_heap 0x000002f7 Thumb Code 2 hguard.o(.text)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Is it possibly to get the source code to the c libraries that the
linker automatically links in so i can compare it to the executed
assembler instructions in &amp;quot;malloc&amp;quot; ?&lt;br /&gt;
&lt;br /&gt;
and that coudl help me to understand why it is not calling the
__user_initial_stackheap&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Regards&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/150460?ContentTypeID=1</link><pubDate>Wed, 24 Feb 2016 09:52:09 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ff03708e-9842-4a9a-a58a-f1e1cfc22fd7</guid><dc:creator>Robert McNamara</dc:creator><description>&lt;p&gt;&lt;p&gt;
Any chance you are using C++?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/150057?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2016 06:11:22 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:cd155c93-e698-4d68-b4f8-2d1d3eeb7ea9</guid><dc:creator>Stefan Olsson</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;b&gt;To Per Westermark&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
Accoring the searching I did before I made post it said that a
main like this, &amp;quot;int main(int argc, char **argv)&amp;quot; require a
initiation of the heap. That is, the function
__user_initial_stackheap must/will be called unlike if &amp;quot;use microlib&amp;quot;
is checked, then the main must look like this &amp;quot;void main(void)&amp;quot;&lt;/p&gt;

&lt;p&gt;
&lt;br /&gt;
&lt;b&gt;To Westonsupermare Pier&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
I have changed it, but it wont call the __user_initial_stackheap
before calling main&lt;/p&gt;

&lt;p&gt;
&lt;br /&gt;
&lt;b&gt;To Robert McNamara&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
ARM_LIB_HEAP: Yes, i have tested it, it did not make any
difference, it still wont call __user_initial_stackheap before
main(...)&lt;br /&gt;
&lt;br /&gt;
__user_initial_stackheap is included, I used &amp;quot;new project&amp;quot; option the
keil and it automatically produced that code, but it is not calle&lt;/p&gt;

&lt;p&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;To All&lt;/b&gt;&lt;br /&gt;
Becosue &amp;quot;new project&amp;quot; produced startup_LPC17xx.s, with the stack,
heap reserved and __user_initial_stackheap created (without changing
the scatter file) I assumed everything should be working, but it
seems not to be.&lt;/p&gt;

&lt;p&gt;
&lt;br /&gt;
&lt;br /&gt;
Regards Stefan&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/149578?ContentTypeID=1</link><pubDate>Mon, 22 Feb 2016 09:49:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e2facd25-9d73-405d-abb0-200facf11b9f</guid><dc:creator>Robert McNamara</dc:creator><description>&lt;p&gt;&lt;p&gt;
Or if you want to go the path you are, you can implement the
__user_initial_stackheap function yourself.&lt;/p&gt;

&lt;pre&gt;
; User Initial Stack &amp;amp; Heap

                IF      :DEF:__MICROLIB

                EXPORT  __initial_sp
                EXPORT  __heap_base
                EXPORT  __heap_limit

                ELSE

                IMPORT  __use_two_region_memory
                EXPORT  __user_initial_stackheap
__user_initial_stackheap

                LDR     R0, =  Heap_Mem
                LDR     R1, =(Stack_Mem + Stack_Size)
                LDR     R2, = (Heap_Mem +  Heap_Size)
                LDR     R3, = Stack_Mem
                BX      LR

&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/149057?ContentTypeID=1</link><pubDate>Mon, 22 Feb 2016 09:09:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b093dbff-d4ad-438d-bd65-674c5635325a</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
Third field in scatter file region description is the length of
the region, not the end address.&lt;/p&gt;

&lt;pre&gt;
  RW_IRAM1 0x20000000 0x00040000  {  ; RW data 256KB
   .ANY (+RW +ZI)
  }
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/129168?ContentTypeID=1</link><pubDate>Mon, 22 Feb 2016 07:13:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7c7af6b1-298d-4388-a847-60814b22aee4</guid><dc:creator>Robert McNamara</dc:creator><description>&lt;p&gt;&lt;p&gt;
That really seems like the way you would allocate a heap in
previous versions, but not in any recent.&lt;/p&gt;

&lt;p&gt;
See if this helps.&lt;/p&gt;

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

&lt;p&gt;
i.e make an ARM_LIB_HEAP region and it will be initialized for use
before main is called.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/120741?ContentTypeID=1</link><pubDate>Mon, 22 Feb 2016 04:15:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3d8f2064-c432-4c88-8a57-431d218eb985</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
s/new/knew/&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/108665?ContentTypeID=1</link><pubDate>Mon, 22 Feb 2016 02:51:39 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1f7ad3b2-7318-4e03-b67c-a6cb44bf43bd</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
I didn&amp;#39;t new argc and argv would need any heap allocation - why
would they?&lt;/p&gt;

&lt;p&gt;
Next thing - I have never used argc and argv on a bare-bones
embedded platform, since I wouldn&amp;#39;t have any operating system sending
in any parameters from any command-line.&lt;/p&gt;

&lt;p&gt;
What magic do you send in through these parameters?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/83051?ContentTypeID=1</link><pubDate>Mon, 22 Feb 2016 02:21:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:57a8cbda-8afc-4d5d-a7fe-5a32de3d3796</guid><dc:creator>Stefan Olsson</dc:creator><description>&lt;p&gt;&lt;p&gt;
Additional information&lt;/p&gt;

&lt;p&gt;
It seems that it thinks i am on a &amp;quot;bare metal&amp;quot; despite i have
a&lt;/p&gt;

&lt;p&gt;
int main(int argc, char **argv)&lt;/p&gt;

&lt;p&gt;
becouse if i make the call&lt;br /&gt;
_init_alloc((uintptr_t)&amp;amp;__heap_base,
(uintptr_t)&amp;amp;__heap_limit);&lt;/p&gt;

&lt;p&gt;
in the begining of my main the malloc stuff works later works
however i can not realy do this becosue the main argument (argc and
argv ) would require a heap allocation&lt;/p&gt;

&lt;p&gt;
Regards Stefan&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Malloc returns NULL</title><link>https://community.arm.com/thread/64535?ContentTypeID=1</link><pubDate>Mon, 22 Feb 2016 01:30:52 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e76b3707-8705-45c1-a0a8-6869ca0c8668</guid><dc:creator>Stefan Olsson</dc:creator><description>&lt;p&gt;&lt;p&gt;
Additional information&lt;/p&gt;

&lt;p&gt;
I have even tried an own scatter file&lt;/p&gt;

&lt;p&gt;
RW_IRAM_STACK 0x10000000 0x10002000 { ; RW data .ANY (STACK) }&lt;/p&gt;

&lt;p&gt;
RW_IRAM1 0x10002000 0x10006000 { ; RW data .ANY (+RW +ZI) }&lt;/p&gt;

&lt;p&gt;
RW_IRAM_HEAP 0x10006000 0x10008000 { ; RW data .ANY (HEAP) }&lt;/p&gt;

&lt;p&gt;
But this does not work either&lt;/p&gt;

&lt;p&gt;
It also seems that the code does not call the default generated
code&lt;/p&gt;

&lt;p&gt;
IMPORT __use_two_region_memory EXPORT __user_initial_stackheap&lt;br /&gt;
__user_initial_stackheap&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>