Success! Subscription added.
Success! Subscription removed.
Sorry, you must verify to complete this action. Please click the verification link in your email. You may re-send via your profile.
The init process, that automatically is started by the Kernel, first starts the script file /etc/rc and then uses /etc/inittab to start more processes, if some are defined there. By default the uCLinux-dist uses an empty inittab thus only /etc/rc is used to bring up the system.
By default the uCLinux-dist uses sash (compiled as the "sh" executable in /bin) as the shell that executes the rc script. This is nice, as sash has a lot of useful "internal" commands and has a very small footprint. OTOH, sash is a very basic shell and can't do things like "if" and does not support pipes from files and between the processes it starts. Thus it often is not good enough for more complex shell scripts.
If one day, the uCLinux Tool Chain might support XIP (Execute in place: executables in memory based file systems can be executed without loading [copying] them), it will make more sense to drop sash completely and use hush as the only shell and activate all necessary commands as "external" commands in busybox.
On a "full" Linux with an MMU-enabled NIOS, supposedly shared libraries can be used, and the concept based on busybox again will need some rethinking.
A way to use more complex shell scripts with sash as the initial shell, is to activate hush and some "external" shell commands (such as "ls" and "cat") in busybox. (echo and test ( aks "[" ) are builtin commands with hush and don't need to be activated (this is why hush is much faster with scripts than msh, which is depreciated due to several bugs, anyway)
... / BusyBox / Coreutils --->
[*] cat
[*] ls
... / BusyBox / Shells --->
[*] hush
[*] Support for if/then/elif/else/fi
[*] Support for while and until loops
[*] Support for case ... esac statement
Now we can just call several shell scripts from rc and have them executed by hush (as usual, this is done by defining the interpreter in the first line of the script:
#!/bin/hush
and setting the executable flags for the script file.
In rc, the script is now simply called like a normal executable.
Usually the complex script files will be located in /etc. To have them moved there, they are created in vendor/altera/nios2 and the Makefile in that directory is edited to handle them appropriately.
It makes much sense to use one or more simple script files in a Flash file system that are called (i.e. "sourced") by the rc-file(s) and just do some environment settings that are to be acknowledged by the initialization scripts.
These Flash based files can be changed "online" by an appropriate mechanism. Very easy is doing this with FTP (which is enabled in our uCLinux-dist by default). A much more user-friendly way is to do this with a web browser via boa and cgi. Here using a "haserl" script is most appropriate,
You must have "hush" shell and the coreutil "cat" 'enabled 'in busybox (see on top)!
An example of cascaded initialization scripts is provided here. These are used in the current version of the binary NEEK distribution that can be found on the TryOutuClinuxpage.
/etc/rc is the initial script executed by the init process using /bin/sh (thus sash)
/etc/rc0 is called by rc and executed by hush. Here the configuration is read and decisions are made based on the configuration settings. rc0 writes the file /etc/rcc that can be read by any shell using the "source" or "." command to use the preprocessed configuration options.
/etc/rcts does additional system configuration settings
/etc/rca is meant for starting the primary applications (based on configuration settings)
/etc/rcd does the default configuration settings that are used even if the configuration in flash is not (yet) available
/etc/rcc can be read by any shell (sash using the "source", hush using the "." command) to use the preprocessed configuration options. As the environment variables can be e.g. names of additional script files, decisions that are done when rc0 was executed can get effective later.
/mnt/configflash/rc1 is located in the Flash. It does configuration settings and can be edited on the running device.
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t usbfs none /proc/bus/usb
mkdir /var/tmp
mkdir /var/log
mkdir /var/run
mkdir /var/lock
mkdir /var/empty
ifconfig lo 127.0.0.1
route add -net 127.0.0.0 netmask 255.0.0.0 lo
cat /etc/motd
#########################
# FLASH #
#########################
mkdir /mnt/configflash
mount -t jffs2 /dev/mtdblock0 /mnt/configflash
#########################
# Read configuration #
#########################
/etc/rc0
source /etc/rcc
#########################
# APPLICATIONS #
#########################
/etc/rca
#########################
# AFTER STARTING APPS #
#########################
#!/bin/hush
#using the more versatile shell to read the configuration settings
RC=/etc/rcd
if [ -e $RC ]; then
echo reading configuration settings in $RC
. $RC
fi
RC=/mnt/configflash/rc1
if [ -e $RC ]; then
echo reading configuration settings in $RC
. $RC
fi
if [ $NANOX == Y ]; then
RC=/etc/rcts
if [ -e $RC ]; then
echo reading configuration settings in $RC
. $RC
if [ -e $TSLIB_CALIBFILE ]; then
echo touch screen support enabled
export TSLIB_FBDEVICE
export TSLIB_CONSOLEDEVICE
export TSLIB_CALIBFILE
export TSLIB_TSDEVICE
else
export TSLIB_FBDEVICE=none
export TSLIB_CONSOLEDEVICE=none
export TSLIB_CALIBFILE=none
export TSLIB_TSDEVICE=none
fi
fi
fi
RC=/etc/rcc
echo HOSTNAME=$HOSTNAME > $RC
echo DHCP=$DHCP >> $RC
echo IP=$IP >> $RC
echo INETD=$INETD >> $RC
echo BOA=$BOA >> $RC
echo NANOX=$NANOX >> $RC
echo DEMO=$DEMO >> $RC
echo DEMOPIC=$DEMOPIC >> $RC
echo TSLIB_FBDEVICE=$TSLIB_FBDEVICE >> $RC
echo TSLIB_CONSOLEDEVICE=$TSLIB_CONSOLEDEVICE >> $RC
echo TSLIB_CALIBFILE=$TSLIB_CALIBFILE >> $RC
echo TSLIB_TSDEVICE=$TSLIB_TSDEVICE >>$RC
echo =========================
cat $RC
echo =========================
/bin/sh -c hostname $HOSTNAME
if [ $DHCP == Y ]; then
echo starting dhcp client
dhcpcd -p -a -h $HOSTNAME eth0 &
else
echo set IP to $IP
/bin/sh -c ifconfig eth0 $IP
fi
if [ $INETD == Y ]; then
echo starting inetd
inetd &
fi
if [ $BOA == Y ]; then
echo starting boa
boa -d &
fiif [ $NANOX == Y ]; then
echo starting nano-X
nano-X &
nanowm &
fi
TSLIB_FBDEVICE=/dev/fb0
TSLIB_CONSOLEDEVICE=none
TSLIB_CALIBFILE=/mnt/configflash/pointercl
TSLIB_TSDEVICE=/dev/input/event0
#!/bin/hush
#using the more versatile shell to start application
. /etc/rcc
if [ $DEMO == Y ]; then
echo starting nano-X demo
nxview $DEMOPIC &
fi
# Default configuration
# used if the flash based configuration files are not available
HOSTNAME=uclinux
DHCP=Y
IP=0.0.0.0
INETD=Y
BOA=Y
NANOX=Y
DEMO=Y
DEMOPIC=/etc/p.jpg
HOSTNAME=uclinux
DHCP=Y
IP=192.168.37.173
INETD=Y
BOA=Y
NANOX=Y
DEMO=Y
DEMOPIC=/mnt/configflash/demo.jpg
TSLIB_FBDEVICE=/dev/fb0
TSLIB_CONSOLEDEVICE=none
TSLIB_CALIBFILE=/mnt/configflash/pointercl
TSLIB_TSDEVICE=/dev/input/event0
HOSTNAME=uclinux
DHCP=Y
IP=192.168.37.173
BOA=Y
DEMO=Y
DEMOPIC=/mnt/configflash/demo.jpg
Community support is provided Monday to Friday. Other contact methods are available here.
Intel does not verify all solutions, including but not limited to any file transfers that may appear in this community. Accordingly, Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade.
For more complete information about compiler optimizations, see our Optimization Notice.