Shell in uClinux

Source: Internet
Author: User
The shell in uClinux-general Linux technology-Linux programming and kernel information. The following is a detailed description. The uClinux operating system is a branch of standard Linux. It is an operating system specially designed for CPUs without MMU (Storage Management Unit) and has made many small tasks for embedded systems. Currently, common application libraries in uClinux are mC-libc and mClibc.
When you use make menuconfig to configure uClinux, you can see that the available shells include sash, minix-Shell, nwsh, bash, and Other.

The sash code is uClinux-Samsung/user/sash, and the minix-shell code is uClinux-Samsung/user/sh, the nwsh code is uClinux-Samsung/user/nwsh, the bash code is uClinux-Samsung/user/bash, And the Other code indicates that Other shells can be selected, it mainly refers to several shells in Busybox.

Where:
Minix-shell can be compiled and used in both mC-libc and mClibc, but it is not very powerful. nwsh can be compiled in both mC-libc and mClibc, however, they all work abnormally and cannot enter the command line prompt. bash cannot be compiled in mC-libc or mClibc, and its structure is not suitable for uClinux. This article mainly discusses how to use the Shell in Busybox.

Shell in Busybox
Busybox was first written on the Debian Linux installation disk and integrated a large number of Linux tools into an executable file. Currently, Busybox provides more than 100 commands, but its executable file is only several hundred KB, providing a complete and small POSIX runtime environment for embedded systems. However, these commands have fewer Parameter options than the original complete GNU command.

The following Shell is integrated in Busybox.
① Lash: very small, with a total of 10 k. It is very suitable for executing commands and supports pipelines and redirection, but does not support the Bourne Shell syntax and cannot interpret scripts.

② Hush: very small, around 18 K. It supports the Bourne Shell syntax and can well process the if/then/else/fi structure statements, however, it cannot process loop statements such as for/do/done or case/esac.

③ Msh: a total of about 30 kb, capable of processing loop statements such as for/do/done and case/esac. Msh can do this as long as it can be done by the Bourne shell. Its syntax and the Bourne Shell syntax may be different, but most of the Bourne Shell syntax can be interpreted by Msh. Msh uses vfork to create a new process, so it is suitable for the uClinux operating system.

④ Ash: it is about 60 K by default. It is the most complete Shell in Busybox, but it cannot be compiled on uClinux.

To sum up, Msh in Busybox is the best Shell in uClinux.

Port:
Make menuconfig and reconfigure the uClinux kernel. When configuring sash, select the following items:

BusyBox
Shell
Msh: Minix shell

MSH is/bin/sh
After removing sash, you must compile some common internal commands in sash in Busybox, such as ls, cp, and other basic commands. These are originally sash Internal commands, now with Shell, you must use the commands in Busybox as independent small applications. This document selects the following common commands: clear, mkdir, ping, cat, cp, ln, ls, ifconfig, etc, you must select all the functions under the ls and ifconfig commands.

There is an error during compilation, which refers to msh. c does not have the definition of _ NSIG, which must be in msh. in c, add the following sentence: # define _ NSIG 255, which can be compiled later.

After compilation, compile a single independent execution program named busybox.exe under the uClinux-Samsung \ user \ busybox directory. Copy the compiled busybox.exe file to the uClinux-Samsung \ romfs \ home directory and re-compile the kernel (no need to configure the kernel ). Download and run the compiled uClinux operating system kernel, and use the Msh Shell and various commands in Busybox. Busybox is easy to use. You only need to create a symbolic link. However, the default root file system romfs in uClinux is read-only, and only the/tmp and/var directories are read/write directories implemented by using virtual ramdisks (after the system loses power, the contents stored in the directory are all lost. Therefore, you must link to the two readable and writable directories during symbolic links, such as ln-s/bin/busybox/tmp/ls, when/tmp/ls is executed, Busybox will execute the ls function, and the command line parameters will be processed according to the ls method.

After running successfully, we can find that this Shell is different from the original sash, and its prompt is #. It supports up and down key lookup commands, but does not support Tab key completion.

Find the uClinux-dist/config. in file and edit

Bool 'sh: tab completion 'CONFIG_USER_BUSYBOX_TAB _ COMPLETION
Bool 'sh: username completion 'CONFIG_USER_BUSYBOX_USER NAME_COMPLETION
Changed:
Bool 'sh: tab completion 'CONFIG_USER_BUSYBOX_COMMAND _ TAB_COMPLETION
Bool 'sh: username completion 'CONFIG_USER_BUSYBOX_COM MAND_USERNAME_COMPLETION

Then make menuconfig, select the Shell feature of Busybox, re-compile it, and then download and run it to implement the Tab key completion function.

In addition, other features of Msh Shell can be added. For example, the ls command can display different attribute files in color.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.