第一篇:嵌入式Linux下3G模块的驱动和应用
嵌入式Linux下3G模块的驱动和应用
1、开发资源 1.1、硬件资源:
ZTE-mf637u(中国联通)ZTE-mu351(中国移动)
1.2、软件资源:
1.2.1、usb-modeswitch-1.1.3 libusb-0.1.12.tar.gz usb-modeswitch-1.1.3.tar.bz2
1.2.2、ppp-2.4.4 libpcap-0.9.8.tar.gz ppp-2.4.4.tar.gz
1.2.3、wvdial 1.2.3.1、wvdial-1.54.0(arm-linux-gcc 3.4.1)zlib-1.2.5.tar.bz2 openssl-0.9.7g.tar.gz openssl-0.9.7g-fix_manpages-1.patch wvstreams-4.0.1.tar.bz2
wvstreams-4.0.1-tcl84-1.patch wvdial-1.54.0.tar.gz 1.2.3.2、wvdial_1.60.4(arm-linux-gcc 4.2.2)zlib-1.2.5.tar.bz2 openssl-0.9.8n.tar.gz openssl-0.9.8n-fix_manpages-1.patch wvstreams-4.6.1.tar.gz wvdial_1.60.4.tar.gz
2、Linux开发环境 2.1、主机环境 2.1.1、主机linux系统
Fedora Core 6
2.1.2、主机编译环境 2.1.2.1、gcc-v Using built-in specs.Target: i386-redhat-linux Configured with:../configure--prefix=/usr--mandir=/usr/share/man--infodir=/usr/share/info--enable-shared--enable-threads=posix--enable-checking=release--with-system-zlib--enable-__cxa_atexit--disable-libunwind-exceptions--enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada--enable-java-awt=gtk--disable-dssi--enable-plugin--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre--with-cpu=generic--host=i386-redhat-linux Thread model: posix gcc version 4.1.1 20061011(Red Hat 4.1.1-30)
2.1.2.2、/usr/local/arm/3.4.1/bin/arm-linux-gcc-v Reading specs from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/specs Configured with: /work/crosstool-0.27/build/arm-linux/gcc-3.4.1-glibc-2.3.2/gcc-3.4.1/configure--target=arm-linux--host=i686-host_pc-linux-gnu--prefix=/usr/local/arm/3.4.1--with-headers=/usr/local/arm/3.4.1/arm-linux/include--with-local-prefix=/usr/local/arm/3.4.1/arm-linux--disable-nls--enable-threads=posix--enable-symvers=gnu--enable-__cxa_atexit--enable-languages=c,c++--enable-shared--enable-c99--enable-long-long Thread model: posix gcc version 3.4.1
2.1.2.3、/usr/local/arm/4.2.2/usr/bin/arm-linux-gcc-v Using built-in specs.Target: arm-unknown-linux-gnueabi Configured with: /home/scsuh/workplace/coffee/buildroot-20071011/toolchain_build_arm/gcc-4.2.2/configure--prefix=/usr--build=i386-pc-linux-gnu--host=i386-pc-linux-gnu--target=arm-unknown-linux-gnueabi--enable-languages=c,c++--with-sysroot=/usr/local/arm/4.2.2-eabi/
--with-build-time-tools=/usr/local/arm/4.2.2-eabi//usr/arm-unknown-linux-gnueabi/bin--disable-__cxa_atexit--enable-target-optspace--with-gnu-ld--enable-shared--with-gmp=/usr/local/arm/4.2.2-eabi//gmp--with-mpfr=/usr/local/arm/4.2.2-eabi//mpfr--disable-nls--enable-threads--disable-multilib--disable-largefile--with-arch=armv4t--with-float=soft--enable-cxx-flags=-msoft-float Thread model: posix gcc version 4.2.2
2.2、开发板环境
2.2.1、CES-6410开发平台
Samsung S3C6410X, ARM1176JZF-S 128MB, Mobile DDR SDRAM USB HOST:一个USB HOST 接口,USB2.0全速(12Mbits/s)
3、Linux应用软件的编译 3.1、usb-modeswitch-1.1.3 [root@localhost cdma]# tar xzf libusb-0.1.12.tar.gz [root@localhost cdma]# cp libusb-0.1.12 libusb-0.1.12-arm [root@localhost cdma]# cd libusb-0.1.12-arm [root@localhost libusb-0.1.12-arm]#./configure--prefix=/works/cdma/install--host=arm-linux CC=arm-linux-gcc CXX=arm-linux-g++ [root@localhost libusb-0.1.12-arm]# make [root@localhost libusb-0.1.12-arm]# make install
[root@localhost libusb-0.1.12-arm]# cd..[root@localhost cdma]# tar xjf usb-modeswitch-1.1.3.tar.bz2 [root@localhost cdma]# cp usb-modeswitch-1.1.3 usb-modeswitch-1.1.3-arm [root@localhost cdma]# cd usb-modeswitch-1.1.3-arm [root@localhost usb-modeswitch-1.1.3-arm]# 修改Makefile CC = gcc 改为
CC = arm-linux-gcc CFLAGS +=-Wall-l usb 改为
CFLAGS +=-Wall-l usb-I/works/cdma/install/include-L/works/cdma/install/lib 修改usb_modeswitch.c // readConfigFile(“/etc/usb_modeswitch.setup”);改为
readConfigFile(“/etc/usb_modeswitch.setup”);[root@localhost usb-modeswitch-1.1.3-arm]# make [root@localhost usb-modeswitch-1.1.3-arm]# make install [root@localhost usb-modeswitch-1.1.3-arm]# cd..[root@localhost cdma]#
3.2、ppp-2.4.4 [root@localhost cdma]# tar xzf libpcap-0.9.8.tar.gz [root@localhost cdma]# cp libpcap-0.9.8 libpcap-0.9.8-arm [root@localhost libpcap-0.9.8-arm]#./configure--prefix=/works/cdma/install--host=arm-linux--with-pcap make: *** No rule to make target `pcap-yes.o', needed by `libpcap.a'.Stop.修改Makefile PSRC = pcap-yes.c 改为
PSRC = pcap-linux.c [root@localhost libpcap-0.9.8-arm]# make [root@localhost libpcap-0.9.8-arm]# make install [root@localhost libpcap-0.9.8-arm]# cd..[root@localhost cdma]# tar xzvf ppp-2.4.4.tar.gz [root@localhost cdma]# cd ppp-2.4.4 [root@localhost ppp-2.4.4]#./configure--host=arm-linux vi pppd/Makefile
LIBS +=-lpcap
CFLAGS +=-DPPP_FILTER 改为
LIBS +=-lpcap-L../../libpcap-0.9.8 CFLAGS +=-DPPP_FILTER-I../../libpcap-0.9.8
[root@localhost ppp-2.4.4]# make CC=arm-linux-gcc
3.3、wvdial 3.3.1、wvdial-1.54.0 [root@localhost wvdial-1.54.0]# export PATH=/usr/local/arm/3.4.1/bin:$PATH [root@localhost wvdial-1.54.0]# tar xjf zlib-1.2.5.tar.bz2 [root@localhost wvdial-1.54.0]# cd zlib-1.2.5 [root@localhost zlib-1.2.5]#./configure--prefix=/works/wvdial-1.54.0/install 修改Makefile CC = arm-linux-gcc CPP=arm-linux-gcc-E AR=arm-linux-ar rc RANLIB=arm-linux-ranlib [root@localhost zlib-1.2.5]# make [root@localhost zlib-1.2.5]# make install
[root@localhost wvdial-1.54.0]# tar xzf openssl-0.9.7g.tar.gz [root@localhost wvdial-1.54.0]# cd openssl-0.9.7g [root@localhost openssl-0.9.7g]# patch-Np1-i../openssl-0.9.7g-fix_manpages-1.patch
[root@localhost openssl-0.9.7g]#./Configure--prefix=/works/wvdial-1.54.0/install os/compiler:arm-linux-gcc [root@localhost openssl-0.9.7g]# make [root@localhost openssl-0.9.7g]# make install [root@localhost openssl-0.9.7g]# cd..[root@localhost wvdial-1.54.0]# tar xjf wvstreams-4.0.1.tar.bz2 [root@localhost wvdial-1.54.0]# cd wvstreams-4.0.1 [root@localhost wvstreams-4.0.1]# patch-Np1-i../wvstreams-4.0.1-tcl84-1.patch 修改configure with_openssl=no 改为
with_openssl=yes(有两处)
[root@localhost wvstreams-4.0.1]#./configure--prefix=/works/wvdial-1.54.0/install--host=arm-linux CFLAGS=-I/works/cdma/install/include LDFLAGS=-L/works/cdma/install/lib/--with-zlib=/works/cdma/zlib-1.2.5--with-openssl=/works/cdma/openssl-0.9.8n--without-dbus--with-pam=no--with-tcl=no--with-qt=no
[root@localhost wvstreams-4.0.1]# make linking libwvutils.so.../usr/lib/libz.so: could not read symbols: Invalid operation collect2: ld returned 1 exit status make: *** [libwvutils.so] Error 1 [root@localhost wvstreams-4.0.1]# arm-linux-gcc-L./xplc-L/works/cdma/install/lib/-L./xplc-L.-g-Wl,-soname,libwvutils.so.4.0-shared-o libwvutils.so utils/strcrypt.o utils/verstring.o utils/wvaudioencoder.o utils/wvbase64.o utils/wvbdbhash.o utils/wvcrash.o utils/wvdiriter.o utils/wvgzip.o utils/wvhashtable.o utils/wvhex.o utils/wvmagiccircle.o utils/wvmatrix.o utils/wvqdbmhash.o utils/wvrateadjust.o utils/wvserialize.o utils/wvshmzone.o utils/wvstringtable.o utils/wvsubproc.o utils/wvtest.o utils/wvwordwrap.o libwvbase.so-lsupc++-lgcc_eh [root@localhost wvstreams-4.0.1]# make [root@localhost wvstreams-4.0.1]# vi wvrules.mk XX_LIBS := $(XX_LIBS)$(shell $(CC)-lsupc++-lgcc_eh 2>&1 | grep-q “undefined reference” && echo “-lsupc++-lgcc_eh”)改为
XX_LIBS := $(XX_LIBS)$(shell $(CC)-lsupc++-lgcc_eh 2>&1 | grep-q “undefined reference” && echo “-lz-lcrypt-lsupc++-lgcc_eh”)[root@localhost wvstreams-4.0.1]# make compiling crypto/wvtripledes.o...crypto/wvtripledes.cc: In member function `virtual bool WvTripleDESEncoder::_encode(WvBuf&, WvBuf&, bool)': crypto/wvtripledes.cc:108: error: cannot convert `const unsigned char*' to `
unsigned char(*)[8]' for argument `1' to `void DES_ecb3_encrypt(unsigned
char(*)[8], unsigned char(*)[8], DES_key_schedule*, DES_key_schedule*,DES_key_schedule*, int)' make: *** [crypto/wvtripledes.o] Error 1 解决方法:
crypto/wvtripledes.cc 修改
#if OPENSSL_VERSION_NUMBER >= 0x0090705FL 改为 #if 0
compiling crypto/wvx509.o...crypto/wvx509.cc: In member function `WvString WvX509Mgr::get_extension(int)': crypto/wvx509.cc:1168: error: invalid conversion from `unsigned char**' to ` const unsigned char**' crypto/wvx509.cc:1171: error: invalid conversion from `unsigned char**' to ` const unsigned char**' make: *** [crypto/wvx509.o] Error 1 解决方法: crypto/wvx509.cc if(method->it)
ext_data = ASN1_item_d2i(NULL, &ext->value->data, ext->value->length, ASN1_ITEM_ptr(method->it));else ext_data = method->d2i(NULL, &ext->value->data, ext->value->length);改为
if(method->it)ext_data = ASN1_item_d2i(NULL,(const unsigned char **)&ext->value->data, ext->value->length, ASN1_ITEM_ptr(method->it));else ext_data = method->d2i(NULL,(const unsigned char **)&ext->value->data, ext->value->length);
compiling streams/wvpam.o...streams/wvpam.cc: In member function `bool WvPam::authenticate(const
WvFastString&, const WvFastString&, const WvFastString&)': streams/wvpam.cc:71: error: `fail' undeclared(first use this function)streams/wvpam.cc:71: error:(Each undeclared identifier is reported only once
for each function it appears in.)make: *** [streams/wvpam.o] Error 1 解决方法:
return fail;改为
return false;
[root@localhost wvstreams-4.0.1]# make install [root@localhost wvstreams-4.0.1]# cp libwvutils.so../install/lib/libwvutils.so.4.0-a [root@localhost wvstreams-4.0.1]# cd..[root@localhost wvdial-1.54.0]# tar xzf wvdial-1.54.0.tar.gz [root@localhost wvdial-1.54.0]# cd wvdial-1.54.0 [root@localhost wvdial-1.54.0]# cp /works/wvdial-1.54.0/install/include/wvstreams/*.h.[root@localhost wvdial-1.54.0]# vi Makefile PREFIX=/usr/local 改为
PREFIX=/works/wvdial-1.54.0/install
PPPDIR=/etc/ppp/peers
改为
PPPDIR=${PREFIX}/etc/ppp/peers
XPATH=..../wvstreams/include $(PKGINC)改为
XPATH=/works/wvdial-1.54.0/install/include/wvstreams
LIBS +=-L../wvstreams-lwvutils-lwvstreams 改为
LIBS +=-L/works/wvdial-1.54.0/install/lib-lwvutils-lwvstreams-lwvbase-lz
[root@localhost wvdial-1.54.0]# vi wvrules.mk 增加
CC = arm-linux-g++ CXX = arm-linux-g++ [root@localhost wvdial-1.54.0]# make [root@localhost wvdial-1.54.0]# make install
3.3.2、wvdial-1.60.4 export PATH=/usr/local/arm/4.2.2-eabi/usr/bin:$PATH tar xjf zlib-1.2.5.tar.bz2
cd zlib-1.2.5./configure--prefix=/works/cdma/install-4.2.2 修改Makefile CC = arm-linux-gcc CPP=arm-linux-gcc-E AR=arm-linux-ar rc LDSHARED=arm-linux-gcc....RANLIB=arm-linux-ranlib make make install
openssl-0.9.8n patch-N-p 1-i../openssl-0.9.8n-fix_manpages-1.patch
./Configure--prefix=/works/cdma/install-4.2.2 os/compiler:arm-linux-gcc make make install
wvstreams-4.6.1 修改configure
with_zlib=no 改为
with_zlib=yes(有两处)
with_openssl=no 改为
with_openssl=yes(有两处)
./configure--prefix=/works/cdma/install-4.2.2--host=arm-linux CPPFLAGS=-I/works/cdma/install-4.2.2/include LDFLAGS=-L/works/cdma/zlib-1.2.5-4.2.2 CFLAGS=-I/works/cdma/zlib-1.2.5-4.2.2--with-zlib=/works/cdma/zlib-1.2.5-4.2.2/--with-openssl=/works/cdma/openssl-0.9.8n-4.2.2--without-dbus--with-pam=no--with-tcl=no--with-qt=no--without-valgrind make 如果出现 undefined reference to “EVP_MD_size”错误
将出现错误的语句 return EVP_MD_size((evp_md_st *)evpmd;改成 return((evp_md_st *)evpmd)->md_size;即可
make install
wvdial-1.60.4 修改Makefile prefix=/usr/local 改为
prefix=/works/cdma/install-4.2.2
PPPDIR=/etc/ppp/peers 改为
PPPDIR=${prefix}/etc/ppp/peers
PC_CFLAGS=$(shell pkg-config--cflags libwvstreams)改为
PC_CFLAGS=-I/works/cdma/install-4.2.2/include/wvstreams
PC_LIBS=$(shell pkg-config--libs libwvstreams)PC_LIBS=-L/works/cdma/install-4.2.2/lib-lwvstreams-lwvutils-lwvbase
修改wvrules.mk WVLINK_CC = gcc
改为
WVLINK_CC = arm-linux-g++ CC = arm-linux-g++ CXX = arm-linux-g++ make make install
4、Linux内核的配置与修改 4.1、linux内核配置 make menuconfig Device Drivers--->
[*] Network device support--->
[*] USB support--->
4.2、linux内核修改 drivers/usb/serial/option.c static struct usb_device_id option_ids[] = { … };在这个数组中添加两项
{ USB_DEVICE(0x19d2, 0x0031)}, { USB_DEVICE(0x19d2, 0x0034)}, 4.3、linux内核编译 make zImage make modules5、3G模块的使用 5.1、加载内核模块 insmod option.ko insmod cdc-acm.ko
insmod slhc.ko insmod ppp_generic.ko insmod pppox.ko insmod pppoe.ko insmod ppp_synctty.ko insmod ppp_deflate.ko insmod crc-ccitt.ko insmod ppp_async.ko insmod sha1_generic.ko insmod ppp_mppe.ko
5.2、加载USB文件系统
mount-t usbfs usbfs /proc/bus/usb
5.3、ZTE-mf637u(中国联通)的使用 5.3.1、配置文件/etc/usb_modeswitch.setup # Configuration for the usb-modeswitch package, a mode switching tool for # USB devices providing multiple states or modes # # This file is evaluated by the wrapper script “usb_modeswitch” in /lib/udev # To enable an option, set it to “1”, “yes” or “true”(case doesn't matter)
# Everything else counts as “disable”
# Disable automatic mode switching globally(e.g.to access the original # install storage)
DisableSwitching=0
# Enable logging(results in a extensive report file in /var/log, named # “usb_modeswitch_
EnableLogging=0
# ZTE MF622(aka “Onda MDC502HS”)# ZTE MF626 # ZTE MF628+(tested version from Telia / Sweden)# ZTE MF633 # ZTE MF636(aka “Telstra / BigPond 7.2 Mobile Card”)# ZTE MF637
# # Contributor: Joakim Wennergren and others
DefaultVendor= 0x19d2 DefaultProduct= 0x2000
TargetVendor= 0x19d2 TargetProduct= 0x0031
MessageContent=“******1b******” MessageContent2=“******1b******”
NeedResponse=1
5.3.2、配置文件/etc/wvdial.conf [Dialer Defaults]
Modem = /dev/ttyUSB2
Init1 = ATZ
Init3 = ATE0V1
Init5 = ATS0=0
Init6 = AT+CGDCONT=1,“IP”,“uninet”
Init7 = AT+CFUN=1
Modem Type = USB Modem
Baud = 460800
New PPPD = yes ISDN = 0
Phone = *99***1#
Password = any
Username = any
Stupid Mode = 1
5.3.3 ZTE-mf637u(中国联通)的操作步骤 5.3.3.1、设置环境变量
export PATH= /works/wvdial-1.54.0/install/bin: /works/cdma/install/bin :$PATH export LD_LIBRARY_PATH= /works/wvdial-1.54.0/install/lib: /works/cdma/install/lib:$LD_LIBRARY_PATH 5.3.3.2、插入ZTE-mf637u(中国联通)无线网卡 5.3.3.3、等待5秒钟左右、运行usb-modeswitch-W 5.3.3.4、运行wvdial--> WvDial: Internet dialer version 1.54.0--> Cannot open /dev/ttyUSB2: Cannot get information for serial port.--> Cannot open /dev/ttyUSB2: Cannot get information for serial port.--> Cannot open /dev/ttyUSB2: Cannot get information for serial port.解决:(两种方法)5.3.3.4.1将wvstreams-4.0.1/streams/wvmodem.cc #if HAVE_LINUX_SERIAL_H 改为
#if 0
5.3.3.4.2.wvstreams-4.0.1的配置命令增加ac_cv_header_linux_serial_h=no 即./configure--prefix=/works/wvdial-1.54.0/install--host=arm-linux CFLAGS=-I/works/cdma/install/include LDFLAGS=-L/works/cdma/install/lib/--with-zlib=/works/cdma/zlib-1.2.5--with-openssl=/works/cdma/openssl-0.9.8n--without-dbus--with-pam=no--with-tcl=no--with-qt=no ac_cv_header_linux_serial_h=no 重新编译。
5.4、ZTE-mu351(中国移动)的使用 5.4.1、配置文件/etc/wvdial.conf Modem = /dev/ttyACM2 Init1 = ATZ Init3 = ATE0V1 Init5 = ATS0=0 Init6 = AT+CGDCONT=1,“IP”,“cmnet” Init7 = AT+CFUN=1 Modem Type = USB Modem Baud = 460800 New PPPD = yes ISDN = 0 Phone = *99***1#
Password = any Username = any Stupid Mode = 1 5.4.2、ZTE-mu351(中国移动)的操作步骤 5.4.2.1、设置环境变量
export PATH=/root/cdma:$PATH export LD_LIBRARY_PATH=/root/cdma:$LD_LIBRARY_PATH 5.4.2.2、插入ZTE-mu351(中国移动)无线网卡
5.4.2.3、等待5秒钟左右、运行eject /dev/sr0。(5.3.3.3也可以使用此方法)5.4.2.4、运行wvdial--> WvDial: Internet dialer version 1.54.0--> Initializing modem.--> Sending: ATZ ATZ OK--> Sending: ATE0V1 ATE0V1 OK--> Sending: ATS0=0 OK--> Sending: AT+CGDCONT=1,“IP”,“cmnet”
OK--> Sending: AT+CFUN=1 OK--> Modem initialized.--> Sending: ATDT*99***1#--> Waiting for carrier.NO CARRIER--> No Carrier!Trying again.--> Sending: ATDT*99***1#--> Waiting for carrier.NO CARRIER--> No Carrier!Trying again.--> Sending: ATDT*99***1#--> Waiting for carrier.NO CARRIER--> No Carrier!Trying again.--> Sending: ATDT*99***1#--> Waiting for carrier.NO CARRIER--> No Carrier!Trying again.--> Sending: ATDT*99***1#
--> Waiting for carrier.^MODE: 15 CONNECT 2800000--> Carrier detected.Starting PPP immediately.--> Starting pppd at Mon Aug 16 16:17:15 2010--> pid of pppd: 1364--> Using interface ppp0--> local IP address 10.67.54.108--> remote IP address 192.200.1.21--> primary DNS address 211.136.20.203--> secondary DNS address 211.136.17.107
6、参考资料
http://sourceforge.net/projects/libusb/files/libusb-1.0/ http:// http://#ppp
http://code.google.com/p/wvstreams/downloads/detail?name=wvstreams-4.6.1.tar.gz&can=2&q= http://code.google.com/p/wvstreams/downloads/list
http://ftp.debian.org/debian/pool/main/w/wvdial/ http://code.google.com/p/wvstreams/downloads/list
第二篇:嵌入式linu学习心得
嵌入式Linux学习心得
1、Linux命令
ls:查看目录-l以列表方式查看;ls –l 与ll的功能一样 pwd: 查看当前的目录
cd:改变当前操作目录cd /直接跳到根目录 cd..回到上一级目录 cat: 打印显示当前文件的内容信息
mkdir:创建目录
fdisk: 查看硬盘分区信息,-l以列表方式查看
->代表是链接文件,类似window下的快捷方式。
cp: 复制命令,例子cp 文件名 /home/dir/
mv: 移动或改名,如mv sonf.confsonf.txt(改名)移动:mv sonf.conf / rm:删除命令,如rm –f test.c;如删除目录rm –fr d
man:查看某个命令的帮助,man 命令
2、各系统目录的功能
drw—r—w--:d代表是目录,drw代表当前用户的权限,r代表组用户的权限,w代表其它用户的权限。x代表有执行权限。
/boot/gruff.conf: 启动引导程序
/dev:brw—rw--:b代表是块设备。Linux设备有三种,块设备(b开头)、字符设备(c开头)、网络设备。had代表第一个硬盘,hdb代表第二个硬盘。Hdb2代表第二块硬盘的第二个分区。3,67代表主设备为3,从设备为67./etc:存放的是系统的配置文件。Inittab文件存放不同启动方式下必须启动的进程。Inittab文件中有6个启动level,wait中对应着6个level的目录,respawn代表当一个进程被意外终止了,但会自动启动的进程,如守护进程。rc.d目录中存放了一个rc.sysinit文件,里面存放系统初始化配置信息。/etc还有一个vsftpd里面存放tcp、ftp的配置。
/home : 用户目录,存放用户的文件,/lib:存放库文件,后缀为so的文件代表动态链接库。
/lost+found:系统意外终止,存放一些可以找回的文件。
/mnt:挂载外部设备,如挂载光驱:mount –t /dev/cdrom/mnt/cdrom,如
果在双系统中,要查看windows中D盘的文件,首先应该将D盘的文件映射过来,mount –t /dev/hda2/mnt/windows/d
/opt:用户安装的应用程序
/proc:是系统运行的映射,比较重要。里面的文件数字代表进程号。每个进程号目录下包含进程的基本信息。还有其他信息,如cpuinfo等,内核支持的文件系统filesystem等。系统支持的中断interrupts,iomen代表内存分配情况。ioport存放IO端口号。还有分区信息,modole信息,状态信息,版本信息
对于Linux的设备驱动程序,有两种加载模式,一种是直接加载进linux内核,一种是以模块的方式加载到内核。
/sbin: 系统管理的一些工具。如poweroff关机工具。
/usr: 安装系统时很多文件放在此目录下面,包含一些更新等,include包含的头文件,lib 是Linux的库文件,src包含Linux2.4的内核源码
/var:存放是临时变量
3、
第三篇:嵌入式linux驱动学习总结
调用gcc: export PATH=$PATH:/usr/local/arm/3.4.1/bin 用gcc编译:arm-linux-gcc –o run adc.c 查看gcc: arm-linux-gcc –v 配置NFS 安装NFS Ubuntu上默认是没有安装NFS服务器的,首先要安装NFS服务程序: sudo apt-get install nfs-kernel-server 安装nfs-kernel-server时,apt会自动安装nfs-common和portmap 这样,宿主机就相当于NFS Server 配置NFS(1)配置portmap 方法1: 编辑/etc/default/portmap, 将-i 127.0.0.1 去掉.我用的是第一种方法!但不知道具体什么意思
方法2: $ sudo dpkg-reconfigure portmap , 对Should portmap be bound to the loopback address? 选N.(2)配置/etc/hosts.deny 禁止任何host(主机)能和你的NFS服务器进行NFS连接,加入: ### NFS DAEMONS portmap:ALL lockd:ALL mountd:ALL rquotad:ALL statd:ALL(3)配 置/etc/hosts.allow 允许那些你想要的主机和你的NFS服务器建立连接。下列步骤将允许任何IP地址以192.168.2开头的主机(连接到NFS服务器上),也可以指定 特定的IP地址,加入: ### NFS DAEMONS portmap: 192.168.1.lockd: 192.168.1.rquotad: 192.168.1.mountd: 192.168.1.statd: 192.168.1./etc/hosts.deny 和 /etc/hosts.allow 设置对portmap的访问.采用这两个配置文件有点类似“mask”的意思.现在/etc/hosts.deny中禁止所有用
户对portmap的访问.再在/etc/hosts.allow 中允许某些用户对portmap的访问.sudo /etc/init.d/portmap restart 重启portmap daemon.(4)配置/etc/exports NFS挂载目录及权限由/etc/exports文件定义 比如我要将将我的/opt/FriendlyARM/mini2440/root_nfs目录让用户的IP共享, 则在该文件末尾添加下列语句:
/opt/FriendlyARM/mini2440/root_nfs *(rw,sync,no_root_squash)NFS客户端能够共享NFS服务器/opt/FriendlyARM/QQ2440/root_nfs目录内容.且有读,写权限, 并且该用户进入
/opt/FriendlyARM/mini2440/root_nfs目录后的身份为root 最好加上sync, 否则 $ sudo exportfs-r 时会给出警告, sync是NFS的默认选项.showmount-e 查看NFS server的export list.若更改了/etc/exports, 运行 sudo exportfs-r 更新
运行 /etc/init.d/nfs-kernel-server restart 重启nfs服务
(5)测试NFS 可以尝试一下挂载本地磁盘
我前面开始时已经提到了我的主机IP是192.168.1.101 我现在试把/opt/FriendlyARM/mini2440/root_nfs目录挂载到/mnt目录下 mount-t nfs 192.168.1.101:/opt/FriendlyARM/mini2440/root_nfs /mnt 就101和:之间的空格我耗了1个小时
成功的挂载上的话你会在/mnt目录下看到root_nfs这个文件夹下的内容
Arm9之家账户:李向阳85 安装ncurses
ncurses是字符终端下屏幕控制的基本库。可能很多新开发的程序都不使用了,不过如果要编译一些老程序,还经常遇得到。
安装:ncurses
http://ftp.gnu.org/pub/gnu/ncurses/
./configure--without-debug #以及其它自己需要的参数
make
make install
3,继续你的make menuconfig。
图形界面出来了。
允 23:22:22
小允 23:22:31
小允 23:22:40 有用不同的名字的吗 寂寞沙洲冷 23:22:42 我把drivers下面的Makefile都添加上了 寂寞沙洲冷 23:23:17 叫misc devices 可以吧 小允 23:23:22 2410ADC_driver和2410ADC_FEATURESnengbutongma 小允 23:23:33 这两个必须一样 小允 23:23:42 这才是Kconfig的工作原理
第四篇:嵌入式软件工程师底层驱动内核工程师
嵌入式软件工程师 嵌入式软件工程师嵌入式系统是以应用为中心,以计算机技术为基础,并且软硬件可裁剪,适用于应用系统对功能、可靠性、成本、体积、功耗有严格要求的专用计算机系统。它一般由嵌入式微处理器、外围硬件设备、嵌入式操作系统以及用户的应用程序等四个部分组成,用于实现对其他设备的控制、监视或管理等功能。
嵌入式软件工程师就是编写嵌入式系统的工程师。
嵌入式软件工程师待遇
IBM、微软、华为、Yahoo、联想、搜狐、亚信、花旗...2010'应届毕业生就业安置计划火热启动:先实训后上岗,转正年薪50000元。
怎样做个嵌入式软件工程师
应具备哪些能力,最直接的方法,就是去根据各公司,招聘网站的嵌入式软件工程师的应聘要求来分析
我帮你总结下:
1.最重要的是C语言编程,以及C++,这个与你读程,应用,开发项目,做系统移植息息相关;
2.操作系统: LINUX,WINCE等,至少学习过一种,并且还需要对些基础知识有蛮多的了解;
3.对ARM,FPGA,DSP等这些硬件比较了解。
这是最常规的条件
当然,一些基本素质,像英语能力,或是啥的,也很重要
推荐: 你可以去按照招聘要求分析,也可以按照培训机构的培训目的,方向,内容来分析得知,像海同科技就是蛮不错的嵌入式软件工程师发展前景分析
嵌入式领域较新,目前发展非常快,很多软硬件技术出现的时间都不太长(如ARM处理器、嵌入式操作系统、LINUX操作系统),大多数人没有条件接触或进入嵌入式行业,更谈不上能有机会接受专业人士的指导。因此,踏进这个行业的难度比较大,嵌入式人才稀缺,身价自然也水涨船高。
权威部门统计,我国嵌入式人才缺口每年50万人左右。根据前程无忧网发布的调查报告,嵌入式软件开发是未来几年最热门和最受欢迎的职业之一,具有10年工作经验的高级嵌入式工程师年薪在30万元左右。即使是初级的嵌入式软件开发人员,平均月薪也达到了3000—5000元,中高级的嵌入式工程师月薪平均超过10000元。做软件实际上有高下之分,开发语言从机器语言、汇编到C、C++,再到红透半边天的Java、C#等,该学哪种呢?为什么有些开发者工资低,而有些开发者千金难求?为什么3年的Java高级程序员薪水仅仅8k-10k,而一个Linux底层C语言程序员两
年经验就敢要10k的薪水?
还是门槛,比如月薪15k的Linux嵌入式开发职位,门槛就有 Linux系统、Shell编程、Linux开发环境、C语言、ARM硬件平台、数据结构、Linux内核、驱动程序等,粗略数数就有8道关口,他需要非常熟悉整个的计算机体系,能做出实际的产品,而Java的开发者却仅仅是会使用名叫Java的语言工具,始终高高飘在众多层次之上,开发项目非常快,甚至可以不知道OSI模型,很可能自始至终都是软件蓝领。嵌入式开发本身也有高下之分,至少包含嵌入式应用程序工程师和底层的驱动内核工程师两种。前者同样是使用现成工具进行简单劳动,比如使用J2ME开发小游戏或者进行一些界面开发,而后者是根据芯片具体情况把操作系统(如Linux)移植到上面,同时编写必要的驱动程序,改写相应的内核代码。很显然后者是一个公司真正的技术核心。而技术核心的工资很可能是其他开发者的数倍。
嵌入式开发突出强制和项目,学习不仅仅是学习几项技术,而是构建你的知识体系。比如学习嵌入式开发,就要从基础Linux,C语言,数据结构开始,到ARM,汇编,Linux内核、驱动等,更重要的是更多的项目练习,设计至少5个项目,多达10000行强制核心代码的编写可以让你真正获得知识。为进入外企或者出国做准备。
未来的几年内,随着信息化,智能化,网络化的发展,嵌入式系统技术也将获得广阔的发展空间。美国著名未来学家尼葛洛庞帝99年1月访华时预言,4~5年后嵌入式智能(电脑)工具将是PC和因特网之后最伟大的发明。我国著名嵌入式系统专家沈绪榜院士98年11月在武汉全国第11次微机学术交流会上发表的《计算机的发展与技术》一文中,对未来10年以嵌入式芯片为基础的计算机工业进行了科学的阐述和展望。1999年世界电子产品产值已超过12000亿美元,2000年达到13000亿美元,预计2005年,销售额将达18000亿美元。目前一些先进的PDA在显示屏幕上已实现汉字写入、短消息语音发布,日用范围也将日益广阔。对于企业专用解决方案,如物流管理、条码扫描、移动信息采集等,这种小型手持嵌入式系统将发挥巨大的作用。自动控制领域,不仅可以用于ATM机,自动售货机,工业控制等专用设备,和移动通讯设备结合、GPS、娱乐相结合,嵌入式系统同样可以发挥巨大的作用。
第五篇:嵌入式Linux应用:概述
Embedded Linux applications: An overview Linux now spans the spectrum of computing applications, including IBM's tiny Linux wrist watch, hand-held devices(PDAs and cell phones), Internet appliances, thin clients, firewalls, industrial robotics, telephony infrastructure equipment, and even cluster-based supercomputers.Let's take a look at what Linux has to offer as an embedded system, and why it's the most attractive option currently available.One.Emergence of embedded systems The computers used to control equipment, otherwise known as embedded systems, have been around for about as long as computers themselves.They were first used back in the late 1960s in communications to control electrome chanical telephone switches.As the computer industry has moved toward ever smaller systems over the past decade or so, embedded systems have moved along with it, providing more capabilities for these tiny machines.Increasingly, these embedded systems need to be connected to some sort of network, and thus require a networking stack, which increases the complexity level and requires more memory and interfaces, as well as, you guessed it, the services of an operating system.Off-the-shelf operating systems for embedded systems began to appear in the late 1970s, and today several dozen viable options are available.Out of these, a few major players have emerged, such as VxWorks, pSOS, Neculeus, and Windows CE.Two.Advantages/disadvantages of using Linux for your embedded system Although most Linux systems run on PC platforms, Linux can also be a reliable workhorse for embedded systems.The popular “back-to-basics” approach of Linux, which makes it easier and more flexible to install and administer than UNIX, is an added advantage for UNIX gurus who already appreciate the operating system because it has many of the same commands and programming interfaces as traditional UNIX.The typical shrink-wrapped Linux system has been packaged to run on a PC, with a
hard disk and tons of memory, much of which is not needed on an embedded system.A fully featured Linux kernel requires about 1 MB of memory.However, the Linux micro-kernel actually consumes very little of this memory, only 100 K on a Pentium CPU, including virtual memory and all core operating system functions.With the networking stack and basic utilities, a complete Linux system runs quite nicely in 500 K of memory on an Intel 386 microprocessor, with an 8-bit bus(SX).Because the memory required is often dictated by the applications needed, such as a Web server or SNMP agent, a Linux system can actually be adapted to work with as little as 256 KB ROM and 512 KB RAM.So it's a lightweight operating system to bring to the embedded market.Another benefit of using an open source operating system like Embedded Linux over a traditional real-time operating system(RTOS), is that the Linux development community tends to support new IP and other protocols faster than RTOS vendors do.For example, more device drivers, such as network interface card(NIC)drivers and parallel and serial port drivers, are available for Linux than for commercial operating systems.The core Linux operating system itself has a fairly simple micro-kernel architecture.Networking and file systems are layered on top of the micro-kernel in modular fashion.Drivers and other features can be either compiled in or added to the kernel at run-time as loadable modules.This provides a highly modular building-block approach to constructing a custom embeddable system, which typically uses a combination of custom drivers and application programs to provide the added functionality.An embedded system also often requires generic capabilities, which, in order to avoid re-inventing the wheel, are built with off-the-shelf programs and drivers, many of which are available for common peripherals and applications.Linux can run on most microprocessors with a wide range of peripherals and has a ready inventory of off-the-shelf applications.Linux is also well-suited for embedded Internet devices, because of its support of multiprocessor systems, which lends it scalability.This capability gives a designer the option of running a real-time application on a dual processor system, increasing total processing power.So you can run a Linux system on one processor while running a GUI, for example, simultaneously on another processor.The one disadvantage to running Linux on an embedded system is that the Linux architecture provides real-time performance through the addition of real-time software modules that run in the kernel space, the portion of the operating system that implements the scheduling policy, hardware-interrupts exceptions and program execution.Since these
real-time software modules run in the kernel space, a code error can impact the entire system's reliability by crashing the operating system, which can be a very serious vulnerability for real-time applications.An off-the-shelf RTOS, on the other hand, is designed from the ground up for real-time performance, and provides reliability through allocating certain processes a higher priority than others when launched by a user as opposed to by system-level processes.Processes are identified by the operating system as programs that execute in memory or on the hard drive.They are assigned a process ID or a numerical identifier so that the operating system may keep track of the programs currently executing and of their associated priority levels.Such an approach ensures a higher reliability(predictability)with the RTOS time than Linux is capable of providing.But all-in-all, it's still a more economical choice.Three.Different types of Embedded Linux systems There are already many examples of Embedded Linux systems;it's safe to say that some form of Linux can run on just about any computer that executes code.The ELKS(Embeddable Linux Kernel Subset)project, for example, plans to put Linux onto a Palm Pilot.Here are a couple of the more well-known small footprint Embedded Linux versions: ETLinux--a complete Linux distribution designed to run on small industrial computers, especially PC/104 modules.LEM--a small(<8 MB)multi-user, networked Linux version that runs on 386s.LOAF--“Linux On A Floppy” distribution that runs on 386s.uClinux--Linux for systems without MMUs.Currently supports Motorola 68K, MCF5206, and MCF5207 ColdFire microprocessors.uLinux--tiny Linux distribution that runs on 386s.ThinLinux--a minimized Linux distribution for dedicated camera servers, X-10 controllers, MP3 players, and other such embedded applications.Software and hardware requirements Several user-interface tools and programs enhance the versatility of the Linux basic kernel.It's helpful to look at Linux as a continuum in this context, ranging from a stripped-down micro-kernel with memory management, task switching and timer services to a full-blown server supporting a complete range of file system and network services.A minimal Embedded Linux system needs just three essential elements:
A boot utility
The Linux micro-kernel, composed of memory management, process An initialization process Drivers for hardware
One or more application processes to provide the needed functionality A file system(perhaps in ROM or RAM)TCP/IP network stack
A disk for storing semi-transient data and swap capability A 32-bit internal CPU(required by all complete Linux systems)management and timing services
To doing anything useful while remaining minimal, you also need to add:
As additional requirements become necessary, you might also want:
Four.Hardware platform options Choosing the best hardware can be complex because of internal company politics, prejudices, legacies of other projects, a lack of complete or accurate information, and cost, which should take into account the total product costs and not just the CPU itself.Sometimes a fast, inexpensive CPU can become expensive once bus logic and the delays necessary to make it work with other peripherals are considered.To calculate the necessary speed of a CPU for any given project, start with a realistic view of how fast the CPU needs to run to accomplish a given task and triple it.Also, determine how fast the bus needs to run.If there are secondary buses, such as a PCI bus, consider them also.A slow bus(that is, one that is saturated with DMA traffic)can significantly slow down a fast CPU.Here are some of the best hardware solutions for Embedded Linux applications.Bright Star Engineering: Bright Star Engineering's ipEngine-1 is a credit-card sized single-board computer with Embedded Linux support.It utilizes a PowerPC-based CPU and provides an array of on-board peripherals, including Ethernet, LCD/Video Controller, USB, Serial I/O, and a 16K gate user-configurable FPGA.BSE's Embedded Linux configuration allows Linux to be booted from the ipEngine's on-board 4MB flash memory.Calibri: CalibriTM-133 is a ready-to-use, compact, multipurpose network appliance
that uses Embedded Linux as its operating system.It offers a highly efficient and low-cost solution to firewall, VPN, and routing demands.EmbeddedPlanet: EmbeddedPlanet has created a PostPC-era computer that comes loaded with MontaVista's HardHat Linux.Powered by a PowerPC-based computing engine and matching I/O card, Linux Planet comes in a colorful translucent case with a touchscreen and access to digital and analog I/O.Eurotech: Eurotech provides embedded PC SBC and sponsors ET-Linux, a complete Linux system designed to run on small industrial computers and based on glibc 2.1.2.Microprocess Ingenierie: Microprocess develops, produces, and sells standard and customized products for the industrial and embedded market.Microprocess has a global activity in real-time software and great expertise in systems integration.Its products, like the 740 PowerPC compactPCI board, can be ordered with a standard distribution of Linux or an Embedded Linux version.Moreton Bay: Moreton Bay is releasing their NETtel 2520 and NETtel 2500 range of Linux-based Internet routers.These small, easy-to-connect intelligent router solutions are engineered to offer a simple, secure, and affordable extranet-friendly Virtual Private Network(VPN)for flat networks.The NETtel router family runs an Embedded Linux kernel.A development kit is available;it enables customized code to be stored in flash memory and executed inside the NETtel.The code may contain special encryption or authentication protocols, or some local monitoring script where NETtel is used as a remote control device.Matrix Orbital: This an optional, but not recommended, addition.Matrix Orbital manufactures a line of serial LCDs and VFDs, which many Linux users are including in their embedded systems.The product line ranges from 8x2 to 40x4 character LCDs, 20x2 and 20x4 VFDs, plus a 240x64 graphic LC(128x128 on the way).Communication with the displays is accomplished via either RS232 or I2C, both of which are standard on all of their modules.A comprehensive command set is included in the modules' BIOS.Five.Real-time Embedded Linux applications One of the most important issues with embedded systems is the need for a real-time operating system.The definition of real-time here varies quite a bit.To some people, real-time means responding to an event in the one-microsecond range, to others it is 50 milliseconds.The hardness of real-time also varies quite a bit.Some systems need hard
real-time response, with short deterministic response latencies to events.However, on many systems, when analyzed closely, we see a response time requirement that is actually near real-time.Often the real-time requirement is a tradeoff of time and buffer space.With memory getting cheaper, and CPUs getting faster, near real-time is now more typical than hard real-time and many commercial operating systems that claim to be real-time are far from being hard real-time.Usually, when you get into the detailed design of these systems, there are warnings that the drivers' interrupts and applications must be very carefully designed in order to meet real-time requirements.RT-Linux(Linux with real-time extensions)contains time critical functions to provide precise control over interrupt handling, through the use of an interrupt manager, and does a good job of making sure that critical interrupts get executed when needed.The hardness of this approach depends mostly on the CPU interrupt structure and context-switch hardware support.This approach is sufficient for a large range of real-time requirements.Even without the real-time extensions, Linux does pretty well at keeping up with multiple streams of events.For example, a Linux PC system on a low end Pentium is able to keep multiple 10BaseT interfaces executing effectively, while simultaneously running character-level serial ports at a full 56KBPS without losing any data.Some real-time hardware and software Linux APIs to consider are RTLinux, RTAI, EL, and Linux-SRT.RTLinux is a hard real-time Linux API originally developed at the New Mexico Institute of Technology.RTAI(DIAPM)is a spin-off of the RTLinux real-time API that was developed by programmers at the Department of Aerospace Engineering, Polytechnic Politecnico di Milano(DIAPM).EL/IX is a proposed POSIX-based hard real-time Linux API being promoted by Red Hat.And Linux-SRT is a soft real-time alternative to real-time APIs, which provides performance-enhancing capabilities to any Linux program without requiring that the program be modified or recompiled.See the Resources section later in this article for information on the above and for some Web sites offering different flavors of software extensions, development tools, support, and training courses for the standard Linux operating system.Short deterministic response latencies Some real-time embedded systems need to respond quickly to external events in order to accomplish a specific task.A custom microcontroller embedded inside a missile, for example, needs to respond quickly to external events such as moving targets, weather, humans, etc., before instructing the missile to target a specific object in its surrounding
environment.Short deterministic response latencies mean that the embedded system can determine the time it will take to respond to an external event.Six.Configuration procedures Now let's take a look at how to make LEM, a small, embeddable Linux distribution, which provides both network and X server.You can download this distribution, although it is not essential.You will need a full Linux distribution to build your own Embedded Linux operating system, which will contain everything you need(utilities, sources, compiler, debugger, and documentation).Here is a list of the software that can be used to make LEM: TinyLogin: TinyLogin is a suite of tiny UNIX utilities for handling logging into, being authenticated by, changing one's password for, and otherwise maintaining users and groups on an embedded system.It also provides shadow password support to enhance system security.TinyLogin is, as the name implies, very small, and makes an excellent complement to BusyBox on an embedded System.BusyBox: BusyBox is a multicall binary used to provide a minimal subset of POSIX-style commands and specialized functions.It is geared toward the very small, such as boot floppies, embedded systems, etc.Specifically it is used in the Debian Rescue/Install system(which inspired development on the original BusyBox), the Linux Routeur Project, LEM, lineo, and others.Busybox is being maintained by Erik Andersen.Ash: Ash is a very small Bourne shell.Sysvinit: Sysvinit is the most used init package for Linux.We will use init and the C version of the start-stop-daemon.See the Resources section for more information on these items.Seven.Creating a bootdisk A bootdisk is basically a miniature, self-contained Linux system on a floppy diskette.It can perform many of the same functions that a complete full-size Linux system performs.The following material is based on the Bootdisk-HOWTO(see Resources).Step 1.Bios
All PC systems start the boot process by executing code in ROM(specifically, the BIOS)to load the sector from sector 0, cylinder 0 of the boot drive.The boot drive is usually the
first floppy drive(designated A: in DOS and /dev/fd0 in Linux).The BIOS then tries to execute this sector.On most bootable disks, sector 0, cylinder 0 contains either:
Code from a boot loader such as LILO, which locates the kernel, loads it, and The start of an operating system kernel, such as Linux executes it to start the boot proper
If a Linux kernel has been raw copied to a diskette, a hard drive, or another media, the first sector of the disk will be the first sector of the Linux kernel itself.This first sector will continue the boot process by loading the rest of the kernel from the boot device.Step 2.The boot loader
You will use a boot loader like LILO to operate the boot process.It allows the development and production platforms to co-exist on the same hardware and permits switching from one to the other just by rebooting.The LILO boot loader is loaded by the bios.It then loads kernels or the boot sectors of other operating systems.It also provides a simple command line interface to interactively select the item to boot with its options.See Resources for more information on LILO.Step 3.The kernel
The kernel checks the hardware and mounts the root device and then looks for the init program on the root filesystem and executes it.Step 4.Init Init is the parent of all other processes that will run on your Linux OS.It will watch its child processes and start, stop, re-launch them if needed.Init takes all information from /etc/inittab.Step 5.Inittab The file /etc/inittab/ refers to scripts named /etc/rc...to do the system setup.It also has entries for the getty tool to handle the login process.Step 6.The login process
There is one getty available in the inittab file for each console allowed for the users.Getty will launch /bin/login to verify the user password.Step 7.Creating a new partition
From the LFS-HOWTO(see Resources): Before we can build our new Linux system, we need to have an empty Linux partition on which we can build our new system.If you already have a Linux Native partition available, you can skip this step and the following one.Start the fdisk program(or cfdisk if you prefer that program)with the appropriate hard disk as the option(like /dev/hda if you want to create a new partition on the primary
master IDE disk).Create a Linux Native partition, write the partition table, and exit the(c)fdisk program.If you get the message that you need to reboot your system to ensure that the partition table is updated, then please reboot your system now before continuing.Step 8.Creating an ext2 file system on the new partition
From the LFS-HOWTO(see Resources): To create a new ext2 file system we use the mke2fs command.Give $LFS as the only option, and the file system will be created.From now on I'll refer to this newly created partition as $EMBPART.$EMBPART should be substituted with the partition you have created.Step 9.Mounting the partition
To access the newly created filesystem, you have to mount it.To do this, create an /mnt/hda? directory and type the following at the shell prompt:
mkdir /mnt/hda? mount $EMBPART /mnt/hda? If you created your partition on /dev/hda4 and you mounted it on /mnt/hda4, then you'll need to return to the step where you copied a file to $dollar;EMBPART/usr/sbin, and copy that file to /mnt/hda4/usr/bin.Do this after the last command in Step 14(Copy the file in $EMBPART/usr/sbin).Step 10.Populating the filesystem
The root filesystem must contain everything needed to support a full Linux system.We will build a directory structure not that far from the File Hierarchy Standard(see Resources).Step 11.Directories The mkdir function in the new mounted filesystem creates the following directories: /proc
Directory stub required by the proc filesystem /etc :System configuration file /sbin :Critical System binaries
/bin :Basic binaries considered part of the system /lib :Shared Libraries to provide run-time support /mnt :Mount point for maintenance /usr :Additional utilities and applications
cd /mnt/hda?
mkdir bin dev home proc sbin usr boot etc liv mnt root tmp var mkdir-p usr/bin usr/sbin usr/share usr/lib mkdir-p etc/config etc/default etc/init.d etc/rc.boot
mkdir-p etc/rc0.d etc/rc1.d etc/rc2.d etc/rc3.d etc/rc4.d etc/rc5.d etc/rc6.d etc/rcS.d
/dev :The dev directory is the stub required to perform devices input / output.Each file in this directory may be created using the mknod function.You may save time by directly copying the required dev entries from your desktop Linux, using the following instruction: cp-dpR /dev /mnt Eight.Installing TinyLogin and login dependencies TinyLogin(see the Resources section to install it)will give us the following tools in less than 35Kb:
/bin/addgroup, /bin/adduser, /bin/delgroup, /bin/deluser, /bin/login, /bin/su, /sbin/getty, /sbin/sulogin, /usr/bin/passwd.Please refer to your main distribution doc or man pages for a full description of those commands.Step 12.Configuring TinyLogin
From the TinyLogin README: TinyLogin is modularized to help you build only the components you need, thereby reducing binary size.To turn off unwanted TinyLogin components, simply edit the file tinylogin.def.h and comment out the parts you do not want using C++ style(//)comments.Step 13.Installing TinyLogin After the build is complete, a tinylogin.links file is generated, which is then used by make install to create symlinks to the tinylogin binary for all compiled-in functions.By default, make install will place a symlink forest into pwd /_install unless you have defined the PREFIX environment variable.Step 14.Installing Sysvinit and start-stop daemon
After the kernel is done loading, it tries to run the init program to finalize the boot process.Now: 1.Unpack the Sysvinit archive 2.Go to the src directory
3.Copy the init executable in $EMBPART/sbin
The Sysvinit package also offers a C version of the start-stop-daemon in the contrib directory.1.Compile it
2.Copy the file in $EMBPART/usr/sbin Step 15.Configuring Sysvinit
Sysvinit needs a configuration file named inittab, which should be placed in $EMBPART/etc.Here is the one used in the LEM distribution: # /etc/inittab: init(8)configuration.# $Id: inittab,v 1.6 1997/01/30 15:03:55 miquels Exp $ # Modified for LEM 2/99 by Sebastien HUET # default rl.id:2:initdefault: # first except in emergency(-b)mode.si::sysinit:/etc/init.d/rcS # single-user mode.~~:S:wait:/sbin/sulogin # /etc/init.d executes the S and K scripts upon change # 0:halt 1:single-user 2-5:multi-user(5 may be X with xdm or other)6:reboot.l0:0:wait:/etc/init.d/rc 0 l1:1:wait:/etc/init.d/rc 1 l2:2:wait:/etc/init.d/rc 2 l3:3:wait:/etc/init.d/rc 3 l4:4:wait:/etc/init.d/rc 4 l5:5:wait:/etc/init.d/rc 5 l6:6:wait:/etc/init.d/rc 6 # CTRL-ALT-DEL pressed.ca:12345:ctrlaltdel:/sbin/shutdown-t1-r now # Action on special keypress(ALT-UpArrow).kb::kbrequest:/bin/echo “Keyboard Request--edit /etc/inittab to let this work.” # /sbin/mingetty invocations for runlevels.1:2345:respawn:/sbin/getty 9600 tty1 2:23:respawn:/sbin/getty 9600 tty2 #3:23:respawn:/sbin/getty tty3 #you may add console there #4:23:respawn:/sbin/getty tty4 Step 16.Creating initial boot scripts
As seen in the inittab file, Sysvinit needs additional scripts in its own directories.Step 17.Creating the necessary directories and base files
Use the following command to create the directories: cd $EMBPART/etc mkdir rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d init.d rcS.d rc.boot Go to the unpacked Sysvinit source directory Copy the debian/etc/init.d/rc to:$EMBART/etc/init.d Go to the $EMBPART/etc/init.d/ Create a new file rcS like those in LEM: #!/bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin runlevel=S prevlevel=N umask 022 export PATH runlevel prevlevel /etc/default/rcS export VERBOSE # Trap CTRL-C only in this shell so we can interrupt subprocesses.trap “:” 2 3 20 # Call all parts in order.for i in /etc/rcS.d/S??* do
[!-f “$i” ] && continue
case “$i” in
*.sh)
(trap-2 3 20
.$i start)
;;
*)
$i start
;;
esac done # run the files in /etc/rc.boot [-d /etc/rc.boot ] && run-parts /etc/rc.boot
Copy run-parts from your distro to $EMBPART/bin.Step 18.Adding base scripts
A lot of the commands being used here are UNIX/Linux commands that set, export, etc.paths that are embedded inside of a UNIX shell script. Create a new file reboot containing the following: #!/bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin echo-n “Rebooting...” reboot-d-f-i Create a new file halt containing the following: #!/bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin halt-d-f-i-p
Nine.Summary The Linux operating system has a very bright future in the area of embedded applications for anything from Internet appliances to dedicated control systems.Roughly 95% of all newly manufactured microcomputer chips are used for embedded applications.The power, reliability, flexibility, and scalability of Linux, combined with its support for a multitude of microprocessor architectures, hardware devices, graphics support, and communications protocols have established Linux as an increasingly popular software platform for a vast array of projects and products.Because Linux is openly and freely available in source form, many variations and configurations of Linux and its supporting software components have evolved to meet the diverse needs of the markets and applications to which Linux is being adapted.There are small footprint versions and real-time enhanced versions.Despite the origins of Linux as a PC architecture operating system, there are now ports to numerous non-x86 CPUs, with and without memory management units, including PowerPC, ARM, MIPS, 68K, and even microcontrollers.But look out, there's more coming in the near future for many other Information Technology(IT)domains!