cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
200982
Adventurer
Adventurer
12,671 Views
Registered: ‎10-27-2011

heap & stack size

Jump to solution

Hello,

 

I have C program running on BRAM.

 

When I use malloc()  it returns NULL.

 

I dont get any Error when I use Array instead. Although, I'm not sure if Microblaze is throwing an Error when overflow occurs.

 

So, one topic three questions:

 

1.) Will there be any Error-Message when there is an overflow on BRAM?

2.) Is there another possiblilty that malloc() returns NULL except for overflow?

3. and most important ) How do I decide how big my BRAM has to be? Is there some kind of output telling me how big my binaries of the C-Code is? ( I use SDK & Microblaze). Or is the decision on the size just try and error?

 

Thanks alot. 

0 Kudos
1 Solution

Accepted Solutions
200982
Adventurer
Adventurer
15,411 Views
Registered: ‎10-27-2011

I just changed to Xilkernel and it gave me that Error Massage:

 

c:\xilinx\13.3_3\sdk\sdk\gnu\microblaze\nt64\bin\..\lib\gcc\microblaze-xilinx-elf\4.1.2\..\..\..\..\microblaze-xilinx-elf\bin\ld.exe: region ilmb_cntlr_CI_dlmb_cntlr_CI is full (ci_host_1.elf section .heap)
c:\xilinx\13.3_3\sdk\sdk\gnu\microblaze\nt64\bin\..\lib\gcc\microblaze-xilinx-elf\4.1.2\..\..\..\..\microblaze-xilinx-elf\bin\ld.exe: section .stack [00000050 -> 0000084f] overlaps section .text [00000050 -> 00006feb] 

 

View solution in original post

0 Kudos
4 Replies
bsutin
Observer
Observer
12,659 Views
Registered: ‎04-08-2009
The linker script is going to tell you how much heap you have available for allocation. Malloc() space will come from there, so it isn't competing for space with anything else once the program is running. I vaguely recall that the default heap is 0x400, which may be too small for your array.
0 Kudos
200982
Adventurer
Adventurer
12,649 Views
Registered: ‎10-27-2011

Hell, the Heap is already 0x64'00.

It still crushes. I did check every mallo()...yes, I do free everything. And program crushes really early.

 

Although, the code is quite large. About 1'000 lines.

But no one is telling there's a problem.

0 Kudos
200982
Adventurer
Adventurer
15,412 Views
Registered: ‎10-27-2011

I just changed to Xilkernel and it gave me that Error Massage:

 

c:\xilinx\13.3_3\sdk\sdk\gnu\microblaze\nt64\bin\..\lib\gcc\microblaze-xilinx-elf\4.1.2\..\..\..\..\microblaze-xilinx-elf\bin\ld.exe: region ilmb_cntlr_CI_dlmb_cntlr_CI is full (ci_host_1.elf section .heap)
c:\xilinx\13.3_3\sdk\sdk\gnu\microblaze\nt64\bin\..\lib\gcc\microblaze-xilinx-elf\4.1.2\..\..\..\..\microblaze-xilinx-elf\bin\ld.exe: section .stack [00000050 -> 0000084f] overlaps section .text [00000050 -> 00006feb] 

 

View solution in original post

0 Kudos
moeadham
Visitor
Visitor
12,600 Views
Registered: ‎12-21-2011

I was once having heap& stack size problems using the Xikernel. One "scorched earth" approach that I took was to create 3 BRAMS in XPS, one for Code sections, one for Data sectiona and one for the Heap+stack.

 

If you have an empty FPGA, you can create 64k for all three. Compile the FPGA, and export it to SDK. Then you can go into the SDK:

- Xilinx Tools> Generate Linker Script

- Point Code, Data and H&S into your newly created 

- Define your Heap and Stack Sizes manually.

 

Also, if you are using especially large arrays, maybe open your BSP, and change the maximum thread stack size.

 

Then, when you are done your code, you can calculate how much of each section you actually need and downsize accordingly.

 

Good Luck

 

0 Kudos