1. 首页
  2. 嵌入式开发
  3. 浅谈telnet和gdbserver

浅谈telnet和gdbserver

  下面要讲的是如何使用pc机telnet目标机,和如何使用gdbserver调试目标机的代码.  1.拿到板子后,我所说的烧了boot,kerner,rootfs的板子,可以正常使用的,确保串口终端...

  下面要讲的是如何使用pc机telnet目标机,和如何使用gdbserver调试目标机的代码.

  1.拿到板子后,我所说的烧了boot,kerner,rootfs的板子,可以正常使用的,确保串口终端能正常使用。

  2.完成1之后在目标机rootfs加载完成之后,配置好目标机的ip,单网口可以使用,ifconfig eth0 192.168

  .1.xxx ,双网口需要多配置一路, ifconfig eth1 192.168.1.xxx。配制完成之后可以ping一下同一网段的pc机,看看网络是否已通畅。

  3.Telnet在文件系统中的一些相关支持,如下:

  3.1 内核(2.6)和busybox都需要支持udev,并且/usr/sbin/telnetd文件存在。

  3.2 /etc/services,里面可以指定telnet的端口号,默认是23.

  3.3 /etc/passwd 指定登陆的用户账号和密码。

  3.4 /etc/protocols指定telnet的使用协议,一般使用TCP即可。

  3.5 在rootbox中添加

  mkdir /dev/pts

  mount -t devpts devpts /dev/pts

  udevd --daemon

  udevstart

  Telnetd

  重新启动之后,用ps察看一下,网络守护进程是否已经起来,然后PC上用telnet工具登陆即可.

  关于GDB server的使用缘由,做过linux嵌入式开发的人都有这个感触, 资源太少了 , 显然在目标板上要调试gdb那显然不可能,GDBserver由此诞生,即在交叉编译环境中,由目标机指定代码,端口号,IP(PC机),如gdbserver 192.168.1.58 : 123456 hello 其中58为我自己的PC机的IP. 不过在这之前你需要确定在你的rootfs中有gdbserver存在,一般都是在/bin或/sbin下面的。上述流程顺畅之后,就可以在PC上使用gdb调试了, gdb命令需要跟代码相对应,如使用arm-linux-gcc -g -c -o hello hello.c生成的,需要使用arm-linux-gdb hello调试。

  还有一点就上在挂载nfs网络文件系统的时候,为了不使用默认的udp协议,需要修改挂载参数,

  eg:mount -t nfs -o intr,tcp,nolock 192.168.1.8:/home/mstar/nfsroot/root /home

  其中-o 选向man mount->nfs如下:

  proto=transport

  The transport the NFS client uses to transmit requests to the NFS server for this mount point. transport can be either udp or tcp.Each transport uses different default retrans and timeo settings; refer to the description of these two mount options for details.In addition to controlling how the NFS client transmits requests to the server, this mount option also controls how the mount(8) command

  communicates with the server鈙 rpcbind and mountd services. Specifying proto=tcp forces all traffic from the mount(8) command and the NFS client to use TCP. Specifying proto=udp forces all traffic types to use UDP. If the proto mount option is not specified, the mount(8) command discovers which protocols the server supports and chooses an appropriate transport for each service. Refer to the TRANSPORT METHODS section for more details.

  udp The udp option is an alternative to specifying proto=udp. It is included for compatibility with other operating systems.

  tcp The tcp option is an alternative to specifying proto=tcp. It is included for compatibility with other operating systems.

  port=n The numeric value of the server鈙 NFS service port. If the server鈙 NFS service is not available on the specified port, the mount request fails.

  If this option is not specified, or if the specified port value is 0, then the NFS client uses the NFS service port number advertised by the server鈙 rpcbind service. The mount request fails if the server鈙 rpcbind service is not available, the server鈙 NFS service is not registered with its rpcbind service, or the server鈙 NFS service is not available on the advertised port.

  mountport=n The numeric value of the server鈙 mountd port. If the server鈙 mountd service is not available on the specified port, the mount request fails.

  is 0, then the mount(8) command uses the mountd service port number adver-

  tised by the server鈙 rpcbind service. The mount request fails if the server鈙 rpcbind service is not available, the server鈙 mountd ser-vice is not registered with its rpcbind service, or the server鈙 mountd service is not available on the advertised port.This option can be used when mounting an NFS server through a firewall that blocks the rpcbind protocol.

  mountproto=transport

  The transport the NFS client uses to transmit requests to the NFS server鈙 mountd service when performing this mount request, and when later unmounting this mount point. transport can be either udp or tcp.This option can be used when mounting an NFS server through a firewall that blocks a particular transport. When used in combination with the proto option, different transports for mountd requests and NFS requests can be specified. If the server鈙 mountd service is not

  available via the specified transport, the mount request fails. Refer to the TRANSPORT METHODS section for more on how the mountproto mount option interacts with the proto mount option.mounthost=name The hostname of the host running mountd. If this option is not specified, the mount(8) command assumes that the mountd service runs on the same host as the NFS service.

  mountvers=n The RPC version number used to contact the server鈙 mountd. If this option is not specified, the client uses a version number appropriate to the requested NFS version. This option is useful when multiple NFS services are running on the same remote server host.

  namlen=n The maximum length of a pathname component on this mount. If this option is not specified, the maximum length is negotiated with the server. In most cases, this maximum length is 255 characters.Some early versions of NFS did not support this negotiation. Using this option ensures that pathconf(3) reports the proper maximum compo-nent length to applications in such cases.

  nfsvers=n The NFS protocol version number used to contact the server鈙 NFS service. The Linux client supports version 2 and version 3 of the NFS protocol when using the file system type nfs. If the server does not support the requested version, the mount request fails. If this option is not specified, the client attempts to use version 3, but negotiates the NFS version with the server if version 3 support is not available.

  vers=n This option is an alternative to the nfsvers option. It is included for compatibility with other operating systems.

  lock / nolock Selects whether to use the NLM sideband protocol to lock files on the server. If neither option is specified (or if lock is specified),NLM locking is used for this mount point. When using the nolock option, applications can lock files, but such locks provide exclusion only against other applications running on the same client. Remote applications are not affected by these locks.NLM locking must be disabled with the nolock option when using NFS to mount /var because /var contains files used by the NLM implementa-tion on Linux. Using the nolock option is also required when mounting exports on NFS servers that do not support the NLM protocol.

  intr / nointr Selects whether to allow signals to interrupt file operations on this mount point. If neither option is specified (or if nointr is speci-fied), signals do not interrupt NFS file operations. If intr is specified, system calls return EINTR if an in-progress NFS operation is interrupted by a signal.Using the intr option is preferred to using the soft option because it is significantly less likely to result in data corruption.

  cto / nocto Selects whether to use close-to-open cache coherence semantics. If neither option is specified (or if cto is specified), the client uses close-to-open cache coherence semantics. If the nocto option is specified, the client uses a non-standard heuristic to determine when files on the server have changed.Using the nocto option may improve performance for read-only mounts, but should be used only if the data on the server changes only occa-sionally. The DATA AND METADATA COHERENCE section discusses the behavior of this option in more detail.

  acl / noacl Selects whether to use the NFSACL sideband protocol on this mount point. The NFSACL sideband protocol is a proprietary protocol imple-mented in Solaris that manages Access Control Lists. NFSACL was never made a standard part of the NFS protocol specification.If neither acl nor noacl option is specified, the NFS client negotiates with the server to see if the NFSACL protocol is supported, and

  uses it if the server supports it. Disabling the NFSACL sideband protocol may be necessary if the negotiation causes problems on the client or server. Refer to the SECURITY CONSIDERATIONS section for more details.

  rdirplus / nordirplus Selects whether to use NFS version 3 READDIRPLUS requests. If this option is not specified, the NFS client uses READDIRPLUS requests on

  NFS version 3 mounts to read small directories. Some applications perform better if the client uses only READDIR requests for all direc-tories.

  上述是我在搭建平台的时候遇到的一些经验总结,希望能对大家有用。

哎哎
相关推荐