嵌入系统开发注意事项

来源:互联网 发布:java输出语句 编辑:程序博客网 时间:2024/05/16 23:59

一. NFS
1. 关闭iptable, 否则从开发板上无法访问host上的NFS内容.
/etc/init.d/iptables stop
2. 编辑/etc/exports
增加需要export的选项,如:
/demo3                   *(rw,sync)
3. 启动nfs服务
/etc/init.d/nfs restart
ubuntu下为:
sudo /etc/init.d/nfs-kernel-server restart

二. tftp
1. atftpd
需要的话,安装一个tftpd, 如: atftpd.
ubuntu可能需要自己安装.
2. 使用xinetd
tftp是要inetd来控制的.
如果你使用的是Fedora系统,那么不用自己安装xinetd了.
如果是ubuntu系统, 就需要自己安装xinetd了.
3. 配置/etc/xinetd.conf
里面可能包含
defaults
{
        instances               = 60
        log_type                = SYSLOG authpriv
        log_on_success          = HOST PID
        log_on_failure          = HOST
        cps                     = 25 30
}
includedir /etc/xinetd.d

再查看/etc/xinetd.d, 下面可能包含了
[root@localhost ]# ls /etc/xinetd.d
chargen      cups-lpd  daytime-udp  echo-udp  gssftp  krb5-telnet  ktalk  tftp  time-udp
chargen-udp  daytime   echo         eklogin   klogin  kshell       rsync  time

看到tftp,查看它/etc/xinetd.d/tftp
service tftp
{
        disable = no
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = /tftpboot
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

其中/usr/sbin/in.tftpd -> /usr/sbin/atftpd是个符号联接.
3. /tftpboot
mkdir /tftpboot
chmod 777 /tftpboot
4. 启动xinetd服务
/etc/init.d/xinetd restart

三. NFS启动脚本简例
/sbin/ifconfig lo 127.0.0.1 up
/sbin/ifconfig eth0 192.168.1.100 netmask 255.255.255.0
/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo
/sbin/route add default gw 192.168.1.1

mount -t proc none /proc
mount -t ramfs none /tmp
echo nameserver 168.95.1.1 > /tmp/resolv.conf
cd  /tmp
mkdir demo3
mount -t nfs -o nolock 192.168.1.66:/demo3 /tmp/demo3
cd bin
./sqlite test.db

四. memory查看
1. meminfo查看
先保证proc已经mount
# cat /proc/meminfo
        total:    used:    free:  shared: buffers:  cached:
Mem:  44523520 26906624 17616896        0   282624   311296
Swap:        0        0        0
MemTotal:        43480 kB
MemFree:         17204 kB
MemShared:           0 kB
Buffers:           276 kB
Active:            360 kB
Inactive:          220 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:        43480 kB
LowFree:         17204 kB
SwapTotal:           0 kB
SwapFree:            0 kB
2. top查看
Mem: 28276K used, 15204K free, 0K shrd, 436K buff, 384K cached
Load average: 0.26, 0.15, 0.05    (State: S=sleeping R=running, W=waiting)

  PID USER     STATUS   RSS  PPID %CPU %MEM COMMAND
    9 0        SW         0     1  0.0  0.0 mtdblockd
    1 0        SW         0     0  0.0  0.0 init
    4 0        RW         0     1  2.3  0.0 kswapd
  118 0        SW         0    16  0.0  0.0 sh

3. slabinfo查看
为了提高linux的效率, kernel使用了很多缓存cache, 反映在/proc/slabinfo中
# cat /proc/slabinfo
slabinfo - version: 1.1
inode_cache          212    224    480   28   28    1
dentry_cache         219    270    128    9    9    1

                  active-objects
| allocated-objects
| | object-size
| | | active-slab-allocations
| | | | total-slab-allocations
| | | | | alloc-size
| | | | | |
inode_cache 212 224  480 28 28 1 : x x
| |
limit |
batch-count
在kernel中, 分配是预先使用page_size这样的块大小来分配的,而不是要分配多少时再去分配一个大小。 kernel预先分配了一些基本大小的cache,如:
size-32
size-32(DMA)
size-64
size-64(DMA)
size-96
size-96(DMA)
size-128
size-128(DMA)
也就是说,如果一个object要分配一个60 byte的objects,那么它就可以从size-64的slab中分配(或者如果需要DMA方式访问它们,那么就可以从size-64(DMA)中分配)
这些参数在分析系统内存泄漏时是一个非常有效的方法。你会看到某个size的大小会不断增长, 而没有减小,说明有泄漏。
原创粉丝点击