Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Valued Contributor III
837 Views

who can help me save my memory?

hello! 

I explant my uclinux system form arm(Samsung 4510) to nios2, I need build ppp with serial port, so we need pppd, now I have a terrible problem,I find the pppd consume neraly 1.2M sdram. I can't abide it, beacause only 300kb memory is needed in the arm system. 

I indeed the source is same in the two plats. who can help me? 

Thank you for all response!
0 Kudos
18 Replies
Highlighted
Valued Contributor III
5 Views

Did your arm have shared obj? The current nios2 did not support shared obj yet. 

 

Another question, how do you take the size of the exec obj?
0 Kudos
Highlighted
Valued Contributor III
5 Views

 

--- Quote Start ---  

originally posted by hippo@Mar 8 2006, 09:15 AM 

did your arm have shared obj? the current nios2 did not support shared obj yet. 

 

another question, how do you take the size of the exec obj? 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=13221) 

--- quote end ---  

 

--- Quote End ---  

 

 

Hi,hippo! 

Thanks for your repsonds, there are no mmu in the both flatforms arm and nios2, 

I only use the lib uClibc, I am a begginer, so I don&#39;t know share obj clearly. 

I get the memory size of the pppd exec through catting the /proc/meminfo content. 

I think the free memory&#39;s difference between before and after the pppd run is the memory size of pppd used.In addition, I find 1.2M excess memory is impropriated 

at the begging of ppp building.In other word, the pppd process need almost 2.4Mb memory when they attempt building ppp link with remote. After the ppp link is successful build, the excess 1.2Mb memory will be free 

can you tell another better mothod to caculater the memory size of the exec obj clearly? 

Thanks a lot.
0 Kudos
Highlighted
Valued Contributor III
5 Views

Did you count in buffer/cache for free memory? 

Use "free" command is easier than "cat /proc/meminfo", you should include buffer/cache for free memory.
0 Kudos
Highlighted
Valued Contributor III
5 Views

Hi, hippo. 

thank you for your help.I find the size of cache and the buffer isn&#39;t change,the only difference of the memory info before and after pppd run is freemem.the result is same by "cat /proc/meminfo" and using free command. 

in addition, I find all the application use more memory than arm. 

I am looking forward to you reply, thank you very much
0 Kudos
Highlighted
Valued Contributor III
5 Views

Hi smalllight, 

Let try find out what&#39;s the diff in exec, please use xxxxx-flthdr to each of them.
0 Kudos
Highlighted
Valued Contributor III
5 Views

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

let try find out what&#39;s the diff in exec, please use xxxxx-flthdr to each of them.[/b] 

--- Quote End ---  

 

 

What dose "xxxxx-flthdr" meaning? Could you figure out in detail? Thank u in advance. 

 

BTW, what do those flags meanings? 

 

1. elf2flt -s 16000 / elf2flt -s 8192 

2. gcc -Wl (Does -W have anymore flags? ) or , pls show us how to find more information about hwo to use gcc ?
0 Kudos
Highlighted
Valued Contributor III
5 Views

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

What dose "xxxxx-flthdr" meaning? Could you figure out in detail?[/b] 

--- Quote End ---  

 

the exec format in uclinux is "binary flat" or "flt" in short. 

I need to know the headers of the exec, eg pppd, in both platform. 

For nios2, xxxx is nios2-linux-uclibc-flthdr (or nios2-elf-flthdr) 

For arm, it may be arm-elf-flthdr ? 

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

1. elf2flt -s 16000 / elf2flt -s 8192[/b] 

--- Quote End ---  

 

nios2-linux-uclibc-elf2flt or nios2-elf-elf2flt 

will show the usage. 

-s set stack size 

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

2. gcc -Wl  (Does -W have anymore flags? ) or , pls show us how to find more information about hwo to use gcc ?[/b] 

--- Quote End ---  

 

Those flags are used pass options to linker. 

altera/kits/nios2/documents/gnu-tools 

gcc.gnu.org
0 Kudos
Highlighted
Valued Contributor III
5 Views

Hello, Hippo! 

 

I use the XXXX-flthdr in both of the platforms,the display is as follow: 

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

In nios2 platform:[/b] 

--- Quote End ---  

 

 

[nios2linux@localhost pppd]$ nios2-elf-flthdr pppd 

pppd 

Magic: bFLT 

Rev: 4 

Build Date: Mon Mar 6 17:02:53 2006 

Entry: 0x44 

Data Start: 0x23c30 

Data End: 0x2adf8 

BSS End: 0x46d4c 

Stack Size: 0x1000 

Reloc Start: 0x2adf8 

Reloc Count: 0x1130 

Flags: 0x1 ( Load-to-Ram ) 

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

In arm platform:[/b] 

--- Quote End ---  

 

 

[root@localhost pppd]# arm-elf-flthdr pppd 

pppd 

Magic: bFLT 

Rev: 4 

Build Date: Tue Jul 20 16:25:09 2004 

Entry: 0x50 

Data Start: 0x24c60 

Data End: 0x2b820 

BSS End: 0x359e0 

Stack Size: 0x2000 

Reloc Start: 0x2b820 

Reloc Count: 0xa2e 

Flags: 0x1 ( Load-to-Ram ) 

 

what do you find? Thanks.
0 Kudos
Highlighted
Valued Contributor III
5 Views

I didi find problems in the flts. Let&#39;s look at detail of memory usage. 

Try "cat /proc/(pid of pppd)/maps" for both paltform.
0 Kudos
Highlighted
Valued Contributor III
5 Views

"cat maps" print nothing,the directory /proc/(pppd pid) is as following: 

arm platform:# cat maps# ls -l 

-r--r--r-- 1 root 0 0 Mar 13 10:13 mounts 

lrwxrwxrwx 1 root 0 0 Mar 13 10:13 exels: ls:./exe: No such 

file or directory 

 

lrwxrwxrwx 1 root 0 0 Mar 13 10:13 root -> / 

lrwxrwxrwx 1 root 0 0 Mar 13 10:13 cwd -> / 

-rw------- 1 root 0 0 Mar 13 10:13 mem 

-r--r--r-- 1 root 0 0 Mar 13 10:13 maps 

-r--r--r-- 1 root 0 0 Mar 13 10:13 statm 

-r--r--r-- 1 root 0 0 Mar 13 10:13 stat 

-r--r--r-- 1 root 0 0 Mar 13 10:13 cmdline 

-r--r--r-- 1 root 0 0 Mar 13 10:13 status 

-r-------- 1 root 0 0 Mar 13 10:13 environ 

dr-x------ 2 root 0 0 Mar 13 10:13 fd 

 

nios2 flatform:# cat maps# ls -l 

-r-------- 1 root root 0 Nov 30 00:01 auxv 

-r--r--r-- 1 root root 0 Nov 30 00:00 cmdline 

lrwxrwxrwx 1 root root 0 Nov 30 00:01 cwd -> / 

-r-------- 1 root root 0 Nov 30 00:01 environ 

lrwxrwxrwx 1 root root 0 Nov 30 00:01 exels: ./exe: No such f 

le or directory 

 

dr-x------ 2 root root 0 Nov 30 00:01 fd 

-r--r--r-- 1 root root 0 Nov 30 00:01 maps 

-rw------- 1 root root 0 Nov 30 00:01 mem 

-r--r--r-- 1 root root 0 Nov 30 00:01 mounts 

-rw-r--r-- 1 root root 0 Nov 30 00:01 oom_adj 

-r--r--r-- 1 root root 0 Nov 30 00:01 oom_score 

lrwxrwxrwx 1 root root 0 Nov 30 00:01 root -> / 

-r--r--r-- 1 root root 0 Nov 30 00:00 stat 

-r--r--r-- 1 root root 0 Nov 30 00:01 statm 

-r--r--r-- 1 root root 0 Nov 30 00:01 status 

dr-xr-xr-x 3 root root 0 Nov 30 00:01 task
0 Kudos
Highlighted
Valued Contributor III
5 Views

ll

0 Kudos
Highlighted
Valued Contributor III
5 Views

Please remove your e-mail address in previous post. 

 

Sorry, there is no /proc//maps in nios uclinux. 

Please try /proc/(your ppd process id)/status and statm.
0 Kudos
Highlighted
Valued Contributor III
5 Views

hippo,Thanks you a lot. 

this the result: 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

nios flatforum[/b] 

--- Quote End ---  

# cat /proc/74/status Name:   pppd State:  S (sleeping) SleepAVG:       87% Tgid:   74 Pid:    74 PPid:   64 TracerPid:      0 Uid:    0       0       0       0 Gid:    0       0       0       0 FDSize: 32 Groups: Mem:      544160 bytes Slack:    229815 bytes Shared:        0 bytes Threads:        1 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000000081006 SigCgt: 0000000057816ef9 CapInh: 0000000000000000 CapPrm: 00000000fffffeff CapEff: 00000000fffffeff# cat /proc/74/statm 1065672 1065672 0 146416 0 377528 0 

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

arm platform[/b] 

--- Quote End ---  

 

 

# cat /proc/65/status Name:   pppd State:  S (sleeping) Tgid:   65 Pid:    65 PPid:   44 TracerPid:      0 Uid:    0       0       0       0 Gid:    0       0       0       0 FDSize: 32 Groups: Mem:      239584 bytes Slack:      1292 bytes Shared:        0 bytes SigPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000000081006 SigCgt: 0000000057816ef9 CapInh: 0000000000000000 CapPrm: 00000000fffffeff CapEff: 00000000fffffeff# cat /proc/65/statm 113 113 0 37 0 20 0
0 Kudos
Highlighted
Valued Contributor III
5 Views

I think there may be problems in memory management of nios2 kernel. 

How about other apps? Do they have the same problems?
0 Kudos
Highlighted
Valued Contributor III
5 Views

Thank you hippo for all your coaching. 

my god! evey apps have this problem. the mm code is a sealed book for me. 

 

In addition,I want to download my kernel image from my pc by u-boot. 

Do you know how can I use the u-boot&#39;s ftp service?
0 Kudos
Highlighted
Valued Contributor III
5 Views

I don&#39;t use uboot. Scott is an expert on it. 

I will look at the mm code when I have time.
0 Kudos
Highlighted
Valued Contributor III
5 Views

Our nios2linux Cross Compiler: 

1. bin files from Altera nios2 tools CD under redhat , and we copied them to proper directories. 

2. build some nessary tools according "hippo_mini_nios2linux",such as elf2flt 

3. modify config.arch to export CROSS_COMPILE, CC... 

 

So we guess there are some mistakes happens.  

 

Here we copy our modified config.arch 

 

############################################################################# # Settings for building user apps# ifdef UCLINUX_BUILD_USER     SLIBC        = -lc     SLIBM        = -lm     SLIBNET      =# -lnet#jwq:20051010 avoid route error     SLIBDES      = -ldes     SLIBAES      = -laes     SLIBPCAP     = -lpcap     SLIBSSL      = -lssl     SLIBCRYPTO   = -lcrypto  ifeq ($(LIBCDIR),libc)     SLIBCRYPT    = -lcrypt_old    else     SLIBCRYPT    = -lcrypt# //modi by zlx# reModified :jwq: 20051010 for avoiding pppd error    # SLIBCRYPT    = -lcrypt_old    endif     SLIBPTHREAD  = -lpthread     LIBC        = $(SLIBC)     LIBM        = $(SLIBM)     LIBNET      = $(SLIBNET)     LIBDES      = $(SLIBDES)     LIBAES      = $(SLIBAES)     LIBPCAP     = $(SLIBPCAP)     LIBSSL      = $(SLIBSSL)     LIBCRYPTO   = $(SLIBCRYPTO)     LIBPTHREAD  = $(SLIBPTHREAD)     LIBCRYPT    = $(SLIBCRYPT)     LIBGCC      = -lgcc     LIBIBERTY   = -liberty     LIBIO       = -lio     LIBIOSTREAM = -liostream     LIBSTDCPP   = -lstdc++     LDPATH =      -L$(ROOTDIR)/$(LIBCDIR)/.      -L$(ROOTDIR)/$(LIBCDIR)/lib      -L$(ROOTDIR)/lib/libm      -L$(ROOTDIR)/lib/libnet      -L$(ROOTDIR)/lib/libdes      -L$(ROOTDIR)/lib/libaes      -L$(ROOTDIR)/lib/libpcap      -L$(ROOTDIR)/lib/libcrypt_old      -L$(ROOTDIR)/lib/libssl      -L$(ROOTDIR)/lib/zlib     INCLIBC = -I$(ROOTDIR)/$(LIBCDIR)/include     INCLIBM = -I$(ROOTDIR)/lib/libm     INCNET  = -I$(ROOTDIR)/lib/libnet     INCDES  = -I$(ROOTDIR)/freeswan/libdes     INCAES  = -I$(ROOTDIR)/freeswan/libcrypto/libaes     INCGMP  = -I$(ROOTDIR)/lib/libgmp     INCPCAP = -I$(ROOTDIR)/lib/libpcap     INCSSL  = -I$(ROOTDIR)/lib/libssl/include     INCZ    = -I$(ROOTDIR)/lib/zlib     INCVEND = -I$(ROOTDIR)/vendors/include     INCCRYPTOLD = -I$(ROOTDIR)/lib/libcrypt_old  ifdef CONFIG_USER_DEBUG     CFLAGS  :=  $(if $(UOPT),$(UOPT),-O1) -g  else     CFLAGS  :=  $(if $(UOPT),$(UOPT),-O2) -g -Wall -fomit-frame-pointer  endif     CFLAGS  += $(CPUFLAGS)     CFLAGS  += $(VENDOR_CFLAGS)     CFLAGS  += -Dlinux -D__linux__ -Dunix -D__uClinux__ -DEMBED     CFLAGS  += $(INCLIBC) $(INCLIBM) $(INCCRYPTOLD)     CFLAGS  += -I$(ROOTDIR)     CFLAGS  += -fno-builtin     CFLAGS  += -nostartfiles  ifndef DISABLE_XIP     CFLAGS  += -D__PIC__ -fpic -msingle-pic-base  endif    #    # the following is needed for 2.4    #     CFLAGS  += -I$(ROOTDIR)/$(LINUXDIR)/include     CXXFLAGS = $(CFLAGS) $(INCCXX)  ifeq ($(LIBCDIR),libc)     LDFLAGS  = $(CFLAGS) -Wl,-elf2flt $(ROOTDIR)/lib/libc/crt0.o  else    # LDFLAGS  = $(CFLAGS) -Wl,-elf2flt $(ROOTDIR)/lib/$(LIBCDIR)/lib/crt0.o    #    $(ROOTDIR)/lib/$(LIBCDIR)/lib/crti.o    #    $(ROOTDIR)/lib/$(LIBCDIR)/lib/crtn.o    # jwq:20051005     LDFLAGS  = $(CFLAGS) -Wl,-elf2flt $(ROOTDIR)/$(LIBCDIR)/lib/crt0.o    $(ROOTDIR)/$(LIBCDIR)/lib/crti.o    $(ROOTDIR)/$(LIBCDIR)/lib/crtn.o          endif  ifndef DISABLE_MOVE_RODATA      LDFLAGS += -Wl,-move-rodata  endif     LDFLAGS += $(LDPATH)     LDLIBS         = $(LIBC)     LDLIBS_static  = $(SLIBC)     CXXLIBS        = $(LIBSTDCPP) $(LIBIOSTREAM) $(LIBIO) $(LIBIBERTY)      $(LIBC) $(LIBGCC)# ############################################################################# from nios Rules.mak in order to add right uClibc for nios only CRT0  := $(ROOTDIR)/$(LIBCDIR)/lib/crt0.o LIBC  := $(ROOTDIR)/$(LIBCDIR)/lib/libc.a LIBGCC  := $(shell $(CC) -print-file-name=libgcc.a) LIBM     := $(shell $(CC) -print-file-name=libm.a) LIBGCCDIR   := $(dir $(LIBGCC)) LINKSCRIPT  := $(UTILSDIR)/elf2flt.ld LDFLAGS   := -msys-crt0=$(CRT0) -r -d -L$(ROOTDIR)/$(LIBCDIR)/lib LDLIBS    := $(LIBM) $(LIBGCC) $(LIBC) # ############################################################################# from nios Rules.mak in order to add right uClibc for nios only# but now it is not used # because old arm one(CFLAHS)seems OK# CFLAGS := -nostdinc -D__linux__ -O2 -I$(ROOTDIR)/$(LINUXDIR)/include -I"d:/EDA/altera/kits/nios5/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0"/include -I/cygdrive/d/EDA/altera/kits/nios5/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1//include -fno-optimize-sibling-calls -mhw-mul -mhw-mulx  -Wall# ##################      ifndef FLTFLAGS     FLTFLAGS :=  endif     export FLTFLAGS    # for anyone still using it     CONVERT = /bin/true     UCLINUX_BUILD_SET=1 endif# ########################################################################### 

 

 

and an example of makefile under a user application 

 

#jwq:20051017 PROJ_NAME=chat EXEC = $(PROJ_NAME).exe OBJS = chat.o ifdef CONFIG_USER_CHAT_CHAT_NETWORK CFLAGS += -DENABLE_NETWORK_SUPPORT=1 endif all: $(EXEC)# jwq:20051017 $(PROJ_NAME).bin: $(OBJS)     $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS) romfs:     $(ROMFSINST) /bin/$(PROJ_NAME) clean:     -rm -f $(EXEC) *.elf *.gdb *.o *.bin *.exe $(PROJ_NAME)# ############################################################################ default stack size is 4K# # jwq:20051017 FLTFLAGS:= WARNING_FLAGS := -Wall %.exe : %.flt     cp -f $< $@     cp -f $@ $(PROJ_NAME)# # Make a relocatable flat file from an ELF file.# STACKSIZE is defined by individual makefiles.# %.flt : %.elf     $(ELF2FLT) $(FLTFLAGS) -o $@ $< # # Make a relocatable ELF file.# %.elf : %.bin     $(LD) -T $(LINKSCRIPT) -Ur -o $@ $<     # ########################################################################### 

 

 

 

there is one big difference: 

we find that "-elf2flt" in LDFLAGS has no effect in original Makefile, so we modified Makefile to ELF2FLT explicitly in one step according to Microtronix&#39;s did in Nios2IDE. 

 

here are messages in compling: 

 

nios2-elf-gcc  -O2 -g -Wall -fomit-frame-pointer   -Dlinux -D__linux__ -Dunix -D__uClinux__ -DEMBED -I/home/nios2linux/user_nios2linux/../uClibc_1.4.0/include -I/home/nios2linux/user_nios2linux/lib/libm -I/home/nios2linux/user_nios2linux/lib/libcrypt_old -I/home/nios2linux/user_nios2linux -fno-builtin -nostartfiles -I/home/nios2linux/user_nios2linux/../linux-2.6.x/include   -c -o interface.o interface.c nios2-elf-gcc  -msys-crt0=/home/nios2linux/user_nios2linux/../uClibc_1.4.0/lib/crt0.o -r -d -L/home/nios2linux/user_nios2linux/../uClibc_1.4.0/lib -o loadconfig.bin loadconfig.o conf.o util.o user.o interface.o ../public_function/mysem.o ../public_function/i2c-usr.o /usr/local/bin/../lib/gcc/nios2-elf/3.4.1/../../../../nios2-elf/lib/libm.a /usr/local/bin/../lib/gcc/nios2-elf/3.4.1/libgcc.a /home/nios2linux/user_nios2linux/../uClibc_1.4.0/lib/libc.a -lcrypt nios2-elf-ld -T /usr/local/bin/elf2flt.ld -Ur -o loadconfig.elf loadconfig.bin /usr/local/bin/nios2-elf-elf2flt  -o loadconfig.flt loadconfig.elf cp -f loadconfig.flt loadconfig.exe cp -f loadconfig.exe loadconfig rm loadconfig.flt loadconfig.elf
0 Kudos
Highlighted
Valued Contributor III
5 Views

Yes, mountain8848 may be right. It could be problem of your build system. 

I tested inetd, ftpd and boa on my board, and there is no mm problem. 

 

I would suggest you try the guide on linux, 

http://forum.niosforum.com/forum/index.php?showtopic=3174 (http://forum.niosforum.com/forum/index.php?showtopic=3174)
0 Kudos