Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

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!

18 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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

    How about other apps? Do they have the same problems?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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

    I will look at the mm code when I have time.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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