01-09-2014 06:19 AM
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.
'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)
01-09-2014 09:42 AM
01-09-2014 11:32 AM
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.
06-05-2015 09:16 AM
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:
yes just empty main with loop. pedro_uno do you have any news?
06-05-2015 09:34 AM
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.
02-21-2016 10:03 PM
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
02-21-2016 11:40 PM
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
08-18-2016 02:22 PM
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