So Tired !_! 逆水行舟, 不进则退!

10Dec/18

端口tagged和untagged详解

Posted by Nick Xu

情况列举 Switch收发 Switch对标记的处理 remark
Access (接收) Tagged = PVID 不接收 注:部分高端产品可能接收。
Access (接收) Tagged =/ PVID 不接收 注:部分高端产品可能接收。
Access (接收) Untagged 接收 增加tag=PVID 从PC

Access (发送) Tagged = PVID 转发 删除tag
Access (发送) Tagged =/ PVID 不转发 不处理
Access (发送) Untagged 无此情况 无此情况 无此情况

Trunk (接收) Tagged = PVID 接收 不修改tag
Trunk (接收) Tagged =/ PVID 接收 不修改tag
Trunk (接收) Untagged 接收 增加tag=PVID
Trunk (发送) Tagged = PVID If Passing then 转发 删除tag
Trunk (发送) Tagged =/ PVID If Passing then 转发 不修改tag
Trunk (发送) Untagged 无此情况 无此情况 无此情况(注)

Hybrid (接收) Tagged = PVID 接收 不修改tag 对端是trunk
Hybrid (接收) Tagged =/ PVID 接收 不修改tag 对端是trunk
Hybrid (接收) Untagged 接收 增加tag=PVID 类Trunk
Hybrid (发送) Tagged = PVID Tag 和 untag 中列出的vlan可以passing 看Tag项和untag项
Hybrid (发送) Tagged =/ PVID Tag 和 untag 中列出的vlan可以passing 看Tag项和untag项
Hybrid (发送) Untagged 无此情况 无此情况 无此情况(注)
我来解释一下
收报文:
Acess端口1、收到一个报文,判断是否有VLAN信息:如果没有则打上端口的PVID,并进行交换转发,如果有则直接丢弃(缺省)
发报文:
Acess端口: 1、将报文的VLAN信息剥离,直接发送出去
收报文:
trunk端口: 1、收到一个报文,判断是否有VLAN信息:如果没有则打上端口的PVID,并进行交换转发,如果有判断该trunk端口是否允许该 VLAN的数据进入:如果可以则转发,否则丢弃
发报文:
trunk端口: 1、比较端口的PVID和将要发送报文的VLAN信息,如果两者相等则剥离VLAN信息,再发送,如果不相等则直接发送
收报文:
hybrid端口: 1、收到一个报文
2、判断是否有VLAN信息:如果没有则打上端口的PVID,并进行交换转发,如果有则判断该hybrid端口是否允许该VLAN的数据进入:如果可以则转发,否则丢弃
发报文:
hybrid端口:1、判断该VLAN在本端口的属性(disp interface 即可看到该端口对哪些VLAN是untag, 哪些VLAN是tag)
2、如果是untag则剥离VLAN信息,再发送,如果是tag则直接发送

先呈请一下上面的几个帖子的术语:

Tag为IEEE802.1Q协议定义的VLAN的标记在数据帧中的标示;
ACCESS端口,TRUNK端口是厂家对某一种端口的叫法,并非IEEE802.1Q协议的标准定义;

这个数据交换的过程比较复杂,如果想解释的话,首先要了解一下几个IEEE802.1Q协议的定理;
1、下面是定义的各种端口类型对各种数据帧的处理方法;

  Tagged数据帧 Untagged数据帧
in out in out
Tagged端口 原样接收 原样发送 按端口PVID打TAG标记 按照PVID打TAG标记
Untagged端口 丢弃 去掉TAG标记 按端口PVID打TAG标记 原样发送

2、所谓的Untagged Port和tagged Port不是讲述物理端口的状态,而是讲诉物理端口所拥有的某一个VID的状态,所以一个物理端口可以在某一个VID上是Untagged Port,在另一个VID上是tagged Port;

3、一个物理端口只能拥有一个PVID,当一个物理端口拥有了一个PVID的时候,必定会拥有和PVID的TAG等同的VID,而且在这个VID上,这个物理端口必定是Untagged Port;

4、PVID的作用只是在交换机从外部接受到Untagged 数据帧的时候给数据帧添加TAG标记用的,在交换机内部转发数据的时候PVID不起任何作用;

5、拥有和TAG标记一致的VID的物理端口,不论是否在这个VID上是Untagged Port或者tagged Port,都可以接受来自交换机内部的标记了这个TAG标记的tagged 数据帧;

6、拥有和TAG标记一致的VID的物理端口,只有在这个VID上是tagged Port,才可以接受来自交换机外部的标记了这个TAG标记的tagged 数据帧;

以下是神州数码对命令的定义(各个厂家对命令的定义可能不一定一致,但是都必须遵循上面的定理):

1、Trunk端口就是在一个物理端口上增加这个交换机所有VLAN的VID标示,并且除了和这个物理端口PVID标示一致的VID标示为Untagged Port外,在其他的VID上都是Tagged Port;

2、Access端口就是指拥有一个和PVID标记相同的VID的物理端口,在这个VID上,遵循定理一定为untagged Port;

在了解了以上的基础理论之后,我们在来看一下楼主的问题:

一个数据包从PC机发出经过ACCESS端口->TRUNK端口->TRunk->ACCESS->PC数据包发生了怎么样的变化?

我们先把上述的描述变换为IEEE802.1Q的标准描述:

一个数据包从PC机发出经过(Untagged 数据帧)

ACCESS端口(PVID定义为100,VID=100=Untagged Port)->

TRUNK端口(PVID定义为1〈出厂配置,没有更改〉,VID=1=Untagged Port,VID=100=tagged Port)->

另一个交换机的TRunk端口(PVID定义为1〈出厂配置,没有更改〉,VID=1=Untagged Port,VID=100=tagged Port)->

另一个交换机的ACCESS端口(PVID定义为100,VID=100=Untagged Port)->

PC数据包发生了怎么样的变化?(Untagged 数据帧)

首先假设两台交换机刚刚开机(MAC地址表为空)从PC机发出的数据帧进入交换机的ACCESS端口以后,会按照这个端口的PVID打100的Tag标记,根据交换机的转发原理,交换机会把这个数据帧转发给VID=100的所有端口(除了进口以外),这个过程叫做VLAN Flood;参照上面的定理1;

由于Trunk端口拥有VID=100,所以才可接受这个标记Tag为100的tagged数据帧;参照上面的定理5;

由于Trunk端口在VID=100上为tagged Port,所以在发送数据帧出交换机的时候,不改变Tagged数据帧的结构;参照上面的定理1;

到了另一个交换机的Trunk端口的时候,由于Trunk端口拥有VID=100,所以才可接受这个标记Tag为100的tagged数据帧;参照上面的定理6;

另一个交换机的Trunk端口,接收到标记tag为100的tagged数据帧,并不作任何的更改;参照上面的定理1;

另一个交换机收到到标记tag为100的tagged数据帧,根据交换机的转发原理,交换机会把这个数据帧转发给VID=100的所有端口(除了进口以外);参照交换机交换原理(受到一个未知目的MAC数据帧);

这样另一个交换机的ACCESS端口就可以收到标记tag为100的tagged数据帧;参照上面的定理5;

另一个交换机的ACCESS端口在发出标记tag为100的tagged数据帧的时候,会去掉TAG标记,转发untagged数据帧给PC;参照上面的定理1;

这样PC机就收到了这个数据;

读 深入理解华为交换机的hybrid端口模式

Tag,untag以及交换机的各种端口模式是网络工程技术人员调试交换机时接触最多的概念了,然而笔者发现在实际工作中技术人员往往对这些概念似懂非懂,笔者根据自己的理解再结合一个案例,试图向大家阐明这些概念

untag就是普通的ethernet报文,普通PC机的网卡是可以识别这样的报文进行通讯;
tag报文结构的变化是在源mac地址和目的mac地址之后,加上了4bytes的vlan信息,也就是vlan tag头;一般来说这样的报文普通PC机的网卡是不能识别的

带802.1Q的帧是在标准以太网帧上插入了4个字节的标识。其中包含:
2个字节的协议标识符(TPID),当前置0x8100的固定值,表明该帧带有802.1Q的标记信息。
2个字节的标记控制信息(TCI),包含了三个域。
Priority域,占3bits,表示报文的优先级,取值0到7,7为最高优先级,0为最低优先级。该域被802.1p采用。
规范格式指示符(CFI)域,占1bit,0表示规范格式,应用于以太网;1表示非规范格式,应用于Token Ring。
VLAN ID域,占12bit,用于标示VLAN的归属。

以太网端口的三种链路类型:Access、Hybrid和Trunk:
Access类型的端口只能属于1个VLAN,一般用于连接计算机的端口;
Trunk类型的端口可以允许多个VLAN通过,可以接收和发送多个VLAN的报文,一般用于交换机之间连接的端口;
Hybrid类型的端口可以允许多个VLAN通过,可以接收和发送多个VLAN的报文,可以用于交换机之间连接,也可以用于连接用户的计算机。
Hybrid端口和Trunk端口在接收数据时,处理方法是一样的,唯一不同之处在于发送数据时:Hybrid端口可以允许多个VLAN的报文发送时不打标签,而Trunk端口只允许缺省VLAN的报文发送时不打标签。

在这里大家要理解端口的缺省VLAN这个概念
Access端口只属于1个VLAN,所以它的缺省VLAN就是它所在的VLAN,不用设置;
Hybrid端口和Trunk端口属于多个VLAN,所以需要设置缺省VLAN ID。缺省情况下,Hybrid端口和Trunk端口的缺省VLAN为VLAN 1
如果设置了端口的缺省VLAN ID,当端口接收到不带VLAN Tag的报文后,则将报文转发到属于缺省VLAN的端口;当端口发送带有VLAN Tag的报文时,如果该报文的VLAN ID与端口缺省的VLAN ID相同,则系统将去掉报文的VLAN Tag,然后再发送该报文。

注:对于华为交换机缺省VLAN被称为“Pvid Vlan”, 对于思科交换机缺省VLAN被称为“Native Vlan”

交换机接口出入数据处理过程:

Acess端口收报文:
收到一个报文,判断是否有VLAN信息:如果没有则打上端口的PVID,并进行交换转发,如果有则直接丢弃(缺省)

Acess端口发报文:
将报文的VLAN信息剥离,直接发送出去
trunk端口收报文:
收到一个报文,判断是否有VLAN信息:如果没有则打上端口的PVID,并进行交换转发,如果有判断该trunk端口是否允许该 VLAN的数据进入:如果可以则转发,否则丢弃

trunk端口发报文:
比较端口的PVID和将要发送报文的VLAN信息,如果两者相等则剥离VLAN信息,再发送,如果不相等则直接发送

hybrid端口收报文:
收到一个报文,判断是否有VLAN信息:如果没有则打上端口的PVID,并进行交换转发,如果有则判断该hybrid端口是否允许该VLAN的数据进入:如果可以则转发,否则丢弃(此时端口上的untag配置是不用考虑的,untag配置只对发送报文时起作用)

hybrid端口发报文:
1、判断该VLAN在本端口的属性(disp interface 即可看到该端口对哪些VLAN是untag, 哪些VLAN是tag)
2、如果是untag则剥离VLAN信息,再发送,如果是tag则直接发送

Filed under: Linux, 嵌入式 Comments Off
9Feb/14

Cubietruck 安装lubuntu笔记

Posted by Nick Xu

系统下载地址: http://dl.cubieboard.org/software/a20-cubietruck/lubuntu/

其它下载地址: http://cubieboard.org/download/

线刷工具: http://docs.cubieboard.org/downloads

默认用户名密码linaro:linaro

Configuration

Install tools and change default setting

#sudo passwd root
#sudo apt-get install -y bash-completion vim tmux
#sudo apt-get install -y build-essential make gcc g++ git-core x11vnc

#ls /sys/class/leds/*/brightness | xargs -i -n1 echo "echo 0 > {}" | sh
#locale-gen en_US.UTF-8
#dpkg-reconfigure locales
#echo "export LC_ALL=en_US.UTF-8" >> /etc/profile
#echo "auto eth0:1" >> /etc/network/interfaces
#echo "iface eth0:1 inet static" >> /etc/network/interfaces
#echo "address 192.168.2.123" >> /etc/network/interfaces
#echo "netmask 255.255.255.0" >> /etc/network/interfaces
#echo bcmdhd >> /etc/modules

 

VNC

#vi /etc/init/x11vnc.conf

start on login-session-start
script
x11vnc -display :0 -auth /var/run/lightdm/root/:0 -forever -bg -rfbport 5900
end script

#reboot

Set Time Zone/DateTime

1.Set time zone

  $sudo tzselect

Select the Asia , press Enter and chose China ,at last selet Beijing.

2. Cope file to /etc directory

  $sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

3. Update time

  $sudo ntpdate time.windows.com

Set keyboard language

To be defined ….

Flashplayer

Download the flashplayerarm,type:

$tar zxvf flashplayerarm.tar.gz  
$sudo cp libpepflashplayer.so /usr/lib/chromium-browser/plugins
$sudo cp default /etc/chromium-browser

Wifi

CB1 and CB2 do not integraed wifi chip on board ,but we can use USB WIFI. Make sure the wifi driver you use have been loaded. If not ,use

  $insmod /lib/modules/3.4.XX/kernel/drivers/net/wireless/XXX.ko

CB3(cubietruck) has Integrated wifi chip .

Type : modprobe bcmdhd to load the driver .

Add "bcmdhd" at the end of file /etc/modules to activate WiFi during boot. For ecample with Lubuntu Desktop:

  $sudo nano /etc/modules

Configure wifi at cubieboards and cubietruck the same way as descibed her:

  $apt-get install linux-firmware
  $reboot
  $ifconfig wlan0 up   //open the wifi ,maybe wlan1 ..
  $iwlist wlan0 scan   //scan the wifi signal
  $wpa_passphrase SSID passwd >> /etc/wpa_supplicant.conf  // the SSid is name of signal want to be used
  $vi /etc/network/interfaces

Add below configuration to /etc/network/interfaces

  auto wlan0
  iface wlan0 inet dhcp
  wpa-conf /etc/wpa_supplicant.conf

Add below configuration to /etc/resolv.conf

  nameserver 8.8.8.8

Reboot the cubieboard,auto gain the IP.

Setting CPU Frequency

Cubieboard CPU frequency can be adjusted in real time, , the following file save as shell file, or placed in / etc / rc.local before the exit 0 can be executed. Specific CPU frequency maximum and minimum values ​​can be set based on usage .

  #!/bin/sh
  echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  echo 1000000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
  echo 600000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
  echo 25 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
  echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor

After testing, Cubieboard single core version (A10) CPU frequency can be overclocked to 1.2GHz, stable operation (would be better to stick a CPU heatsink); Cubieboard dual-core version (A20) can also be overclocked to 1.2GHz

Developing

Using serial debug port

The tutorial how to use TTL cable: http://linux-sunxi.org/Cubieboard/TTL

Install the tool name minicom in your computer:

  $sudo apt-get install minicom

Set the minicom configuratiaon, TTL and cubieboard are connected ,then minicomin the terminal ,enter into the console.

Installing target Toolchains

  $sudo apt-get update
  $sudo apt-get upgrade
  $sudo apt-get install vim build-essential git libusb-1.0-0-dev pkg-config -y

Hardware Testing

The best way to test hardware is install the office firmware from http://dl.cubieboard.org and usr office fitting fromhttp://docs.cubieboard.org/addons,which can find the problem quickly you met. Of course ,you should save the data before reinstall firmware.

LEDs On Cubieboaed

These are blue LED1 meaning heartbeat and green LED2 on cb1 and cb2. LED1 - GPIO port PH21, LED2 - GPIO port PH20.
These are LED1~4 on cb3(cubietruck). LED1 - PH21, LED2 - PH20,LED3 - PH11,LED4 - PH07.Refer to FAQ about cubietruck 
For cb1 and cb2:

  $echo 1 > /sys/class/gpio/export   //open the PH20
  $echo 2 > /sys/class/gpio/export   //open the PH21

The directories /sys/class/gpio/gpio1_PH20 and/sys/class/gpio/gpio2_PH21 had been create .

  $cd /sys/class/gpio /gpio1_PH20
  $echo out > direction    //set PH20 as output
  $echo 1 > value          //set PH20 as high ,grenn LED is light
  $echo 0 > value          //set PH20 as low,turn off the LED

HDMI

It would be best way connect the HDMI cable before power on the cubieboard,becuse some cable maybe appear the promble of sequence in time.
If your have not full screen display, you can try the following commands

$fbset -left 10

1.If you are using lubuntu, try the following commands

$wget http://dl.cubieboard.org/software/tools/armhf/cb-display-tool
$chmod 777 cb-display-tool
$cb-display-tool -o 8 -m 11  //switch to VGA type
$cb-display-tool -o 4 -m 4  //switch to HDMI type

If you switch to other resolution, you need to restart your X after the modification

2.The default display configuration in script.bin of uboot partition of official desktop-firmware as :

;disp init configuration
;
;disp_mode            (0:screen0<screen0,fb0> 1:screen1<screen1,fb0> 2:two_diff_screen_diff_contents<screen0,screen1,fb0,fb1>
;                      3:two_same_screen_diff_contets<screen0,screen1,fb0> 4:two_diff_screen_same_contents<screen0,screen1,fb0>)
;screenx_output_type  (0:none; 1:lcd; 2:tv; 3:hdmi; 4:vga)
;screenx_output_mode  (used for tv/hdmi output, 0:480i 1:576i 2:480p 3:576p 4:720p50 5:720p60 6:1080i50 7:1080i60 8:1080p24 9:1080p50 10:1080p60 11:pal 14:ntsc)
;screenx_output_mode  (used for vga output, 0:1680*1050 1:1440*900 2:1360*768 3:1280*1024 4:1024*768 5:800*600 6:640*480 10:1920*1080 11:1280*720)
;fbx format           (4:RGB655 5:RGB565 6:RGB556 7:ARGB1555 8:RGBA5551 9:RGB888 10:ARGB8888 12:ARGB4444)
;fbx pixel sequence   (0:ARGB 1:BGRA 2:ABGR 3:RGBA) --- 0 for linux, 2 for android
;lcd0_bright          (lcd0 init bright,the range:[0,256],default:197
;lcd1_bright          (lcd1 init bright,the range:[0,256],default:197

[disp_init]
disp_init_enable = 1
disp_mode = 0
screen0_output_type = 3
screen0_output_mode = 4
screen1_output_type = 0
screen1_output_mode = 4
fb0_width = 1024
fb0_height = 768
fb0_framebuffer_num = 2
fb0_format = 10
fb0_pixel_sequence = 0
fb0_scaler_mode_enable = 0
fb1_width = 1024
fb1_height = 768
fb1_framebuffer_num = 2
fb1_format = 10
fb1_pixel_sequence = 0
fb1_scaler_mode_enable = 0

Modify the parameter according to the using HDMI displayer . You can get more information about display from Display and modify script.bin from edit_the_system_configuration

VGA

Refer to HDMI section.

USB Host

The quickly way to test the interface of USB is plug the U disk . The system will identify the U disk .Use fdisk -l can see its information which meaning the interface of USB is working.

IR

IR had beed add into the kernel .If not, use command to load the moudle:

  $insmnod /lib/modules/3.4.X/kernel/drivers/input/keyboard/sun4i-ir.ko
  $sudo cat /dev/input/event0 | hexdump

Press the key of IR remote control,the terminal will print the message as:

0000000 8415 525f 50cf 0003 0001 0094 0001 0000
0000010 8415 525f 50db 0003 0000 0000 0000 0000
0000020 8415 525f 22f7 0007 0001 0094 0000 0000
0000030 8415 525f 22ff 0007 0000 0000 0000 0000

The digital '0094' is keycode of the remote control .

Headphone Jack

There are two audio devices HDMI and headphone in the cubieboard.

  $sudo  alsamixer

There are two audio devices named sunxi-sndhdmi and sunxi-CODEC in the system. The sound output is send out from HDMI by default . You can adjust volume and other configuration ,use Ctrl + z to save it.
alsamixer GUI

To set sound care being sunxi-CODEC modify /etc/asound.conf to turn on the headphone.

  pcm.!default {
    type hw
    card 0    //If you want to set HDMI as output ,turn 0 to 1.
    device 0
  }
  ctl.!default {
    type hw
    card 0   //If you want to set HDMI as output ,turn 0 to 1.
  }

If Plug in the headphone and type:

  $speaker-test -twav -c2

The sound "sound left,sound right,sound left" will output from headphone.

Let cubieboard speak by package named espeak :

  $sudo apt-get install espeak
  $espeak "hello"            //say: hello
  $espeak "hello_cubieboar"  //say: hello cubieboard

Camera

Most of the camera driver has integrated in the kernel,so it is available insert usb-camera into the cubieboard.

$sudo apt-get install luvcview
$luvcview -s 1080x720 (can modify the resolution)
14Feb/13

Eclipse和单片机开发环境Keil的集成编译工具KeilMake源码

Posted by Nick Xu

Eclipse和单片机开发环境Keil的集成编译工具KeilMake

通过KeilMake可以在Eclipse上进行单片机开发且编译

这个东东是为了通用而到网上抄一些需要用到的代码做出来的东东,估计很多代码是可以换成一两句话可以解决问题的. 最近经常有人找我问这个工具的问题,但是我已经不搞单片机好多年,所以把源码放出来,让有心人来维护吧:)

代码已经更新到github上,有需要的请自行下载和修改吧,为了能造福更多人群,希望改进后的代码能继续更新到github上,让更多人一起学习和研究

https://github.com/qdog2012/keilmake

25Nov/12

[HOWTO] Build OpenWRT Trunk from svn on Mac OS X

Posted by Nick Xu

I recommend following these steps
1) Install XCode & Macports
2) Getting a build environment ready
3) Grabbing sources
4) Modifying Makefiles (e2fsprogs really doesn't like 64-bit Lion, and qemu refuses to compile)
5) Installing the missing dependancies
6) Building OpenWRT (from Updating Feeds on)

 

1. XCode & Macports
a. You will need to install Xcode 4.0 from the Apple developers' webpage, which will redirect you to the App Store entry for Xcode where you will follow the instructions on that page to install.

b. Then,  grab the latest MacPorts .pkg installer for Lion.
Mount the disk image and install MacPorts with the .pkg file. Open the Terminal.app from /Applications/Utilities

sudo port -v selfupdate && sudo port install subversion

Follow these directions if the above command does not work after mounting the dmg and installing.

Then:

port select --list gcc

Should give you an output similar to

air:~ alex$ port select --list gcc

Available versions for gcc:

apple-gcc42

gcc42

llvm-gcc42

mp-gcc44 (active)

none

I do not believe the version of gcc matters, but if it does, here's how to replicate my set up:

sudo port install gcc44 && sudo port select --set gcc mp-gcc44

Don't follow the above step unless you run into trouble later in the HOWTO when we try to compile OpenWRT.  The above command will build gcc-4.4 from scratch and that takes time. A lot of time.

 

2. Set up the build environment
a. Now install the packages needed to manipulate the OpenWRT source (horizontal scroll to see entire command, its long):

sudo port install coreutils asciidoc binutils bzip2 fastjar flex getopt gtk2 intltool jikes zlib openssl p5-extutils-makemaker python26 rsync ruby sdcc unzip gettext libxslt bison gawk autoconf wget gmake ncurses

While this is compiling the packages for your system, continue on to 2b and 3a since they don't depend on any of the above packages.

b. The OpenWRT source is case-sensitive, unfortunately HFS+ drives formatted by Apple are not set to be case-sensitive; so we're going to create a .sparseimage workspace by opening Disk Utility in the /Applications/Utilities directory.

Click File -> New -> Blank Disk Image...
On the top of the dialog that just came up fill in "OpenWRT" without the quotes in the Save As: field and in the lower Name: field.

Choose a size larger than 3GB. My disk image is ~8G and will reach it's limit after compiling the packages and firmware images more than a few times.
IMPORTANT: In the Format: drop down, select  Mac OS Extended (case-sensitive

In the Image Format: drop down select "sparse disk image". Then click Create. The newly created disk image will be on the left panel of the Disk Utility, double clicking it will mount it on /Volumes/OpenWRT

3.Grabbing the source tree
a. Open the Terminal and type:

cd /Volumes/OpenWRT && svn co svn://svn.openwrt.org/openwrt/trunk/

Give it a few minutes while it pulls the source from the repository.

4. Modifying Makefiles
Open TextEdit.app and open /Volume/OpenWRT/trunk/tools/Makefile

cd /Volume/OpenWRT/trunk && open tools/Makefile

On line 17 erase the "e2fsprogs entry so it should look like this:

tools-y += sstrip ipkg-utils genext2fs  mtd-utils mkimage

Comment out line 22 like so:

#tools-$(CONFIG_TARGET_x86) += qemu

Then go on to comment out line 50, line 52, line 58; they are the build dependencies for mtd-utils (dep: e2fsprogs), qemu (dep: e2fsprogs), and e2fsprogs respectively.

5. Installing the missing dependencies
Now let's install and copy MacPort's e2fsprogs and osso-uuid's libraries and headers so we can build tools/mtd-utils correctly

sudo port install e2fsprogs osso-uuid

Followed by:

cd /Volumes/OpenWRT/trunk;

mkdir -p staging_dir/host/include/e2fsprogs;

cp -R /opt/local/include/ossp staging_dir/host/include/e2fsprogs/;

cp /opt/local/lib/libuuid* staging_dir/host/lib

Then follow this manual on how to build OpenWRT now that you have successfully built the necessary tools to compile OpenWRT images on Mac OS X 10.7 Lion.

Start from the section titled "Updating Feeds" and follow the wiki in it's entirety. Do not select any 'qemu' entries when you reach the make menuconfig step; qemu will not build on 64-bit Lion.

Tagged as: , , , , No Comments
4May/12

DD-WRT Printer Sharing 路由器打印机共享设置

Posted by Nick Xu

DD-WRT allows for clientless printer sharing making it easy to install printers directly into the router without the need for a seperate computer. You must have installed USB support (usb_storage, sd_mod etc. can be left out if no need for external storage).

Some of the information below is outdated. I made a guide for how to get USB printing working on the Asus WL-520gU. It should also apply to other routers with USB. http://wl520gu.googlepages.com/

The following must be done via telnet or SSH:

Contents

[hide]

Printer driver

Install printer driver:

 ipkg -force-depends install kmod-usb-printer

Edit /jffs/etc/config/usb.startup and add

 insmod /jffs/lib/modules/2.4.30/printer.o

Connect printers and reboot your router

See if any printers have been found:

 dmesg | grep usb

It should show something like this (I have 2 printers connected)

 <6>printer.c: usblp0: USB Bidirectional printer dev 5 if 0 alt 0 proto 2 vid 0x04F9 pid 0x000D
 <6>printer.c: usblp1: USB Bidirectional printer dev 6 if 0 alt 0 proto 2 vid 0x04A9 pid 0x108C

usblp0 means that the found printer is accessible at /dev/usb/lp0 etc.

Note: The 'USB Support' link above refers to installing several modules. On my WRT350N, I had to install these additional modules (usb-uhci.o and usb-ohci.o) to get my router to detect that my printer was plugged in.

comments from wmd1942:

I found the command "insmod /jffs/lib/modules/2.4.30/printer.o" is unnecessary if you have Core USB Support, USB 2.0 Support and USB Printer Support enabled in the 'Services' section of the router web page.

 

Notes For v24 Stable

The new v24 stable (i.e. not the release candidate versions) contains support for printer sharing and usb support in the web UI. I just got my printer server working and I figured I'd share my experience and maybe save somebody and hour or two.

Here's what I had to do to get my LaserJet 3020 to work with DDWRT on an Asus WL-500g Premium with the "DD-WRT v24 (05/24/08) mega - build 9526" version of the firmware:

1. Enable "JFFS2 Support" on the Administration tab.

(Note from another user: I had to enable "Clean JFFS2" as well, and reboot. After reboot, I ran "ipkg update", then installed the package mentioned in the first step of the "Printer Driver" section above.)

2. Enable SSH on the Services tab

3. Enable "Core USB Support", "USB 1.1 Support (UHCI)", "USB 1.1 Support (OHCI)", "USB 2.0 Support", "USB Printer Support" on the Services tab (all items under "USB Support" except for "USB Storage Support"). Note that the router did not recognize my printer if I left the USB 1.1 drivers unselected. This even though the printer supports USB 2.0.

4. Connect your printer to the router

5. Reboot your router

6. Log in with SSH to your router. And check if your printer was recognized:

 root@my-ddwrt-router:/jffs/etc/default# ls -la /dev/usb/
 drwxr-xr-x    1 root     root            0 Jan  1  1970 .
 drwxr-xr-x    1 root     root            0 Jan  1  1970 ..
 crw-rw----    1 root     root     180,   0 Jan  1  1970 lp0

if there is nothing in /dev/usb/ you need to change something, probably involving installing some other driver for your printer.

7. Look at the following files:

  /jffs/etc/default/p910nd
  /jffs/etc/init.d/p910nd

To do so, type: vi /jffs/etc/default/p910nd. vi is a text editor. You start in "command mode". Press 'a' to switch to editing mode, where you can edit the file. Press 'Esc' to get to command mode. Press :w[enter] to write (save) and :q[enter] to quit without saving, or :wq[enter] to save and quit.

At least on my version of v24, the third line in the startup script had the following line:

  DEFAULT=/etc/default/p910nd

this was invalid on my router (people more familiar with the router, please correct me here or explain the intricacies involved) and I had to edit this file and change the line to say:

  DEFAULT=/jffs/etc/default/p910nd

there are two commands that you can run to check if the server is running:

  root@my-ddwrt-router:/jffs/etc/init.d# netstat -an
  Active Internet connections (servers and established)
  Proto Recv-Q Send-Q Local Address           Foreign Address         State
  tcp        0      0 0.0.0.0:9100            0.0.0.0:*               LISTEN
  tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN
  root@ddwrt-se-office:/jffs/etc/init.d# ps | grep p9100d
  561 root        680 S   p9100d -b -f /dev/usb/lp0 0

If you see a 91xx port listening in netstat and you see the p9100d running in ps, your server is probably up and running properly. Check that the server is not running yet. If not, test starting the the server by issuing:

  /jffs/etc/init.d/p910nd

For v24_TNG (sp2) versions, the command should be:

  /jffs/etc/init.d/p910nd start

and check that it came up. You should be able to print now (see bottom of this page for instructions on how to set up your workstation for IP printing via ddwrt).

8. Add the above command to the Administration->Commands edit box and click "Save Startup". This makes sure that the printer server comes up the next time you reboot your router.

Hope that helps. --Mbjarland 07:33, 27 June 2008 (CEST)

Note: On my DD-WRT v24-sp2 (10/10/09) mini-usb-ftp the command: '/jffs/etc/init.d/p910nd start' works on the ssh shell, but not on the Administration->Commands edit box

This commands works on the Administration->Commands edit box:

/jffs/usr/sbin/p910nd -b -f /dev/usb/lp0 0

 

Print server

Now Install printserver daemon:

 ipkg install p910nd

Edit /jffs/etc/config/usb.startup and add

 #brother laser
 /jffs/usr/sbin/p910nd -b -f /dev/usb/lp0 0
 #canon inkjet
 /jffs/usr/sbin/p910nd -b -f /dev/usb/lp1 1

(correct the above to match your setup)

Eliminating the -b flag may resolve failure to print for some printers.

NOTE from another user: I needed go without the -b flag on my Canon MX310 printer for it to work.

-b means bidirectional, -f specifices device name, and the last number can be 0,1 or 2, making the print server listen at port 9100, 9101 and 9102 respectively.

Reboot your router

Now, you router works as a print server over TCP/IP

Note: You may have to remove the '-b' option for p910nd. I couldn't print with that option included.

comments from wmd1942:

In order to load the printer server in startup, the execution permission has to be added to this "usb.startup" file:

root@DD-WRT:chmod +x /jffs/etc/config/usb.startup

After reboot, use command:

ps | grep p910

The screen should be something like:

root@DD-WRT:~# ps | grep p910 306 root 356 S /jffs/usr/sbin/p9100d -f /dev/usb/lp0 0 n

NOTE:

Multifunction printers which have fax machines attached to them may also be made to work. Ie: A CANON MF4150 with VendorID=0x04A9 and ProductID=0x26A3 will have lp0 and lp1 available. Running two instances of p9100 on different ports (9100 and 9101) and creating the respective port in windows will allow fax functions to work in conjunction with print functions as long as proper drivers are used to access the proper port. Most printers have print functions listed as lp0 and fax functions list as lp1.

EXAMPLE:

 #canon printer
 /jffs/usr/sbin/p910nd -b -f /dev/usb/lp0 0
 #canon fax
 /jffs/usr/sbin/p910nd -b -f /dev/usb/lp1 1

Workstation setup

Ubuntu Linux

  • Go to System, Administration, Printing.
  • Click New Printer
  • Choose AppSocket/HP JetDirect
  • Hostname: IP address of the wireless printer (normally 192.168.1.1)
  • Port: 9100 for first printer, 9101 for second printer, etc
  • Click Forward and go on with the printer wizard to select brand, model and settings as you would do for a local printer

Windows XP

  • Find your printer in Control Panel - Printers etc. and open the properties page for it.
  • Select the Ports tab.
  • Click Add Port and choose Standard TCP/IP printer port and click New Port
  • Enter you router's IP address (normally 192.168.1.1) and click Next
  • Set Device type to custom and click settings.
  • Make sure RAW is selected and specify the necessary port number (normally 9100, 9101 for second printer, etc) and click OK
  • Click Next and Finish and Close
  • Make sure the newly created port is selected for your printer and click OK

Mac OS X 10.5 (Leopard)

  • Open System Preferences
  • Open Print & Fax
  • Click the + button below the list of installed printers
  • Select the toolbar button called 'IP'
  • Set protocol to: HP Jetdirect - Socket
  • Enter the address of your router followed by : and the port - ie. normally 192.168.1.1:9100
  • Leave 'Queue' blank
  • Set a friendly name for your printer (whatever you like)
  • And a friendly location (again, up to you)
  • Print Using: choose 'Select a driver to use'
  • A list will pop up of all installed printer drivers - choose the one that works for you (see Note below)
  • Add your printer

Note (Mac only): the driver must be compatible with the CUPS printing system, which is one of the two printing systems included in OS X. Certain printers e.g. Canon Pixma series and Epson Inkjet include OSX drivers which do not use CUPS. You may find compatible printer drivers from Gutenprint (free) orPrintFab ($). OS X Leopard appears to include certain Gutenprint drivers, but the quality may vary and it may be worth checking their website for updated versions, or try PrintFab.

 

Printing from WAN

If you want to be able to print from the WAN side of your router do the following:

In the web interface go to Administration - Commands and hit the "Command shell" field and type in

 /usr/sbin/iptables -I INPUT 1 -p tcp --dport 9100:9102 -j logaccept

And click Save Firewall

Your router reboots and you can now print from WAN side

NOTE: This is not recommended if your WAN is directly accessible from internet, but useful at private subnets of companies, colleges etc.

 

Installing on Asus WL500G Deluxe, with DD-WRT v24-sp2

Install dd-wrt.v24_usb_generic.bin firmware
Enable JFFS, and clear JFFS
Enable SSH
reboot router
Enable All USB options - set mount point to /opt
Since ipkg update seems broken, 
Download http://downloads.openwrt.org/backports/rc5/p910nd_0.7-2_mipsel.ipk to a USB stick formatted with FAT32
Insert USB into router and reboot router
SSH to router
cd /opt
ipkg -d root install p910nd_0.7-2_mipsel.ipk

p910nd is now installled and you have the configuration files in /jffs/etc/ and you can continue at the guide above.

 

Notes for K26

With the new kernel 2.6 the kernel doesn't create the device file /dev/usb/lp0 anymore. You have to do that manually once. Just issue

mknod -m 660 /dev/usb/lp0 c 180 0

once and everything is going to work. This should probably be done before starting the p910nd server.

Note from another user: I had to add this mknod command to /jffs/etc/config/usb.startup.

25May/10

定制自己的Windows CE 5.0 ARM中文模拟器(转)

Posted by Nick Xu

一、生成OS

1. 安装Windows CE 5.0(记得CPU类型里把ARMV4I选上)装完之后装DeviceEmulatorBSP.msi,这是ARMV4I模拟器的BSP。

我补充个DeviceEmulatorBSP.msi的下载地址:

http://www.microsoft.com/downloads/details.aspx?FamilyID=474b03a6-e87d-455d-bc16-b8cf18ef39b4&displaylang=en

2. 运行Platform Builder,新建一个Platform,给你的新Platform取一个名字,我这里取为MyCEEmu。BSP选择Microsoft DeviceEmulator:ARMV4I,Design Template选择Mobile Handheld,Application & Media随你选,Networking & Communications只选择Local Area Network(LAN)->Wired Local Area Network,其余都去掉。最后完成向导。

3. 添加网卡。在Catalog View的Device Drivers->Networking->Local Area Networking (LAN) devices目录下,把NE2000-compatible(PCMCIA car)添加进来。

4. 如果要开发托管程序,添加Catalog View的Core OS->Windows CE Devices->Applications – End User->CAB File Installer/Uninstaller。

5. 添加ActiveSync(可选),在Catalog View的Core OS->Windows CE Devices->Applications – End User目录下。

6. 添加闪存支持。有三个部件:SMFlash,Partition Driver和FAT。
先转到Catalog View:
SMFlash在BSP->Microsoft Device Emulator->Storage Drivers->MSFlash Drivers->SmartMedia NAND Flash Driver (SMFLASH),
Partition Driver在Core OS->>Windows CE Devices->File Systems and Data Store-> Storage Manager->Partition Driver
FAT在Core OS->Windows CE Devices->File Systems and Data Store->Storage Manager->FAT File System。

7. 打开菜单Platform->Setting,这里有三个地方要设置:
1) Build Options选项卡下,去掉Enable CE Target Control Support和Enable KITL;
2) Environment选项卡,添加环境变量CE_MODULES_SERIAL=1,这是用来将DMA添加进来;
3) Locale选项卡,用来添加你想要的语言支持,可改可不改。我这里先Clear All然后选了中文(中国)和英语(美国)。Default Language选为中文。

8. 视情况添加其他所需的组件。我添加了MSXML的支持。

9. BuildOS->Sysgen。

二、生成SDK

1. 运行SDK Wizard(Platform->SDK->New SDK),填写必要的信息之后,把支持的开发工具都勾上,完成。下面是配置SDK(选择Platform->SDK->Configure SDK),要是觉得没有什么好配置的也可以跳过。

2. 打开ExportSdk.sdkcfg文件(先做好备份,这个文件一般在项目根目录下,就是在New Platform Wizard的第2步中所指定的目录,默认是%_WINCEROOT%PBWorkspaces下)。这是一个XML格式的文本文件,找到这两行:
<PropertyBag NAME="DeviceEmulation">
</PropertyBag>
把这两行替换为如下的片断:
<PropertyBag NAME="DeviceEmulation">
<Property NAME="Default Image">1</Property>
<PropertyBag NAME="1">
<Property NAME="ImageName">MyCEEmu</Property>
<Property NAME="VMID"></Property>
<Property NAME="Default Skin"/>
<Property NAME="Height">240</Property>
<Property NAME="Width">320</Property>
<Property NAME="BitDepth">16</Property>
<Property NAME="Memory">128</Property>
<Property NAME="Bin Dest">Emulationnk.bin</Property>
<Property NAME="Fixed Screen">1</Property>
<Property NAME="CpuName">ARMV4I</Property>
<Property NAME="DPIX">96</Property>
<Property NAME="DPIY">96</Property>
<Property NAME="SupportRotation">0</Property>
<Property NAME="Enabled">1</Property>
<Property NAME="Bin Path"></Property>
<Property NAME="Ethernet">1</Property>
<Property NAME="Ports">1</Property>
<Property NAME="AdditionalParameters"></Property>
<PropertyBag NAME="Skins"/></PropertyBag>
</PropertyBag>
<PropertyBag NAME="Added Files">
<PropertyBag NAME="{3B388597-0924-4102-ADFA-2519D2C3E11B}">
<Property NAME="Source">C:WINCE500MyCEEmuReleaseImage</Property>
<Property NAME="Destination">Emulation</Property>
<Property NAME="Subfolders">0</Property>
</PropertyBag>
</PropertyBag>

3. 设定变量。上面替换的代码中有几个变量需要设定,分别是:
1) ImageName:这是程序员在Visual Studio IDE里所看到的名字;
2) VMID:一个GUID,可以用GuidGen.exe来生成一个;
3) Height/Width:模拟器屏幕的宽高;
4) BitDepth:颜色深度;
5) Memory:分配给模拟器的RAM大小;
6) DPIX/DPIY:屏幕DPI;
7) Source:这是一个目录,包含编译生成的NK.bin。建议最好在%_WINCEROOT%下新建一个目录,专门用于存放NK.bin。

这里我设为C:WINCE500MyCEEmuReleaseImage。
修改完成后保存。

3. 生成SDK。Platform->SDK->Build SDK。一切顺利的话应该可以在当前工程目录的SDK目录下找到打包成msi文件的SDK安装包。

三、配置Visual Studio 2005
1. 先安装生成好的SDK。运行Visual Studio 2005,选择菜单“工具->选项”,打开选项设置对话框,从左边的树型列表中选择“设备工具->设备”,右边的下拉列表框拉到底可以看到 “MyCEEmu”,这就是我们刚刚生成的那个Platform。下面的设备列表里有两项,双击MyCEEmu,设定传输为DMA传输,再点击“仿真器选 项”,在“显示”选项卡里设定好模拟器屏幕尺寸,颜色深度等,全部保存。

2. 新建一个智能设备项目,向导第2步选择平台的时候用我们的MyCEEmu替换Pocket PC 2003,完成。然后按F5运行程序,不出意外的话模拟器应该就出来了。

Tagged as: , No Comments
25May/10

移植linux2.6.29内核+yaffs2文件系统过程[转贴]

Posted by Nick Xu

软件平台:vm(fodera 9)+arm-linux-gcc 4.3.2

硬件平台:友善之臂出的mini2440开发板友善之臂

参考资料:网上n多资料,在这里先谢谢这些无私贡献自己经验的前辈们。
<<嵌入式Linux应用开发完全手册>>作者:韦东山,书完全是根据作者的经验写的,
和2410 2440的板子比较配套,我觉得这是一本非常好的参考书,特别是用2410或者是2440的初学者.

现在开始移植了,bootloader我还是用的mini2440的supervivi,这个比较方便,功能十
分强大,u-boot就留给以后吧.2440的板子移植内核还是比较简单的,因为内核里面已经有了2410的配置文件,
简单的改一下,基本就可以了,再就是外设驱动的修改了.

1.修改顶层Makefile文件

直接将Makefile文件里面的 ln193

ARCH ?= $(SUBARCH)

CROSS_COMPILE ?=

改为:

ARCH ?= arm

CROSS_COMPILE ?=arm-linux-

然后用S3C2410的默认配置文件

#make s3c2410_defconfig //此命令 configuration written to .config
//要先按上面方法修改完成Makefile文件才能执行这一步

#make menuconfig //只需修改下面几项
[*] Enable loadable module support --->
[*] Module unloading
[*] Automatic kernel module loading
选择这两个,剩下的可以去掉

System Type ---->
[*] S3C2410 DMA support
[*] Support ARM920T processor
S3C2410 Machines --->
[*] SMDK2410/A9M2410
S3C2440 Machines --->
[*] SMDK2440
[*] SMDK2440 with S3C2440 CPU module

**************************************************************************************************************

2.修改时钟,不修改超级终端中会出现乱码

修改Arch/arm/mach-s3c2440/mach-smdk2440.c ln163

S3c24xx_init_clocks(16934400);

改为:

S3c24xx_init_clocks(12000000);

3.修改mach-type
方法1:修改vivi的启动参数
从nandflash启动后,迅速按住SPACE键进入supervivi
Supervivi> menu,进入菜单vivi

##### FriendlyARM BIOS for 2440 #####

[v] Download vivi

[k] Download linux kernel

[y] Download root_yaffs image

[c] Download root_cramfs image

[n] Download Nboot

[e] Download Eboot

[i] Download WinCE NK.nb0

[w] Download WinCE NK.bin

[d] Download & Run

[f] Format the nand flash

[p] Partition for Linux

[b] Boot the system

[s] Set the boot parameters

[t] Print the TOC struct of wince

[q] Goto shell of vivi

Enter your selection: s

##### Parameter Menu #####

[r] Reset parameter table to default table

[s] Set parameter

[v] View the parameter table

[w] Write the parameter table to flash memeory

[q] Quit

Enter your selection: s

Enter the parameter's name(mach_type, media_type, linux_cmd_line, etc): mach_type

Enter the parameter's value(if the value contains space, enclose it with "): 362

Change 'mach_type' value. 0x0000030e(782) to 0x0000016a(362)
这一步有时候会卡很长时间,多试几遍就好了,不知道什么原因。

##### Parameter Menu #####

[r] Reset parameter table to default table

[s] Set parameter

[v] View the parameter table

[w] Write the parameter table to flash memeory

[q] Quit

Enter your selection: w

Found block size = 0x0000c000

Erasing... ... done

Writing... ... done

Written 49152 bytes

Saved vivi private data

##### Parameter Menu #####

[r] Reset parameter table to default table

[s] Set parameter

[v] View the parameter table

[w] Write the parameter table to flash memeory

[q] Quit

Enter your selection: v

Number of parameters: 9

name : hex integer

-------------------------------------------------------------

mach_type : 0000016a 362

media_type : 00000003 3

boot_mem_base : 30000000 805306368

baudrate : 0001c200 115200

xmodem : 00000001 1

xmodem_one_nak : 00000000 0

xmodem_initial_timeout : 000493e0 300000

xmodem_timeout : 000f4240 1000000

boot_delay : 01000000 16777216

Linux command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200

##### Parameter Menu #####

[r] Reset parameter table to default table

[s] Set parameter

[v] View the parameter table

[w] Write the parameter table to flash memeory

[q] Quit

Enter your selection: q

方法2:修改内核文件
修改cpu ID,不修改将会出现无法进入内核由于CPU mach_type 不对应找不到对应的CPU。
arch/arm/tools/mach-types 这个文件打开修改 对应CPU 的ID
比如我修改 S3C2410 对应为 782(我的VIVI的ID)。这样就可以找到S3C2410了

***********************************************************************************************************************

4.修改MTD分区
MTD分区信息在arch/arm/plat-s3c24xx/common-smdk.c文件中修改. ln109
这个也比较简单,我是根据supervivi里面的分区信息来的,我的分区信息如下:

static struct mtd_partition smdk_default_nand_part[] = {

[0] = {

.name = "vivi",

.size = 0x00030000,

.offset = 0X00000000,

},

[1] = {

.name = "kernel",

.offset = 0x00050000,

.size = 0x00200000,

},

[2] = {

.name = "root",

.offset =0x00250000,

.size =0x03dac000,

}

};

有的文章介绍说这个文件还要修改smdk_nand_info如下:
static struct s3c2410_platform_nand smdk_nand_info = {
.tacls = 0, //default is 20
.twrph0 = 30, //default is 60
.twrph1 = 0, //defualt is 20 changed by yangdk
.nr_sets = ARRAY_SIZE(smdk_nand_sets),
.sets = smdk_nand_sets,
};
但查看友善之臂的内核发现并没有改,因此我也没有修改,最终也没出现问题
启动之后还是会现panci信息因为还没有写入文件系统.

5.内核增加yaffs2支持

到网上下载ysffs2源代码,解压之后进行如下修改:

./patch-ker.sh c /2440/linux-2.6.29
上面命令完成下面三件事情
(1)修改内核fs/Kconfig
增加一行:source "fs/yaffs2/Kconfig"
(2)修改内核fs/Kconfig
增加一行:ojb-$(CONFIG_YAFFS_FS) +=yaffs2/
(3)在内核fs/目录下创建yaffs2目录
将yaffs2源码目录下面的Makefile.kernel文件复制为内核fs/yaffs2/Makefie;
将yaffs2 源码目录的Kconfig文件复制到内核fs/yaffs2目录下;
将yaffs2源码目录下的*.c *.h文件复制到内核fs/yaffs2目录下.
在内核根目录下执行:
#make menuconfig 配置yaffs2文件支持
File systems --->
Miscellaneous filesystems --->
<*>YAFFS2 file system support

这里留着默认配置不知道可不可以,我在移植yaffs文件系统中由于出现问题一直找不到原因
后来将这里完全按照友善之臂的配置改了一下,但是并没有解决我的问题。

6.#make uImage 生成zImage

**********************************************************************************************************************

7.创建yaffs文件系统

具体移植过程如下:
1. 创建必须的文件夹及设备文件
# mkdir rootfs
# cd rootfs
# mkdir bin dev etc lib mnt proc sbin sys root
# mkdir /etc/var
# mkdir /etc/tmp

# ln -s /etc/var /var
# ln -s /etc/tmp /tmp

2. 创建设备文件系统
从 Linux-2.6.18开始,负责旧版本的设备管理系统devfs已被废除,但新
版本的udev是一个基于用户空间的设备管理系统。在内核启动时并不能
自动创建设备节点,固需手动创建console和null两个启动过程必须的设
备节点。我们将采用busybox中内置的mdev,一个简化的udev版本.
# mknod -m 660 dev/console c 5 1
# mknod -m 660 dev/null c 1 3

3. 建立动态运行库
由于linux只安装上了arm-linux-gcc 4.3.2没有glibc的库文件,只好把友善之臂提供的
yaffs2文件系统下的lib文件拷贝过来。
# cp -rfd /2440/root_qtopia/lib/* /2440/rootfs/lib/
拷贝经过交叉编译的库文件,参数-d,保持库文件的链接关系。

4. 交叉编译busybox
解压缩tar -zxf busybox1.13.3.tar
解压后修改Makefile,指明交叉编译器:
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-

5.执行make CONFIG_PREFIX=/2440/rootfs install
在/2440/rootfs目录下生成sbin,usr目录和linuxrc文件

6.创建etc目录下文件
在rootfs/etc目录下创建一个inittab文件
内容如下:
# /etc/inittab
::sysinit:/etc/init.d/rcS
s3c2410_serial0::askfirst:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r

创建etc/init.d/rcS文件
#!/bin/sh
ifconfig eth0 192.168.1.17
mount -a
mkdir /dev/pts
mount -t devpts devpts /dev/pts
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
最后还要改变它的属性使它能够执行。
chmod +x etc/init.d/rcS

创建etc/fstab文件
#device mount-point type options dump fack order
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
tmpfs /dev tmpfs defaults 0 0

7.构建其他目录
mkdir proc mnt tmp sys root

8.使用mkyaffsimgae命令生成yaffs映像文件
mkyaffsimage rootfs rootfs.yaffs

9.通过supervivi将内核映像zImage和rootfs.yaffs下载到开发板上

启动内核出现
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.4.3:USB FTDI Serial Converters Driver
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mice: PS/2 mouse device common for all mice
s3c2440-i2c s3c2440-i2c: slave address 0x10
s3c2440-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c2440-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs filesystem) on device 31:2.
Freeing init memory: 132K
Kernel panic - not syncing: Attempted to kill init!

后来对比友善之臂的menuconfig把Kernel Features改为
Kernel Features --->
Memory split...--->
[ ]preemptible Kernel...
[*]Use the ARM EABI to compile the kernel
[*] Allow old ABI binaries to run ......
Memory model (flatMemory)--->
[ ]Add lru list to tarck non-evictable pages
解决问题

以下为启动信息,可能还有点小问题以后解决

VIVI version 0.1.4 (root@capcross) (gcc version 2.95.3 20010315 (release)) #0.1.4 Mon Oct 27 10:18:15 CST 2008
MMU table base address = 0x33DFC000
Succeed memory mapping.
DIVN_UPLL0
MPLLVal [M:7fh,P:2h,S:1h]
CLKDIVN:5h

+---------------------------------------------+
| S3C2440A USB Downloader ver R0.03 2004 Jan |
+---------------------------------------------+
USB: IN_ENDPOINT:1 OUT_ENDPOINT:3
FORMAT: +++
NOTE: Power off/on or press the reset button for 1 sec
in order to get a valid USB device address.

NAND device: Manufacture ID: 0xec, Chip ID: 0x76 (Samsung K9D1208V0M)
Found saved vivi parameters.
Press Return to start the LINUX/Wince now, any other key for vivi
Copy linux kernel from 0x00050000 to 0x30008000, size = 0x00200000 ... done
zImage magic = 0x016f2818
Setup linux parameters at 0x30000100
linux command line is: "noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0"
MACH_TYPE = 362
NOW, Booting Linux......
Uncompressing Linux.......................................................................................................... done, booting the kernel.
Linux version 2.6.29 (root@LINUX) (gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72) ) #4 Wed Apr 15 10:29:11 HKT 2009
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0
irq: clearing pending status 02000000
irq: clearing subpending status 00000002
PID hash table entries: 256 (order: 8, 1024 bytes)
Console: colour dummy device 80x30
console [ttySAC0] enabled
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 61420KB available (3024K code, 270K data, 132K init)
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 716 bytes
NET: Registered protocol family 16
S3C2410 Power Management, (c) 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
NetWinder Floating Point Emulator V0.97 (extended precision)
yaffs Apr 15 2009 10:21:24 Installing.
msgmni has been set to 120
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Console: switching to colour frame buffer device 30x40
fb0: s3c2410fb frame buffer device
lp: driver loaded but no devices found
ppdev: user-space parallel port driver
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
dm9000 Ethernet Driver, V1.31
Uniform Multi-Platform E-IDE driver
ide-gd driver 1.18
ide-cd driver 5.00
Driver 'sd' needs updating - please use bus_type methods
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2440-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)
Scanning device for bad blocks
Creating 3 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x000000000000-0x000000050000 : "vivi"
0x000000050000-0x000000250000 : "kernel"
0x000000250000-0x000003ffc000 : "rootfs"
usbmon: debugfs is not available
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.4.3:USB FTDI Serial Converters Driver
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mice: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2440-i2c s3c2440-i2c: slave address 0x10
s3c2440-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c2440-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs filesystem) on device 31:2.
Freeing init memory: 132K
ifconfig: SIOCSIFADDR: No such device

Please press Enter to activate this console.

25May/10

定制mini2440 wince启动界面

Posted by Nick Xu

定制mini2440 wince启动界面过程

我的显示屏是3.5寸的,所以应该按照分辨率制作一张240*320像素的图片。

详细步骤如下:

1、我用photoshop的制作的,如下图:

2、用bmp2T.exe转换这个图片,在命令符下输入bmp2T空格图片名称,如

>bmp2T forhibaidu.bmp

很快就能转换好,生成同名的forhibaidu.H文件

内容格式如:

static const unsigned short FORHIBAIDU[]={
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000还有很多字符

3、修改*:WINCE500PLATFORMsmdk2440KERNELHAL下 的samsung_n35.c内容

*代表你装pb的盘符。

只要修改const unsigned short ScreenBitmap_A70[]={以下内容即可,可以直接从forhibaidu.H里复制的。

保存后,打开PB编译你的OS。

然后在烧录到你的开发版即可。

其他尺寸的显示屏,只要制作相符的图片,修改*:WINCE500PLATFORM smdk2440KERNELHAL下相应的.c文件即可,samsung_a70.c(7寸屏)   samsung_n35.c(3.5寸) samsung_vga1024x768.c(VGA)

goodluck :)

Tagged as: , No Comments
25May/10

WINCE启动桌面的定制(转贴)

Posted by Nick Xu

Windows CE.NET的桌面确实漂亮,但是如果我们的嵌入式系统使用微软的桌面,总让我感觉不伦不类。因此,要想个办法,让我们的程序开机启动,把微软的那个桌面 给替换掉。
其中使用startup的快捷方式再加上隐藏任务栏的方法,效果非常的好,但是每次启动的时候,总是微软的桌面先出来,再启动我们的程序,感觉还是不爽。
最近发现一种方法,
1) 首先新建工程,把你的应用程序放到内核里面去(前面介绍了如何做);
2) 编译平台;
3) 修改shell.reg的文件 :
在文件中有这样一行:
[HKEY_LOCAL_MACHINEinit]
"Launch50"="explorer.exe"
"Depend50"=hex:14,00, 1e,00
把这个explorer.exe改成你的应用程序(比如:MyApp.exe)就可以了;
4) Platform Builder IDE:【Build】->【Make Image】(记得千万不要Build或者Rebuild)
5) 成功后,得到的NK.bin(或NK.nb0)就包含了应用程序MyApp.exe和MyApp.lnk,当把相应的内核烧入开发板MyApp程序就会在 系统启动时自动运行。

至此,随心所欲的让自己的程序在Windows CE系统启动时自动运行了,一个字,爽!

注意:如果自己的程序有关闭退出之类的按钮,切忌不要点击,最后做到让其消失!!!

25May/10

详解WINCE的控制面板(转)

Posted by Nick Xu

//========================================================================
//TITLE:
//    详解WINCE的控制面板
//AUTHOR:
//    norains
//DATE:
//    Tuesday  29-August-2006
//========================================================================
曾经在我的一篇《控制面板的创建》中介绍过WinCE控制面板的结构,不过由于那篇文章其目的只在于控制面板如何调用EXE程序,故对控制面板也仅是泛泛 而谈.不过在这篇文章中,我们将对WinCE的使用方法来个整体的详解.
1.控制面板的结构
控制面板其实也是个动态链接库,区别只在于后缀名为.cpl,以及对外接口为CPlApplet().
接口的原型为:
LONG CALLBACK CPlApplet(HWND hwndCPL,UINT message, LPARAM lParam1, LPARAM lParam2)
在接口函数中我们需要实现特定几个消息的响应,控制面板才能正常运作.为方便观察,在这里直接贴出消息的响应结构:

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// The entry point to the Control Panel application.
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
extern "C"  LONG CALLBACK CPlApplet(HWND hwndCPL,UINT message, LPARAM lParam1, LPARAM lParam2)
{
  switch (message)
  {
    case CPL_INIT:
          // Perform global initializations, especially memory
          // allocations, here.
          // Return 1 for success or 0 for failure.
          // Control Panel does not load if failure is returned.
          return 1;
    case CPL_GETCOUNT:
          // The number of actions supported by this Control
          // Panel application.
          return 1;
    case CPL_NEWINQUIRE:
        {
              // This message is sent once for each dialog box, as
              // determined by the value returned from CPL_GETCOUNT.
              // lParam1 is the 0-based index of the dialog box.
              // lParam2 is a pointer to the NEWCPLINFO structure.
                return 0; //means CPLApplet succeed
                return 1;  // Nonzero value means CPlApplet failed.
            }
    case CPL_DBLCLK:
            {
              // The user has double-clicked the icon for the
              // dialog box in lParam1 (zero-based).
                return 0;     // CPlApplet succeed.
                return 1;     // CPlApplet failed.
            }
    case CPL_STOP:
                // Called once for each dialog box. Used for cleanup.
    case CPL_EXIT:
                // Called only once for the application. Used for cleanup.
    default:
          return 0;
  }
  return 1;  // CPlApplet failed.
}  // CPlApplet

这几个消息的作用分别是:
CPL_INIT:初始化,可以在这分配内存等等.
CPL_GETCOUNT:返回控制面板程序的个数.因为一个.cpl文件中,可能包含多个Applets.
CPL_NEWINQUIRE:返回包含程序名和图标信息的NEWCPLINFO结构
CPL_DBLCLK:双击时响应
CPL_STOP:单个组件退出时响应,用来清除资源内存等
CPL_EXIT:退出整个cpl程序时响应
这些消息的定义可以在cpl.h中找到
2.在explorer中使用
如果定制的系统中带有explorer UI,只要把编译好的文件放进"windows",然后再打开"控制面板"就可以看到.
3.如何调用.cpl
就像PC机中.dll文件不能直接运行,需要借助rundll32.exe来运行一样,WinCE下的.cpl也需要相应的程序来调用,这个程序就 是:"ctlpnl.exe".
比如我们需要调用系统自带的cplmain.cpl的"电源管理",只要在开始菜单的运行中输入:"ctlpnl.exe windowscplmain.cpl,5".在路径后面紧跟的"5"只是因为"电源管理"在cplmain.cpl中输入第五个Applet而已.
由此我们不难得出在程序中运用ShellExecuteEx()函数调用控制面板的Applet的方法.以下这段代码,效果和在命令行中输入命令一样,也 是调用"电源管理".

    SHELLEXECUTEINFO info;    
    TCHAR szControlPanelCmdLine[ 200 ];
    swprintf( szControlPanelCmdLine, L"\windows\cplmain.cpl,5");
    info.cbSize = sizeof( info );
    info.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
    info.lpVerb = NULL;
    info.lpFile = TEXT("ctlpnl.exe");
    info.lpParameters = szControlPanelCmdLine;
    info.lpDirectory = NULL;
    info.nShow = SW_SHOW;
    info.hInstApp = NULL;
    ShellExecuteEx( &info );

如果想调用cplmain.cpl的其它Applet,只要把数字改为相对应的即可.
以下所列的第一项序号为0,接下的为1,其后的继续递增.
0        CPL_Comm
1        CPL_Dialing
2        CPL_Keyboard
3        CPL_Password
4        CPL_Owner
5        CPL_Power
6        CPL_System
7        CPL_Screen
8        CPL_Mouse
9        CPL_Stylus
10        CPL_Sounds
11        CPL_SIP
12        CPL_Remove
13        CPL_DateTime
14        CPL_Certs
15        CPL_Accessib
4.系统自带控制面板的代码
微软对控制面板的代码是完全公开的,如果安装的是PB4.2,代码可以在"PUBLICWCESHELLFEOAKCTLPNL"中找到.
CTLPNL文件夹中有九个文件夹,分别对应不同的CPL文件:
ADVBACKLIGHT:高级背光灯管理
BTHPNL:蓝牙
CONNPNL:拨号网络
CONTROL:主控制台,我们在explorer中看到的"控制面板"应该就是这个
CPLMAIN:会生成cplmain.cpl,控制面板的大多数选项均源自于此
CTLPNL:和CONTROL相关联的
DMPNL:没使用过,不太清楚.不过查看rc文件应该是设置上网的.
INTL2:区域和语言设置
STGUI:存储器管理

site
site