QNX常用命令

来源:互联网 发布:淘宝大布包 编辑:程序博客网 时间:2024/05/29 08:32
QNX常用命令


0.#use -- Print a usage message (QNX Neutrino)(查看各命令帮助)
#use ls


1.#pidin -- Display system statistics (QNX Neutrino)(查看系统信息)
#pidin a        #pidin mem     #pidin info    #pidin fa   ...
     pid tid name               prio STATE       Blocked
       1   1 /sys/procnto-instr   0f READY
       1   3 /sys/procnto-instr  10r RUNNING
       1   4 /sys/procnto-instr  12r RECEIVE     1
       2   1 sbin/tinit          10o REPLY       1
       3   1 proc/boot/slogger   10o RECEIVE     1
       5   1 proc/boot/pci-bios  10o RECEIVE     1
       6   1 roc/boot/devb-eide  10o SIGWAITINFO
       6   2 roc/boot/devb-eide  21r RECEIVE     1


2.#hogs -- List the processes that are hogging the CPU(查看CPU 使用情况)
$ hogs -n -% 10
PID             NAME  MSEC  PIDS SYSTEM
1                             451   41%    15%
6          devb-eide   141   13%     4%
8             fs-pkg      391   36%    13%


3.#sin -- Display system information
$ sin -u techpubs
procnto                                  1     0     0       0        0              268759990
devc-con                                2   36K   68K  128M  128M       614
pci-bios                                  3   28K   60K    4K     516K        16
tinit                                         4    8K    44K    4K     516K         4
......


4.#coreinfo -- Display information about a QNX Neutrino core file
#coreinfo test_g.core


5.#dumpifs -- Dump an image filesystem
  #dumpefs -- Dump an embedded filesystem


$ dumpifs shell.ifs
   Offset     Size  Name
        0      288  *.boot
      288      100  Startup-header flags1=0x1 paddr_bias=0
      388     6008  startup.*
     6390       59  Image-header mountpoint=/
     63ec      1ac  Image-directory
     ----     ----  Root-dirent
     6598       8c  proc/boot/data1
     6624       5c  proc/boot/.script
     6680       14  proc/boot/data2
     7000    2c02c  proc/boot/procnto
    34000    12ad0  proc/boot/devc-con
    47000     b66c  proc/boot/esh
    53000     d7fc  proc/boot/ls
    61000     7394  proc/boot/cat
Checksums: image=0x6d5fb484 startup=0x274d7c89


6.#showmem -- Display memory information(查看内存信息)


7.qconfig -- Query and display QNX installations and configurations(查看版本等安装信息)


QNX常用小技巧


1.跳过登陆
跳过图形:
在/etc/rc.d/rc.local中增加/usr/photon/bin/Photon -l '/usr/photon/bin/phlogin -O -Uuser:password'
跳过命令行:
修改/etc/config/ttys文件,con1 "/bin/login -f root" qansi-m on


2.使用Pindows
在/etc/inetd.conf文件里去掉此句注释:phrelay stream tcp nowait root /usr/bin/phrelay phrelay -x


杀死并重新运行inetd:1.#slay inetd              2.#inetd


3.去掉shelf [Photon Shelf Manager -- 边框
用命令#shelf -e
或 A more permanent approach is to set the PHSHELF_DISABLE environment variable to 1. You can do this in your .profile file, with export PHSHELF_DISABLE=1


4.登入时进命令行模式
/etc/rc.d/rc.sysinit runs tinit. [If the -p option is specified, tinit starts Photon.]By default, the system starts Photon, but if you create a file called /etc/system/config/nophoton, then rc.sysinit tells tinit to use text mode.


5.自动运行程序
If you want to run a Photon application whenever Photon starts, put it in your $HOME/.ph/phapps file. Put each command on a separate line. For example, to start the Photon editor when you start Photon, include this line: ped &
[注:phapps需加可执行权限,例如 #chmod +x /root/.ph/phapps]


6.登陆记录
The login utility also updates system accounting information in var/log/utmp, /var/log/wtmp,and /var/log/lastlog. if they already exist. The login utility doesn't create /var/log/utmp, /var/log/wtmp, and /var/log/lastlog if they don't already exist. These files can quickly become very big, which isn't good on an embedded system with limited resources.


7.TCP/IP 网络设置
设置IP,在图形界面可用phlip
在命令行可用:先要确定Network I/O在运行:io-net -dne2000 -ptcpip
指定IP ifconfig en0 10.0.0.100
指定路由:route add default 10.0.0.1
用DHCP自动获取IP dhcp.client -i en0 -m -u -t 1


Start the second instance of the TCP/IP stack by invoking io-net as follows:
io-net -i1 -del900 pci=0x1 -ptcpip prefix=/sock2


The -i option in the second instance of TCP/IP tells io-net to register itself as /dev/io-net1. The prefix option to npm-tcpip.so causes the second stack to be registered as /sock2/dev/socket instead of the default, /dev/socket. TCP/IP applications that wish to use the second stack must specify the environment variable SOCK. For example:SOCK=/sock2 netstat -in
Are io-net and the drivers running? pidin -P io-net mem
Is the TCP/IP protocol stack or Ethernet driver installed? ls /dev/io-net
How do I map hostnames to IP addresses /etc/hosts
How do I get the network status? netstat -in
List the interfaces, including the MAC and IP addresses that they've been configured with. netstat -rn 
Display the network routing tables that determine how the stack can reach another host. netstat -an
List information about TCP/IP connections to or from your system. For the tiny TCP/IP stack, you have to use the following command as it doesn't support netstat:  cat /proc/ipstats
How do I display information about an interface controller? /usr/sbin/nicinfo /dev/io-net/en0


QNX-从4到6简单入门


By Nicholas ZHOU


第一部分: QNX系统的安装与使用


QNX的微内核,甚至不包括进程管理,仅提供进程间的通信(Software Bus)。但在实际编译的系统中,仍然是进程调度、同步、进程间通信等编译在同一个可执行文件中的,它就是/boot/sys/procnto (QNX6).
QNX 4.x仅支持x86,QNX 6.x可支持PowerPC等
QNX 4.x只有Process,没有Thread,QNX 6.x都有了,这跟POSIX 1003 – 2001是同步的。
如何创建启动镜像:(QNX4)
在/boot/build里,install.1是启动镜像的配置文件
cd /boot
make b=install.1
上述步骤会成功编译出/boot/images/install.1镜像文件(该文件为MS-DOS可执行文件),其中包含了/boot/build/install.1配置文件中指定的所有可执行文件的映象(如Proc32、Slib32等)。
copy install.1 到 /.boot即可
clear屏幕,使用ctrl+l
文件系统/块设备的驱动,qnx4在/bin下,如Fsys.eide,而qnx6在/sbin目录下。
块设备命名,可以通过/boot/build/install.1的设备驱动加载参数来指定,一般会是hd0.0(对应primary master)、hd0.1(对应primary slave)、h1.0(对应secondary master)、hd1.1(对应secondary slave)。
hd0t79,其中t79是指type 和type id
添加块设备后,可以使用fdisk进行分区,如fdisk /dev/hd0.1,分区后,查看/dev/hd*还只能看见/dev/hd0.1,要查找新分出来的分区,需要使用mount –p /dev/hd0.1 (probe)。
启动过程


如何制作软盘启动的系统(QNX4)
cd /boot
make b=floppy
格式化软驱fdformat /dev/fd0;初始化软驱dinit –hb /dev/fd0;将软盘挂载到/fd - mount /dev/fd0 /fd
cp /boot/images/floppy /fd/.boot,启动映象就好了。
mkdir etc;mkdir etc/config;mkdir bin;mkdir usr;mkdir /usr/bin
cp /etc/config/sysinit.floppy /fd/etc/config/sysinit
cp /etc/logo.F /fd/etc/
将必要的一些二进制文件从/bin/或/usr/bin拷贝到/fd/bin或/fd/usr/bin(对应的),如ls、pax、fcat、esh、sh、echo、vi、Dev、Fsys.eide、mount、rm、rmdir、mv、melt、Fsys、Dev、Dev.con、chkfsys、ps、prefix、emu87、mount、rtc、df、dinit、fdformat等。
修改/etc/config/sysinit,从而加载硬盘驱动,添加下面一行:
/bin/Fsys.eide fsys –Ndsk0 –n0=hd0. –n5=cd0. eide –a1f0 –i14
重新启动,从软盘加载,搞定。
关机命令:shutdown –b(完全关机不重启)
用户环境
Boot Image -> /etc/config/sysinit.node -> /etc/profile -> $HOME/.profile


压缩解压
melt / freeze,前者释放abc.F为abc,后者将abc压缩为abc.F(only for QNX4)
gzip / gunzip
拷贝
cp
cpio
第二部分:QNX网络


QNX有很强的网络功能,最具特色的是它的FLEET Networking,该技术框架可以将跨接于不同网络(如Ethernet + Token)的节点直接链接起来,用户程序只需要使用msg_send即可跟网络上的任意qnx节点通信。


Fleet Network的配置需修改:


配置结点号
修改/boot/build/install.1文件名为install.x(x为你要的ID,比如2,下同),修改install.2中的$ /boot/sys/Proc32 –l 1为$ /boot/sys/Proc32 –l 2,后面这个2就是结点号。


生成新的image
cd /boot
make b=install.2
cp images/install.2 /.boot
修改配置文件
cd /etc/config
cp sysinit.1 sysinit.2
cp inetd.1 inetd.2
cd bin
cp Input.1 Input.2
cp ph.1 ph.2
cp tcpip.1 tcpip.2
修改tcpip.2,两个内容,一个是ip地址,如果想使用dhcp,则注释掉/usr/ucb/ifconfig en1 10.1.1.119 node$NODE up,替换为/usr/ucb/dhcp.client
然后修改/.licenses,将license添加进去
最后修改/etc/config/netmap,把网内的各个节点添加进去,完成
使用netmap –f,即时更新网络节点表,使用netmap可查看现有的 节点,使用alive可查看各节点的在线状况
如过网卡不灵等,可用以下命令来重启相关服务。
slay Net
Net &
Net.ether2100 –l1 –p0x1080 –i9 &
slay Socklet
Socklet node2 &
其它网络相关部分


1. 如何控制远程机器:ditto –n3 –k,即可控制远程node3。
2. 如何查看网卡状态:netstat –in
3. 如何查看路由表: netstat –rn
4. 如何使用远程桌面:phindows –n/dev/photon,在qnx侧则需要激活phrelay(inetd)。
5. 如何查PCI卡的IO地址和中断:show pci
6. 如何进入另外一台机起:on –f 3 /bin/sh
7. 如何检查网络监听:netstat –an
8. 如何查看启动后系统执行过的命令: sin ar
9. sin mem:当前进程虚拟地址分配情况
10. sin –t: 查看每个进程用了多少CPU时间。


关于QNX网络架构——
从驱动到应用层:Net -> Net.ether -> Socket/Socklet -> inetd -> nfsd
配置工具:ifconfig、route、hostname、netmap
查询工具:netstat、alive


第三部分:QNX6基础


Build Boot Image
/boot/build仍然是build启动映象的配置文件
bios.build是X86通用的
mkifs –v bios.build bios.img
在momentics中生成一个启动映象(支持硬盘和QNX4文件系统)
生成QNX System Builder Project,在build文件生成一节,选择导入/boot/build/bios.build文件。
双击打开project.bld,在binaries中加入devb-eide
在DLL中加入cam-disk.so、io-blk.so、fs-qnx4.so。
在share library中加入libcam.so.2
点击bios,右键菜单调出properties窗口,在SYSTEM的PATH、LD_LIBRARY_PATH中添加必要的路径,包括/bin:/sbin:/usr/bin:/usr/sbin等PATH以及/lib:/usr/lib等库路径。
修改bios.bsh,在PCI的section后增加硬盘驱动的部分
i. #start IDE drive
ii. devb-eide &
iii. waitfor /dev/hd0t79
iv. mount /dev/hd0t79 /
v. waitfor /bin
修改bios.bsh,在最后增加启动/etc/system/sysinit脚本的部分。
i. [+session] sh –c “/etc/system/sysinit”


ii. 最后注释掉ide驱动和这之间的其它部分。


编译生成bios.ifs,拷贝该文件到/.boot即可。
其它
QNX6的启动脚本已经更象Linux/Unix了,包括了sysinit和rc.d。而QNX6的设备驱动则远比4要灵活——顺便提一下,QNX4甚至没有提供DDK给用户,几乎所有的QNX4下的设备驱动都是QNX公司自己开发的(或受客户委托开发)。QNX6则改变了这一局面——而且QNX6已经完全开源了,QNX6用户也不再受那些license的困扰,普通个人用户可以直接下载和安装QNX6的RTOS和开发环境,包括使用Qnet——要知道,QNX4的Fleet Network倘若没有2个以上的licenses,是无法使用的。


第四部分:关于QNX6的网络架构和Qnet


QNX6的网络尤其是它的Qnet与QNX4一样独具特色。相对而言,QNX4的Fleet Network无论从配置还是使用来讲都要显得复杂一些,也要偏僻一些。而QNX6的Qnet则大大简化了配置的复杂性,也同时在尽量让远程的访问显得更正常。


首先,QNX6的网络驱动不同于qnx4的Net + Net.ether + Socket/Socklet或netmap的方式,而是采用了模块化更强,更灵活也更具一致性的方式。这个改变应当源于QNX6底层架构的升级。


从QNX6的启动看,在x86上,首先由BIOS启动startup-bios(一个二进制包),然后就启动了微内核procnto,紧接着在启动脚本里开始加载一些驱动。首先加载的一般是一个console,devc-con;然后应当加载pci-bios,试PCI总线开始工作;接着加载硬盘驱动和文件系统;最后启动一些进程通信管理程序,如mqueue、pipe等。


在QNX6里,网络、硬盘与其它设备(如音频)一样,都由一个io-xxx的程序来管理,硬盘是io-blk,网络则是io-net,而音频则是io-audio。但它们之间也有差别,比如硬盘,可执行的程序是devb-eide(常用的字符设备和块设备好像都是这个方式),而网络的则是io-net(net、audio这些好像是一样的),这多少显得有些怪异。


扯远了,回到io-net。


io-net的启动一般带一些参数,这些参数可以在加载网卡驱动的同时,加载各种协议栈,包括tcpip和Qnet。比如:


# io-net –dpcnet –ptcpip –pqnet


这一步操作即可在vmware虚拟机上跑的qnx6中成功加载网卡驱动、tcpip协议栈和Qnet协议栈。通过下面的命令可以检查io-net加载的状况:


# ls /dev/io-net


en0 ip0 ip_en qnet_en


此外,还有一种方式可以向已经启动的io-net中添加设备驱动和协议栈。比如:


# slay io-net


# io-net


# mount –Tio-net devn-pcnet.so


# mount –Tio-net npm-tcpip.so


# mount –Tio-net npm-qnet.so


这三个操作便向io-net添加了pcnet网卡驱动、tcpip和qnet协议栈。


其它一些命令:


查看io-net中已经加载的驱动:ls /dev/io-net
查看网络中其它的qnet节点:ls /net
访问网络中其它的qnet节点:cd /net/nodename(切换到目标结点的根目录).至于节点名称,则是通过hostname来设置的。
最后,补充一个,在qnx里,msg_send是阻塞的。
0 0