cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
pedro_uno
Advisor
Advisor
14,534 Views
Registered: ‎02-12-2013

MicroBlaze - section `.text' will not fit in region

I am trying to build a small microblaze systems to do some calculations that need to support the processing pipeline.  I have calculated the operations per second and the microblaze should be able to handle it.  My code is all written in C without any aparent library dependencies. Unfortunately I still get an error message saying my .text section will not fit in BRAM.

 

Right now I have my BRAM size set to 8K.  I could increase it a little but the idea was to keep this little microcontroller small.  I don't want to consume a lot of BRAMs.

 

Can anyone tell me how to determine what is consuming so much memory and then how to minimize it?

 

Here is the SDK output showing that I overflow by 19232 bytes.

 

make all

'Building target: test3.elf'

'Invoking: MicroBlaze gcc linker'

mb-gcc -Wl,-T -Wl,../src/lscript.ld -L../../test3_bsp/microblaze_0/lib -mlittle-endian -mcpu=v9.2 -mxl-soft-mul -Wl,--no-relax -Wl,--gc-sections -o "test3.elf" ./src/mat_inv_4x4.o ./src/mat_inv_4x4_tb.o -Wl,--start-group,-lxil,-lgcc,-lc,--end-group

c:/xilinx/sdk/2013.4/gnu/microblaze/nt/bin/../lib/gcc/microblaze-xilinx-elf/4.6.4/../../../../microblaze-xilinx-elf/bin/ld.exe: test3.elf section `.text' will not fit in region `microblaze_0_local_memory_ilmb_bram_if_cntlr_microblaze_0_local_memory_dlmb_bram_if_cntlr'

c:/xilinx/sdk/2013.4/gnu/microblaze/nt/bin/../lib/gcc/microblaze-xilinx-elf/4.6.4/../../../../microblaze-xilinx-elf/bin/ld.exe: region `microblaze_0_local_memory_ilmb_bram_if_cntlr_microblaze_0_local_memory_dlmb_bram_if_cntlr' overflowed by 19232 bytes

collect2: ld returned 1 exit status

make: *** [test3.elf] Error 1

09:16:30 Build Finished (took 702ms)

----------------------------------------
DSP in hardware and software
-----------------------------------------
0 Kudos
7 Replies
sampatd
Scholar
Scholar
14,525 Views
Registered: ‎09-05-2011

Well, the elf size is purely based on your code. Having said that there are few techniques to reduce the code size:

http://www.xilinx.com/support/answers/36807.htm
http://www.xilinx.com/support/answers/21533.htm

Regards,
0 Kudos
pedro_uno
Advisor
Advisor
14,520 Views
Registered: ‎02-12-2013

I guess I am wondering if there is a standard way to actually look at a report or other output file to determine what is making my .text section so large.

 

I don't think turning off debug or changing stack and heap size will fix my problem.  I am getting an extra 128KB size in my .text section.  My program just loads an array of 16 float's does some multipication and addition on those values then returns. I don't call any library functions.  My microblaze has hardware floating point logic turned on so it should not call a library for that.

 

I think the .elf itself is a good place to look for what is causing large code.  Unfortunately the build routine doesn't write a .elf file because elfcheck fails.  I think I will try to manually force the linker to generate an .elf to see what is so big.

----------------------------------------
DSP in hardware and software
-----------------------------------------
0 Kudos
bartiko
Adventurer
Adventurer
11,975 Views
Registered: ‎11-23-2014

Hi,

 

I got the same problem. But my code doesn't do anything, so there is no problem with library too and it looks just like this:

 

int main(void)

{

      for(;;);

}

 

yes just empty main with loop. pedro_uno do you have any news?

0 Kudos
bartiko
Adventurer
Adventurer
11,966 Views
Registered: ‎11-23-2014

I tried regenerate linker script with the same setting and the error just "jump over" from .text to .heap size. I'm using the 8KB memmory for data and for code and I don't think that the memmory is too small.

0 Kudos
akshaymhaske
Newbie
Newbie
10,834 Views
Registered: ‎02-21-2016

Hi all,

I am also facing a same problem.

But I am getting this problem only if I use scanf function. If I remove the scanf function then its working fine.

Please provide the solution for this scanf issue.

 

Thanks & Regards

Akshay Mhaske

0 Kudos
goran
Xilinx Employee
Xilinx Employee
10,828 Views
Registered: ‎08-06-2007

Hi,

 

You can do "mb-objdump -S" on your .elf file, this will generate an assembler output of the generated code.

I always do this in order to investigate what code that has been generated.

 

There are plenty of ways of reducing your code size.

1. Use performance version with barrel, hw-mul, hw-div and pattern-compare, be sure to enable these for the compiler

2. Compile with -Os

3. Follow (it will remove dead code and data) http://www.xilinx.com/support/answers/21533.htm

4. Avoid malloc, printf, rand and other standard libraries unless you really need them

 

Göran

 

0 Kudos
fredjobsearch
Visitor
Visitor
10,009 Views
Registered: ‎10-19-2012

I had that happen twice too me..... The cause.....   printf !!!!

I am using print("blah blah blah") and xil_printf("  some %d %x stuff", vars);  

 

Those don't seem to hog code space..

 

Whenever I have accidentally done a   printf   instead of a print   then I get:  overflowed by 75744 bytes +/-  75Kish

 

I'm doing the basic microblaze standalone 

 

So if it was fitting then is suddenly 70-80K not fitting did you suddenly use printf for the 1st time.

could add something like:  #define printf PRINTF_SUCKS