TS-7600 initramfs: Difference between revisions

From embeddedTS Manuals
No edit summary
(updates from 47xx)
Line 55: Line 55:
</source>
</source>


Many applications are capable of running from the initramfs.  Even though the full Linux root has not booted at this point, $PATH and symlinks make it possible to run many applications.  The default initramfs startup script will execute "/ts/init" in the Linux Root which can be used for any initialization that is requiredWhen executing in this environment there are several differences from Debian:
If you do not have a serial console, make sure you first configure Debian's network settings first before booting directly to Debian.  Once JP1 is enabled, the initramfs does not run ifplugd/udhcpc to configure the network.
* The second partition is mounted at /mnt/root/ as read only
 
** You can mount this as read/write with:
Most development should be done in Debian, however many applications are capable of running from the initramfs.  The initramfs itself cannot be easily modified, and it is not recommended to do so.  The initramfs however has several hooks for applications to use.  Debian is mounted at /mnt/root as a read only filesystem which includes the /ts/ directory that includes several hooks.
 
''' /mnt/root/ts/init '''
 
For headless applications you can create a bash script with any initialization you require in /ts/init.  This does not use the same $PATH as Debian, so you should enter the full path to any applications you intend to run from this environment.  The init file does not exist by default and must be created:
<source lang=bash>
<source lang=bash>
mount -o remount,rw /mnt/root/
#!/bin/sh
# Write data
 
mount -o remount,ro /mnt/root/
/path/to/your/application &
sync
</source>
 
''' /mnt/root/ts/initramfs-xinit '''
 
Graphical applications should use /ts/initramfs-xinit.  The [https://wiki.debian.org/Xinitrc xinit] file is used to start up a window manager and any applications.  The default initramfs-xinit starts a webbrowser viewing localhost:
<source lang=bash>
#!/bin/sh
# Causes .Xauthority and other temp files to be written to /root/ rather than default /
export HOME=/root/
# Disables icewm toolbars
export ICEWM_PRIVCFG=/mnt/root/root/.icewm/
 
# minimalistic window manager
icewm-lite &
 
# this loop verifies the window manager has successfully started
while ! xprop -root | grep -q _NET_SUPPORTING_WM_CHECK
do
    sleep 0.1
done
 
# This launches the fullscreen browser.    If the xinit script ever closes, x11 will close.  This is why the last
# command is the target application which is started with "exec" so it will replace the xinit process id.
exec /usr/bin/fullscreen-webkit http://localhost
</source>
</source>
* Make sure the SD card is mounted read only when the write is complete to avoid corruption caused by unplanned power outages.  Interrupting a write to the SD card can cause corruption.
* $PATH is set up to use /bin:/sbin:/mnt/root/bin:/mnt/root/sbin:/usr/bin:/usr/sbin.
* Do not use apt-get in this environment.  This is not where the Debian/OE install scripts are intended to run and will have unintended side effects.  You can type "exit" to do a full boot to run these utilities.
* The shell is using busybox sh which is optimized for size so many utilities do not implement all options as the GNU alternative.  Many times the best documentation for these utilities is in the comments in the utilitys' [http://git.busybox.net/busybox/tree/ source code].  The other option is to call the full Linux utility by full path.  For example, to call Debian's "ls" utility you would use /mnt/root/bin/ls.

Revision as of 15:04, 6 November 2013

When the board first boots up you should have a console such as:

HTLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLFLC              
>> TS-BOOTROM - built Sep  4 2013 14:49:24                                               
>> Copyright (c) 2013, Technologic Systems                                               
LLCLLLLLLLFLCLLJUncompressing Linux... done, booting the kernel.                         
Booted in 3.89s                                                                          
Initramfs Web Interface: http://ts7600-4f3029.local                                        
#       

This is a minimalistic initial ram filesystem that includes our specific utilities for the board, and is then used to bootstrap the Linux root. The initramfs is built into the kernel image so it cannot be modified without rebuilding the kernel, but it does include 8 bits for common configuration option we call soft jumpers.

Soft Jumpers
Jumper Function
1 Boot automatically to Debian [1]
2 Reserved
3 Reserved
4 Reserved
5 Reserved
6 Reserved
7 Boot as fast as possible [2]
8 Reserved
  1. initramfs boot is default
  2. This will skip all setup of networking, baseboard detection and configuration, and is not compatible with DoubleStore boot devices

There are 2 ways to manipulate soft jumpers on the board. The web interface at "http://<model>-<last 6 chars of the MAC>.local" has a list of checkboxes that will immediately change the values. You can also use tshwctl:

# Boot automatically to Debian:
tshwctl --setjp=1

# Or revert to the initramfs:
tshwctl --removejp=1

If you do not have a serial console, make sure you first configure Debian's network settings first before booting directly to Debian. Once JP1 is enabled, the initramfs does not run ifplugd/udhcpc to configure the network.

Most development should be done in Debian, however many applications are capable of running from the initramfs. The initramfs itself cannot be easily modified, and it is not recommended to do so. The initramfs however has several hooks for applications to use. Debian is mounted at /mnt/root as a read only filesystem which includes the /ts/ directory that includes several hooks.

/mnt/root/ts/init

For headless applications you can create a bash script with any initialization you require in /ts/init. This does not use the same $PATH as Debian, so you should enter the full path to any applications you intend to run from this environment. The init file does not exist by default and must be created:

#!/bin/sh

/path/to/your/application &

/mnt/root/ts/initramfs-xinit

Graphical applications should use /ts/initramfs-xinit. The xinit file is used to start up a window manager and any applications. The default initramfs-xinit starts a webbrowser viewing localhost:

#!/bin/sh
# Causes .Xauthority and other temp files to be written to /root/ rather than default /
export HOME=/root/
# Disables icewm toolbars
export ICEWM_PRIVCFG=/mnt/root/root/.icewm/

# minimalistic window manager
icewm-lite &

# this loop verifies the window manager has successfully started
while ! xprop -root | grep -q _NET_SUPPORTING_WM_CHECK
do
    sleep 0.1
done

# This launches the fullscreen browser.    If the xinit script ever closes, x11 will close.  This is why the last
# command is the target application which is started with "exec" so it will replace the xinit process id.
exec /usr/bin/fullscreen-webkit http://localhost