Difference between revisions of "ICub PC104 Linux Image - Detailed info"

From Wiki for iCub and Friends
Jump to: navigation, search
(Kernel modules)
(iCub startup scripts)
Line 64: Line 64:
  
 
=== iCub startup scripts ===
 
=== iCub startup scripts ===
 +
Some scripts need to be execute at startup time, so we modified the rc.local file as follows
 +
#!/bin/sh
 +
#
 +
# rc.local
 +
#
 +
# This script is executed at the end of each multiuser runlevel.
 +
# Make sure that the script will "exit 0" on success or any other
 +
# value on error.
 +
#
 +
# In order to enable or disable this script just change the execution
 +
# bits.
 +
#
 +
# By default this script does nothing.
 +
# run iCub config scripts
 +
SCRIPT_DIR=/etc/rciCub.d
 +
echo "Running scripts in $SCRIPT_DIR"
 +
for filename in ${SCRIPT_DIR}/S*.sh; do
 +
  echo "Running $filename"
 +
  bash $filename
 +
done 
 +
exit 0
 +
In this way, all the startup scripts in /etc/rciCub.d are executed:
 +
* ''script required to load the kernel modules required by peripherals (see )''
 +
* ''The NTP script''
 +
#!/bin/sh -e
 +
#start script to synchronize data in a separated shell to avoid init process waiting for a response
 +
/etc/rciCub.d/synchtime.sh &
 +
exit 0
 +
Which executes the following script in background
 +
#!/bin/sh
 +
sleep 30
 +
for TRIALS in 0 1 2 3 4 5 6 7 8 9 ; do
 +
  /usr/sbin/ntpdate-debian -u 2> /dev/null
 +
  RESULT=$?
 +
  if [ $RESULT -eq 0 ]; then
 +
    echo "ntpdate synch OK "
 +
    exit 0
 +
  else
 +
    sleep 20
 +
  fi
 +
done
 +
echo "ntpdate synch failed: aborting!"
 +
exit 1
  
 
=== Kernel modules ===
 
=== Kernel modules ===

Revision as of 13:22, 24 November 2014

NOTE : this page is valid ONLY for the PC104 image with version 5.0 and above for older versions read this page

This page contains detailed information about the Linux distribution running inside the iCub's pc104 and keep track of important if all files and configurations which make this image different from a vanilla Debian GNU/Linux LIVE (at the time of writing Debian 7 wheezy)

Additional Packages

The image is (at the moment of writing, version 5.0) based on a default Debian Wheezy (7) LIVE image, but with some additional packages:

build-essential
sudo
gcc
g++
make
cmake
cmake-curses-gui
pkg-config
ssh
openssh-server
libtinyxml-dev
nfs-common
vim
less
ntpdate
libportaudio2
libace-dev
libgsl0-dev
libcv-dev
iperf
dnsutils
resolvconf
libpcap-dev
glade
libglademm-2.4-dev
libgtkmm-2.4-dev
libhighgui-dev
libcvaux-dev
libncurses5-dev
alsa-utils
subversion
git
bash-completion
meld
gedit
libraw1394-dev
libdc1394-22-dev
ethtool
usbutils
libpcap0.8
netcat-traditional
fxload
audacity
festival
nmap

The kernel

this session is still to be completed

Customized files

README, VERSION and ChangeLog

The following files, available in the root filesystem contains various info about the LIVE release

  • README : contains useful info about the LIVE imag and its requirements
  • VERSION : contains version info (build version, build date and distro on which this build is created)
  • ChangeLog : contains the release ChangeLog

iCub startup scripts

Some scripts need to be execute at startup time, so we modified the rc.local file as follows

#!/bin/sh
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# run iCub config scripts
SCRIPT_DIR=/etc/rciCub.d
echo "Running scripts in $SCRIPT_DIR"
for filename in ${SCRIPT_DIR}/S*.sh; do
  echo "Running $filename"
  bash $filename
done   

exit 0 In this way, all the startup scripts in /etc/rciCub.d are executed:

  • script required to load the kernel modules required by peripherals (see )
  • The NTP script
#!/bin/sh -e
#start script to synchronize data in a separated shell to avoid init process waiting for a response
/etc/rciCub.d/synchtime.sh &
exit 0

Which executes the following script in background

#!/bin/sh
sleep 30
for TRIALS in 0 1 2 3 4 5 6 7 8 9 ; do
  /usr/sbin/ntpdate-debian -u 2> /dev/null
  RESULT=$?
  if [ $RESULT -eq 0 ]; then
    echo "ntpdate synch OK "
    exit 0
  else
    sleep 20 
  fi
done
echo "ntpdate synch failed: aborting!"
exit 1

Kernel modules

this session is still to be completed

Network configuration

The configuration is done via /etc/network/interfaces as follows

# The primary network interface (Motors network)
allow-hotplug eth0
iface eth0 inet static
  address 10.0.1.104
  netmask 255.255.255.0
auto eth0
# The secondary network interface (External network)
allow-hotplug eth1
iface eth1 inet static
  address 10.0.0.2
  netmask 255.255.255.0
  network 10.0.0.0
  broadcast 10.0.0.255
  gateway 10.0.0.1
  dns-nameservers 10.0.0.1 8.8.8.8 
  dns-domain icub.local
  dns-search icub.local
auto eth1

SSH configuration

  • In order to speed up SSH connection, the DNS lookup is disabled
UseDNS no
  • because the live system disables the password authentication at system startup, the script
/lib/live/config/9100-openssh-login

is used to enable it on starup by attind the following line to /etc/ssh/sshd_config PasswordAuthentication yes

NTP configuration

We use icub-srv (10.0.0.1) as NTP server.
The package ntp is installed but not executed, so we add the followng line to /etc/ntp.conf

server 10.0.0.1

and we change the file /etc/default/ntp as follows

STARTUP_DISABLED='yes'

NFS configuration

we mount the following two remote NFS shares from icub-srv

icubsrv:/exports/code /usr/local/src/robot nfs _netdev,auto,hard,intr
icubsrv:/exports/local_yarp /home/icub/.local/share/yarp nfs  _netdev,auto,hard,intr

So, the startup script is use to try to mount those shares, see /etc/rc_iCub.d/s90_mount-remote-fs.sh Moreover, inorder to mount the aboive share with the correct user rights, we add the following line to the file /etc/default/nfs-common

NEED_IDMAPD=yes

Hostname

The hostname in /etc/hostname is set to

pc104

And the file /etc/hosts is as follows

127.0.0.1	localhost
127.0.1.1	pc104.icub.local pc104
10.0.0.1 	icubsrv

User environment

The SKEL (/etc/skel) files are used to generate the desired user environment for the icub user modfing the following files

.bashrc

These lines are added ad the end of the dafault .bashrc file

# Load the iCub custom bashrc
if [ -f ~/.bashrc_iCub ]; then
  . ~/.bashrc_iCub
fi

.bashrc_iCub

if [ "$PS1" ]; then 
  echo "Setting up yarp and iCub env vars"
fi
# YARP and iCub enviroment variables
export ROBOT_CODE=/usr/local/src/robot/
export ICUBcontrib_DIR=$ROBOT_CODE/iCubContrib
export YARP_ROOT=$ROBOT_CODE/yarp
export YARP_DIR=$YARP_ROOT/build-pc104
export ICUB_ROOT=${ROBOT_CODE}/icub-main
export ICUB_DIR=${ICUB_ROOT}/build-pc104
export icub_firmware_shared_DIR=${ROBOT_CODE}/icub-firmware-shared/build-pc104
export YARP_DATA_DIRS=${YARP_DIR}/share/yarp:${ICUB_DIR}/share/iCub:${ICUBcontrib_DIR}/share/ICUBcontrib
export FIRMWARE_BIN=${ROBOT_CODE}/icub-firmware/build
# Set the name of your robot here.
# Please change also the root user password
export YARP_ROBOT_NAME=
if [ "$YARP_ROBOT_NAME" = "" ] && [ -f "${ROBOT_CODE}/yarp_robot_name.txt" ]
then
  export YARP_ROBOT_NAME=$( head --lines=1 ${ROBOT_CODE}/yarp_robot_name.txt )
fi
# For compiling
DRIVER_ROOT=/lib/modules/$(uname -r)/iCubDrivers/
# to be used if the corresponding hardware is mounted on the robot 
#export ESDCANAPI_DIR=$DRIVER_ROOT/esdCanApi/
#export PLXCANAPI_DIR=$DRIVER_ROOT/plxCanApi/
export CFW2CANAPI_DIR=$DRIVER_ROOT/cfw002/
# Set-up optimizations
export CMAKE_BUILD_TYPE=Release
export PATH=$PATH:$ICUB_DIR/bin:$YARP_DIR/bin
# DebugStream customization
export ICUB_VERBOSE_OUTPUT=0
export ICUB_COLORED_OUTPUT=1
export ICUB_TRACE_ENABLE=0
# To enable tab completion on yarp port names
if [ -f $YARP_ROOT/scripts/yarp_completion ]; then
  source $YARP_ROOT/scripts/yarp_completion
fi
# git mod for prompt
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[00;32m\]$(__git_ps1 " (%s)")\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(__git_ps1 " (%s)")\$ '
fi

.gitconfig

[core]
       pager = less -FRSX
       editor = vim
       autocrlf = input
[merge]
       tool = vimdiff
[credential]
       helper = cache --timeout=7200
[branch]
       autosetuprebase = always
[user]

name = iCub User email = robotcub-hackers@lists.sourceforge.net

.ssh/authorized_keys

This file contains the key for passwordless login

.local/share/yarp/REMOTEFS_NOT_MOUNTED

This is a placeholder for the remote mounted path

Other improvements

The following files are modified in order to obtain better real time netowrking performaces

  • /etc/security/limits.d/icub.conf
 icub	soft	rtprio	99
 icub	hard	rtprio	99
  • /etc/sysctl.d/20-net-rbuffer.conf
# This sets the max OS receive buffer size for all types of connections
net.core.rmem_max=8388608

Live-related customization

How the iCub LIVE image is built

The iCub live ISO image is built with a script based on the Debian LIVE tools (included in the package live-build).