TS-4710 Initrd / Busybox: Difference between revisions

From embeddedTS Manuals
No edit summary
No edit summary
Line 2: Line 2:


<pre style="font-family:monospace,Courier New ;background:black; width:18cm; white-space: pre-wrap; white-space: -moz-pre-wrap; word-wrap: break-word; color:white; ">
<pre style="font-family:monospace,Courier New ;background:black; width:18cm; white-space: pre-wrap; white-space: -moz-pre-wrap; word-wrap: break-word; color:white; ">
>> TS-BOOTROM - built Jan 21 2013 16:17:55
>> TS-BOOTROM - built Mar 14 2013 15:01:50
>> Copyright (c) 2012, Technologic Systems
>> Copyright (c) 2012, Technologic Systems
.
.
.
.
Uncompressing Linux... done, booting the kernel.
Uncompressing Linux... done, booting the kernel.
Booted in 0.67 s
Booted in 0.90s
Type 'tshelp' for help
Initramfs Web Interface: http://ts47XX-112233
Manual: http://wiki.embeddedarm.com/wiki/TS-47XX
</pre>
</pre>


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.
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 several bits for common configuration option we call soft jumpers.


{|class=wikitable
{|class=wikitable
Line 19: Line 20:
| Function
| Function
|-
|-
| 1
| 1i
| Boot automatically to Debian <ref>initramfs boot is default</ref>
| Boot automatically to Debian <ref>initramfs boot is default.  Configure the network in Debian before setting this jumper if you do not have the serial console.</ref>
|-
|-
| 2
| 2
Line 32: Line 33:
|-
|-
| 5
| 5
| Disable Network Autoconfiguration <ref> Do not disable this without having access to a Serial Console.  The default will bring up the network interface with link-local addressing (ipv4ll), and a virtual interface (eg, eth0:0) with a dhcp address.  The ipv4ll address will come up almost immediately and resolve as long as zeroconf is working.  The DHCP interface can take several seconds to resolve depending on the DHCP server present on the network.</ref>
| Disable Network Autoconfiguration <ref> Do not disable this without having access to a Serial Console.</ref>
|-
|-
| 6
| 6
Line 46: Line 47:
<references />
<references />


There are 2 ways to manipulate soft jumpers on the board.  The web interface at "http://ts4710-<last 6 chars of the MAC" has a list of checkboxes that will immediately change the values.  You can also use tshwctl:
There are 2 ways to manipulate soft jumpers on the board.  The web interface at "http://ts<model>-<last 6 chars of the MAC" has a list of checkboxes that will immediately change the values.  You can also use tshwctl:
<source lang=bash>
<source lang=bash>
# Boot automatically to Debian:
# Boot automatically to Debian:
Line 55: Line 56:
</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:14, 7 August 2013

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

>> TS-BOOTROM - built Mar 14 2013 15:01:50
>> Copyright (c) 2012, Technologic Systems
.
.
Uncompressing Linux... done, booting the kernel.
Booted in 0.90s
Initramfs Web Interface: http://ts47XX-112233
Manual: http://wiki.embeddedarm.com/wiki/TS-47XX

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 several bits for common configuration option we call soft jumpers.

Soft Jumpers
Jumper Function
1i Boot automatically to Debian [1]
2 Baseboard Specific
3 Baseboard Specific
4 Read Only mode [2]
5 Disable Network Autoconfiguration [3]
6 Reserved
7 Reserved
8 Skip full DRAM test on startup [4]
  1. initramfs boot is default. Configure the network in Debian before setting this jumper if you do not have the serial console.
  2. The read only mode creates a unionfs where the full Linux root is mounted read only, and a tmpfs is mounted read/write. This allows services to run that require write access, but doesn't commit any changes to disk. This can be used to protect your application from corruption caused by sudden poweroffs.
  3. Do not disable this without having access to a Serial Console.
  4. The DRAM test can be used to verify the RAM, but adds approximately 20 seconds to the boot time. This should normally only be enabled when diagnosing problems.

There are 2 ways to manipulate soft jumpers on the board. The web interface at "http://ts<model>-<last 6 chars of the MAC" 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