嵌入式小问题的解决:
1:启动时出现-sh: can't access tty; job control turned off
危害:不能使用CTRL+C终止进程, 特别郁闷的是ping 的时候不能退出
busybox 手册中:
Why do I keep getting "sh: can't access tty; job control turned off" errors? Why doesn't Control-C work within my shell?
This isn't really a uClibc question, but I'll answer it here anyways. Job control will be turned off since your shell can not obtain a controlling terminal. This typically happens when you run your shell on /dev/console. The kernel will not provide a controlling terminal on the /dev/console device. Your should run your shell on a normal tty such as tty1 or ttyS0 and everything will work perfectly. If you REALLY want your shell to run on /dev/console, then you can hack your kernel (if you are into that sortof thing) by changing drivers/char/tty_io.c to change the lines where it sets "noctty = 1;" to instead set it to "0". I recommend you instead run your shell on a real console...
看来解决办法是: 修改内核
另外一种: 参看牛贴:
修改/etc/inittab
我刚开始把上面贴子里的方法加上了inittab文件,一些方法全部试了,都不行。 后来记起来我的linuxrc是一个sh脚本,不是busybox生成的。
这是因为原来买开发板时自带的文件系统,后来一直模仿这个制作文件系统,也没有用inittab。
原来的linuxrc 是
#!/bin/sh
echo "mount /etc as ramfs"
/bin/mount -n -t ramfs ramfs /etc
/bin/cp -a /mnt/etc/* /etc
echo "re-create the /etc/mtab entries"
# re-create the /etc/mtab entries
/sbin/insmod -f /lib/yaffs.o
/bin/mount -f -t yaffs -o remount,rw /dev/mtdblock/3 /
#/bin/mount -f -t ramfs ramfs /etc
/bin/mount -t yaffs /dev/mtdblock/4 /usr
#/bin/cp -a /usr/etc/linutte/* /etc/linutte
/sbin/ifconfig lo up
/sbin/ifconfig eth0 59.69.75.186 netmask 255.0.0.0 up
/sbin/route add default gw 59.69.75.1
#/sbin/insmod -f /lib/mmcsd_core.o
#/sbin/insmod -f /lib/mmcsd_disk.o
#/sbin/insmod -f /lib/mmcsd_slot.o
#/sbin/insmod -f /lib/mmc_fix.o
exec /sbin/init
分析这个文件刚开始也没什么大不了的,最重要的是最后的一句exec /sbin/init 。
而busybox生成的linuxrc是指向busybox,不知是那个命令。
所以我把busybox生成的linuxrc覆盖现在的linuxrc 脚本。inittab文件为;
# This is run first except when booting in single-user mode.
#
::sysinit:/etc/init.d/rcS
# /bin/sh invocations on selected ttys
#
# Start an "askfirst" shell on the console (whatever that may be)
::askfirst:-/bin/sh
# Start an "askfirst" shell on /dev/tty2-4
tty2::askfirst:-/bin/sh
tty0::askfirst:-/bin/sh
tty3::askfirst:-/bin/sh
tty4::askfirst:-/bin/sh
试验,解决了。
VFS: Mounted root (nfs filesystem).
Mounted devfs on /dev
Freeing init memory: 108K
Please press Enter to activate this console.
BusyBox v1.2.1 (2007.01.13-23:04+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
[root@hjembed /]# ls
bin etc lib mnt sbin usr
dev hello linuxrc proc tmp var
[root@hjembed /]# ./hello
hello,world
[root@hjembed /]# ping 59.69.74.87
PING 59.69.74.87 (59.69.74.87): 56 data bytes
64 bytes from 59.69.74.87: icmp_seq=0 ttl=64 time=0.8 ms
64 bytes from 59.69.74.87: icmp_seq=1 ttl=64 time=0.7 ms
64 bytes from 59.69.74.87: icmp_seq=2 ttl=64 time=0.7 ms
--- 59.69.74.87 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 0.7/0.7/0.8 ms
[root@hjembed /]# ls
bin etc lib mnt sbin usr
dev hello linuxrc proc tmp var
[root@hjembed /]# ./hello
hello,world
[root@hjembed /]# ping
PING (211.94.144.100): 56 data bytes
--- ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss
这里再插入: linuxrc文件的作用。
The kernel makes it's first transition to user-mode in one of two places. When the filesystem is loaded as an initrd, it executes the program /linuxrc from the file init/do_mounts_initrd.c. But this is a fleeting reference. The normal transition to user-mode occurs in init/main.c where the kernel executes a series of programs until one of them doesn't return. These programs include /sbin/init, /etc/init, /bin/init, and /bin/sh. If a program is given to the kernel on the command line as init=filename, then the kernel will first attempt to execute filename before checking for the others.
In order for this first program to execute, several features must be present in the root filesystem. This first step is the most difficult because there tends to be few diagnostics explaining the reason that the kernel cannot start the first program.
Abstract from
第二个问题是板子上面的telnetd的问题, 以前看到论坛上有人议论这个,留意了一下,试验不行,
[root@hujunlinux dy_box]# telnet hjembed
Trying 59.69.74.159...
Connected to hjembed.
Escape character is '^]'.
hjembed login:
这时不管你不输,还是输入annoymous, root,...都不能进入,就放着了。 今天顺便试了一下
[root@hujunlinux dy_box]cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
59.69.74.87 hujunLinux hjLinux
59.69.74.159 hjembed hjembed
59.69.74.1 mygw mygw
[root@hujunlinux dy_box]# vi /etc/hosts
[root@hujunlinux dy_box]# telnet hjembed
Trying 59.69.74.159...
Connected to hjembed.
Escape character is '^]'.
hjembed login:
hjembed login: root
BusyBox v1.2.1 (2007.01.13-23:04+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
[root@hjembed /]# ls
bin etc lib mnt sbin usr
dev hello linuxrc proc tmp var
[root@hjembed /]#
板子这边
[root@hjembed /]# login[715]: root login on `pts/0'
证明没有问题。
我的配置是使用busybox生成的telnetd,用inetd管理。
[root@hujunlinux etc]# cat inetd.conf
#
#ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd
#telnet stream tcp nowait root /sbin/telnetd
#www stream tcp nowait root /sbin/httpd
telnet stream tcp nowait root /sbin/telnetd /sbin/telnetd
特此记录。
这次做的文件系统是用的toolchain 3.4.1 +busybox1.2.1, 使用共享库, 以前使用共享库的方式启动时
老是不成功,以前别人给我的意见是:
设定 LD_LIBRARY_PATH, PATH , 刚试验了一下,取消了设定,启动后运行程序也正常,
不知为何??
[root@hjembed /]# cat /etc/profile
# core files by default
#ulimit -S -c 0 > /dev/null 2>&1
PS1='[\u@\h \W]\$ '
#echo "Set search library path in /etc/profile"
#export LD_LIBRARY_PATH=/lib:/usr/lib
#PATH=/bin:/sbin/:/usr/bin/:/usr/sbin
#HOSTNAME=`/bin/hostname`
export PS1 PATH
alias ll="ls -l"
[root@hjembed /]#
6: 关于LCD 屏幕保护, 现象: 长时间不动屏幕的时候, 再运行qt 程序, 屏幕启动不了,
弊端:调试Qt 程序时,需不断的reboot,启动之后立即运行qt才行,不然过了半个小时屏幕就不能点亮了。
解决方法: 来自:
在drivers\char\vt.c中有1个函数:
static void blank_screen_t(unsigned long dummy)
{
if (unlikely(!keventd_up())) {
mod_timer(&console_timer, jiffies + blankinterval);
return;
}
blank_timer_expired = 1;
schedule_work(&console_work);
}
把这个函数的执行内容注销掉后,我的小企鹅就再也没有消失过了,哈哈
7:ping 及主机名的方法
1:文件系统中/lib有
[root@hjembed /]# ls /lib/libnss*
/lib/libnss_dns-2.3.2.so /lib/libnss_files-2.3.2.so
/lib/libnss_dns.so /lib/libnss_files.so
/lib/libnss_dns.so.2 /lib/libnss_files.so.22: 三个文件
[root@hjembed /]# cat /etc/hosts
127.0.0.1 localhost
59.69.74.87 hujunlinux #为我开发的host 机器
[root@hjembed /]# cat /etc/host.conf
order hosts,bind
还有一个nsswitch.conf , 我是直接从host machine: FC2 下考出来的
[root@hjembed /]# cat /etc/nsswitch.conf
#
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Legal entries are:
#
# nisplus or nis+ Use NIS+ (NIS version 3)
# nis or yp Use NIS (NIS version 2), also called YP
# dns Use DNS (Domain Name Service)
# files Use the local files
# db Use the local database (.db) files
# compat Use NIS on compat mode
# hesiod Use Hesiod for user lookups
# [NOTFOUND=return] Stop searching if not found so far
#
# To use db, put the "db" in front of "files" for entries you want to be
# looked up first in the databases
#
# Example:
#passwd: db files nisplus nis
#shadow: db files nisplus nis
#group: db files nisplus nis
passwd: files
shadow: files
group: files
#hosts: db files nisplus nis dns
hosts: files dns
# Example - obey only what nisplus tells us...
#services: nisplus [NOTFOUND=return] files
#networks: nisplus [NOTFOUND=return] files
#protocols: nisplus [NOTFOUND=return] files
#rpc: nisplus [NOTFOUND=return] files
#ethers: nisplus [NOTFOUND=return] files
#netmasks: nisplus [NOTFOUND=return] files
bootparams: nisplus [NOTFOUND=return] files
ethers: files
netmasks: files
networks: files
protocols: files
rpc: files
services: files
netgroup: files
publickey: nisplus
automount: files
aliases: files nisplus
3:试验:
[root@hjembed /]# ping
PING (211.94.144.100): 56 data bytes
--- ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss
[root@hjembed /]# ping hujunlinux (主机名)
PING hujunlinux (59.69.74.87): 56 data bytes
64 bytes from 59.69.74.87: icmp_seq=0 ttl=64 time=0.5 ms
64 bytes from 59.69.74.87: icmp_seq=1 ttl=64 time=0.5 ms
64 bytes from 59.69.74.87: icmp_seq=2 ttl=64 time=0.5 ms
64 bytes from 59.69.74.87: icmp_seq=3 ttl=64 time=0.5 ms
64 bytes from 59.69.74.87: icmp_seq=4 ttl=64 time=0.5 ms
--- hujunlinux ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 0.5/0.5/0.5 ms
ok!