large bss size for sample applications

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Sep 23 12:50:58 UTC 2015


Hello Jeff,

On 23/09/15 00:27, Jeff Webb wrote:
> I am new to RTEMS, and I am interested in getting a an ARM-based 
> development system up an running.  Ultimately, I would like to use 
> RTEMS on a Zynq-based board with no external RAM.  Is it possible to 
> do anything useful in a few hundred kilobytes of RAM on the Zynq 
> platform?  The sample applications I have generated have very large 
> bss sizes that do not seem to be in line with the reported values for 
> other platforms that I have found in web searches.
>
> I found an excellent tutorial [1] (thanks!) for getting started with 
> RTEMS on the Raspberry Pi.  I followed the instructions and 
> successfully built and ran the ticker.exe sample application on the 
> Pi.  I was curious about the memory usage, so I attempted to determine 
> how much memory this application required.
>
>   $ arm-rtems4.11-size  ticker.exe
>    text       data        bss        dec        hex    filename
>   94196       1692    134077844    134173732    7ff5424 ticker.exe
>
> The executable size is 3.1M, which is reduced to 95K after running 
> arm-rtems4.11-strip on it.

the size program is not the right tool. Better use 
arm-rtems4.11-readelf, e.g.

arm-rtems4.11-readelf -l ticker.exe

Elf file type is EXEC (Executable file)
Entry point 0x104040
There are 4 program headers, starting at offset 52

Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
   EXIDX          0x0156a4 0x001195e4 0x001195e4 0x00008 0x00008 R 0x4
   LOAD           0x0000c0 0x00104000 0x00104000 0x1566c 0xfe800 RWE 0x40
   LOAD           0x015740 0x00202800 0x00202800 0x00988 0x1fcfd800 RW  0x20
   LOAD           0x0160c8 0x1ff00000 0x1ff00000 0x00000 0x100000 RW 0x1

  Section to Segment mapping:
   Segment Sections...
    00     .ARM.exidx
    01     .start .text .init .fini .rodata .ARM.exidx .eh_frame 
.init_array .fini_array .jcr .rwbarrier .vector
    02     .data .bss .work
    03     .xbarrier .robarrier .stack .nocache

or

arm-rtems4.11-readelf -S ticker.exe
There are 32 section headers, starting at offset 0x3c7b40:

Section Headers:
   [Nr] Name              Type            Addr     Off    Size   ES Flg 
Lk Inf Al
   [ 0]                   NULL            00000000 000000 000000 00      
0   0  0
   [ 1] .start            PROGBITS        00104000 0000c0 000524 00 AX  
0   0  4
   [ 2] .xbarrier         PROGBITS        00104524 0160c8 000000 00 W  
0   0  1
   [ 3] .text             PROGBITS        00104540 000600 013b82 00 WAX  
0   0 64
   [ 4] .init             PROGBITS        001180c4 014184 00000c 00 AX  
0   0  4
   [ 5] .fini             PROGBITS        001180d0 014190 00000c 00 AX  
0   0  4
   [ 6] .robarrier        PROGBITS        001180dc 0160c8 000000 00 W  
0   0  1
   [ 7] .rodata           PROGBITS        001180dc 01419c 001508 00 A  
0   0  4
   [ 8] .ARM.exidx        ARM_EXIDX       001195e4 0156a4 000008 00 AL  
3   0  4
   [ 9] .eh_frame         PROGBITS        001195ec 0156ac 000074 00 A  
0   0  4
   [10] .init_array       INIT_ARRAY      00119660 015720 000004 00 WA  
0   0  4
   [11] .fini_array       FINI_ARRAY      00119664 015724 000004 00 WA  
0   0  4
   [12] .jcr              PROGBITS        00119668 015728 000004 00 WA  
0   0  4
   [13] .rwbarrier        NOBITS          0011966c 01572c 0e6994 00 WA  
0   0  1
   [14] .vector           NOBITS          00200000 01572c 002800 00 WA  
0   0  1
   [15] .data             PROGBITS        00202800 015740 000988 00 WA  
0   0  8
   [16] .bss              NOBITS          002031a0 0160c8 00223c 00 WA  
0   0 32
   [17] .work             NOBITS          002053dc 0160c8 1fcfac24 00  
WA  0   0  1
   [18] .stack            PROGBITS        1ff00000 0160c8 000000 00 W  
0   0  1
   [19] .nocache          NOBITS          1ff00000 0160c8 100000 00 WA  
0   0  1
   [20] .comment          PROGBITS        00000000 0160c8 000072 01 MS  
0   0  1
   [21] .debug_aranges    PROGBITS        00000000 016140 003010 00      
0   0  8
   [22] .debug_info       PROGBITS        00000000 019150 2cece5 00      
0   0  1
   [23] .debug_abbrev     PROGBITS        00000000 2e7e35 03098e 00      
0   0  1
   [24] .debug_line       PROGBITS        00000000 3187c3 05535b 00      
0   0  1
   [25] .debug_frame      PROGBITS        00000000 36db20 006f58 00      
0   0  4
   [26] .debug_str        PROGBITS        00000000 374a78 01a079 01 MS  
0   0  1
   [27] .debug_loc        PROGBITS        00000000 38eaf1 0272c8 00      
0   0  1
   [28] .ARM.attributes   ARM_ATTRIBUTES  00000000 3b5db9 000033 00      
0   0  1
   [29] .shstrtab         STRTAB          00000000 3b5dec 000128 00      
0   0  1
   [30] .symtab           SYMTAB          00000000 3b5f14 00a020 10     
31 1663  4
   [31] .strtab           STRTAB          00000000 3bff34 007c0c 00      
0   0  1
Key to Flags:
   W (write), A (alloc), X (execute), M (merge), S (strings)
   I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
   O (extra OS processing required) o (OS specific), p (processor specific)

Please notice the .work section (see also 
c/src/lib/libbsp/arm/shared/startup/linkcmds.base). For details look at 
the ELF manual.

>
> When I used objcopy to create an image for copying to the raspberry pi 
> SD card, the resulting image was 999K:
>
>   $ arm-rtems4.11-objcopy -Obinary ticker.exe ticker.img
>
> Since I had success with the Pi, I decided to try the Zedboard.  I 
> successfully got the ticker application built using this configure 
> command:
>
> ../rtems-git/configure --target=arm-rtems4.11 \
> --enable-rtemsbsp=xilinx_zynq_zedboard \
> --enable-tests=samples \
> --enable-networking \
> --enable-posix \
> --prefix=/opt/rtems/bsps/4.11 BSP_ARM_A9MPCORE_PERIPHCLK=333333333U
>
> The bss size of the resulting executable was also large:
>
>   $ arm-rtems4.11-size  ticker_zed.exe
>    text       data        bss        dec        hex    filename
>   72588       1780    535731528    535805896    1fefbfc8 ticker_zed.exe
>
>   $ ls -lh ticker_zed*
>   3.2M Sep 22 17:16 ticker_zed.exe
>   74K Sep 22 17:18 ticker_zed_stripped.exe
>
> I tried shrinking the memory map for the zedboard using various 
> techniques, but it looks like I'm running out of memory.  One 
> technique I attempted was to add something like 
> "BSP_ZYNQ_RAM_LENGTH=1536K BSP_ZYNQ_NOCACHE_LENGTH=128K" to the 
> configure command, which would yield an error message like this:
>
> arm-rtems4.11-gcc -B../../../../../xilinx_zynq_zedboard/lib/ -specs 
> bsp_specs -qrtems -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard 
> -mtune=cortex-a9 -O2 -g -Wall -Wmissing-prototypes 
> -Wimplicit-function-declaration -Wstrict-prototypes 
> -Wnested-externs    -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard 
> -mtune=cortex-a9   -o hello.exe init.o
> linkcmds.base:383 cannot move location counter backwards (from 
> 0000000000203c34 to 0000000000160000)
>
> Can anyone point me in the right direction?

I would use a custom linker command file. Use 
c/src/lib/libbsp/arm/xilinx-zynq/startup/linkcmds.in as a template. In 
particular the line

bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? 
bsp_section_rwbarrier_align : 1M;

is probably not the right thing for you. Maybe use

bsp_section_rwbarrier_align = 1;

Verify that the MMU setup is all right with this (set a break point to 
zynq_setup_mmu_and_cache()).

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.




More information about the users mailing list