| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 | // -*- mode:doc; -*-// vim: set syntax=asciidoc:Running OpenADK created Linux firmware======================================Bootloader~~~~~~~~~~~The Bootloader is used to initialize the machine and load the Linux kernel.A list of popular Bootloaders can be found on http://elinux.org/Bootloader.OpenADK provides the Bootloader if necessary for a target system.You can find them in +make menuconfg+ under +Packages/Bootloader+.Some Bootloaders require the Linux kernel in a special format (SREC, ELF, ..),compressed or with a special header. This will be automatically done byOpenADK in +target/<arch>/Makefile+ while creating the firmware archives orimages.Linux kernel~~~~~~~~~~~~The kernel is a program that constitutes the central core of a computeroperating system. It has complete control over everything that occurs in thesystem. The Bootloader can provide some basic runtime configuration parameters via the kernel commandline feature.The Linux kernel in OpenADK is intended to be very small in size and willbe by default compressed with xz compression algorithm, if available forthe target system. You can configure the compression algorithm used for thecompression of the Linux kernel and if choosen the initramfs filesystem in+make menuconfig+. In +Kernel configuration+ you have the choice betweendfferent kernel versions. The latest version will be automatically used.There you can choose any needed addon drivers or any supported runtimeand debugging features.The kernel expands itself on boot, if compressed, and then initialize thehardware. The additional kernel modules are loaded later by a init script.The kernel will autoamtically mount the virtual filesystem /dev as devtmpfsand then will execute +/sbin/init+ in userspace.init system~~~~~~~~~~~The _init_ program is the first userspace program started by the kernel (itcarries the PID number 1), and is responsible for starting the userspaceservices and programs (for example: web server, graphical applications, othernetwork servers, etc.).OpenADK uses *Busybox* init. Amongst many programs, Busybox has animplementation of a basic +init+ program, which is sufficient for most embeddedsystems. The Busybox +init+ program will read the +/etc/inittab+ file at bootto know what to do. The syntax of this file can be found inhttp://git.busybox.net/busybox/tree/examples/inittab (note that Busybox+inittab+ syntax is special: do not use a random +inittab+ documentation fromthe Internet to learn about Busybox +inittab+). The default +inittab+ inOpenADK is generated while producing the +base-files+ package.  The main jobthe default inittab does is to start the +/etc/init.d/rcS+ shell script, andstart one or more +getty+ programs (which provides a login prompt)./dev management~~~~~~~~~~~~~~~On a Linux system, the +/dev+ directory contains special files, called_device files_, that allow userspace applications to access thehardware devices managed by the Linux kernel. Without these _devicefiles_, your userspace applications would not be able to use thehardware devices, even if they are properly recognized by the Linuxkernel.OpenADK uses *dynamic device nodes using devtmpfs and mdev*. This method relieson the _devtmpfs_ virtual filesystem in the kernel, which is enabled by defaultfor all OpenADK generated kernels, and adds the +mdev+ userspace utility on topof it. +mdev+ is a program part of Busybox that the kernel will call every timea device is added or removed. Thanks to the +/etc/mdev.conf+ configurationfile, +mdev+ can be configured to for example, set specific permissions orownership on a device file, call a script or application whenever a deviceappears or disappear, etc. Basically, it allows _userspace_ to react on deviceaddition and removal events. +mdev+ is also important if you have devices thatrequire a firmware, as it will be responsible for pushing the firmware contentsto the kernel. +mdev+ is a lightweight implementation (with fewer features) of+udev+. For more details about +mdev+ and the syntax of its configuration file,see http://git.busybox.net/busybox/tree/docs/mdev.txt.initscripts~~~~~~~~~~~The /etc/init.d/rcS script will execute all shell scripts in /etc/init.d inorder with the parameter +autostart+. The order is identified by the +#INIT+comment in the script. All scripts are sourcing the +/etc/rc.conf+ file todetermine if a service should be started on boot and which flags if any areused for the service. By default all services are disabled. If the variablefor a service is set to "DAEMON" and mksh is installed, the service startsasynchronously in the background. Most scripts provided by OpenADK via+package/<pkgname>/files/<pkgname>.init+ are like:---------------------#!/bin/sh#PKG foo#INIT 60. /etc/rc.confcase $1 inautostop) ;;autostart)        test x"${foo:-NO}" = x"NO" && exit 0	test x"$foo" = x"DAEMON" && test -x /bin/mksh && exec mksh -T- $0 start        exec sh $0 start        ;;start)        /usr/sbin/foo $foo_flags        ;;stop)        kill $(pgrep -f /usr/sbin/foo )        ;;restart)        sh $0 stop        sh $0 start        ;;*)        echo "usage: $0 (start|stop|restart)"        exit 1esacexit $?---------------------cfgfs - configuration file system~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~The cfgfs application for the OpenADK system uses a special small partition onthe block device of your embedded system (f.e. flash, sd card, compact flashor hard disk). Only changes made to /etc on your embedded system are saved in acompressed form (using LZO1 compression algorithm) in this partition. There isno Linux filesystem on this partition. The embedded system initializationprocess will setup /etc correctly on boot up, when cfgfs application is found.After making any changes to /etc, which should survive a reboot of the embeddedsystem must be written to the cfgfs partition via “cfgfs commit”. Trying toreboot, shutdown or halt an embedded system with unsaved changes will generatean error, which can be circumvented. Updates to /etc via a packagemanager (f.e. ipkg) will be reported.---------------------cfgfsConfiguration Filesystem Utility (cfgfs), Version 1.09Syntax:        /sbin/cfgfs commit [-f]        /sbin/cfgfs erase        /sbin/cfgfs setup [-N]        /sbin/cfgfs status [-rq]        /sbin/cfgfs { dump | restore } [<filename>]---------------------network configuration~~~~~~~~~~~~~~~~~~~~~On bootup +/etc/network/interfaces+ is used to find out which network configurationshould be used. The default is to use DHCP (via busybox +udhcpc+) on the first foundethernet device to configure the network. See network configuration for detailed syntaxof +/etc/network/interfaces+. It is similar to Debian network configuration and uses+ifupdown+ from +busybox+.See Appendix xref:network-configuration[]getting a shell on the system~~~~~~~~~~~~~~~~~~~~~~~~~~~~~There are two methods available to get a shell on your embedded system created withOpenADK. You can either login locally via serial console or graphical console or youcan login remotely via secure shell.In both cases the default user is +root+ and the default password is+linux123+. *You should always change the default password!!* You can do thiseither via +passwd+ on the system or you can preconfigure a password via +makemenuconfig+ under +Runtime configuration+.The default shell used in OpenADK is +mksh+ from http://www.mirbsd.org/mksh/.You can change the shell in +make menuconfig+ under +Runtime configuration+. Beaware of the fact that the bootup process might use some +mksh+ features tospeedup the system start. When you change the shell for system +/bin/sh+ theslower startup is used as a fallback.
 |