embedded linux ,android

顯示具有 project 標籤的文章。 顯示所有文章
顯示具有 project 標籤的文章。 顯示所有文章

2010年12月6日 星期一

satellite


bootcmd=if mmc init; then if run loadbootscript; then run bootscript; else if run loaduimage; then run mmcboot; else run nandboot; fi; fi; else run nandboot; fi
bootdelay=10
baudrate=115200
bootfile=uImage
loadaddr=0x82000000
usbtty=cdc_acm
console=ttyS2,115200n8
mmcargs=setenv bootargs console=${console} root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait
nandargs=setenv bootargs console=${console} root=/dev/mtdblock4 rw rootfstype=jffs2
loadbootscript=fatload mmc 0 ${loadaddr} boot.scr
bootscript=echo Running bootscript from mmc ...; source ${loadaddr}
loaduimage=fatload mmc 0 ${loadaddr} uImage
mmcboot=echo Booting from mmc ...; run mmcargs; bootm ${loadaddr}
nandboot=echo Booting from nand ...; run nandargs; onenand read ${loadaddr} 280000 400000; bootm ${loadaddr}
stdin=serial
stdout=serial
stderr=serial
dieid#=139600211ff00000015a5e590e018014
ethact=smc911x-0
filesize=24A29C

//=====================================

setenv nandboot 'echo Booting from nand ...; run nandargs; nand read ${loadaddr} 280000 400000; bootm ${loadaddr}'
setenv loadaddr '0x80200000' //
setenv console 'ttyS0,115200n8' //............down-

setenv mtdids 'nand0=nand_mtd'
setenv mtdparts 'mtdparts=nand_mtd:0x120000@0(uboot)ro,0x400000@0x280000(kernel)ro,0x1000000@0x1000000(RootFS)ro'
setenv nandargs=setenv bootargs console=${console} $(mtdparts) root=/dev/mtdblock3 rw rootfstype=cramfs
setenv nandboot 'echo Booting from nand ...; run nandargs; nand read ${loadaddr} 280000 400000; bootm ${loadaddr}'

//======================================


1
tar -xzvf iperf-2.0.4.tar.gz  
cd iperf-2.0.4
 
2
export CC=xxx-gcc
export CXX=xxx-g++
./configure --prefix=/root --host=arm-linux
make

3.
tftp -g -r iperf xx.xx.xx.xx

4.
chmod +x iperf
iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------


2010年11月15日 星期一

NAS110_88f6281




uboot env
===NAS110 PCBA nfs_boot:
setenv ipaddr '192.168.1.99'
setenv serverip '192.168.1.100'
setenv setconsole 'console=ttyS0,115200'
setenv setip 'ip=dhcp'
setenv setip 'ip=192.168.1.98'
setenv setnfs 'root=/dev/nfs nfsroot=192.168.1.100:/home/NAS110/rootfilesystem/rootfs'
setenv loadkernel 'tftpboot 0x200000 uImage.20090930'
setenv bootcmd '$(loadkernel);setenv bootargs $(setconsole) $(setip) $(setnfs);bootm 0x200000;'
saveenv

===NAS110 PCBA nand boot(mtd boot)
setenv mtdids 'nand0=nand_mtd'
setenv mtdparts 'mtdparts=nand_mtd:0x100000@0(uboot)ro,0x100000@0x100000(system1),0x100000@0x200000(system2),0x300000@0x300000(kernel)ro,0x700000@0x600000(RootFS)ro'
setenv bootcmd 'nand read 0x2000000 0x300000 0x300000 ;setenv bootargs $(console) $(mtdparts) rootfstype=squashfs root=/dev/mtdblock5;bootm 0x2000000;'
setenv console 'console=ttyS0,115200'
setenv ipaddr '192.168.1.99'
setenv serverip '192.168.1.100'
setenv bootargs ''

===NAS110 PCBA nand boot(ramdisk boot)
setenv loadimage ''
setenv setbootargs 'setenv bootargs console=ttyS0,115200 root=/dev/ram0 rootfstype=squashfs initrd=0x2000000,0x700000 ramdisk_size=7168'
setenv bootcmd 'nand read 0x800000 0x300000 0x300000;nand read 0x2000000 0x600000 0x700000;$(setbootargs);bootm 0x800000;'
setenv console 'console=ttyS0,115200'
setenv ipaddr '192.168.1.99'
setenv serverip '192.168.1.100'

===build squashfs
mksquashfs ./rootfs rootfs20090917

===load image
nand erase 0x300000 0x300000
tftpboot 0x1000000 uImage.20090930
nand write 0x1000000 0x300000 0x300000

nand erase 0x600000 0x700000
tftpboot 0x1000000 rootfs20090917.sqfs
nand write 0x1000000 0x600000 0x700000

===write uboot:
bubt u-boot-db88f6281abp_400db_nand_20090819.bin
bubt u-boot-db88f6281abp_400db_nand@20090821.bin
bubt u-boot-db88f6281abp_400db_nand-3.4.19@20090824.bin
bubt u-boot-db88f6281abp_400db_nand_20090826.bin
bubt u-boot-db88f6281abp_400db_nand_3.4.18_20090826.bin
bubt u-boot-db88f6281abp_3.4.19_nand@20090902.bin
bubt u-boot-db88f6281abp_400db_nand.bin
bubt u-boot-Foxlink-1GB.bin
bubt u-boot-1114.bin
bubt u-boot-20090915.bin
bubt u-boot-20090916.bin
bubt u-boot-20090917_2.bin
==========================================================================
==========================================================================
=====proware nand boot
nand erase  0x300000 0x300000
tftpboot  0x1000000 uImage.20090930
nand write  0x1000000 0x300000 0x300000

nand erase  0x600000 0x3500000
tftpboot  0x1000000 rootfs.squashfs_0930
nand write  0x1000000 0x600000 0x3500000

nand erase 0x3b00000 0x6b00000
tftpboot 0x1000000 dom_0930.img
nand write 0x1000000 0x3b00000 0x6b00000

setenv loadimage ''

setenv setbootargs  ‘setenv bootargs console=ttyS0,115200 rootfstype=squashfs initrd=0x2000000,0x3500000 ramdisk_size=128000’

setenv bootcmd  ‘nand read 0x800000 0x300000 0x300000;nand read 0x200000 0x600000 0x3500000;$(setbootargs);bootm 0x800000;’
bubt
Marvell>> setenv ipaddr '192.168.1.99'
Marvell>> setenv serverip '192.168.1.100'
Marvell>> bubt u-boot-db88f6281abp_400db_nand-3.4.19@20090824.bin
Using egiga0 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.99
Filename 'u-boot-db88f6281abp_400db_nand-3.4.19@20090824.bin'.
Load address: 0x2000000
Loading: #################################################################
         ############################
done
Bytes transferred = 474036 (73bb4 hex)

**Warning**
If U-Boot Endiannes is going to change (LE->BE or BE->LE), Then Env parameters should be overriden..
Override Env parameters? (y/n) n
Erase 0 - 655360 ... 
Copy to Nand Flash... Failed write verify, nand offset 0x00000000. Suggest to erase block and repeat write ope!
 If problem persists suggest marking block as bad (nand markbad ) and repeating the operation!
writing NAND page at offset 0x0 failed
Data did not fit into device, due to bad blocks
Error - NAND burn faild!
build kernel
1. cd /home/NAS110/Kernel/linux-2.6.22.18
2. . ./set_path.sh
3. make mrproper
4. make mv88f6281_defconfig
5. make uImage (uImage會放在arch/arm/boot/)
6. cp ./arch/arm/boot/uImage /home/NAS110/images

2010年11月11日 星期四

Surveyor

Project:   Surveyor
Product:  NAS ( Network Attached Storage )
Solution: Marvell 88F6180 BSP





































Patch
patch_rootfs.sh
#!/bin/sh

. ./scripts/build_subr.sh

#cd ${TOPDIR}/rootfs/dev 
#mknod /dev/nfs b 0 255

touch ${TOPDIR}/rootfs/etc/resolv.conf
chmod 644 ${TOPDIR}/rootfs/etc/resolv.conf

cp ${TOPDIR}/patch/sysconf/services ${TOPDIR}/rootfs/etc

cp ${TOPDIR}/patch/sysconf/smb.conf ${TOPDIR}/rootfs/etc

cp ${TOPDIR}/patch/sysconf/issue ${TOPDIR}/rootfs/etc

cp ${TOPDIR}/patch/sysconf/group ${TOPDIR}/rootfs/etc

cp ${TOPDIR}/patch/sysconf/passwd ${TOPDIR}/rootfs/etc

cp ${TOPDIR}/patch/sysconf/fstab ${TOPDIR}/rootfs/etc

cp ${TOPDIR}/patch/sysconf/inittab.patch ${TOPDIR}/rootfs/etc
cd ${TOPDIR}/rootfs/etc
patch -p0 < inittab.patch
rm -f inittab.patch

chmod 644 ${TOPDIR}/rootfs/etc/inittab ${TOPDIR}/rootfs/etc/fstab

cp -f ${TOPDIR}/patch/sysconf/rcS ${TOPDIR}/rootfs/etc/init.d

mkdir ${TOPDIR}/rootfs/tmp ${TOPDIR}/rootfs/mnt ${TOPDIR}/rootfs/sys
chmod 1777 ${TOPDIR}/rootfs/tmp

mkdir ${TOPDIR}/rootfs/var/lib ${TOPDIR}/rootfs/var/log ${TOPDIR}/rootfs/var/run ${TOPDIR}/rootfs/var/tmp  
chmod 1777 ${TOPDIR}/rootfs/var/tmp

mkdir ${TOPDIR}/rootfs/syrmnt ${TOPDIR}/rootfs/smbmnt

mknod ${TOPDIR}/rootfs/dev/FLK_gpio c 254 0

echo "Done"
patch_server.sh
#!/bin/sh

. ./scripts/build_subr.sh

echo "===start server==="
echo "**此script必須在pwd=/home/surveyor/rootfs下執行 ./scripts/patch_server.sh**"
echo "1. roofs放在/home/surveyor下"
echo "2. uImage放在/home/surveyor/kernel/linux-2.6.22.18-bin下"
echo "3. 請先安裝dhcp-3.0.6-12.fc8"
echo "4. 請先安裝tftp-0.42-5-fc8"
echo "5. 請先安裝nfs-utils-1.1.0-6.fc8"
echo "6. 請先安裝squashfs-tools"
echo "7. 更改uboot env,請參照.../patch/fedora8/uboot_env.conf"

echo "Setting IP"
ifdown eth0
ifconfig eth0 192.168.1.100
ifup eth0

echo "Satrting DHCP"
cp -f ${TOPDIR}/patch/fedora8/dhcpd.conf /etc
/etc/init.d/dhcpd restart

echo "Satrting TFTP"
cp -f ${TOPDIR}/patch/fedora8/tftp /etc/xinetd.d
service xinetd restart

echo "Satrting NFS"
cp -f ${TOPDIR}/patch/fedora8/exports /etc/
/etc/init.d/rpcbind restart
/etc/init.d/nfs restart

echo "Install squashfs"
modprobe squashfs

echo "===Down==="
build_squashfs.sh
#! /bin/sh

. ./scripts/build_subr.sh

today=`date +%Y%m%d`

mksquashfs ./rootfs ./rootfs.image/rootfs.$today.sqfs

chmod +r ./rootfs.image/rootfs.$today.sqfs

cp -f ./rootfs.image/rootfs.$today.sqfs /home/surveyor/kernel/linux-2.6.22.18-bin


Host Env
dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample  
#

ddns-update-style interim;
ignore client-updates;
allow bootp;

subnet 192.168.1.0 netmask 255.255.255.0 {

 range dynamic-bootp 192.168.1.50 192.168.1.60;
 default-lease-time 21600;
 max-lease-time 43200;

      host surveyor {
           hardware ethernet 00:50:43:52:02:29;
           fixed-address 192.168.1.99;
           next-server 192.168.1.3;
           filename "uImage";
           option root-path "/home/surveyor/rootfs/rootfs";
        }

}
exports
/home/surveyor/rootfs/rootfs *(rw,no_root_squash)
tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol.  The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
 socket_type  = dgram
 protocol  = udp
 wait   = yes
 user   = root
 server  = /usr/sbin/in.tftpd
 server_args  = -c -s /home/surveyor/kernel/linux-2.6.22.18-bin
# disable  = yes
 per_source  = 11
 cps   = 100 2
 flags   = IPv4
}
Uboot Env
nfs_boot:
setenv console 'console=ttyS0,115200'
setenv bootargs '$(console) $(bootargs_root) ip=dhcp nfsroot=192.168.1.100:/home/surveyor/rootfs/rootfs'
setenv bootcmd 'nand read 0x2000000 0x300000 0x300000;setenv bootargs $(console) $(mtdparts) $(bootargs_root) ip=dhcp nfsroot=192.168.1.100:/home/surveyor/rootfs/rootfs; bootm 0x2000000;'
setenv ipaddr '192.168.1.99'
setenv serverip '192.168.1.100'

mtd_boot:
setenv mtdid 'nand0=nand_mtd'
setenv mtdparts 'mtdparts=nand_mtd:0x100000@0(uboot)ro,0x100000@0x100000(system1),0x100000@0x200000(system2),0x300000@0x300000(kernel)ro,0x700000@0x600000(RootFS)ro'
setenv bootcmd 'nand read 0x2000000 0x300000 0x300000 ;setenv bootargs $(console) ip=dhcp $(mtdparts) rootfstype=squashfs root=/dev/mtdblock5;bootm 0x2000000;'
setenv console 'console=ttyS0,115200'
setenv ipaddr '192.168.1.99'
setenv serverip '192.168.1.100'

burn to flash:
tftpboot 0x1000000 uImage.20090514
nand erase 0x300000 0x300000
nand write 0x1000000 0x300000 0x300000

tftpboot 0x1000000 rootfs.20090514.sqsh
nand erase 0x600000 0x700000
nand write 0x1000000 0x600000 0x700000
Intergrate BSP
fstab
#/dev/nfs   /          nfs       defaults         0    0
proc       /proc      proc      defaults         0    0
devpts     /dev/pts   devpts    gid=4,mode=620   0    0
sysfs      /sys       sysfs     defaults         0    0
group
root:x:0:root
nobody:x:500:
inittab.patch
--- inittab 2005-12-18 18:52:42.000000000 +0800
+++ inittab.new 2009-05-09 10:41:44.000000000 +0800
@@ -1,6 +1,38 @@
+#/**+===========================================================================
+#File: inittab
+#
+#Description: be parsed for /sbin/init 
+#
+#Revision: V1.0
+#
+#History: 
+#+------------------+-------------+--------------------------------------------+
+#|  date         |   author   |       comments                  |
+#+------------------+-------------+--------------------------------------------+
+#| 2009/05/06    | Wade Chiu  |        Initial build                 |
+#+------------------+-------------+--------------------------------------------+
+#
+#-------------------------------------------------------------------------------
+#** Cheng Uei Precision Industry CONFIDENTIAL
+#** Copyright(C) 2009 Uei Precision Industry Co., Ltd. All Rights Reserved.
+#**
+#** The source code contained or described herein and all documents related
+#** to the source code (Material) are owned by Cheng Uei.
+#** The Material is protected by worldwide copyright and trade secret laws and
+#** treaty provisions. No part of the Material may be used, copied, reproduced,
+#** modified, published, uploaded, posted, transmitted, distributed, or disclosed
+#** in any way without Cheng Uei prior express written permission.
+#============================================================================+*/
+
+#==========================================
+# sysinit script
+#==========================================
 ::sysinit:/etc/init.d/rcS
-::respawn:-/bin/sh
-#::respawn:-/bin/sh
-#tty2::askfirst:-/bin/sh
-#::ctrlaltdel:/bin/umount -a -r
+
+#==========================================
+# respawn
+#==========================================
+# Put a getty on the serial port
+ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100
+
issue
Foxlink NAS release 1 (Serveyor)
passwd
root:$1$$oCLuEVgI1iAqOA8pwkzAg1:0:0:root:/root:/bin/sh
nobody:x:500:500:Linux User,,,:/home/nobody:/bin/sh
rcS
#!/bin/bash

echo "Mounting file system"
/bin/mount -a

ifconfig | head -n 1 | awk '{print $5}' | awk '{FS=":"} {print "RPL"$4$5$6}' | xargs hostname

#execute flk_main_program

echo "Mounting shares"
ntfs-3g -o rw,noatime,nodirtime,remove_hiberfile,streams_interface=windows /dev/sda1 /tmp > /dev/null 2>&1

echo "allow_restart"
echo 1 > /sys/block/sda/device/scsi_disk*/allow_restart

echo "Starting telnet"
/usr/sbin/telnetd -f /etc/issue

echo "Starting samba"
/sbin/nmbd -D -s/etc/smb.conf 
/sbin/smbd -D -s/etc/smb.conf
services
# /etc/services:
# $Id: services,v 1.1 2004/10/09 02:49:18 andersen Exp $
#
# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, most entries here have two entries
# even if the protocol doesn't support UDP operations.
# Updated from RFC 1700, ``Assigned Numbers'' (October 1994).  Not all ports
# are included, only the more common ones.

tcpmux  1/tcp    # TCP port service multiplexer
echo  7/tcp
echo  7/udp
discard  9/tcp  sink null
discard  9/udp  sink null
systat  11/tcp  users
daytime  13/tcp
daytime  13/udp
netstat  15/tcp
qotd  17/tcp  quote
msp  18/tcp    # message send protocol
msp  18/udp    # message send protocol
chargen  19/tcp  ttytst source
chargen  19/udp  ttytst source
ftp-data 20/tcp
ftp  21/tcp
ssh  22/tcp    # SSH Remote Login Protocol
ssh  22/udp    # SSH Remote Login Protocol
telnet  23/tcp
# 24 - private
smtp  25/tcp  mail
# 26 - unassigned
time  37/tcp  timserver
time  37/udp  timserver
rlp  39/udp  resource # resource location
nameserver 42/tcp  name  # IEN 116
whois  43/tcp  nicname
re-mail-ck 50/tcp    # Remote Mail Checking Protocol
re-mail-ck 50/udp    # Remote Mail Checking Protocol
domain  53/tcp  nameserver # name-domain server
domain  53/udp  nameserver
mtp  57/tcp    # deprecated
bootps  67/tcp    # BOOTP server
bootps  67/udp
bootpc  68/tcp    # BOOTP client
bootpc  68/udp
tftp  69/udp
gopher  70/tcp    # Internet Gopher
gopher  70/udp
rje  77/tcp  netrjs
finger  79/tcp
www  80/tcp  http  # WorldWideWeb HTTP
www  80/udp    # HyperText Transfer Protocol
link  87/tcp  ttylink
kerberos 88/tcp  kerberos5 krb5 # Kerberos v5
kerberos 88/udp  kerberos5 krb5 # Kerberos v5
supdup  95/tcp
# 100 - reserved
hostnames 101/tcp  hostname # usually from sri-nic
iso-tsap 102/tcp  tsap  # part of ISODE.
csnet-ns 105/tcp  cso-ns  # also used by CSO name server
csnet-ns 105/udp  cso-ns
# unfortunately the poppassd (Eudora) uses a port which has already
# been assigned to a different service. We list the poppassd as an
# alias here. This should work for programs asking for this service.
# (due to a bug in inetd the 3com-tsmux line is disabled)
#3com-tsmux 106/tcp  poppassd
#3com-tsmux 106/udp  poppassd
rtelnet  107/tcp    # Remote Telnet
rtelnet  107/udp
pop-2  109/tcp  postoffice # POP version 2
pop-2  109/udp
pop-3  110/tcp    # POP version 3
pop-3  110/udp
sunrpc  111/tcp  portmapper # RPC 4.0 portmapper TCP
sunrpc  111/udp  portmapper # RPC 4.0 portmapper UDP
auth  113/tcp  authentication tap ident
sftp  115/tcp
uucp-path 117/tcp
nntp  119/tcp  readnews untp # USENET News Transfer Protocol
ntp  123/tcp
ntp  123/udp    # Network Time Protocol
netbios-ns 137/tcp    # NETBIOS Name Service
netbios-ns 137/udp
netbios-dgm 138/tcp    # NETBIOS Datagram Service
netbios-dgm 138/udp
netbios-ssn 139/tcp    # NETBIOS session service
netbios-ssn 139/udp
swat  901/tcp
imap2  143/tcp    # Interim Mail Access Proto v2
imap2  143/udp
snmp  161/udp    # Simple Net Mgmt Proto
snmp-trap 162/udp  snmptrap # Traps for SNMP
cmip-man 163/tcp    # ISO mgmt over IP (CMOT)
cmip-man 163/udp
cmip-agent 164/tcp
cmip-agent 164/udp
xdmcp  177/tcp    # X Display Mgr. Control Proto
xdmcp  177/udp
nextstep 178/tcp  NeXTStep NextStep # NeXTStep window
nextstep 178/udp  NeXTStep NextStep # server
bgp  179/tcp    # Border Gateway Proto.
bgp  179/udp
prospero 191/tcp    # Cliff Neuman's Prospero
prospero 191/udp
irc  194/tcp    # Internet Relay Chat
irc  194/udp
smux  199/tcp    # SNMP Unix Multiplexer
smux  199/udp
at-rtmp  201/tcp    # AppleTalk routing
at-rtmp  201/udp
at-nbp  202/tcp    # AppleTalk name binding
at-nbp  202/udp
at-echo  204/tcp    # AppleTalk echo
at-echo  204/udp
at-zis  206/tcp    # AppleTalk zone information
at-zis  206/udp
qmtp  209/tcp    # The Quick Mail Transfer Protocol
qmtp  209/udp    # The Quick Mail Transfer Protocol
z3950  210/tcp  wais  # NISO Z39.50 database
z3950  210/udp  wais
ipx  213/tcp    # IPX
ipx  213/udp
imap3  220/tcp    # Interactive Mail Access
imap3  220/udp    # Protocol v3
ulistserv 372/tcp    # UNIX Listserv
ulistserv 372/udp
https  443/tcp    # MCom
https  443/udp    # MCom
snpp  444/tcp    # Simple Network Paging Protocol
snpp  444/udp    # Simple Network Paging Protocol
saft  487/tcp    # Simple Asynchronous File Transfer
saft  487/udp    # Simple Asynchronous File Transfer
npmp-local 610/tcp  dqs313_qmaster # npmp-local / DQS
npmp-local 610/udp  dqs313_qmaster # npmp-local / DQS
npmp-gui 611/tcp  dqs313_execd # npmp-gui / DQS
npmp-gui 611/udp  dqs313_execd # npmp-gui / DQS
hmmp-ind 612/tcp  dqs313_intercell# HMMP Indication / DQS
hmmp-ind 612/udp  dqs313_intercell# HMMP Indication / DQS
#
# UNIX specific services
#
exec  512/tcp
biff  512/udp  comsat
login  513/tcp
who  513/udp  whod
shell  514/tcp  cmd  # no passwords used
syslog  514/udp
printer  515/tcp  spooler  # line printer spooler
talk  517/udp
ntalk  518/udp
route  520/udp  router routed # RIP
timed  525/udp  timeserver
tempo  526/tcp  newdate
courier  530/tcp  rpc
conference 531/tcp  chat
netnews  532/tcp  readnews
netwall  533/udp    # -for emergency broadcasts
uucp  540/tcp  uucpd  # uucp daemon
afpovertcp 548/tcp    # AFP over TCP
afpovertcp 548/udp    # AFP over TCP
remotefs 556/tcp  rfs_server rfs # Brunhoff remote filesystem
klogin  543/tcp    # Kerberized `rlogin' (v5)
kshell  544/tcp  krcmd  # Kerberized `rsh' (v5)
kerberos-adm 749/tcp    # Kerberos `kadmin' (v5)
#
webster  765/tcp    # Network dictionary
webster  765/udp
#
# From ``Assigned Numbers'':
#
#> The Registered Ports are not controlled by the IANA and on most systems
#> can be used by ordinary user processes or programs executed by ordinary
#> users.
#
#> Ports are used in the TCP [45,106] to name the ends of logical
#> connections which carry long term conversations.  For the purpose of
#> providing services to unknown callers, a service contact port is
#> defined.  This list specifies the port used by the server process as its
#> contact port.  While the IANA can not control uses of these ports it
#> does register or list uses of these ports as a convienence to the
#> community.
#
nfsdstatus 1110/tcp
nfsd-keepalive 1110/udp

ingreslock 1524/tcp
ingreslock 1524/udp
prospero-np 1525/tcp   # Prospero non-privileged
prospero-np 1525/udp
datametrics 1645/tcp old-radius # datametrics / old radius entry
datametrics 1645/udp old-radius # datametrics / old radius entry
sa-msg-port 1646/tcp old-radacct # sa-msg-port / old radacct entry
sa-msg-port 1646/udp old-radacct # sa-msg-port / old radacct entry
radius  1812/tcp   # Radius
radius  1812/udp   # Radius
radacct  1813/tcp   # Radius Accounting
radacct  1813/udp   # Radius Accounting
nfsd  2049/tcp nfs
nfsd  2049/udp nfs
cvspserver 2401/tcp   # CVS client/server operations
cvspserver 2401/udp   # CVS client/server operations
mysql  3306/tcp   # MySQL
mysql  3306/udp   # MySQL
rfe  5002/tcp   # Radio Free Ethernet
rfe  5002/udp   # Actually uses UDP only
cfengine 5308/tcp   # CFengine
cfengine 5308/udp   # CFengine
bbs  7000/tcp   # BBS service
#
#
# Kerberos (Project Athena/MIT) services
# Note that these are for Kerberos v4, and are unofficial.  Sites running
# v4 should uncomment these and comment out the v5 entries above.
#
kerberos4 750/udp  kerberos-iv kdc # Kerberos (server) udp
kerberos4 750/tcp  kerberos-iv kdc # Kerberos (server) tcp
kerberos_master 751/udp    # Kerberos authentication
kerberos_master 751/tcp    # Kerberos authentication
passwd_server 752/udp    # Kerberos passwd server
krb_prop 754/tcp    # Kerberos slave propagation
krbupdate 760/tcp  kreg  # Kerberos registration
kpasswd  761/tcp  kpwd  # Kerberos "passwd"
kpop  1109/tcp   # Pop with Kerberos
knetd  2053/tcp   # Kerberos de-multiplexor
zephyr-srv 2102/udp   # Zephyr server
zephyr-clt 2103/udp   # Zephyr serv-hm connection
zephyr-hm 2104/udp   # Zephyr hostmanager
eklogin  2105/tcp   # Kerberos encrypted rlogin
#
# Unofficial but necessary (for NetBSD) services
#
supfilesrv 871/tcp    # SUP server
supfiledbg 1127/tcp   # SUP debugging
#
# Datagram Delivery Protocol services
#
rtmp  1/ddp    # Routing Table Maintenance Protocol
nbp  2/ddp    # Name Binding Protocol
echo  4/ddp    # AppleTalk Echo Protocol
zip  6/ddp    # Zone Information Protocol
#
# Services added for the Debian GNU/Linux distribution
poppassd 106/tcp    # Eudora
poppassd 106/udp    # Eudora
mailq  174/tcp    # Mailer transport queue for Zmailer
mailq  174/tcp    # Mailer transport queue for Zmailer
omirr  808/tcp  omirrd  # online mirror
omirr  808/udp  omirrd  # online mirror
rmtcfg  1236/tcp   # Gracilis Packeten remote config server
xtel  1313/tcp   # french minitel
coda_opcons 1355/udp   # Coda opcons            (Coda fs)
coda_venus 1363/udp   # Coda venus             (Coda fs)
coda_auth 1357/udp   # Coda auth              (Coda fs)
coda_udpsrv 1359/udp   # Coda udpsrv            (Coda fs)
coda_filesrv 1361/udp   # Coda filesrv           (Coda fs)
codacon  1423/tcp venus.cmu # Coda Console           (Coda fs)
coda_aux1 1431/tcp   # coda auxiliary service (Coda fs)
coda_aux1 1431/udp   # coda auxiliary service (Coda fs)
coda_aux2 1433/tcp   # coda auxiliary service (Coda fs)
coda_aux2 1433/udp   # coda auxiliary service (Coda fs)
coda_aux3 1435/tcp   # coda auxiliary service (Coda fs)
coda_aux3 1435/udp   # coda auxiliary service (Coda fs)
cfinger  2003/tcp   # GNU Finger
afbackup 2988/tcp   # Afbackup system
afbackup 2988/udp   # Afbackup system
icp  3130/tcp   # Internet Cache Protocol (Squid)
icp  3130/udp   # Internet Cache Protocol (Squid)
postgres 5432/tcp   # POSTGRES
postgres 5432/udp   # POSTGRES
fax  4557/tcp   # FAX transmission service        (old)
hylafax  4559/tcp   # HylaFAX client-server protocol  (new)
noclog  5354/tcp   # noclogd with TCP (nocol)
noclog  5354/udp   # noclogd with UDP (nocol)
hostmon  5355/tcp   # hostmon uses TCP (nocol)
hostmon  5355/udp   # hostmon uses TCP (nocol)
ircd  6667/tcp   # Internet Relay Chat
ircd  6667/udp   # Internet Relay Chat
webcache 8080/tcp   # WWW caching service
webcache 8080/udp   # WWW caching service
tproxy  8081/tcp   # Transparent Proxy
tproxy  8081/udp   # Transparent Proxy
mandelspawn 9359/udp mandelbrot # network mandelbrot
amanda  10080/udp   # amanda backup services
amandaidx 10082/tcp   # amanda backup services
amidxtape 10083/tcp   # amanda backup services
isdnlog  20011/tcp   # isdn logging system
isdnlog  20011/udp   # isdn logging system
vboxd  20012/tcp   # voice box system
vboxd  20012/udp   # voice box system
binkp           24554/tcp   # Binkley
binkp           24554/udp   # Binkley
asp  27374/tcp   # Address Search Protocol
asp  27374/udp   # Address Search Protocol
tfido           60177/tcp   # Ifmail
tfido           60177/udp   # Ifmail
fido            60179/tcp   # Ifmail
fido            60179/udp   # Ifmail

# Local services
smb.conf
[global]
server string      =  FLKNAS
workgroup          =  SEAGATEGROUP
log file           =  /private/%L.log
max log size       =  1024
security           =  share
smb passwd file    =  /private/smbpasswd
private dir        =  /private
dns proxy          =  No
lock directory     =  /private/locks
pid directory      =  /private/locks
client lanman auth =  yes
use sendfile       =  yes
vfs objects        =  streams_xattr

[tmp]
path=/tmp
read only=no
public=yes
Porting Server
build_ntfs-3g.sh
#!/bin/sh

. ./scripts/build_subr.sh

rm -rf ${INSTALLDIR}
mkdir -p ${INSTALLDIR}
unpack "ntfs-3g-2009.4.4"
SRC="build/ntfs-3g-2009.4.4"

cd ${TOPDIR}/${SRC}

export  LD_LIBARY_PATH=${CROSS_COMPILE}/lib
export  CPPFLAGS=-I${CROSS_COMPILE}/include
export  LDFLAGS=-L${CROSS_COMPILE}/lib
export  CC=${CROSS_COMPILE}-gcc
export  PATH=${PATH}:${TOPDIR}/tools/gcc/bin

./configure --host=arm-linux --prefix=${INSTALLDIR} --exec-prefix=${INSTALLDIR}

make
check_errno

make install
check_errno

cd ${INSTALLDIR}/..

tar -jc -f ${TOPDIR}/pkg/softfp/ntfs-3g-2009.4.4.full-bin.tar.bz2 ${ROOTFS}
check_errno

mv ${INSTALLDIR}/share ${INSTALLDIR}/share.qq
rm -rf ${INSTALLDIR}/share.qq 

#rm -f ${INSTALLDIR}/bin/ntfs-3g.probe

mv ${INSTALLDIR}/lib/pkgconfig ${INSTALLDIR}/lib/pkgconfig.qq
rm -rf ${INSTALLDIR}/lib/pkgconfig.qq

mv ${INSTALLDIR}/include ${INSTALLDIR}/include.qq
rm -rf ${INSTALLDIR}/include.qq

mv ${INSTALLDIR}/sbin ${INSTALLDIR}/sbin.qq
rm -rf ${INSTALLDIR}/sbin.qq 

tar -jc -f ${TOPDIR}/pkg/softfp/ntfs-3g-2009.4.4-bin.tar.bz2 ${ROOTFS} 
check_errno

mv ${TOPDIR}/build ${TOPDIR}/build.qq
mkdir -p ${TOPDIR}/build
rm -rf ${TOPDIR}/build.qq &

mv ${TOPDIR}/tmp ${TOPDIR}/tmp.qq
mkdir -p ${TOPDIR}/tmp
rm -rf ${TOPDIR}/tmp.qq &   

cd ${TOPDIR}
build_samba.sh
#!/bin/sh

. ./scripts/build_subr.sh

rm -rf ${INSTALLDIR}
mkdir -p ${INSTALLDIR}
unpack "samba-3.3.4"
SRC="build/samba-3.3.4/source"

cp -f ${TOPDIR}/patch/samba-3.3.4/configure.patch ${TOPDIR}/${SRC}
cp -f ${TOPDIR}/patch/samba-3.3.4/mtab.c.patch ${TOPDIR}/${SRC}/client

cd ${TOPDIR}/${SRC}
patch -p0 < configure.patch

cd ${TOPDIR}/${SRC}/client
patch -p0 < mtab.c.patch

cd ..

export  LD_LIBARY_PATH=${CROSS_COMPILE}/lib
export  CPPFLAGS=-I${CROSS_COMPILE}/include
export  LDFLAGS=-L${CROSS_COMPILE}/lib
export  CC=${CROSS_COMPILE}-gcc
export  PATH=${PATH}:${TOPDIR}/tools/gcc/bin

export samba_cv_CC_NEGATIVE_ENUM_VALUES=yes
export libreplace_cv_READDIR_GETDIRENTRIES=no
export libreplace_cv_READDIR_GETDENTS=no
export linux_getgrouplist_ok=no
export samba_cv_HAVE_WRFILE_KEYTAB=yes
export samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes
export samba_cv_HAVE_IFACE_IFCONF=yes

./configure --build=i686-linux --host=arm-linux --target=arm-linux --prefix=${INSTALLDIR} --disable-shared --disable-cups --disable-iprint --disable-pie --disable-fam --without-ldap

cp -f ${TOPDIR}/patch/samba-3.3.4/config.h ${TOPDIR}/${SRC}/include

make
check_errno

make install
check_errno

cd ${INSTALLDIR}/..

tar -jc -f ${TOPDIR}/pkg/softfp/samba-3.3.4.full-bin.tar.bz2 ${ROOTFS} 
check_errno

mv ${INSTALLDIR}/swat ${INSTALLDIR}/swat.qq
rm -rf ${INSTALLDIR}/swat.qq

mv ${INSTALLDIR}/share ${INSTALLDIR}/share.qq
rm -rf ${INSTALLDIR}/share.qq 

rm -f ${INSTALLDIR}/sbin/mount.cifs
rm -f ${INSTALLDIR}/sbin/swat
rm -f ${INSTALLDIR}/sbin/umount.cifs
rm -f ${INSTALLDIR}/sbin/winbindd

mv ${INSTALLDIR}/lib ${INSTALLDIR}/lib.qq
rm -rf ${INSTALLDIR}/lib.qq

mv ${INSTALLDIR}/include ${INSTALLDIR}/include.qq
rm -rf ${INSTALLDIR}/include.qq

mv ${INSTALLDIR}/bin ${INSTALLDIR}/bin.qq
rm -rf ${INSTALLDIR}/bin.qq 

tar -jc -f ${TOPDIR}/pkg/softfp/samba-3.3.4-bin.tar.bz2 ${ROOTFS} 
check_errno

mv ${TOPDIR}/build ${TOPDIR}/build.qq
mkdir -p ${TOPDIR}/build
rm -rf ${TOPDIR}/build.qq &

mv ${TOPDIR}/tmp ${TOPDIR}/tmp.qq
mkdir -p ${TOPDIR}/tmp
rm -rf ${TOPDIR}/tmp.qq &   

cd ${TOPDIR}
configure.patch
--- configure 2009-04-29 02:53:51.000000000 +0800
+++ configure.new 2009-05-05 16:23:23.000000000 +0800
@@ -13066,13 +13066,17 @@
 else
 
     if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
+#  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+#   { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: uclibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: uclibc <= samba 3.3.4 check skipped" >&2;
+}
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -23586,12 +23590,12 @@
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
+   builtin and then its argument prototype would st cannot run test program while cross compilingill apply.  */
 #ifdef __cplusplus
 extern "C"
 #endif
 char $ac_func ();
-/* The GNU C library defines this for functions which it implements
+/* The GNU C library defines this for functions whi cannot run test program while cross compilingch it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
 #if defined __stub_$ac_func || defined __stub___$ac_func
@@ -23801,13 +23805,17 @@
 else
 
  if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
+#  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+#   { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -23989,13 +23997,17 @@
 else
 
  if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
+#  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+#   { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}   
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -44068,13 +44080,17 @@
     *linux*)
        # glibc <= 2.3.2 has a broken getgrouplist
        if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
+#  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+#   { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}   
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -67118,13 +67134,17 @@
 else
 
     if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
+#  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+#   { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}   
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -67393,13 +67413,17 @@
  LDFLAGS="$LDFLAGS";
  export LDFLAGS;
  if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
+#  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+#   { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}   
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -67494,13 +67518,17 @@
  LDFLAGS="$LDFLAGS";
  export LDFLAGS;
  if test "$cross_compiling" = yes; then
-  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-$as_echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }; }
+#  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+#$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+#{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&5
+#$as_echo "$as_me: error: cannot run test program while cross compiling
+#See \`config.log' for more details." >&2;}
+#   { (exit 1); exit 1; }; }; }
+{
+echo "$as_me:$LINENO: glibc <= samba 3.3.4 check skipped" >&5
+echo "$as_me: glibc <= samba 3.3.4 check skipped" >&2;
+}   
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
mtab.c.patch
--- mtab.c 2009-04-28 14:46:16.000000000 +0800
+++ mtab.c.new 2009-05-05 16:25:33.000000000 +0800
@@ -34,6 +34,8 @@
 #include <sys/time.h>
 #include <time.h>
 #include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <mntent.h>
 #include <stdlib.h>
 #include <signal.h>
Application
netlink_udev.c
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include <ctype.h> 
#include <sys/un.h> 
#include <sys/ioctl.h> 
#include <sys/socket.h> 
#include <linux/types.h> 
#include <linux/netlink.h> 
#include <errno.h> 
#include <unistd.h> 
#include <arpa/inet.h> 
#include <netinet/in.h> 

#define UEVENT_BUFFER_SIZE 2048 

static int init_hotplug_sock() 
{ 
    const int buffersize = 1024; 
    int ret; 

    struct sockaddr_nl snl; 
    bzero(&snl, sizeof(struct sockaddr_nl)); 
    snl.nl_family = AF_NETLINK; 
    snl.nl_pid = getpid(); 
    snl.nl_groups = 1; 

    int s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT); 
    if (s == -1)  
    { 
        perror("socket"); 
        return -1; 
    } 
    setsockopt(s, SOL_SOCKET, SO_RCVBUF, &buffersize, sizeof(buffersize)); 

    ret = bind(s, (struct sockaddr *)&snl, sizeof(struct sockaddr_nl)); 
    if (ret < 0)  
    { 
        perror("bind"); 
        close(s); 
        return -1; 
    } 

    return s; 
} 

int main(int argc, char* argv[]) 
{ 
   int hotplug_sock = init_hotplug_sock(); 
  
    while(1) 
    { 
      /* Netlink message buffer */ 
        char buf[UEVENT_BUFFER_SIZE * 2] = {0}; 
        recv(hotplug_sock, &buf, sizeof(buf), 0); 
        printf("%s\n", buf); 
    } 
    return 0; 
}
scsi_serial.c
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <scsi/sg.h>

#define SCSI_TIMEOUT 5000 /* ms */

static char *device  = "/dev/sdd";

int scsi_io(int fd, unsigned char *cdb, unsigned char cdb_size, int xfer_dir, 
            unsigned char *data, unsigned int *data_size, 
            unsigned char *sense, unsigned int *sense_len)
{
    sg_io_hdr_t io_hdr;

    memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
    io_hdr.interface_id = 'S';

    /* CDB */
    io_hdr.cmdp = cdb;
    io_hdr.cmd_len = cdb_size;

    /* Where to store the sense_data, if there was an error */
    io_hdr.sbp = sense;
    io_hdr.mx_sb_len = *sense_len;
    *sense_len=0;

    /* Transfer direction, either in or out. Linux does not yet
       support bidirectional SCSI transfers ?
     */
    io_hdr.dxfer_direction = xfer_dir;

    /* Where to store the DATA IN/OUT from the device and how big the
       buffer is
     */
    io_hdr.dxferp = data;
    io_hdr.dxfer_len = *data_size;

    /* SCSI timeout in ms */
    io_hdr.timeout = SCSI_TIMEOUT;

    if(ioctl(fd, SG_IO, &io_hdr) < 0){
        perror("SG_IO ioctl failed");
        return -1;
    }

    /* now for the error processing */
    if((io_hdr.info & SG_INFO_OK_MASK) != SG_INFO_OK){
        if(io_hdr.sb_len_wr > 0){
            *sense_len=io_hdr.sb_len_wr;
            return 0;
        }
    }
    if(io_hdr.masked_status){
        printf("status=0x%x\n", io_hdr.status);
        printf("masked_status=0x%x\n", io_hdr.masked_status);
        return -2;
    }
    if(io_hdr.host_status){
        printf("host_status=0x%x\n", io_hdr.host_status);
        return -3;
    }
    if(io_hdr.driver_status){
        printf("driver_status=0x%x\n", io_hdr.driver_status);
        return -4;
    }
    return 0;
}

int scsi_inquiry_unit_serial_number(int fd)
{
    unsigned char cdb[]={0x12,0x01,0x80,0,0,0};

    unsigned int data_size=0x00ff;
    unsigned char data[data_size];

    unsigned int sense_len=32;
    unsigned char sense[sense_len];

    int res, pl, i;

    cdb[3]=(data_size>>8)&0xff;
    cdb[4]=data_size&0xff;


    printf("INQUIRY Unit Serial Number:\n");

    res=scsi_io(fd, cdb, sizeof(cdb), SG_DXFER_FROM_DEV, data, &data_size, sense, &sense_len);
    if(res){
        printf("SCSI_IO failed\n");
        return -1;
    }
    if(sense_len){
        return -1;
    }

    /* Page Length */
    pl=data[3];

    /* Unit Serial Number */
    printf("Unit Serial Number:");
    for(i=4;i<(pl+4);i++)printf("%c",data[i]&0xff);printf("\n");
    return 0;
}

int open_scsi_device(const char *dev)
{
    int fd, vers;

    if((fd=open(dev, O_RDWR))<0){
        printf("ERROR could not open device %s\n", dev);
        return -1;
    }
    if ((ioctl(fd, SG_GET_VERSION_NUM, &vers) < 0) || (vers < 30000)) {
        printf("/dev is not an sg device, or old sg driver\n");
        close(fd);
        return -1;
    }

    return fd;
}

int main(int argc, const char *argv[])
{
    int fd;

    fd=open_scsi_device(device);
    if(fd<0){
        printf("Could not open SCSI device %s\n",device);
        _exit(10);
    }

    scsi_inquiry_unit_serial_number(fd);
    return 0;
}
FSinotify.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/file.h>
#include <sys/sysinfo.h>
#include <sys/epoll.h>
#include <signal.h>
#include <linux/inotify.h>
#include <net/if.h>
#include <netinet/in.h>
 
struct queue_struct
{
    int capacity;
    int front;
    int rear;
    int size;
    void **array;
};
 
struct queue_struct;
typedef struct queue_struct *queue_t;
 
int queue_empty (queue_t q)
{
    return q->size == 0;
}
 
int queue_full (queue_t q)
{
    return q->size == q->capacity;
}


void queue_make_empty (queue_t q)
{
    q->size = 0;
    q->front = 1;
    q->rear = 0;
}
 
queue_t queue_create (int num_elements)
{
    queue_t q;
 
    q = malloc (sizeof (struct queue_struct));
 
    if (q == NULL)
        exit (-1);
 
    q->array = malloc(sizeof (void *) * num_elements);
 
    if (q->array == NULL)
        exit (-1);
 
    q->capacity = num_elements;
 
    queue_make_empty (q);
 
    return q;
}
 
void queue_destroy (queue_t q)
{
    if (q != NULL)
    {
        if (q->array)
            free (q->array);
 
        free (q);
    }
}
 
 
static int next_position (int v, queue_t q)
{
    if (++v == q->capacity) {
        v = 0;
    }
 
    return v;
}
 
void queue_enqueue (void *d, queue_t q)
{
    if (queue_full (q))
    {
        return;
    }
 
    q->size++;
    q->rear = next_position (q->rear, q);
    q->array[q->rear] = d;
}
 
void *queue_front (queue_t q)
{
    if (!queue_empty(q))
        return q->array [q->front];
 
    return NULL;
}
 
void queue_dequeue (queue_t q)
{
    if (!queue_empty (q))
    {
        q->size--;
        q->front = next_position (q->front, q);
    }
}
 
/* This method does the dirty work of determining what happened,
then allows us to act appropriately
*/
void handle_event (struct inotify_event *event)
{
    /* If the event was associated with a filename, we will store it here */
    char * cur_event_filename = NULL;
    /* This is the watch descriptor the event occurred on */
    int cur_event_wd = event->wd;
    if (event->len)
    {
        cur_event_filename = event->name;
    }
    printf("FILENAME=%s\n", cur_event_filename);
    printf("watch descriptor=%d\n",cur_event_wd);
    printf("\n");
    /* Perform event dependent handler routines */
    /* The mask is the magic that tells us what file operation occurred */
    switch (event->mask)
    {
    /* File was accessed */
    case IN_ACCESS:
        printf("ACCESS EVENT OCCURRED: File \"%s\" on WD #%i\n",
        cur_event_filename, cur_event_wd);
    break;
    /* File was modified */
    case IN_MODIFY:
        printf("MODIFY EVENT OCCURRED: File \"%s\" on WD #%i\n",
        cur_event_filename, cur_event_wd);
    break;
    /* File changed attributes */
    case IN_ATTRIB:
        printf("ATTRIB EVENT OCCURRED: File \"%s\" on WD #%i\n",
        cur_event_filename, cur_event_wd);
    break;
    /* File was closed */
    case IN_CLOSE:
        printf("CLOSE EVENT OCCURRED: File \"%s\" on WD #%i\n",
    cur_event_filename, cur_event_wd);
    break;
    /* File was opened */
    case IN_OPEN:
    printf("OPEN EVENT OCCURRED: File \"%s\" on WD #%i\n",
    cur_event_filename, cur_event_wd);
    break;
    /* File was moved from X */
    case IN_MOVED_FROM:
        printf("MOVE_FROM EVENT OCCURRED: File \"%s\" on WD #%i\n",
        cur_event_filename, cur_event_wd);
    break;
    /* File was moved to X */
    case IN_MOVED_TO:
        printf("MOVE_TO EVENT OCCURRED: File \"%s\" on WD #%i\n",
        cur_event_filename, cur_event_wd);
    break;
    /* Watched entry was deleted */
    case IN_DELETE_SELF:
        printf("DELETE_SELF EVENT OCCURRED: File \"%s\" on WD #%i\n",
        cur_event_filename, cur_event_wd);
    break;
    /* Backing FS was unmounted */
    case IN_UNMOUNT:
        printf("UNMOUNT EVENT OCCURRED: File \"%s\" on WD #%i\n",
        cur_event_filename, cur_event_wd);
    break;
    /* Too many FS events were received without reading them
    some event notifications were potentially lost. */
    case IN_Q_OVERFLOW:
        printf("Warning: AN OVERFLOW EVENT OCCURRED: \n");
        break;
    case IN_IGNORED:
        printf("IGNORED EVENT OCCURRED: \n");
    break;
    /* Some unknown message received */
    default:
    printf ("UNKNOWN EVENT OCCURRED for file \"%s\" on WD #%i\n",
    cur_event_filename, cur_event_wd);
    break;
    }
}
 
void handle_events (queue_t q)
{
    struct inotify_event *event;
    while (!queue_empty (q))
    {
        event = queue_front (q);
        queue_dequeue (q);
        handle_event (event);
        free (event);
    }
}
 
int event_check (int fd)
{
    struct timeval timeout;
    int r;
    fd_set rfds;
 
    timeout.tv_sec = 4;
    timeout.tv_usec = 0;
 
    FD_ZERO(&rfds);
    FD_SET(fd, &rfds);
 
    r = select (fd+1, &rfds, NULL, NULL, &timeout);
 
    return r;
}
 
int read_events (queue_t q, int fd)
{
    char buffer[16384];
    size_t buffer_i;
    struct inotify_event *pevent, *event;
    ssize_t r;
    size_t event_size;
    int count = 0;
 
    r = read (fd, buffer, 16384);
 
    if (r <= 0)
        return r;
 
    buffer_i = 0;
    while (buffer_i < r)
    {
        /* Parse events and queue them ! */
        pevent = (struct inotify_event *)&buffer[buffer_i];
        event_size = sizeof(struct inotify_event) + pevent->len;
        event = malloc(event_size);
        memmove(event, pevent, event_size);
        queue_enqueue(event, q);
        buffer_i += event_size;
        count++;
    }
 
    return count;
}
 
int process_inotify_events (queue_t q, int iid)
{
    while (1)
    {
        if( !queue_empty(q) )
        {
            handle_events(q);
        }
        if (event_check(iid) > 0)
        {
            int r;
            r = read_events(q, iid);
            if (r < 0)
                break;
        }
    }
    return 0;
}
 
int main()
{
    queue_t q;
    int     iid;
    int     wd;
    
    q    = queue_create(128);
    iid = inotify_init(); 
    wd   = inotify_add_watch(iid,"/home/test/", IN_CLOSE_WRITE );
    process_inotify_events(q,iid);
  
    queue_destroy(q);
    close(iid);
    return 0;
}




主要工作小結
1. 架設版本控制平台 SVN
2. 專案版本控制管理

3. 專案開發環境架設 fedora8及其BSP環境

4. 管理與整合BSP

5.  build imagerelease版本

6. 應用程式開發



心得

1. 更熟析embedded linux
2. 熟西建構root file system
3. 對linux system programming有一定的了解





2010年11月10日 星期三

MIDC

ProjectMIDC

BIOS:
--英文Basic Input/output System的縮寫,意思是“基本輸入/輸出系統”。

實際上它是被固化在電腦ROM(只讀記憶體)晶片上的一組程式(但大多數人把他當成了一塊
晶片或是CMOS),為電腦提供最低級的、最直接的硬體控制與支援。更形象地說,BIOS就是硬體與軟體程式之間的一個橋梁或者說是介面(雖然它本身也只是一個程式) ,負責解決硬體的即時需求,並按軟體對硬體的操作要求具體執行。負責在電腦開啟時檢測、初始化系統設備、裝入作業系統並調度作業系統向硬體發出的指令。

Embedded Controller:
--即:嵌入式控制器,簡稱EC。
EC在筆記本電腦中有著相當重要的作用,用於控制主要I/O的周邊設備,例如:鍵盤、滑鼠、觸控板等。EC中一般內建某種型號的微處理器(如8032),可以讓筆記本完成各種複雜的ACPI電源管理(包括風扇控制管理)等等。EC除了本身硬體之外,還需要Firmeare(微代碼),這個部分主要由EC廠商和和幾大BIOS生產公司(如Phonix等)配合開發完成。
很多EC都採用了share memory的架構,也就是EC的代碼和系統BIOS代碼共同儲存于同一個FlashRom內。也正是因為這一點,IBM的BIOS升級時,往往需要連同EC一塊升級。其實Embedded Controller是OS載入之前的I/O控制器。光碟機能開機USB device也能開機,這些就是Embedded Controller在做的事

主要工作小結
EC的touch key( SO340010 ) 控制

心得
對firmware有初步了解

參考書籍
1. BIOS 研發技術剖析第二版
2. 以C語言解析電腦

Taurus

Project:   Taurus
Product:  2-bay NAS ( Network Attached Storage )
Solution: Oxford OXE810DSE BSP


























Features:
  • Seamless interface to 2 integrated SATA ports, expandable using PCI SATA bridge chips
  • Accessible from multiple clients using Ethernet (integrated 10/100/1000 Ethernet MAC) with GMII support, or IEEE 802.11 Wi.Fi (via PCI Wi.Fi chips)
  • 367 MHz ARM926EJ.S processor with 32.Kbyte caches & MMU
  • Network coprocessor with TCP / IP acceleration
  • Supports multiple software architectures: Linux OS, TCP/IP & CIFS, EXT3 or XFS
  • Integrated fan tachometer/thermistor controller and pulse width modulators
  • Hardware AES.based encryption supports multiple
  • authentication methods & devices for secure storage of user data
  • 5 channel DMA controller
  • USB 2.0 (high.speed) and USB 1.1 (full.speed) host controllers
  • 128 Kbyte on.chip SRAM
  • DDR1 & DDR2 SDRAM controller 16.bit interface supports combinations up to 256 Mbytes addressable storage
  • 16 bit static memory interface (optional—device boots from HDD) supports up to 4 Mbytes addressable storage per chipselect
  • 90 nm CMOS process with 1.0 V core
  • 19 mm × 19 mm 272 pin PBGA (1 mm ball pitch)




























Application
flk_alarm.c
/**+===========================================================================
File: flk_alarm.c

Description: main program used to control RTC alarm on OX810 platform

Revision: V1.0

History: 
+------------------+-------------+--------------------------------------------+
|  date          |   author    |      comments                       |
+------------------+-------------+--------------------------------------------+
|   2008/07/03     |  Wade Chiu  |     Initial built                          |
+------------------+-------------+--------------------------------------------+

-------------------------------------------------------------------------------
** Cheng Uei Precision Industry CONFIDENTIAL
** Copyright(C) 2008 Uei Precision Industry Co., Ltd. All Rights Reserved.
**
** The source code contained or described herein and all documents related
** to the source code (Material) are owned by Cheng Uei.
** The Material is protected by worldwide copyright and trade secret laws and
** treaty provisions. No part of the Material may be used, copied, reproduced,
** modified, published, uploaded, posted, transmitted, distributed, or disclosed
** in any way without Cheng Uei prior express written permission.
============================================================================+*/


//====================================================================//
// header files                            //
//====================================================================//
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/time.h>
#include <linux/rtc.h>
#include <linux/ioctl.h>
//#include <asm/rtc.h>
#include "flk_comm_debug_api.h"

//====================================================================//
// definition of constant                                  //
//====================================================================//
#define rtm_sec  0
#define rtm_min  50
#define rtm_hour 10
#define rtm_mday 4
#define rtm_mon  6

//====================================================================//
// functions protyping                                                //
//====================================================================//

//====================================================================//
// functions definition                                               //
//====================================================================//
int main(void)
{
    struct rtc_wkalrm walrm;
    struct rtc_wkalrm ralrm;
    int               fd;
    int               rvalue;

//open rtc device
    fd = open("/dev/rtc",O_RDWR);
    if( fd == -1 ) 
    {
 _FLK_PERROR("open /dev/rtc error.");
 exit(-1);
    }

//show write alarm
    walrm.enabled        = 1;
    walrm.pending        = 0; 
    walrm.time.tm_sec   = rtm_sec;
    walrm.time.tm_min   = rtm_min;
    walrm.time.tm_hour  = rtm_hour;
    walrm.time.tm_mday = rtm_mday;
    walrm.time.tm_mon  = rtm_mon;

//set alarm
 rvalue = ioctl(fd,RTC_WKALM_SET,&walrm);
 if( rvalue != 0 )
 {
  _FLK_PERROR("set rtc alarm error.");
  close(fd);
        exit(-1);
 }

//read alarm
 rvalue = ioctl(fd,RTC_WKALM_RD,&ralrm);
 if( rvalue != 0 )
 {
  _FLK_PERROR("set read alarm error.");
  close(fd);
        exit(-1);
 }

//show read alarm
    printf("date:%d %d\n",ralrm.time.tm_mon+1,ralrm.time.tm_mday);
    printf("time:%d %d %d\n",ralrm.time.tm_hour,ralrm.time.tm_min,ralrm.time.tm_sec);
//close device
    close(fd);

 exit(0);
}
flk_hw_reset.c
/**+===========================================================================
File: flk_hw_reset.c
Description: main program used to control LED status on OX810 platform
Revision: V1.0
History: 
+------------------+-------------+--------------------------------------------+
|  date          |   author    |      comments                       |
+------------------+-------------+--------------------------------------------+
|   2008/06/20     |  Wade Chiu  |     Initial built                          |
+------------------+-------------+--------------------------------------------+

-------------------------------------------------------------------------------
** Cheng Uei Precision Industry CONFIDENTIAL
** Copyright(C) 2008 Uei Precision Industry Co., Ltd. All Rights Reserved.
**
** The source code contained or described herein and all documents related
** to the source code (Material) are owned by Cheng Uei.
** The Material is protected by worldwide copyright and trade secret laws and
** treaty provisions. No part of the Material may be used, copied, reproduced,
** modified, published, uploaded, posted, transmitted, distributed, or disclosed
** in any way without Cheng Uei prior express written permission.
============================================================================+*/
//====================================================================//
// header files                            //
//====================================================================//
#include "flk_gpio_ioctl_cmd.h"
#include "flk_comm_debug_api.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>            
//====================================================================//
// definition of constant                  //
//====================================================================//

//====================================================================//
// functions protyping                                                //
//====================================================================//

//====================================================================//
// functions definition                                               //
//====================================================================//
int main(void)
{
    int  fd;
    int  rvalue; 
    int  wvalue; 
//open gpio
    fd = open("/dev/FLK_gpio",O_RDWR); 
    if( fd == -1 ) 
    {
 exit(-1);
    } 
//hardware reset
    wvalue = 0;
    rvalue = ioctl(fd,FLK_IOCTL_WRITE_GPIO_3,&wvalue); 
    if( rvalue != 0 ) 
    {  
        exit(-1);
    }
//close device
    close(fd);
    exit(0);
}
flk_common_debug_api.h
#ifndef _FLK_COMM_DEBUG_API_H
#define _FLK_COMM_DEBUG_API_H

/*=============================================================================
// Include files
//============================================================================*/
#ifdef __KERNEL__
 #include <linux/kernel.h>
#else
 #include <stdio.h>
#endif

/*=============================================================================
// Function used to print out error message 
//============================================================================*/
#ifdef __KERNEL__
    #define _FLK_PERROR(...)        printk(KERN_CRIT "[Error][File::%s--Function::%s(%d)]--",__FILE__,__FUNCTION__,__LINE__); \
         printk(KERN_CRIT __VA_ARGS__); \
         printk(KERN_CRIT "\n\n")
#else
    #define _FLK_PERROR(...)        printf("[Error][File::%s--Function::%s(%d)]--",__FILE__,__FUNCTION__,__LINE__); \
         printf(__VA_ARGS__); \
         printf("\n\n")
#endif


/*=============================================================================
// Function used to print out debug message 
//============================================================================*/
#undef _FLK_DEBUG_MODE

#define _FLK_DEBUG_MODE    /* if you want to disable debug mode, please comment on this line. */ 

#ifdef _FLK_DEBUG_MODE
 #ifdef __KERNEL__
  #define _FLK_PDEBUG(...) printk(KERN_CRIT "[Debug][File::%s--Function::%s(%d)]--",__FILE__,__FUNCTION__,__LINE__); \
         printk(KERN_CRIT __VA_ARGS__); \
         printk(KERN_CRIT "\n\n") 
 #else
  #define _FLK_PDEBUG(...) printf("[Debug][File::%s--Function::%s(%d)]--",__FILE__,__FUNCTION__,__LINE__); \
         printf(__VA_ARGS__); \
         printf("\n\n")
 
 #endif /* end of #ifdef __KERNEL__ */

#else
 #define _FLK_PDEBUG(...)  

#endif /* end of #ifdef _FLK_DEBUG_MODE */

#undef _FLK_PDEBUGG
#define _FLK_PDEBUGG(...)   /* When you want to disable separate debug function, please use this function. */  

#endif /* end of #ifndef _FLK_COMM_DEBUG_API_H */

/*=============================================================================
// Trace Mode
//============================================================================*/
#define __TRACE_MODE 1 //trace function
#if __TRACE_MODE   
     #define TRC_MSG() \
   printf("[Trace][File::%s--Function::%s(%d)]\n",__FILE__,__FUNCTION__,__LINE__)
#else                    
     #define TRC_MSG(...)  
#endif  

/*=============================================================================
// Test Procedure Mode
//============================================================================*/
#define TEST_MSG(...) \
   printf("[Test][File::%s--Function::%s(%d)]--",__FILE__,__FUNCTION__,__LINE__); \
   printf(__VA_ARGS__); \
   printf("\n")

flk_led.c
/**+===========================================================================
File: flk_led.c

Description: function implemented used to control LED status on OX810 platform

Revision: V1.0

History: 
+------------------+-------------+--------------------------------------------+
|    date        |   author    |      comments                       |
+------------------+-------------+--------------------------------------------+
|   2008/05/19     | Wade Chiu   |     Initial built                          |
+------------------+-------------+--------------------------------------------+

-------------------------------------------------------------------------------
** Cheng Uei Precision Industry CONFIDENTIAL
** Copyright(C) 2008 Uei Precision Industry Co., Ltd. All Rights Reserved.
**
** The source code contained or described herein and all documents related
** to the source code (Material) are owned by Cheng Uei.
** The Material is protected by worldwide copyright and trade secret laws and
** treaty provisions. No part of the Material may be used, copied, reproduced,
** modified, published, uploaded, posted, transmitted, distributed, or disclosed
** in any way without Cheng Uei prior express written permission.
============================================================================+*/

//====================================================================//
// header files                            //
//====================================================================//
#include "flk_led.h"
#include "flk_comm_debug_api.h"

//====================================================================//
// functions definition                                               //
//====================================================================//
//class constructor
int Led_Constructor(LED_STATUS *ledObject)
{
    ledObject->init_log_fp              = &Init_LOG;
    ledObject->get_logptr_fp            = &Get_LOGPTR;
    ledObject->run_daemon_fp            = &Run_Daemon;
    ledObject->open_gpio_fp             = &Open_GPIO;
    ledObject->disable_booting_pwm_fp   = &Disable_Booting_PWM;
    ledObject->get_fd_fp                = &Get_fd;
    ledObject->detect_reset_poweroff_fp = &Detect_Reset_Poweroff;

    return 0;
}

//create a log and return file pointer
int Init_LOG(LED_STATUS *ledObject)
{
    FILE *logptr    = NULL;
  
    logptr = fopen(logfile,"w+");
    if( logptr == NULL )
    {
 _FLK_PERROR("open logfile fail.");   
    }
    ledObject->logptr = logptr;
    return 0;
}

//get log pointer
FILE *Get_LOGPTR(LED_STATUS *ledObject)
{
    return ledObject->logptr;
}

//run daemon
int Run_Daemon(LED_STATUS *ledObject)
{   
    int          max_tbl_sz;
    struct stat  fstatus;
    int          i;
    pid_t        pid;
    int          fd;

    pid = fork();
    if( pid == (-1) )
    {
 exit(-1);
    }
 
    if( pid != 0 )
    {
 //parent process
 exit(0); 
    }
    //child process
    umask(0);

    if( setsid() == (-1) )
    {
     exit(-1);
    }
    
    if( chdir("/") == (-1) )
    {
 exit(-1); 
    }
 
    close(STDIN_FILENO);
    close(STDOUT_FILENO);
    close(STDERR_FILENO);
 
    max_tbl_sz = getdtablesize(); 
    for( fd = (STDERR_FILENO + 1); fd < (max_tbl_sz + 1); fd++) 
    {
 if( fstat(fd, &fstatus) == 0 ) 
 {
     close(fd);
 }
    }
    return 0;
}

int Open_GPIO(LED_STATUS *ledObject)
{
    int fd;
    fd = open("/dev/FLK_gpio",O_RDWR);
    if( fd == -1 ) 
    {
 exit(-1);
    }
    ledObject->fd = fd;
    return 0;
}

//get fd
int Get_fd(LED_STATUS *ledObject)
{
    return ledObject->fd;
}

int Disable_Booting_PWM(LED_STATUS *ledObject)
{
    FLK_ioctl_register_cmdT cmd;
    int                     fd;
    int                     rvalue;
    int                     wvalue;

    wvalue = 0;
    fd = ledObject->get_fd_fp(ledObject);
    rvalue = ioctl(fd,FLK_IOCTL_WRITE_GPIO_0,&wvalue);
    if( rvalue != 0 )
    {
        exit(-1);
    }
    return 0;
}

int Detect_Reset_Poweroff(LED_STATUS *ledObject)
{
    int   fd;
    int   checkvalue;
    int   rvalue;
    FILE *logptr;
    
    logptr = ledObject->get_logptr_fp(ledObject);
    fd     = ledObject->get_fd_fp(ledObject);
    fprintf(logptr,"== Detect_Reset_Poweroff. ==\n");
    while(1)
    {
 rvalue = ioctl(fd,FLK_IOCTL_CHECK_RESET_EVENT,&checkvalue);
    if( rvalue != 0 ) 
        {
           fprintf(logptr,"== reset event ioctl function fail. ==\n");
     exit(-1);
        } 

 if( checkvalue == 1 ) 
        {
     //close device
            close(fd);
            //halt os
     system("reboot");
            break;
        }
  
        rvalue = ioctl(fd,FLK_IOCTL_CHECK_PWR_EVENT,&checkvalue);
    if( rvalue != 0 ) 
        {
           fprintf(logptr,"== power event ioctl function fail. ==\n");
     exit(-1);
        } 
 
 if( checkvalue == 1 ) 
        {
     //close device
            close(fd);
            //halt os
     system("reboot");
            break;
        }
        sleep(1);
    }
    return 0;
}
flk_led.h
/**+===========================================================================
File: flk_led.h
Description: main pogram used to control LED status on OX810 platform
Revision: V1.0
History: 
+------------------+-------------+--------------------------------------------+
| date           |   author    |      comments                       |
+------------------+-------------+--------------------------------------------+
|   2008/06/03     |  Wade Chiu  |      Initial built                         |
+------------------+-------------+--------------------------------------------+

-------------------------------------------------------------------------------
** Cheng Uei Precision Industry CONFIDENTIAL
** Copyright(C) 2008 Uei Precision Industry Co., Ltd. All Rights Reserved.
**
** The source code contained or described herein and all documents related
** to the source code (Material) are owned by Cheng Uei.
** The Material is protected by worldwide copyright and trade secret laws and
** treaty provisions. No part of the Material may be used, copied, reproduced,
** modified, published, uploaded, posted, transmitted, distributed, or disclosed
** in any way without Cheng Uei prior express written permission.
============================================================================+*/

//====================================================================//
// header file                                                        //
//====================================================================//
#include "flk_gpio_ioctl_cmd.h"  //gpio
#include                //fopen
#include 
#include 
#include 
#include 
#include               //reboot
#include           //reboot


//====================================================================//
// type definition                                                    //
//====================================================================//
typedef struct _led_status LED_STATUS;
typedef int                (*fp_led_status)(LED_STATUS *ledObject);
typedef int                (*fp_init_log)(LED_STATUS *ledObject);
typedef FILE *             (*fp_get_logptr)(LED_STATUS *ledObject);
typedef int                (*fp_run_daemon)(LED_STATUS *ledObject);
typedef int                (*fp_open_gpio)(LED_STATUS *ledObject);
typedef int                (*fp_disable_booting_pwm)(LED_STATUS *ledObject);
typedef int                (*fp_get_fd)(LED_STATUS *ledObject);
typedef int                (*fp_detect_reset_poweroff)(LED_STATUS *ledObject);

//====================================================================//
// class definition                                                   //
//====================================================================//
struct _led_status
{
//private attribute 
    FILE *logptr;
    int   fd;

//public function pointer
    //constructor pointer
    fp_led_status   led_constructor_fp;
    //log file pointer
    fp_init_log    init_log_fp;
    //get log pointer
    fp_get_logptr   get_logptr_fp;
    //run deamon
    fp_run_daemon   run_daemon_fp;
    //open gpio
    fp_open_gpio   open_gpio_fp;
    //disable booting pwm
    fp_disable_booting_pwm  disable_booting_pwm_fp;
    //get fd
    fp_get_fd               get_fd_fp;
    //detect reset thread
    fp_detect_reset_poweroff  detect_reset_poweroff_fp;
}; 

//====================================================================//
// functions protyping                                                //
//====================================================================//
//constructor
int Led_Constructor(LED_STATUS *ledObject);
//log file
int Init_LOG(LED_STATUS *ledObject);
//get log pointer
FILE *Get_LOGPTR(LED_STATUS *ledObject);
//run daemon
int Run_Daemon(LED_STATUS *ledObject);
//open gpio
int Open_GPIO(LED_STATUS *ledObject);
//disable boting pwm
int Disable_Booting_PWM(LED_STATUS *ledObject);
//get fd
int Get_fd(LED_STATUS *ledObject);
//detect reset poweroff
int Detect_Reset_Poweroff(LED_STATUS *ledObject);

//====================================================================//
// define const                                                       //
//====================================================================//
#define logfile "/etc/init.d/flk_led.log"
flk_led_daemon.c
/**+===========================================================================
File: flk_led_main.c
Description: main program used to control LED status on OX810 platform
Revision: V1.0
History: 
+------------------+-------------+--------------------------------------------+
|  date          |   author    |      comments                       |
+------------------+-------------+--------------------------------------------+
|   2008/06/03     |  Wade Chiu  |     Initial built                          |
+------------------+-------------+--------------------------------------------+

-------------------------------------------------------------------------------
** Cheng Uei Precision Industry CONFIDENTIAL
** Copyright(C) 2008 Uei Precision Industry Co., Ltd. All Rights Reserved.
**
** The source code contained or described herein and all documents related
** to the source code (Material) are owned by Cheng Uei.
** The Material is protected by worldwide copyright and trade secret laws and
** treaty provisions. No part of the Material may be used, copied, reproduced,
** modified, published, uploaded, posted, transmitted, distributed, or disclosed
** in any way without Cheng Uei prior express written permission.
============================================================================+*/

//====================================================================//
// header files                            //
//====================================================================//
#include "flk_led.h"
#include "flk_comm_debug_api.h"

//====================================================================//
// definition of constant                    //
//====================================================================//

//====================================================================//
// functions protyping                                                //
//====================================================================//
static int  Run_LED_Daemon(void);

//====================================================================//
// functions definition                                               //
//====================================================================//
static int Run_LED_Daemon(void)
{
//declare variable
    int        error_code;
    LED_STATUS LEDObject;
    FILE *     logptr;
    int        rvalue;

//init variable
    error_code = 0;
    rvalue     = 0;  

//constructor
    LEDObject.led_constructor_fp = &Led_Constructor;
    LEDObject.led_constructor_fp(&LEDObject);
     
//run deamon
    LEDObject.run_daemon_fp(&LEDObject);
 
//init log
    LEDObject.init_log_fp(&LEDObject);
    logptr = LEDObject.get_logptr_fp(&LEDObject);
    fprintf(logptr,"== init log. ==\n");

//open gpio
    rvalue = LEDObject.open_gpio_fp(&LEDObject);
    if(rvalue == -1)
    {
 fprintf(logptr,"== open gpio fail. ==\n");
    }
    fprintf(logptr,"== open gpio. ==\n");

//disable booting pwm
    rvalue = LEDObject.disable_booting_pwm_fp(&LEDObject);
    if(rvalue == -1)
    {
 fprintf(logptr,"== disable booting pwm fail. ==\n");
    }
    fprintf(logptr,"== disable booting pwm. ==\n"); 
 
//detect reset and power off
    rvalue = LEDObject.detect_reset_poweroff_fp(&LEDObject);
    if(rvalue == -1)
    {
 fprintf(logptr,"== reset event ioctl function fail. ==\n");
    }

//de-constructor
    exit(0);
}

int main(void)
{
    printf("[Foxlink]--Run LED Daemon\n");
    Run_LED_Daemon();
    exit(0);
}
flk_reg.c
/**+===========================================================================
File: flk_reg.c
Description: manipulate gpio of Oxford 810
Revision: V0.01
History: 
+------------------+-------------+--------------------------------------------+
| date           | author  |  comments                            |
+------------------+-------------+--------------------------------------------+
| 2008/05/05     |  Wade Chiu  |   Initial built                            |
+------------------+-------------+--------------------------------------------+

-------------------------------------------------------------------------------
** Cheng Uei Precision Industry CONFIDENTIAL
** Copyright(C) 2008 Uei Precision Industry Co., Ltd. All Rights Reserved.
**
** The source code contained or described herein and all documents related
** to the source code (Material) are owned by Cheng Uei.
** The Material is protected by worldwide copyright and trade secret laws and
** treaty provisions. No part of the Material may be used, copied, reproduced,
** modified, published, uploaded, posted, transmitted, distributed, or disclosed
** in any way without Cheng Uei prior express written permission.
============================================================================+*/

//====================================================================//
// Begin of include header files                                      //
//====================================================================//

#include <unistd.h>     //getopt()
#include <stdio.h>      //printf()
#include <string.h>     //strdup() strcmp() strchr() strtok()
#include <sys/mman.h>   //mmap()
#include <fcntl.h>      //open()

#include <sys/types.h>  //open()
#include <sys/stat.h>   //open()
#include <stdlib.h>     //sscanf()
#include <ctype.h>      //isxdigit()
#include <errno.h>

#define _GNU_SOURCE
#include <getopt.h>

//====================================================================//
// End of include header files                                        //
//====================================================================//

//====================================================================//
// Begin of definition of constant                                    //
//====================================================================//
#define __TEST_PROCEDURE_MODE 0 //execute test procedure

#define __TRACE_MODE 0 //trace function call
#if __TRACE_MODE   
     #define TRC_MSG() \
   printf("[Trace][File::%s--Function::%s(%d)]\n",__FILE__,__FUNCTION__,__LINE__);
#else                    
     #define TRC_MSG(...)  
#endif  

#define __DEBUG_MODE 1 //execute debug mode
#if __DEBUG_MODE   
     #define DBG_MSG(...) \
   printf("[Debug][File::%s--Function::%s(%d)]--",__FILE__,__FUNCTION__,__LINE__); \
   printf(__VA_ARGS__); \
   printf("\n");
#else                    
     #define DBG_MSG(...)  
#endif  

#define GPIOA_BASE          (0x44000000)
#define GPIO_Input_offset   (0x0000 >> 2)
#define GPIO_OE_offset      (0x0004 >> 2)
#define GPIO_Output_offset  (0x0010 >> 2) 
#define GPIOA_BASE_VA       (0xE0000000) 

#define rgpiotable_size     1
#define wgpiotable_size     6
#define gpiovaluetable_size 2
#define map_size            0x1000

//====================================================================//
// End of definition of constant                                      //
//====================================================================//

//====================================================================//
// Begin of functions protyping                                       //
//====================================================================//

//--------------------------------------------------------------------//
// All external functions are declared in this header file            //
//--------------------------------------------------------------------//

//#include "comm/s4_pcyc_test_comm_msg.h"

//-------------------------------------------------------------------
// All private functions are declared here.                           //
//--------------------------------------------------------------------//

static int test_print_optioninfo(int opt);
static int print_usage(void);
static int CheckArgument(void);
static int AccessGPIO(void);

static int InitPhys(void);
static int CheckGPIOformat(const char *gpioarg,const char *mode); //mode:"read","write"
static int ChoiceError(const char *mode);
static void ReadGPIOn(int n);
static void AddressReadGPIO(void);
static void WriteGPIOn(int n);
static void AddressWriteGPIO(void);
static int IsPlatformLittleEndian(void);
static unsigned long *SetBitn(unsigned long *gpiovalue,int bitn);
static unsigned long *ClearBitn(unsigned long *gpiovalue,int bitn);
static unsigned long GetBitn(unsigned long gpiovalue,int bitn);         

//====================================================================//
// End of functions protyping                                         //
//====================================================================//

//====================================================================//
// Begin of variable declaration                                      //
//====================================================================//

//--------------------------------------------------------------------//
// All static variables are declared here                             //
//--------------------------------------------------------------------//
static char          *readgpio       = NULL; //read gpio
static char          *writegpio      = NULL; //write gpio: gpio=value 
static char          *ProgramName    = NULL; //the c file name
static int           showbinary      = 0;    //default zero 1:show binary format
static int           memfd           = -1;   //filedescripter of /dev/mem
static char          *writegpiovalue = NULL; //gpio string
static char          *writegpiogpio  = NULL; //value sring
static unsigned long *gpio_base      = NULL; //kernel gpio mem map tp usr space pointer

const char *rgpiotable[] = 
{
"GPIO5"
};
const char *wgpiotable[] = 
{
"GPIO0","GPIO1","GPIO2","GPIO3","GPIO9","GPIO10"
};
const char *gpiovaluetable[] = 
{
"0x0","0x1"
};

//====================================================================//
// End of variable declaration                                        //
//====================================================================//

//===================================================================
// Begin of functions definition                                      //
//====================================================================//
static ChoiceError(const char *mode)
{
    int error_code = 0;
    if( strcmp(mode,"read") == 0 )
    {
 error_code = 3;
    }
    else if( strcmp(mode,"write") == 0 )
    {
 error_code = 4;
    }
    return error_code;
}

static int CheckGPIOformat(const char *gpioarg,const char *mode)
{
    TRC_MSG();
    int error_code = 0;
    int arglen     = 0;
    
    if( gpioarg != NULL )
    {
        //judge which type 
        arglen = strlen(gpioarg);
        if( arglen > 1 )
 {
            if( gpioarg[0] == '0' )
            {
                //judge if read of write
         if( strcmp(mode,"read") == 0 )
  {
                    if( gpioarg[1] == 'x' || gpioarg[1] == 'X')
                    {
                        int len = arglen;
                        int index  = 2;
                        while( index < len )
   {
       if(!isxdigit( gpioarg[index]) )
       {
    error_code = 8;
                                goto ERROR_AREA;
       }
                            index++;
   }
      }
      else
      {
                     error_code = 3;
          goto ERROR_AREA;
      }
  }
  else 
  {
                    char *p = NULL;                
      if( (p = strchr(gpioarg,'=')) != NULL )
                    {
                        char *dupwritegpio;
                        char *tok;
                        dupwritegpio = strdup(gpioarg);
                        tok          = strtok(dupwritegpio,"=");
                        if( tok != NULL )
   {
                            writegpiogpio = strdup(tok);
                            tok           = strtok(NULL,"=");
                            if( tok != NULL )
       {
                                writegpiovalue = strdup(tok);
    tok = strtok(NULL,"=");
    if(tok != NULL)
    {
        error_code = 4;
        goto ERROR_AREA;
    }
       }
       else
       {
                      error_code = 4;
    goto ERROR_AREA;
       }
   }
   else
   {
                         error_code = 4;
       goto ERROR_AREA;
   }
                    }
                    else
      {
                     error_code = 4;
   goto ERROR_AREA;
      }
                    //check gpio format
      if( writegpiogpio[1] == 'x' || writegpiogpio[1] == 'X')
                    {
                        int len = strlen(writegpiogpio);
                        int index  = 2;
                        while( index < len )
   {
       if(!isxdigit( writegpiogpio[index]) )
       {
    error_code = 8;
                                goto ERROR_AREA;
          }
                            index++;
   }
      }
      else
      {
                     error_code = 4;
          goto ERROR_AREA;
      }
                    //check value format
      if( writegpiovalue[0] == '0' && (writegpiovalue[1] == 'x' || writegpiovalue[1] == 'X') )
                    {
                      int len = strlen(writegpiovalue);
                        int index  = 2;
                        while( index < len )
   {
       if( !isxdigit(writegpiovalue[index]) )
       {
    error_code = 8;
                                goto ERROR_AREA;
       }
                            index++;
   }
      }
      else
      {
                     error_code = 4;
          goto ERROR_AREA;
      }
         }
            }
     else if(gpioarg[0] == 'G')
            {
                //judge if read of write
  if( strcmp(mode,"read") == 0 )
  {
                    int isfind = -1;
                    int i; 
                    for(i = 0; i < rgpiotable_size; i++)
                    {
                     DBG_MSG("rgpiotable[%d] = %s",i,rgpiotable[i]);
                     if( strcmp(gpioarg,rgpiotable[i]) == 0 )
   { 
                            isfind = 0;
                     break;
   }
      }
                    if( isfind != 0 )
                    {
                        error_code = 3;
   goto ERROR_AREA;  
                    }    
  }  
                else
  {
                    char *p = NULL;                
      if( (p = strchr(gpioarg,'=')) != NULL )
                    {
                        char *dupwritegpio;
                        char *tok;
                        dupwritegpio = strdup(gpioarg);
                        tok = strtok(dupwritegpio,"=");
                        if( tok != NULL )
   {
                            writegpiogpio = strdup(tok);
                            tok = strtok(NULL,"=");
                            if( tok != NULL )
       {
                                writegpiovalue = strdup(tok);
    tok = strtok(NULL,"=");
    if(tok != NULL)
    {
        error_code = 4;
        goto ERROR_AREA;
    }
       }
       else
       {
                      error_code = 4;
    goto ERROR_AREA;
       }
   }
   else
   {
                         error_code = 4;
       goto ERROR_AREA;
   }
                    }
                    else
      {
                     error_code = 4;
   goto ERROR_AREA;
      }
                    //check gpio format
      int isfind = -1;
                    int i; 
                    for(i = 0; i < wgpiotable_size; i++)
                    {
                     DBG_MSG("%s",wgpiotable[i]);
                     if( strcmp(writegpiogpio,wgpiotable[i]) == 0 )
   { 
                            isfind = 0;
                     break;
   }       
                    }
                    if( isfind != 0 )
      {
       error_code = 4;
   goto ERROR_AREA;
      } 
             //check value format
                    isfind = -1;
                    for(i = 0; i < gpiovaluetable_size; i++)
                    {
                     DBG_MSG("%s",gpiovaluetable[i]);
                     if( strcmp(writegpiovalue,gpiovaluetable[i]) == 0 )
          { 
                            isfind = 0;
                     break;
   }
      }    
      if( isfind != 0 )
        {
          error_code = 4;
   goto ERROR_AREA;    
      }
  }
     }
     else
     {
                error_code = ChoiceError(mode);
  goto ERROR_AREA;
     }
 }
        else
        {
     error_code = ChoiceError(mode);
            goto ERROR_AREA;
 }
    }
    else
    {
 error_code = 5;
 goto ERROR_AREA;
    }    

ERROR_AREA:
    TRC_MSG();
    return error_code;
}

static int CheckArgument(void)
{
    TRC_MSG();
    int error_code = 0;
    
    if( readgpio != NULL )
    {
     //chcek read gpio format
        DBG_MSG("readgpio = %s",readgpio);
 if( (error_code = CheckGPIOformat(readgpio,"read")) != 0 )
 {
     goto ERROR_AREA;
 }       
    }
    else if( writegpio != NULL )
    {
 //chcek write gpio format
        DBG_MSG("write %s\n",writegpio);
        if( (error_code = CheckGPIOformat(writegpio,"write")) != 0 )
 {
     goto ERROR_AREA;
 }
    }
    
ERROR_AREA:
    TRC_MSG();
    return error_code;
}

static int InitPhys(void)
{
    TRC_MSG();
    int error_code  = 0;
    int offset      = 0; 
    int input       = 0;
    int inputbase   = 0; //user輸入的page整部倍的部份
    int inputoffset = 0; //user輸入的page之外 offset部分

    memfd = open("/dev/mem",O_RDWR);
    if( memfd < 0 )
    {
 error_code = 2;
 goto ERROR_AREA;
    }

    if( readgpio != NULL )
    {
        if( readgpio[0] == '0' ) //read usr specified address
 {            
     sscanf(readgpio,"%10x",&input);
            DBG_MSG("read gpio address = %s(str) --> %08x(hex)",readgpio,input);
     inputbase = input & 0xfffff000;
     inputoffset = input & 0x00000fff;
            DBG_MSG("inputbase = %08x , inputoffset = %08x",inputbase,inputoffset);
     offset = inputbase;
 }
 else //read defined GPIOx
 {
     offset = GPIOA_BASE;
 }
    }
    else if( writegpiogpio != NULL )
    {
 if( writegpiogpio[0] == '0' ) //write usr specified address
 { 
            sscanf(writegpiogpio,"%10x",&input);
     DBG_MSG("read gpio address = %s(str) --> %08x(hex)",writegpiogpio,input);
            inputbase = input & 0xfffff000;
     inputoffset = input & 0x00000fff;
            DBG_MSG("inputbase = %08x , inputoffset = %08x",inputbase,inputoffset);
     offset = inputbase;
 }
 else //write defined GPIOx
     {
            offset = GPIOA_BASE;
     }
    }
    else
    {
 error_code = 6;
    }
 
    DBG_MSG("map_size = %08x",(map_size/* - userdefbase*/));    
    gpio_base = (unsigned long *)mmap(0,
                            (map_size/* - userdefbase*/),
                            PROT_READ|PROT_WRITE,
                            MAP_SHARED,
                            memfd,
                            offset);

 if( gpio_base != (unsigned long *)0xffffffff )
 {
     gpio_base += ( inputoffset >> 2 );
         DBG_MSG("gpio_base = %08x",gpio_base);
        }
 else
 {
     DBG_MSG("errno = %s",strerror(errno))
            error_code = 7;
            goto ERROR_AREA;
 }

ERROR_AREA:
 TRC_MSG();
 return error_code;
}

static int IsPlatformLittleEndian(void)
{
    const int n = 1;
    return  *((char *)&n) ? 1 : 0;
}

static unsigned long* SetBitn(unsigned long *gpiovalue,int bitn)
{
    unsigned long *value = gpiovalue;
    *value |= (1 << bitn);
    return value;
}

static unsigned long* ClearBitn(unsigned long *gpiovalue,int bitn)
{
    unsigned long *value = gpiovalue;
    *value &= ~(1 << bitn);
    return value;
}

static unsigned long GetBitn(unsigned long gpiovalue,int bitn)         
{
    unsigned long value;
    value = (gpiovalue >> bitn) & 1;
    return value;
}

static void WriteGPIOn(int n)
{
    TRC_MSG();
    int            error_code     = 0;
    unsigned long  *gpio_oe       = NULL;
    unsigned long  *gpio_output   = NULL;
    int            islittleendian = -1;  //0:big 1:little    
    unsigned long  gpiovaluedup   = 0;
    unsigned long  bitn           = 0;
    //GPIO_OE bit 0 to be set to 1
    gpio_oe = gpio_base + GPIO_OE_offset;
    DBG_MSG("gpio_oe_offset = %08x",GPIO_OE_offset);    
    DBG_MSG("gpio_oe = %08x",gpio_oe);
    DBG_MSG("gpio_oe_value = %08x",*gpio_oe);
    gpio_oe = SetBitn(gpio_oe,n);
    //gpio_oe = ClearBitn(gpio_oe,0);
    DBG_MSG("after set bit %d gpio_oe_value = %08x",n,*gpio_oe);
    //set GPIO_Input bit 0
    gpio_output = gpio_base + GPIO_Output_offset;
    DBG_MSG("gpio_input_value = %08x",*gpio_output);    
    if( strcmp(writegpiovalue,"0x0") == 0 )
    {
        gpio_output = ClearBitn(gpio_output,n);
    }
    else
    {
        gpio_output = SetBitn(gpio_output,n);
    }
    DBG_MSG("after set value gpio_input_value = %08x",*gpio_output);
    //get GPIO_Input bit 0 
    gpiovaluedup = *gpio_output;
    bitn = GetBitn(gpiovaluedup,n);
    printf("0X%d\n",bitn);
    TRC_MSG();
}

static void AddressReadGPIO()
{
 TRC_MSG();
 printf("%s:0X%08x\n",readgpio,*gpio_base);
 TRC_MSG();
}

static void AddressWriteGPIO(void)
{
    TRC_MSG();
    int value;
    sscanf(writegpiovalue,"%10x",&value);
    DBG_MSG("write gpio value = %s(str) --> %08x(hex)",writegpiovalue,value);
    *gpio_base = (unsigned long)value;
    printf("%s:0X%08x\n",writegpiogpio,*gpio_base);
    TRC_MSG();
}

static void ReadGPIOn(int n)
{
    TRC_MSG();
    int            error_code     = 0;
    unsigned long  *gpio_oe       = NULL;
    unsigned long  *gpio_input    = NULL;
    int            islittleendian = -1;  //0:big 1:little    
    unsigned long  gpiovaluedup   = 0;
    unsigned long  bitn           = 0;
    //GPIO_OE bit 3 to be set to 0
    gpio_oe = gpio_base + GPIO_OE_offset;
    DBG_MSG("gpio_oe_offset = %08x",GPIO_OE_offset);    
    DBG_MSG("gpio_oe = %08x",gpio_oe);
    DBG_MSG("gpio_oe_value = %08x",*gpio_oe);
    gpio_oe = ClearBitn(gpio_oe,n);
    DBG_MSG("after set bit %d gpio_oe_value = %08x",n,*gpio_oe);
    //verify big little edian 
    islittleendian = IsPlatformLittleEndian();
    DBG_MSG("your system is %s", islittleendian?"little endian":"big endian");
    //get GPIO_Input bit 3 
    gpio_input = gpio_base + GPIO_Input_offset;
    DBG_MSG("gpio_input_value = %08x",*gpio_input);
    gpiovaluedup = *gpio_input;
    bitn = GetBitn(gpiovaluedup,n);
    printf("0X%d\n",bitn);
    TRC_MSG();
}

static int AccessGPIO(void)
{
    TRC_MSG();
    int           error_code = 0;
    unsigned long gpiovalue  = 0; 

    //init & open & mmap gpio
    if( (error_code = InitPhys()) != 0)
    {
 goto ERROR_AREA;
    }         
   
    if( readgpio != NULL )
    {
        DBG_MSG("readgpio = %s",readgpio);
        if( strcmp(readgpio,"GPIO3") == 0 ) //read GPIO3
        {
            ReadGPIOn(3);
        }
        else if( readgpio[0] == '0' ) //read address
        {
            AddressReadGPIO();    
        }
        else
        {
            error_code = 6;
            goto ERROR_AREA;
        }
    }
    else if( writegpio != NULL )
    {
 DBG_MSG("write %s\n",writegpio);   
 if(strcmp(writegpiogpio,"GPIO0") == 0 ) //write GPIO0
        {
            WriteGPIOn(0);
        }
        else if( strcmp(writegpiogpio,"GPIO1") == 0 ) //write GPIO1
        {
            WriteGPIOn(1);
        }
        else if( strcmp(writegpiogpio,"GPIO2") == 0 ) //write GPIO2
        {
            WriteGPIOn(2);
        }
        else if( strcmp(writegpiogpio,"GPIO5") == 0 ) //write GPIO5
        {
            WriteGPIOn(5);
        }
 else if( strcmp(writegpiogpio,"GPIO9") == 0 ) //write GPIO9
        {
            WriteGPIOn(9);
        }
 else if( strcmp(writegpiogpio,"GPIO10") == 0 ) //write GPIO10
        {
            WriteGPIOn(10);
        }
        else if( writegpiovalue[0] == '0' ) //write address
        {
     AddressWriteGPIO();
        }
        else
        {
            error_code = 6;
            goto ERROR_AREA;
        }
    }
        
ERROR_AREA:
    if( gpio_base != NULL )
    {
     munmap(gpio_base,map_size /*- userdefbase*/);
    }
    
    if( memfd != -1 )
    {
     close(memfd);
    }    
    TRC_MSG();
    return error_code;
}

static int print_usage(void)
{
    TRC_MSG();
    printf("[%s usage]:\n",ProgramName);
    printf("%s [-r (GPIO) or (address)] [-w (GPIO or address)=(value)] [-h] [-v] [-b]\n\n",ProgramName);
    printf("-r ==>> read just GPIO3 or usr specified address\n");
    printf("-w ==>> write GPIO0,1,2,5,9,10 or usr specified address\n");
    printf("-h ==>> show help\n");
    printf("-v ==>> show version\n");
    printf("-b ==>> show binary format\n");
    TRC_MSG();    
    return 0;
}

int main(int argc, char *argv[])
{
    TRC_MSG();

    int  opt;                    //return value of getopt()       
    int  error_code      = 0;    //error_message
    int  reg_mutex_lock  = 0;    //r:1 w:2 no_arg:3

    ProgramName = argv[0]; 

    //DBG_MSG("start...get_opt()...");
    //opion loop
    while( (opt = getopt(argc,argv,":r:w:vhb")) != -1 )
    {
 switch(opt)
 {
 case 'r': // --reg_read
                DBG_MSG("get_opt()...'-r'");
   if( reg_mutex_lock == 0 )
                {
                    test_print_optioninfo(opt);
                    reg_mutex_lock = 1;
                }
  else
  {
                    error_code = 1;
      goto ERROR_AREA;
  }
                readgpio = strdup(optarg);
  break;
 case 'w': // --reg_write
  DBG_MSG("get_opt()...'-w'");
                if( reg_mutex_lock == 0 )
                {
                    test_print_optioninfo(opt);
                    reg_mutex_lock = 2;
                }
  else
  {
                    error_code = 1;
      goto ERROR_AREA;
  }
                writegpio = strdup(optarg);
         break;
 case 'v': // --version
                DBG_MSG("get_opt()...'-v'");
  test_print_optioninfo(opt);
                printf("version 0.01\n");
  break;
 case 'h': // --help message
                DBG_MSG("get_opt()...'-h'");
  test_print_optioninfo(opt);
                print_usage();
  break;
 case 'b': // --show binary value
                DBG_MSG("get_opt()...'-b'");
  test_print_optioninfo(opt);
                showbinary = 1;
  break;
        case ':': // --find no argument
                DBG_MSG("get_opt()...':'");
  if( reg_mutex_lock == 0 )
                {
                    test_print_optioninfo(opt);
                    reg_mutex_lock = 3;
                }
         else
  {
                    error_code = 1;
      goto ERROR_AREA;
  }
      break;
 case '?': //invalid option
        default:
                DBG_MSG("get_opt()...'?'");
  test_print_optioninfo(opt);
  break;
 }
    }
    //DBG_MSG("end...get_opt()...");

    //check gpio argument
    if( (error_code = CheckArgument()) != 0 )
    {
 goto ERROR_AREA;
    }
    else
    {
        //execute gpio access
        if( (error_code = AccessGPIO()) != 0 )
        {
     goto ERROR_AREA;
        }
    }

ERROR_AREA:
    if( error_code == 1 )
    {
        printf("[error %d]::just allow read('-r') or write('-w') at the same time once\n",error_code);
    }
    else if( error_code == 2 )
    {
 printf("[error %d]::open /dev/men fail\n",error_code); 
    }
    else if( error_code == 3 )
    {
 printf("[error %d]::argument %s is a wrong format\n",error_code,readgpio);
    }
    else if( error_code == 4 )
    {
 printf("[error %d]::argument %s is a wrong format\n",error_code,writegpio);
    }
    else if( error_code == 5 )
    {
 printf("[error %d]::gpio argument is null\n",error_code);
    }
    else if( error_code == 6 )
    {
 printf("[error %d]::no such gpio to access\n",error_code);
    }
    else if( error_code == 7 )
    {
 printf("[error %d]::mmap failed!!maybe u enter a wrong address\n",error_code);
    }
    else if( error_code == 8 )
    {
 printf("[error %d]::a wrong number format\n",error_code);
    }
    TRC_MSG();
    return 0;

}

// test function for test getopt value
static int test_print_optioninfo(int opt)
{
    if( __TEST_PROCEDURE_MODE )
    {
 TRC_MSG();
        if( (opt != ':') && (opt != '?') )
        {
            DBG_MSG("no error");
         if( optarg != NULL )
     {
         printf("option: '-%c' -- argument: %s\n",opt,optarg);
     }
     else
     {
                printf("option: '-%c'\n",opt);
         }
 }
 else
 {
            DBG_MSG("meet an error");
            if( opt == ':' )
            {
                printf("option: '-%c' requires an argument\n",optopt);
            }
     else
     {
                printf("invalid option: '-%c'\n",optopt);
     } 
 }
 TRC_MSG();
    }       
    return 0;
}
inittab
# /etc/inittab
#
# Copyright (C) 2001 Erik Andersen 
#
# Note: BusyBox init doesn't support runlevels.  The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use
# sysvinit.
#
# Format for each entry: :::
#
# id        == tty to run on, or empty for /dev/console
# runlevels == ignored
# action    == one of sysinit, respawn, askfirst, wait, and once
# process   == program to run

# Startup the system
::sysinit:/bin/mount /proc
::sysinit:/bin/mount -a
::sysinit:/bin/mount -o remount,rw,noatime /
::sysinit:/bin/ln -s /proc/mounts /etc/mtab
::sysinit:/sbin/swapon -a

# Mount and repair if necessary the user data partition
::sysinit:/bin/sh /etc/init.d/mount-internal-shares.sh

::sysinit:/bin/chown www-data:www-data /shares/internal
::sysinit:/bin/chmod 755 /shares/internal

::sysinit:/bin/chown www-data:www-data /shares/external
::sysinit:/bin/chmod 755 /shares/external

::sysinit:/bin/chown www-data:www-data /shares/internal/PUBLIC

# Update ownership and modes for cups and samba
::sysinit:/bin/chgrp sys /var/spool/cups
::sysinit:/bin/chmod g+rws /var/spool/cups
::sysinit:/bin/chmod 1777 /var/spool/samba
::sysinit:/bin/chgrp users /var/spool/samba
::sysinit:/bin/chmod 4555 /usr/bin/sudo

# Give lighttpd ownership of it's log directory
::sysinit:/bin/chown -R www-data:www-data /var/log/lighttpd

# Give the WebUI ownership of /etc/smb.conf
::sysinit:/bin/chown -R www-data:www-data /etc/smb.conf

# Load kernel modules
# Temperature control
# Temperature control
::sysinit:/sbin/modprobe thermAndFan
# RTC
::sysinit:/bin/ln -s /dev/rtc0 /dev/rtc > /dev/null 2>&1
#::sysinit:/sbin/modprobe rtc-ds1307
::sysinit:/sbin/modprobe isl1208
::sysinit:/sbin/modprobe i2c-oxnas-bitbash
# USB
::sysinit:/sbin/modprobe ehci-hcd
::sysinit:/sbin/modprobe usb-storage
# Code Page for VFAT
::sysinit:/sbin/modprobe nls_cp437
# Power Button
::sysinit:/bin/sh /etc/init.d/load_power_button_module.sh

# Mount the USB filesystem
::sysinit:/bin/mount -t usbfs usbfs /proc/bus/usb

# Run any rc scripts
::sysinit:/etc/init.d/rcS
::sysinit:/bin/sh /etc/init.d/rc.myinit
::sysinit:/etc/init.d/led_daemon

# Set up a couple of getty's
#tty1::respawn:/sbin/getty 38400 tty1
#tty2::respawn:/sbin/getty 38400 tty2

# Put a getty on the serial port
ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100
#ttyS1::respawn:/sbin/getty -L ttyS1 115200 vt100
#ttyS2::respawn:/sbin/getty -L ttyS2 115200 vt100

# Logging junk
::sysinit:/bin/touch /var/log/messages
::respawn:/sbin/syslogd -n -m 0
::respawn:/sbin/klogd -n
#tty3::respawn:/usr/bin/tail -f /var/log/messages

# Stuff to do for the 3-finger salute
::ctrlaltdel:/sbin/reboot

# Stuff to do before rebooting
# tidy up using start scripts.
::shutdown:/bin/sh /etc/init.d/rc.myexit
::shutdown:/etc/init.d/rcK
# make sure everything else stops.
::shutdown:/bin/sync
::shutdown:/usr/bin/killall klogd
::shutdown:/usr/bin/killall syslogd
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r
#send hardware reset
::shutdown:/etc/init.d/hardware_reset
rc.myinit   
#!/bin/bash
#/**+===========================================================================
#File: rc.myinit
#
#Description: start main program to read/write gpio and registers on
#             OX810 platform
#
#Revision: V0.01
#
#History: 
#+------------------+-------------+--------------------------------------------+
#|     date      |  author   |  comments                        |
#+------------------+-------------+--------------------------------------------+
#|   2008/05/15  |  Wade Chiu |   Initial built                      |
#+------------------+-------------+--------------------------------------------+
#
#-------------------------------------------------------------------------------

#** Cheng Uei Precision Industry CONFIDENTIAL
#** Copyright(C) 2008 Uei Precision Industry Co., Ltd. All Rights Reserved.
#**
#** The source code contained or described herein and all documents related
#** to the source code (Material) are owned by Cheng Uei.
#** The Material is protected by worldwide copyright and trade secret laws and
#** treaty provisions. No part of the Material may be used, copied, reproduced,
#** modified, published, uploaded, posted, transmitted, distributed, or disclosed
#** in any way without Cheng Uei prior express written permission.
#============================================================================+*/

#//inittial part
Module_Name="flk_gpio_driver"
MyinitLog_Name="rc.myinit.log"
Node_Name="FLK_gpio"
PWD="/etc/init.d"

#//test if inittab work
if [ -f $PWD/$MyinitLog_Name ]
then
    rm $PWD/$MyinitLog_Name
fi

#//create a log file to record insert procedure
touch $PWD/$MyinitLog_Name
if [ -f $PWD/$MyinitLog_Name ]
then
    echo "create $PWD/$MyinitLog_Name success."
else
    echo "create $PWD/$MyinitLog_Name fail."
    exit 0
fi

#//check if module exist already
echo "check module if exist:$Module_Name." >> $PWD/$MyinitLog_Name 
lsmod > listmodule_tmp.txt
RVALUE=$(grep -c $Module_Name listmodule_tmp.txt)
if [ $RVALUE -ne 0 ]
then
    rmmod $Module_Name
    echo "remove existed module:$Module_Name" >> $PWD/$MyinitLog_Name
fi
rm listmodule_tmp.txt

#//insert module
echo "insert module:$PWD/$Module_Name.ko." >> $PWD/$MyinitLog_Name 
insmod $PWD/$Module_Name.ko
lsmod > listmodule_tmp.txt
RVALUE=$(grep -c $Module_Name listmodule_tmp.txt)
if [ $RVALUE -eq 0 ]
then
    echo "insert module:$PWD/$Module_Name.KO fail." >> $PWD/$MyinitLog_Name
    rm listmodule_tmp.txt
    exit 0
fi
rm listmodule_tmp.txt

#//check node if exist
echo "check node if exist:/dev/$Node_Name." >> $PWD/$MyinitLog_Name 
#ls /dev/$Node_Name > listnode_tmp.txt
ls /dev > listnode_tmp.txt
RVALUE=$(grep -c $Node_Name listnode_tmp.txt)
if [ $RVALUE -ne 0 ]
then
    rm /dev/$Node_Name
    echo "remove existed module:/dev/$Node_Name" >> $PWD/$MyinitLog_Name
fi
rm listnode_tmp.txt

#get major id
major=$(awk "\$2==\"$Node_Name\" {print \$1}" /proc/devices)
#//make a device node
echo "make a device node:/dev/$Node_Name." >> $PWD/$MyinitLog_Name 
mknod /dev/$Node_Name c $major 0
ls /dev/$Node_Name > node_tmp.txt
RVALUE=$(grep -c /dev/$Node_Name node_tmp.txt)
if [ $RVALUE -eq 0 ]
then
    echo "make a device node:/dev/$Node_Name fail." >> $PWD/$MyinitLog_Name
    rm node_tmp.txt
    exit 0
fi
rm node_tmp.txt
Web GUI
nasMaster.pl
#!/usr/bin/env perl
#!/usr/bin/perl
#
# Routes the request
#
#
# Ian Steel
# September 2006
#
use strict;

use CGI::Fast;
use Config::IniFiles;

use nasCommon;
use nasCore;
use Service::Shares;
#use Permission;

# Load the individual page modules
#
use nas::home;
use nas::driveman;
use nas::fileshare;
use nas::gensetup;
use nas::initsetup;
use nas::home_update;
use nas::home_status;

=for dynamic loading

use nas::chgdatetime;
use nas::chgdevicename;
use nas::chgusername;
use nas::fs_addshare;
use nas::fs_chgaccesstype;
use nas::fs_deluser;
use nas::fs_newuser;
use nas::fs_getSharePerms;
use nas::fs_removeshare;
use nas::fs_renameshare;
use nas::fs_updsecurity;
use nas::fs_userman;
use nas::language;
use nas::updnetwork;

=cut

# Pre run checks.
#
# Write paths to nbin/setupPaths.sh
# ( This means that nasCommon should be the only place that (most) paths 
# need to be changed.)
#
if (! -w nasCommon->nas_paths ) {
 sudo("$nbin/touch.sh ".nasCommon->nas_paths );
 sudo("$nbin/chown.sh www-data:www-data ".nasCommon->nas_paths);
 sudo("$nbin/chmod.sh 0644 ".nasCommon->nas_paths);
}

my $fdPaths = new IO::File( ">".nasCommon->nas_paths );
if ($fdPaths) {
 print( $fdPaths "# Auto generated by nasMaster.pl on ".gmtime(time())."\n" );
 print( $fdPaths "export SMB_PATH=" . nasCommon->smb_lib . "\n");
 print( $fdPaths "export SMB_HOME=" . nasCommon->smb_home . "\n");
 print( $fdPaths "export SMB_CONF=" . nasCommon->smb_conf . "\n");
 print( $fdPaths "export SMB_PASSWD=" . nasCommon->smbpasswd . "\n");
 print( $fdPaths "export SHARES_HOME=" . nasCommon->nas_shares. "\n");
 print( $fdPaths "export OXSEMI_HOME=" . nasCommon->nas_home. "\n");
 print( $fdPaths "export PERL5LIB=" . join(':',$ENV{PERL5LIB},nasCommon->nas_lib). "\n");
 print( $fdPaths "export NETWORK_SETTINGS=" . nasCommon->network_settings. "\n");
 $fdPaths->close();
}

# Remove any locks
#
# This file is typically used to signal that a process is in progress.
unlink( nasCommon->nas_lock ) if ( -r nasCommon->nas_lock );

=for future

Permission->path( nasCommon->nas_nbin ); # Where to find the scripts
Permission->new( nasCommon->nas_home, '0775','root','www-data' )->ensure();
Permission->new( nasCommon->shares_inc, '0644','www-data','www-data' )->ensure();
Permission->new( nasCommon->senvid_inc, '0644','www-data','www-data' )->ensure();
Permission->new( nasCommon->nas_ini, '0666','www-data','www-data' )->ensure();
Permission->new( nasCommon->smb_lib, '0775','www-data','www-data' )->ensure();
Permission->new( nasCommon->smbpasswd, '0664','www-data','www-data' )->ensure();
Permission->new( nasCommon->smb_conf, '0664','www-data','www-data' )->ensure();

=cut

#
# TODO: bruce - I am working on Permissions.pm to simplify this bit of code.
# BUG#2889 bruce - Web UI: No initial shares.inc or senvid.inc files
if (! -w nasCommon->TZ ) {
 sudo("$nbin/touch.sh ".nasCommon->TZ );
 sudo("$nbin/chown.sh root:www-data ".nasCommon->TZ );
 sudo("$nbin/chmod.sh g+w ".nasCommon->TZ );
}
if (! -w nasCommon->network_settings ) {
 sudo("$nbin/chown.sh root:www-data ".nasCommon->network_settings );
 sudo("$nbin/chmod.sh g+w ".nasCommon->network_settings );
}
if (! -w nasCommon->nas_home ) {
 sudo("$nbin/mkdir.sh ".nasCommon->nas_home);
 sudo("$nbin/chown.sh root:www-data ".nasCommon->nas_home);
 sudo("$nbin/chmod.sh 775 ".nasCommon->nas_home);
}
if (! -w nasCommon->shares_inc ) {
 sudo("$nbin/touch.sh ".nasCommon->shares_inc );
 sudo("$nbin/chown.sh www-data:www-data ".nasCommon->shares_inc);
 sudo("$nbin/chmod.sh 0644 ".nasCommon->shares_inc);
}
if (! -w nasCommon->senvid_inc ) {
 sudo("$nbin/touch.sh ".nasCommon->senvid_inc );
 sudo("$nbin/chown.sh www-data:www-data ".nasCommon->senvid_inc);
 sudo("$nbin/chmod.sh 0644 ".nasCommon->senvid_inc);
}
if (! -w nasCommon->nfs_exports ) {
 sudo("$nbin/touch.sh ".nasCommon->nfs_exports );
 sudo("$nbin/chown.sh www-data:www-data ".nasCommon->nfs_exports);
 sudo("$nbin/chmod.sh 0644 ".nasCommon->nfs_exports);
}

# BUG#2890 bruce - /var/oxsemi/nas.ini should be owned by www-data
# Also moved the chmod up to befor the Config::IniFiles
sudo("$nbin/chown.sh www-data:www-data ".nasCommon->nas_ini);
sudo("$nbin/chmod.sh 0666 ".nasCommon->nas_ini);

# BUG#2894 bruce - Check that smbpasswd exists and create if not
if (! -w nasCommon->smbpasswd ) {
 sudo("$nbin/touch.sh ".nasCommon->smbpasswd );
 sudo("$nbin/chown.sh www-data:www-data ".nasCommon->smbpasswd);
 sudo("$nbin/chmod.sh 0664 ".nasCommon->smbpasswd);
 sudo("$nbin/fs_addUser.sh 'www-data' 'blank'" );
}

# BUG#2890 bruce - smb.conf and /usr/local/samba/lib/ should be owned by www-data
# Also moved the chmod up to befor the Config::IniFiles
sudo("$nbin/chown.sh root:www-data ".nasCommon->smb_conf);
sudo("$nbin/chmod.sh 0664 ".nasCommon->smb_conf);
sudo("$nbin/chown.sh root:www-data ".nasCommon->smb_lib);
sudo("$nbin/chmod.sh 0775 ".nasCommon->smb_lib);


# Create the default shares for NFS and Samba
#
Service::Shares->createDefault();

# Open nas.ini
my $config = new Config::IniFiles( -file => nasCommon->nas_ini );

# Extract some data from default-settings and put in nas.ini
if (my $dfs=Config::Tiny->read( nasCommon->default_settings )) {
 my $type = $dfs->{_}->{default_system_type};
 for ($type) {
  # Map the default_system_type names to our internal type name.
  /1nc/i && ($type='1NC',last);
  /2nc/i && ($type='2NC',last);
 }
 # Store the type in config for later use
 $config->newval( 'general','system_type', $type );
}


# Main FCGI Loop
while (my $cgi = new CGI::Fast) 
{
#print $cgi->header(-type => 'text/html; charset=UTF-8',
#                   -cache-control => 'no-cache',
#                   );
#printf("mainloop--start
"); my $language = $config->val('general', 'language'); my $func = $ENV{SCRIPT_NAME}; my $auth = ($func=~/auth/); # Ensure that pages that require authorization do so if ( !$auth && ($func !~ /home|mio_update/)) { $func="home"; # Just display the home page } #printf("File:%s--Line:%d--
\$ENV\{SCRIPT_NAME\}=\$func=%s
",__FILE__,__LINE__,$func); my $auth = ($func=~/auth/); $func =~ s/.*?([^\/]+)\.pl$/$1/; $func = 'home' if $func =~ /nasMaster/; $func = 'home' unless $func; # bruce - Added default if blank # Ensure that the user visits, and completes, the initial setup page(s) - exception is that # they can change language before completing the initial setup. # if ( ($func ne 'initsetup') && ($func ne 'language') && ($func ne 'home_update') && ($func ne 'home_status') && ($func ne 'mio_update_reg') && ($func ne 'mio_update_share') && ($func ne 'language') ) { if ($config->val('general', 'initial_config_done') ne 'y') { $func = 'initsetup'; } } # Use cookies cookies if usecookie is set my $usecookie=$config->val( 'general','usecookie'); if ( ($func =~/^mio_update/) || # Ignore mionet ($func =~/hold/) || # and holding pages ($func =~/networkstatus/) || # and network status ajax ($func =~/ajax/) || # and anything ajax ($func =~/dm_progress/) # and dm_progress ajax ) { # Flag to ignore cookies $usecookie=0; } # Check that the network has finished starting up before we display any page # if ( ( $func!~/mio_update/) && ( $func!~/networkstatus/) && (! -r nasCommon->network_lock) ) { # Not mio and no lock and not the network status report # Go to the hold page and store originalPage if locked $func = "hold"; } # Create a new object based on the $func name being the same name # as a class in nas/*.pm # bruce - perhaps enclose in eval() to trap potential errors $func = "home" unless eval( "use nas::$func;1" ); $func = "nas::$func"; eval { # Try executing the page my $ss = new $func($language,$cgi,$config,$usecookie); #printf("File:%s--Line:%d
\$ss=%s
\$func=%s
",__FILE__,__LINE__,$ss,$func); #printf("File:%s
\$ss = new \$func(lan.cgi.config.cookie)
",__FILE__); #printf("File:%s
\$ss->processRequest()
",__FILE__); $ss->processRequest(); ## ($cgi, $config); 1; } || do { # Display the fatal error page my $ss = new nasCore( $language,$cgi,$config ); $ss->fatalError( $config, 'f00000', $!.$@ ); }; #printf("mainloop--end
"); }



主要工作小結

1. 架設版本控制平台 SVN
2. 專案版本控制管理
3. 專案開發環境架設 fedora8及其BSP環境
4. 管理與整合BSP
5.  build imagerelease版本
6. 應用程式與GUI開發

心得
1.      對嵌入式系統有初步的認識
2.      Linux的操作與shell script有初步認識
3.      了解embedded linux的系統管理
4.      cross toolchain kernel rootfilesystem有初步的認識
5.      lighted perl有初步認識
6.      Linux程式設計有初步的了解