TS-4710 Initrd / Busybox: Difference between revisions

From embeddedTS Manuals
No edit summary
No edit summary
 
(18 intermediate revisions by 4 users not shown)
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.local
</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 read several bits from nonvolatile memory for common configuration options we call soft jumpers. Note:  Soft jumper settings are not stored on the SD media, so re-flashing your SD card will not reset the soft jumpers.  This action can only be taken from within the OS.
 
{{Warning|Setting soft jumper 1 will boot the system straight to Debian, leaving the serial port as the only default access method.  Ensure that alternate access methods (telnet, SSH, etc.) are set up and working in Debian if the serial port is not a viable access method before this jumper is set.  If a lockout situation does occur, please contact us at support@embeddedTS.com}}


{|class=wikitable
{|class=wikitable
|+ Soft Jumpers
|+ Soft Jumpers
|-
|-
| Jumper
! Jumper
| Function
! Function
|-
|-
| 1
| 1
| Boot automatically to Debian <ref>initramfs boot is default</ref>
| Boot automatically to Debian <ref>Initramfs boot is default.  Be sure to configure Debian before setting this jumper if serial port access is not possible, see "Warning" above.</ref>
|-
|-
| 2
| 2
| Baseboard Specific
| Reserved
|-
|-
| 3
| 3
| Baseboard Specific
| Reserved
|-
|-
| 4
| 4
| Read Only mode <ref>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.</ref>
| Reserved
|-
|-
| 5
| 5
| Disable Network Autoconfiguration <ref> 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>
| Reserved
|-
|-
| 6
| 6
Line 38: Line 40:
|-
|-
| 7
| 7
| Reserved
| Skip most of the init. <ref> This option skips a significant amount of setup and will boot to a single SD card as fast as possible with no initialization.  This mode will still execute /mnt/root/ts/init if it exists, or boot to Debian if jp1 is set.  Note that this will not initialize any networking in the initramfs, leaving the serial port as the only access method.  If booting to Debian, see "Warning" above.</ref>
|-
|-
| 8
| 8
Line 46: Line 48:
<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 <pre>"http://ts<model>-<last 6 chars of the MAC>.local" </pre> 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 57:
</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:
The Debian boot can also be inhibited by creating a file in /ts/fastboot in the Debian root.  While this file exists the board will stop booting at the initramfs.  If you do not have a serial console, <b>make sure you first configure Debian's network settings first <i>before</i> booting directly to Debian</b>.  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.  Utilities from Debian can be accessed under /mnt/root as read only, but for Debian services, or using apt-get a full boot into Debian should be performed.  The initramfs itself cannot be easily modified, and it is not recommended to do so.  The initramfs however has several hooks for applications to manipulate it's behavior.
 
''' /mnt/root/ts/init '''
 
For headless applications you can create a bash script with any initialization you require in /ts/initThis 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>
#!/bin/sh
 
/path/to/your/application &
</source>
Remember to set it executable!<br>
<code>chmod a+x /ts/init</code>
 
''' /mnt/root/ts/initramfs-xinit '''
 
Graphical applications run in the initramfs should use /ts/initramfs-xinit.  Users booting to Debian should use /usr/bin/default-x-session.  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>
<source lang=bash>
mount -o remount,rw /mnt/root/
#!/bin/sh
# Write data
# Causes .Xauthority and other temp files to be written to /root/ rather than default /
mount -o remount,ro /mnt/root/
export HOME=/root/
sync
# 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.
''' /mnt/root/ts/config'''
* Do not use apt-get in this environmentThis is not where the Debian/OE install scripts are intended to run and will have unintended side effectsYou 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.
This config file can be used to alter many details of the initramfs boot procedure.
 
<pre>
## This file is included by the early init system to set various bootup settings.
## if $jp7 is enabled none of these settings will be used.
 
## Used to control whether the FPGA is reloaded through software.
## 1 to enable reloading (default)
## 0 to disable reloading
#CFG_FPGARELOAD="0"
 
## By default dns-sd is started which advertises the ts<model>-<last 6 of mac>
## telnet and http services using zeroconf.
## 1 to enable dns-sd (default)
## 0 to disable dns-sd
#CFG_DNSSD_EN="0"
 
## This is used to discover hosts and advertise this host over multicast DNS.
## 1 to enable mdns (default)
## 0 to disable mdns
#CFG_MDNS_EN="0"
 
## ifplugd is started in the initramfs to start udhcpc, and receive an ipv4ll
## address.
## 1 to enable ifplugd (default)
## 0 to disable ifplugd
#CFG_IFPLUGD_EN="0"
 
## By default telnet is started on port 2323.
## 1 to enable telnet (default)
## 0 to disable telnet
##CFG_TELNET_EN="0"
 
## The busybox webserver is used to display a diagnostic web interface that can
## be used for development tasks such as rewriting the SD or uploading new
## software
## 1 to enable (default)
## 0 to disable
##CFG_HTTPD_EN="0"
 
## This eanbles a reset switch on DIO 29 (TS-7700), or DIO 9 on all of the
## boards (except TS-7250-V2)Pull low to reset the board immediately.
## 1 to enable the reset sw (default)
## 0 to disable
#CFG_RESETSW_EN="0"
 
## The console is forwarded through xuartctl which makes the cpu console available
## over telnet or serial console.
## 1 to enable network console (default)
## 0 to disable network console
#CFG_NETCONS_EN="0"
 
## By default Alsa will put the SGTL5000 chip into standby after 5 seconds of
## inactivityThis is desirable in that it results in lower power consumption,
## but it can result in an audible popping noise.  This setting prevents
## standby so the pop is never heard. 
## 1 to disable standby
## 0 to enable standby (default)
#CFG_SGTLNOSTBY="1"
 
## xuartctl is used to access the FPGA uarts.  By default it is configured to
## be IRQ driven which is optimized for best latency, but at the cost of
## additional CPU time.  You can reduce this by specifying a polling rate.
## The xuartctl process also binds to all network interfaces which can provide a
## simple network API to access serial ports remotely.  You can restrict this to
## the local network with the bind option.
## Configure XUART polling 100hz
## Default is IRQ driven
CFG_XUARGS="--irq=100hz"
## Configure xuartctl to bind on localhost
## Default binds on all interfaces
#CFG_XUARGS="--bind 127.0.0.1 --irq=100hz"
## For a full list of arguments, see the xuartctl documentation here:
## http://docs.embeddedts.com/wiki/Xuartctl#Usage
 
## By default the system will probe for up to 10s on USB for a mass storage device
## and mount the first partition.  If there is an executable /tsinit script in the
## root this will be executed.  This is intended for production or updates.
## 2 to enable USB init always (adds 10s or $CFG_USBTIME to startup)
## 1 to enable USB init when jp1=0 (default)
## 0 to disable USB init always
#CFG_USBINIT="2"
 
## The USB init script by default blocks for 10s to detect a thumb drive that
## contains the tsinit script.  Most flash media based drives can be detected
## in 3s or less.  Some spinning media drives can take 10s, or potentially longer.
## This options is the number of seconds to wait before giving up on the
## mass storage device.
#CFG_USBTIME="3"
 
### TS-8700
## Using the TS-8700 baseboard the board will by default initialze all of the
## ethernet ports as individual vlan ports, eg eth0.1, eth0.2, eth0,3, and eth0.4
## The alterantive option sets Port A to eth0.1, and Ports B-D to eth0.2, or
## you can configure all ethernet ports as a single eth0 port.
## See http://docs.embeddedts.com/wiki/TS-8700 for more information
## 2 disables any vlan and passes through all interfaces to eth0
## 1 enables "WLAN" mode setting "A" as eth0.1, and all others as eth0.2
## 0 enables "VLAN" mode for 4 individual ports (default)
#CFG_4ETH="1"
 
### TS-4712 / TS-4720
## These boards include an onboard switch with 2 external ports.  By default
## the switch will detect if it is on a known baseboard that supports the second
## ethernet switch port, and set up VLAN rules to define eth0.1 and eth0.2.  The
## other option is to configure the switch to pass through the packets to eth0
## regarless of port.
## 2 Disable VLAN and pass through to eth0
## 1 Enable VLAN on all baseboards
## 0 Enable VLAN on supported baseboards (Default)
#CFG_2ETH="1"
</pre>

Latest revision as of 09:30, 4 February 2022

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.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 read several bits from nonvolatile memory for common configuration options we call soft jumpers. Note: Soft jumper settings are not stored on the SD media, so re-flashing your SD card will not reset the soft jumpers. This action can only be taken from within the OS.

WARNING: Setting soft jumper 1 will boot the system straight to Debian, leaving the serial port as the only default access method. Ensure that alternate access methods (telnet, SSH, etc.) are set up and working in Debian if the serial port is not a viable access method before this jumper is set. If a lockout situation does occur, please contact us at support@embeddedTS.com
Soft Jumpers
Jumper Function
1 Boot automatically to Debian [1]
2 Reserved
3 Reserved
4 Reserved
5 Reserved
6 Reserved
7 Skip most of the init. [2]
8 Skip full DRAM test on startup [3]
  1. Initramfs boot is default. Be sure to configure Debian before setting this jumper if serial port access is not possible, see "Warning" above.
  2. This option skips a significant amount of setup and will boot to a single SD card as fast as possible with no initialization. This mode will still execute /mnt/root/ts/init if it exists, or boot to Debian if jp1 is set. Note that this will not initialize any networking in the initramfs, leaving the serial port as the only access method. If booting to Debian, see "Warning" above.
  3. 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>.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

The Debian boot can also be inhibited by creating a file in /ts/fastboot in the Debian root. While this file exists the board will stop booting at the initramfs. 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. Utilities from Debian can be accessed under /mnt/root as read only, but for Debian services, or using apt-get a full boot into Debian should be performed. The initramfs itself cannot be easily modified, and it is not recommended to do so. The initramfs however has several hooks for applications to manipulate it's behavior.

/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 &

Remember to set it executable!
chmod a+x /ts/init

/mnt/root/ts/initramfs-xinit

Graphical applications run in the initramfs should use /ts/initramfs-xinit. Users booting to Debian should use /usr/bin/default-x-session. 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

/mnt/root/ts/config

This config file can be used to alter many details of the initramfs boot procedure.

## This file is included by the early init system to set various bootup settings.
## if $jp7 is enabled none of these settings will be used.

## Used to control whether the FPGA is reloaded through software.
## 1 to enable reloading (default)
## 0 to disable reloading
#CFG_FPGARELOAD="0"

## By default dns-sd is started which advertises the ts<model>-<last 6 of mac> 
## telnet and http services using zeroconf.
## 1 to enable dns-sd (default)
## 0 to disable dns-sd
#CFG_DNSSD_EN="0"

## This is used to discover hosts and advertise this host over multicast DNS.
## 1 to enable mdns (default)
## 0 to disable mdns
#CFG_MDNS_EN="0"

## ifplugd is started in the initramfs to start udhcpc, and receive an ipv4ll
## address.
## 1 to enable ifplugd (default)
## 0 to disable ifplugd
#CFG_IFPLUGD_EN="0"

## By default telnet is started on port 2323.
## 1 to enable telnet (default)
## 0 to disable telnet
##CFG_TELNET_EN="0"

## The busybox webserver is used to display a diagnostic web interface that can
## be used for development tasks such as rewriting the SD or uploading new
## software
## 1 to enable (default)
## 0 to disable
##CFG_HTTPD_EN="0"

## This eanbles a reset switch on DIO 29 (TS-7700), or DIO 9 on all of the 
## boards (except TS-7250-V2).  Pull low to reset the board immediately.
## 1 to enable the reset sw (default)
## 0 to disable
#CFG_RESETSW_EN="0"

## The console is forwarded through xuartctl which makes the cpu console available
## over telnet or serial console.
## 1 to enable network console (default)
## 0 to disable network console
#CFG_NETCONS_EN="0"

## By default Alsa will put the SGTL5000 chip into standby after 5 seconds of 
## inactivity.  This is desirable in that it results in lower power consumption,
## but it can result in an audible popping noise.  This setting prevents 
## standby so the pop is never heard.  
## 1 to disable standby
## 0 to enable standby (default)
#CFG_SGTLNOSTBY="1"

## xuartctl is used to access the FPGA uarts.  By default it is configured to
## be IRQ driven which is optimized for best latency, but at the cost of 
## additional CPU time.  You can reduce this by specifying a polling rate.
## The xuartctl process also binds to all network interfaces which can provide a 
## simple network API to access serial ports remotely.  You can restrict this to
## the local network with the bind option.
## Configure XUART polling 100hz
## Default is IRQ driven
CFG_XUARGS="--irq=100hz"
## Configure xuartctl to bind on localhost
## Default binds on all interfaces
#CFG_XUARGS="--bind 127.0.0.1 --irq=100hz"
## For a full list of arguments, see the xuartctl documentation here:
## http://docs.embeddedts.com/wiki/Xuartctl#Usage

## By default the system will probe for up to 10s on USB for a mass storage device
## and mount the first partition.  If there is an executable /tsinit script in the
## root this will be executed.  This is intended for production or updates.
## 2 to enable USB init always (adds 10s or $CFG_USBTIME to startup)
## 1 to enable USB init when jp1=0 (default)
## 0 to disable USB init always
#CFG_USBINIT="2"

## The USB init script by default blocks for 10s to detect a thumb drive that 
## contains the tsinit script.  Most flash media based drives can be detected 
## in 3s or less.  Some spinning media drives can take 10s, or potentially longer.
## This options is the number of seconds to wait before giving up on the 
## mass storage device.
#CFG_USBTIME="3"

### TS-8700
## Using the TS-8700 baseboard the board will by default initialze all of the 
## ethernet ports as individual vlan ports, eg eth0.1, eth0.2, eth0,3, and eth0.4
## The alterantive option sets Port A to eth0.1, and Ports B-D to eth0.2, or
## you can configure all ethernet ports as a single eth0 port.
## See http://docs.embeddedts.com/wiki/TS-8700 for more information
## 2 disables any vlan and passes through all interfaces to eth0
## 1 enables "WLAN" mode setting "A" as eth0.1, and all others as eth0.2
## 0 enables "VLAN" mode for 4 individual ports (default)
#CFG_4ETH="1"

### TS-4712 / TS-4720
## These boards include an onboard switch with 2 external ports.  By default
## the switch will detect if it is on a known baseboard that supports the second
## ethernet switch port, and set up VLAN rules to define eth0.1 and eth0.2.  The
## other option is to configure the switch to pass through the packets to eth0
## regarless of port.
## 2 Disable VLAN and pass through to eth0
## 1 Enable VLAN on all baseboards
## 0 Enable VLAN on supported baseboards (Default)
#CFG_2ETH="1"