2009-08-03 03:38:42 Load share libary Functions into SRAM Problem
roy xue (CHINA)
Message: 78287
Hi, all
I'm trying to put some functions of a share libary in to L1 SRAM. I use "__attribute__ ((l1_text));" to declaration the functions. and use bfin-linux-uclibc-gcc to compiles. But when a appliction calling that libary, it stop and complain "can't map libspandsp.so.1".
When use bfin-linux-uclibc-readelf to check libary, the flags show:
Flags: 0x2, FDPIC
The compile command is:
bfin-linux-uclibc-gcc -shared .libs/adsi.o .libs/async.o .libs/at_interpreter.o .libs/awgn.o .libs/bell_r2_mf.o .libs/bert.o .libs/bit_operations.o .libs/bitstream.o .libs/complex_filters.o .libs/complex_vector_float.o .libs/crc.o .libs/dds_float.o .libs/dds_int.o .libs/dtmf.o .libs/echo.o .libs/fax.o .libs/fsk.o .libs/g711.o .libs/g722_encode.o .libs/g722_decode.o .libs/g726.o .libs/gsm0610_decode.o .libs/gsm0610_encode.o .libs/gsm0610_long_term.o .libs/gsm0610_lpc.o .libs/gsm0610_preprocess.o .libs/gsm0610_rpe.o .libs/gsm0610_short_term.o .libs/hdlc.o .libs/ima_adpcm.o .libs/logging.o .libs/lpc10_analyse.o .libs/lpc10_decode.o .libs/lpc10_encode.o .libs/lpc10_placev.o .libs/lpc10_voicing.o .libs/modem_echo.o .libs/modem_connect_tones.o .libs/noise.o .libs/oki_adpcm.o .libs/playout.o .libs/plc.o .libs/power_meter.o .libs/queue.o .libs/schedule.o .libs/sig_tone.o .libs/silence_gen.o .libs/super_tone_rx.o .libs/super_tone_tx.o .libs/t4.o .libs/t30.o .libs/t30_api.o .libs/t30_logging.o .libs/t31.o .libs/t35.o .libs/t38_core.o .libs/t38_gateway.o .libs/t38_terminal.o .libs/testcpuid.o .libs/time_scale.o .libs/tone_detect.o .libs/tone_generate.o .libs/v17rx.o .libs/v17tx.o .libs/v22bis_rx.o .libs/v22bis_tx.o .libs/v27ter_rx.o .libs/v27ter_tx.o .libs/v29rx.o .libs/v29tx.o .libs/v42.o .libs/v42bis.o .libs/v8.o .libs/vector_float.o .libs/vector_int.o -Wl,--rpath -Wl,/work/co-astfin-532/build_stamp537/tiff-3.8.2/libtiff/.libs -Wl,--rpath -Wl,/usr/local/lib -L/work/co-astfin-532/build_stamp537/tiff-3.8.2/libtiff/.libs /work/co-astfin-532/build_stamp537/tiff-3.8.2/libtiff/.libs/libtiff.so -lm -Wl,-soname -Wl,libspandsp.so.1 -o .libs/libspandsp.so.1.0.0
Why the flags don't change to 0x30? Is the compile command wrong?
Regards
Roy
QuoteReplyEditDelete
2009-08-03 08:34:15 Re: Load share libary Functions into SRAM Problem
Robin Getz (UNITED STATES)
Message: 78303
Roy:
Putting single functions in L1 isn't suppost to change the flags - have a look at the section names. There should be a l1.text and a text section.
QuoteReplyEditDelete
2009-08-03 09:20:42 Re: Load share libary Functions into SRAM Problem
Yi Li (CHINA)
Message: 78309
You may also look at /proc/sram - see if the sram size is large enough.
-Yi
QuoteReplyEditDelete
2009-08-03 22:27:03 Re: Load share libary Functions into SRAM Problem
roy xue (CHINA)
Message: 78321
HI, Robin
I have check the share libary, the .l1.text section from 0xffa00000 to 0xffa00586. The kernel does not have /proc/sram file. Since the 532 have 32KB SRAM, I think it is enough to contain that code.
when asterisk start it say:
root:~> asterisk -f -cvvvvvv
asterisk:582: can't map '/lib/libspandsp.so.1'
asterisk:582: can't map '/lib/libspandsp.so.1'
asterisk: can't load library 'libspandsp.so.1'
Should i need to change the compile flags of the asterisk.
Roy
QuoteReplyEditDelete
2009-08-03 23:04:28 Re: Load share libary Functions into SRAM Problem
Yi Li (CHINA)
Message: 78322
What is your output of "bfin-linux-uclibc-readelf -e libspandsp.so.1"? What is your toolchain and kernel version?
-Yi
QuoteReplyEditDelete
2009-08-03 23:14:23 Re: Load share libary Functions into SRAM Problem
Yi Li (CHINA)
Message: 78325
> the .l1.text section from 0xffa00000 to 0xffa00586. The kernel does not have /proc/sram file. Since the 532 have 32KB SRAM
If SRAM is used by kernel or other program, it is possible your library cannot be loaded. You may check your "# Memory Optimizations" configuration ( to free some L1 mem). Also some mac driver (e.g, bfin_mac) by default uses L1 data memory for tx/rx buffer.
-Yi
QuoteReplyEditDelete
2009-08-04 05:35:27 Re: Load share libary Functions into SRAM Problem
roy xue (CHINA)
Message: 78346
Hi,Yi
I'm using the uClinux-dist-2007R1.1-RC3,blackfin-toolchain-07r1-9.i386.tar.gz
I'm try another kernel module "wcfxs.ko" and it faied too. but that module is run fine at bf537 board.
May be the SRAM space is use up at the 532 board. the "Memory Optimizations" have sellect many options.
Deselect would drop the kernel's performance, which would affect my appliction's performance, isn't it?
How to check the sram status at the 2007R1.1-RC3 kernel?
How to config bfin_mac driver don't use l1 sram?
----------------------------------------------------------------------
root:~> insmod wcfxs.ko
module wcfxs: L1 instruction memory allocation failed
insmod: cannot insert 'mypbx/wcfxs.ko': Operation not permitted (-1): Operation not permitted
----------------------------------------------------------------------
[roy@new-server lib]$ bfin-linux-uclibc-readelf -e libspandsp.so.1
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: Analog Devices Blackfin
Version: 0x1
Entry point address: 0xf8a8
Start of program headers: 52 (bytes into file)
Start of section headers: 652096 (bytes into file)
Flags: 0x2, FDPIC
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 6
Size of section headers: 40 (bytes)
Number of section headers: 27
Section header string table index: 26
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .hash HASH 000000f4 0000f4 001370 04 A 2 0 4
[ 2] .dynsym DYNSYM 00001464 001464 002d10 10 A 3 17 4
[ 3] .dynstr STRTAB 00004174 004174 0030fa 00 A 0 0 1
[ 4] .gnu.version VERSYM 0000726e 00726e 0005a2 02 A 2 0 2
[ 5] .gnu.version_r VERNEED 00007810 007810 000020 00 A 3 1 4
[ 6] .rel.dyn REL 00007830 007830 006508 08 A 2 0 4
[ 7] .rel.plt REL 0000dd38 00dd38 000918 08 A 2 9 4
[ 8] .init PROGBITS 0000e650 00e650 00001a 00 AX 0 0 1
[ 9] .plt PROGBITS 0000e66c 00e66c 00123a 00 AX 0 0 4
[10] .text PROGBITS 0000f8a8 00f8a8 054698 00 AX 0 0 4
[11] .fini PROGBITS 00063f40 063f40 000014 00 AX 0 0 1
[12] .rodata PROGBITS 00063f54 063f54 033ecc 00 A 0 0 4
[13] .rofixup PROGBITS 00097e20 097e20 000004 00 A 0 0 4
[14] .eh_frame_hdr PROGBITS 00097e24 097e24 000008 00 A 0 0 4
[15] .eh_frame PROGBITS 0009be2c 097e2c 000064 00 WA 0 0 4
[16] .ctors PROGBITS 0009be90 097e90 000008 00 WA 0 0 4
[17] .dtors PROGBITS 0009be98 097e98 000008 00 WA 0 0 4
[18] .jcr PROGBITS 0009bea0 097ea0 000004 00 WA 0 0 4
[19] .data.rel.ro PROGBITS 0009bea4 097ea4 001c54 00 WA 0 0 4
[20] .dynamic DYNAMIC 0009daf8 099af8 0000e8 08 WA 3 0 4
[21] .data PROGBITS 0009dbe0 099be0 0008d0 00 WA 0 0 4
[22] .got PROGBITS 0009e4b0 09a4b0 002ed0 00 WA 0 0 8
[23] .bss NOBITS 000a1380 09d380 000d78 00 WA 0 0 4
[24] .comment PROGBITS 00000000 09e588 000ce9 00 0 0 1
[25] .l1.text PROGBITS ffa00000 09e000 000588 00 AX 0 0 4
[26] .shstrtab STRTAB 00000000 09f271 0000cf 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x00000000 0x00000000 0x97e2c 0x97e2c R E 0x1000
LOAD 0x097e2c 0x0009be2c 0x0009be2c 0x05554 0x062cc RW 0x1000
LOAD 0x09e000 0xffa00000 0xffa00000 0x00588 0x00588 R E 0x1000
DYNAMIC 0x099af8 0x0009daf8 0x0009daf8 0x000e8 0x000e8 RW 0x4
GNU_EH_FRAME 0x097e24 0x00097e24 0x00097e24 0x00008 0x00008 R 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8
Section to Segment mapping:
Segment Sections...
00 .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .rofixup .eh_frame_hdr
01 .eh_frame .ctors .dtors .jcr .data.rel.ro .dynamic .data .got .bss
02 .l1.text
03 .dynamic
04 .eh_frame_hdr
05 .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt
----------------------------------------------------------------------------------
[roy@new-server lib]$ bfin-linux-uclibc-readelf -e wcfxs.ko
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: Analog Devices Blackfin
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 24740 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 40 (bytes)
Number of section headers: 24
Section header string table index: 21
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000000 000034 0017e0 00 AX 0 0 4
[ 2] .rela.text RELA 00000000 006464 0014b8 0c 22 1 4
[ 3] .exit.text PROGBITS 00000000 001814 000014 00 AX 0 0 4
[ 4] .rela.exit.text RELA 00000000 00791c 000030 0c 22 3 4
[ 5] .l1.text PROGBITS 00000000 001828 00163c 00 AX 0 0 4
[ 6] .rela.l1.text RELA 00000000 00794c 000f90 0c 22 5 4
[ 7] .init.text PROGBITS 00000000 002e64 000a34 00 AX 0 0 4
[ 8] .rela.init.text RELA 00000000 0088dc 000b88 0c 22 7 4
[ 9] .rodata PROGBITS 00000000 003898 000edc 00 A 0 0 4
[10] .rela.rodata RELA 00000000 009464 00057c 0c 22 9 4
[11] .rodata.str1.4 PROGBITS 00000000 004774 00132c 01 AMS 0 0 4
[12] __param PROGBITS 00000000 005aa0 000118 00 A 0 0 4
[13] .rela__param RELA 00000000 0099e0 0002a0 0c 22 12 4
[14] .modinfo PROGBITS 00000000 005bb8 0001f8 00 A 0 0 4
[15] .data PROGBITS 00000000 005db0 0000b8 00 WA 0 0 4
[16] .rela.data RELA 00000000 009c80 000018 0c 22 15 4
[17] .gnu.linkonce.thi PROGBITS 00000000 005e68 000144 00 WA 0 0 4
[18] .rela.gnu.linkonc RELA 00000000 009c98 000018 0c 22 17 4
[19] .bss NOBITS 00000000 005fac 00074c 00 WA 0 0 4
[20] .comment PROGBITS 00000000 005fac 00003a 00 0 0 1
[21] .shstrtab STRTAB 00000000 005fe6 0000be 00 0 0 1
[22] .symtab SYMTAB 00000000 009cb0 000b50 10 23 127 4
[23] .strtab STRTAB 00000000 00a800 0009ed 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
There are no program headers in this file.
---------------------------------------------------------------------------------------
Regards
Roy
QuoteReplyEditDelete
2009-08-04 05:58:55 Re: Load share libary Functions into SRAM Problem
Yi Li (CHINA)
Message: 78349
Roy,
2007R1.1-RC3 is very old and not supported. If possible, it is better to move to 2009R1 (this will be released soon) or 2008R-1.5.
Newer kernel shows SRAM usage in "/proc/sram", but it is not available on 2007R1.1. If you want to debug, you will have to look at the L1 allocator in kernel, see why the allocation fails.
From the readelf output, it seems you are not using L1 Data SRAM, so the Mac buffer in L1 (if that exists) will not affect.
You can try to free some L1 instruction memory in kernel, at least for test.
-Yi
QuoteReplyEditDelete
2009-08-04 07:27:22 Re: Load share libary Functions into SRAM Problem
roy xue (CHINA)
Message: 78351
YI,
Thanks for you help, I will try your advice.
Roy