Install Barrett System to a CF Card

WARNING: These instructions are not (yet) functional. DO NOT USE!

Install bootstrap system:

# Get the core system (on any Linux system)
wget http://web.barrett.com/support/WAM_Installer/sysroot1204.tar.bz2
# Unzip it
sudo tar xvjf sysroot1204.tar.bz2

-OR-

# Use debootstrap (on an existing Ubuntu 12.04 system)
sudo apt-get install debootstrap
mkdir sysroot
sudo debootstrap precise sysroot http://ubuntu.media.mit.edu/ubuntu
sudo chroot sysroot
apt-get clean
exit
sudo tar cvjf sysroot1204.tar.bz2 sysroot

Switch to the bootstrap system (chroot):

sudo chroot sysroot
cd /dev
MAKEDEV generic

Add packages:

# Add security update repository
echo "deb http://security.ubuntu.com/ubuntu precise-security main" >> /etc/apt/sources.list

apt-get update
apt-get install language-pack-en-base
apt-get install linux-image grub man gcc gdb patch ncurses-dev wget screen openssh-server subversion rsync lm-sensors

Optional (for GUI desktop):
 # Repository for flashplugin-nonfree
 echo "deb http://ubuntu.media.mit.edu/ubuntu karmic multiverse" >> /etc/apt/sources.list

 # Repository for meld, eclipse, geany, vlc, midori
 echo "deb http://ubuntu.media.mit.edu/ubuntu karmic universe" >> /etc/apt/sources.list

 apt-get update
 apt-get install xorg gdm gksu synaptic gnome-terminal update-notifier meld geany gvfs-fuse
 apt-get install human-theme system-config-printer-gnome gnome-network-admin file-roller gnumeric abiword vlc network-manager-gnome gdebi
 apt-get install evince minicom rdesktop midori flashplugin-nonfree conky gcalctool gnome-utils gnome-applets tsclient wine eclipse

 # apt-get install gnome-themes-selected gnome-icon-theme hicolor-icon-theme human-icon-theme xsplash ubuntu-xsplash-artwork
 # dpkg-reconfigure gdm (start gdm automatically)
 # <install RabbitVCS from http://wiki.rabbitvcs.org/wiki/download>
 # wget http://web.barrett.com/support/WAM_Installer/CompareUsingMeld ~/.gnome2/nautilus-scripts/CompareUsingMeld

Install Xenomai kernel:

# Get a tarfile of all preconfigured kernel sources and binaries
wget http://web.barrett.com/support/WAM_Installer/ubuntu910xen252.tar.bz2
tar xvjf ubuntu910xen252.tar.bz2 
rm ubuntu910xen252.tar.bz2

-OR-

cd /usr/src
# Get the base kernel
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.tar.bz2

# Get the Ubuntu 9.10 kernel patches
wget http://web.barrett.com/support/WAM_Installer/linux_2.6.31-14.48.diff.gz

# Get Xenomai
wget http://download.gna.org/xenomai/stable/xenomai-2.5.2.tar.bz2

# Get the Barrett-modified Adeos patch to support Ubuntu's 2.6.31.4 instead of the default 2.6.31.8
wget http://web.barrett.com/support/WAM_Installer/adeos-ipipe-2.6.31.8-x86-2.4-09-barrett.patch

# Unzip the kernel source
tar xvjf linux-2.6.31.tar.bz2

# Make a handy link
ln -sf linux-2.6.31 linux

# Unzip the Xenomai sources
tar xvjf xenomai-2.5.2.tar.bz2

# Make a handy link
ln -sf xenomai-2.5.2 xenomai

# Change to the linux source directory
cd linux

# Apply Ubuntu patches
gunzip ../linux_2.6.31-14.48.diff.gz -c |patch -p1

# Apply Adeos patch
patch -p1 < ../adeos-ipipe-2.6.31.8-x86-2.4-09-barrett.patch

# Apply Xenomai patches
../xenomai-2.5.2/scripts/prepare-kernel.sh --linux=/usr/src/linux --arch=i686

# Grab the default Ubuntu kernel config to use as a starting point
cp /boot/config-2.6.31-20-generic .config

# Update the config with the newly-patched features (accept all defaults)
yes "" |make oldconfig

# Customize the kernel configuration
make menuconfig
 General setup: Local version => -ipipe
 Processor type/features: no sparse IRQ, Processor family => Core2, no Enable -fstack-protector
 Power management: no ACPI Processor, no APM, no CPU Frequency scaling
 Device Drivers:Input Device:Misc: no PC speaker
 Real-time sub-system: add Shared interrupts, add Machine:SMI:Enable SMI, add Drivers:Serial:16550A, add Drivers:CAN:Philips:PEAK PCI
 Kernel hacking: no Kernel debugging

# Build the kernel and associated driver modules
make; make install; make modules_install

# Create the initial ramdisk
update-initramfs -c -k 2.6.31.4-ipipe

# Save the config
cp .config config-xenomai

# Remove the object files to save space
make mrproper

If you are installing this on a running system:

# Exit the chroot environment
exit
sudo umount sysroot/dev
sudo umount sysroot/proc
sudo umount sysroot/sys

# Copy the new kernel, related modules, and source
sudo cp sysroot/boot/*ipipe /boot
sudo cp -a sysroot/lib/modules/2.6.31.4-ipipe /lib/modules
sudo cp -a sysroot/usr/src/* /usr/src

# Create a group for users allowed to execute realtime tasks
sudo addgroup xenomai (take note of the group ID assigned)

# Add yourself to the xenomai group
sudo usermod -aG xenomai <username>

# Update your bootloader with the new kernel and initrd
# The steps required depend on your system
# Just make sure to append the kernel option "xeno_nucleus.xenomai_gid=1001"
# If your "xenomai" group has a different group ID, use it here

# Reboot, then skip down to "Compile and test Xenomai runtime"

If this is a new install to be copied to a fresh disk, set up initial environment:

# Add the 'robot' user
adduser robot
 password = WAM
addgroup xenomai
addgroup admin
echo '%admin ALL=(ALL) ALL' >> /etc/sudoers
usermod -G adm,cdrom,audio,video,plugdev,admin,xenomai robot

# Set the host name
echo 'WAM' > /etc/hostname

# Set the localhost entry
echo '127.0.0.1 localhost WAM' > /etc/hosts

# Set up the time zone
echo 'America/New_York' > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata

# Clear the apt package cache
apt-get clean

# Get the file system table
wget http://web.barrett.com/support/WAM_Installer/fstabAtom -O /etc/fstab

# Get the network interface config file
wget http://web.barrett.com/support/WAM_Installer/interfacesAtom -O /etc/network/interfaces

# Get the modules file
wget http://web.barrett.com/support/WAM_Installer/modulesAtom -O /etc/modules

# Get the rc.local file
wget http://web.barrett.com/support/WAM_Installer/rcAtom -O /etc/rc.local

# wget /etc/conky/conky.conf

exit
sudo umount sysroot/dev
sudo umount sysroot/proc
sudo umount sysroot/sys

Format new disk (use the 9.10 install CD if your parted does not support ext4):

umount /media/<mountpoint>
sudo parted /dev/sdb (or wherever the new disk is)
 print (make sure this is the device you want to use)
 mklabel
  msdos
 mkpart primary ext2 0 64
 mkpart primary ext4 64 8192
 set 1 boot on
 quit
sudo mkfs.ext2 /dev/sdb1 (or wherever the first new partition is)
sudo mkfs.ext4 /dev/sdb2 (or wherever the second new partition is)

Copy system to new disk:

sudo mount /dev/sdb2 /media/sdb2
sudo mkdir /media/sdb2/boot
sudo mount /dev/sdb1 /media/sdb2/boot
sudo cp -av sysroot/* /media/sdb2

Install bootloader:

sudo mount --bind /dev /media/sdb2/dev
sudo mount --bind /proc /media/sdb2/proc
sudo mount --bind /sys /media/sdb2/sys
sudo chroot /media/sdb2
cp /usr/lib/grub/i386-pc/* /boot/grub
wget http://web.barrett.com/support/WAM_Installer/menu.lstAtom -O /boot/grub/menu.lst
grub
 find /grub/grubenv
 root (hd1,0)
 setup (hd1)
 quit

# Erase unused sectors (for better drive image compression)
# Takes up to 30 minutes. Only do this if you plan on imaging the drive.
dd if=/dev/zero of=delme bs=8M; rm delme 

# Exit the chroot environment and unmount everything
exit
sudo umount /media/sdb2/dev
sudo umount /media/sdb2/proc
sudo umount /media/sdb2/sys
sudo umount /media/sdb2/boot
sudo umount /media/sdb2

Boot into new system

Remove disk from host PC
Install disk in target PC
Boot target PC

Compile and test Xenomai runtime:

cd /usr/src/xenomai
sudo ./configure
sudo make
sudo make install
bash /usr/xenomai/bin/xeno-test

Install video drivers (Intel GMA500/Poulsbo)

TBD

Install Barrett software

TBD

Set up swap space:

Not for CF

Shut down the target PC

sudo shutdown -h now

!!! DONE !!!

Installing fsarchiver

sudo add-apt-repository ppa:randomaction/ppa
sudo apt-get update
sudo apt-get install fsarchiver

Make filesystem images using fsarchiver

# Unmount the new drive
sudo umount /media/*

time sudo fsarchiver -v -z 7 -L "Kernel 2.6.31.4-ipipe, P3, no EDID" savefs wamBoot.fsa /dev/sdb1
time sudo fsarchiver -v -z 7 -L "Ubuntu 9.10, Xenomai 2.5.2, SocketCAN" savefs wamRoot.fsa /dev/sdb2

Restore filesystem images to a new disk using fsarchiver

# Unmount the new drive
sudo umount /media/*

# Use parted to partition the disk
sudo parted -s /dev/sdb mklabel msdos
sudo parted -s /dev/sdb mkpart primary 0 64
sudo parted -s /dev/sdb mkpart primary 64 8192
sudo parted -s /dev/sdb set 1 boot on

# Restore the filesystem images
time sudo fsarchiver -v restfs wamBoot.fsa id=0,dest=/dev/sdb1
time sudo fsarchiver -v restfs wamRoot.fsa id=0,dest=/dev/sdb2

# Mount the new system
sudo mount /dev/sdb2 /media/sdb2
sudo mkdir /media/sdb2/boot
sudo mount /dev/sdb1 /media/sdb2/boot

# Install the bootloader
sudo grub-install --root-directory=/media/sdb2/ hd1

# Unmount
sudo umount /media/sdb2/boot
sudo umount /media/sdb2

Make a disk image using dd

# Read from the CompactFlash
# Takes about 30 min for an 8GB CF disk, be patient
sudo dd if=/dev/sdb bs=1k |gzip >cf.img.gz

Restore a disk image to a new disk using dd

# Write to the CompactFlash
# Can take >> 30 min for an 8GB CF disk, be patient
zcat cf.img.gz | sudo dd of=/dev/sdb bs=1k

Shrink an ext2 filesystem to its minimum size:

tune2fs -O ^has_journal /dev/sda1 (dash cap oh) (ext3->ext2, delete journal)
fsck.ext2 -f /dev/sda1 (check filesystem)
resize2fs -M /dev/sda1 (shrink filesystem)

Take note of the output from resize2fs above. It is listed in 4k blocks. But fdisk expects sizes to be specified in 1k blocks, so when you resize the partition, take the above number and multiply by 4.03 (absolute minimum, no room to grow).

Shrink the partition (for efficient imaging):

fdisk /dev/sda 
  d <delete existing>
  n <new primary> 1, start cyl = 1, size = +x (calculated above)
  a <make it bootable> 1
  w <write the new partition table>
  q <quit>
Last modified 11 years ago Last modified on Jul 12, 2013, 3:47:26 PM