Changes between Initial Version and Version 1 of BuildingAPC/CFCardInstall


Ignore:
Timestamp:
Jul 11, 2011, 6:55:18 PM (13 years ago)
Author:
cv
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BuildingAPC/CFCardInstall

    v1 v1  
     1= Install Barrett System to a CF Card =
     2
     3Install bootstrap system:
     4{{{
     5# Get the core system (on any Linux system)
     6wget http://web.barrett.com/support/WAM_Installer/sysroot910.tar.bz2
     7# Unzip it
     8sudo tar xvjf sysroot910.tar.bz2
     9
     10-OR-
     11
     12# Use debootstrap (on a Karmic system)
     13mkdir sysroot
     14sudo debootstrap karmic sysroot http://ubuntu.media.mit.edu/ubuntu
     15sudo chroot sysroot
     16apt-get clean
     17exit
     18sudo tar cvjf sysroot910.tar.bz2 sysroot
     19}}}
     20
     21Switch to the bootstrap system (chroot):
     22{{{
     23sudo mount --bind /dev sysroot/dev
     24sudo mount --bind /proc sysroot/proc
     25sudo mount --bind /sys sysroot/sys
     26sudo chroot sysroot
     27}}}
     28
     29Add packages:
     30{{{
     31# Add security update repository
     32echo "deb http://security.ubuntu.com/ubuntu karmic-security main" >> /etc/apt/sources.list
     33
     34apt-get update
     35apt-get install language-pack-en-base
     36apt-get install linux-image grub man gcc gdb patch ncurses-dev wget screen openssh-server subversion doxygen graphviz rsync lm-sensors
     37
     38Optional (for GUI desktop):
     39 # Repository for flashplugin-nonfree
     40 echo "deb http://ubuntu.media.mit.edu/ubuntu karmic multiverse" >> /etc/apt/sources.list
     41
     42 # Repository for meld, eclipse, geany, vlc, midori
     43 echo "deb http://ubuntu.media.mit.edu/ubuntu karmic universe" >> /etc/apt/sources.list
     44
     45 apt-get update
     46 apt-get install xorg gdm gksu synaptic gnome-terminal update-notifier meld geany gvfs-fuse
     47 apt-get install human-theme system-config-printer-gnome gnome-network-admin file-roller gnumeric abiword vlc network-manager-gnome gdebi
     48 apt-get install evince minicom rdesktop midori flashplugin-nonfree conky gcalctool gnome-utils gnome-applets tsclient wine eclipse
     49
     50 # apt-get install gnome-themes-selected gnome-icon-theme hicolor-icon-theme human-icon-theme xsplash ubuntu-xsplash-artwork
     51 # dpkg-reconfigure gdm (start gdm automatically)
     52 # <install RabbitVCS from http://wiki.rabbitvcs.org/wiki/download>
     53 # wget http://web.barrett.com/support/WAM_Installer/CompareUsingMeld ~/.gnome2/nautilus-scripts/CompareUsingMeld
     54}}}
     55
     56Install Xenomai kernel:
     57{{{
     58# Get a tarfile of all preconfigured kernel sources and binaries
     59wget http://web.barrett.com/support/WAM_Installer/ubuntu910xen252.tar.bz2
     60tar xvjf ubuntu910xen252.tar.bz2
     61rm ubuntu910xen252.tar.bz2
     62
     63-OR-
     64
     65cd /usr/src
     66# Get the base kernel
     67wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.tar.bz2
     68
     69# Get the Ubuntu 9.10 kernel patches
     70wget http://web.barrett.com/support/WAM_Installer/linux_2.6.31-14.48.diff.gz
     71
     72# Get Xenomai
     73wget http://download.gna.org/xenomai/stable/xenomai-2.5.2.tar.bz2
     74
     75# Get the Barrett-modified Adeos patch to support Ubuntu's 2.6.31.4 instead of the default 2.6.31.8
     76wget http://web.barrett.com/support/WAM_Installer/adeos-ipipe-2.6.31.8-x86-2.4-09-barrett.patch
     77
     78# Unzip the kernel source
     79tar xvjf linux-2.6.31.tar.bz2
     80
     81# Make a handy link
     82ln -sf linux-2.6.31 linux
     83
     84# Unzip the Xenomai sources
     85tar xvjf xenomai-2.5.2.tar.bz2
     86
     87# Make a handy link
     88ln -sf xenomai-2.5.2 xenomai
     89
     90# Change to the linux source directory
     91cd linux
     92
     93# Apply Ubuntu patches
     94gunzip ../linux_2.6.31-14.48.diff.gz -c |patch -p1
     95
     96# Apply Adeos patch
     97patch -p1 < ../adeos-ipipe-2.6.31.8-x86-2.4-09-barrett.patch
     98
     99# Apply Xenomai patches
     100../xenomai-2.5.2/scripts/prepare-kernel.sh --linux=/usr/src/linux --arch=i686
     101
     102# Grab the default Ubuntu kernel config to use as a starting point
     103cp /boot/config-2.6.31-20-generic .config
     104
     105# Update the config with the newly-patched features (accept all defaults)
     106yes "" |make oldconfig
     107
     108# Customize the kernel configuration
     109make menuconfig
     110 General setup: Local version => -ipipe
     111 Processor type/features: no sparse IRQ, Processor family => Core2, no Enable -fstack-protector
     112 Power management: no ACPI Processor, no APM, no CPU Frequency scaling
     113 Device Drivers:Input Device:Misc: no PC speaker
     114 Real-time sub-system: add Shared interrupts, add Machine:SMI:Enable SMI, add Drivers:Serial:16550A, add Drivers:CAN:Philips:PEAK PCI
     115 Kernel hacking: no Kernel debugging
     116
     117# Build the kernel and associated driver modules
     118make; make install; make modules_install
     119
     120# Create the initial ramdisk
     121update-initramfs -c -k 2.6.31.4-ipipe
     122
     123# Save the config
     124cp .config config-xenomai
     125
     126# Remove the object files to save space
     127make mrproper
     128}}}
     129
     130If you are installing this on a running system:
     131{{{
     132# Exit the chroot environment
     133exit
     134sudo umount ~/sysroot/dev
     135sudo umount ~/sysroot/proc
     136sudo umount ~/sysroot/sys
     137
     138# Copy the new kernel, related modules, and source
     139sudo cp ~/sysroot/boot/*ipipe /boot
     140sudo cp -a ~/sysroot/lib/modules/2.6.31.4-ipipe /lib/modules
     141sudo cp -a ~/sysroot/usr/src/* /usr/src
     142
     143# Create a group for users allowed to execute realtime tasks
     144sudo addgroup xenomai (take note of the group ID assigned)
     145
     146# Add yourself to the xenomai group
     147sudo usermod -aG xenomai <username>
     148
     149# Update your bootloader with the new kernel and initrd
     150# The steps required depend on your system
     151# Just make sure to append the kernel option "xeno_nucleus.xenomai_gid=1001"
     152# If your "xenomai" group has a different group ID, use it here
     153
     154# Reboot, then skip down to "Compile and test Xenomai runtime"
     155}}}
     156
     157If this is a new install to be copied to a fresh disk, set up initial environment:
     158{{{
     159# Add the 'robot' user
     160adduser robot
     161 password = WAM
     162addgroup xenomai
     163addgroup admin
     164echo '%admin ALL=(ALL) ALL' >> /etc/sudoers
     165usermod -G adm,cdrom,audio,video,plugdev,admin,xenomai robot
     166
     167# Set the host name
     168echo 'WAM' > /etc/hostname
     169
     170# Set the localhost entry
     171echo '127.0.0.1 localhost WAM' > /etc/hosts
     172
     173# Set up the time zone
     174echo 'America/New_York' > /etc/timezone
     175dpkg-reconfigure -f noninteractive tzdata
     176
     177# Clear the apt package cache
     178apt-get clean
     179
     180# Get the file system table
     181wget http://web.barrett.com/support/WAM_Installer/fstabAtom -O /etc/fstab
     182
     183# Get the network interface config file
     184wget http://web.barrett.com/support/WAM_Installer/interfacesAtom -O /etc/network/interfaces
     185
     186# Get the modules file
     187wget http://web.barrett.com/support/WAM_Installer/modulesAtom -O /etc/modules
     188
     189# Get the rc.local file
     190wget http://web.barrett.com/support/WAM_Installer/rcAtom -O /etc/rc.local
     191
     192# wget /etc/conky/conky.conf
     193
     194exit
     195sudo umount ~/sysroot/dev
     196sudo umount ~/sysroot/proc
     197sudo umount ~/sysroot/sys
     198}}}
     199
     200Format new disk (use the 9.10 install CD if your parted does not support ext4):
     201{{{
     202umount /media/<mountpoint>
     203sudo parted /dev/sdb (or wherever the new disk is)
     204 print (make sure this is the device you want to use)
     205 mklabel
     206  msdos
     207 mkpart primary ext2 0 64
     208 mkpart primary ext4 64 8192
     209 set 1 boot on
     210 quit
     211sudo mkfs.ext2 /dev/sdb1 (or wherever the first new partition is)
     212sudo mkfs.ext4 /dev/sdb2 (or wherever the second new partition is)
     213}}}
     214
     215Copy system to new disk:
     216{{{
     217sudo mkdir -p /media/sdb2/boot
     218sudo mount /dev/sdb2 /media/sdb2
     219sudo mount /dev/sdb1 /media/sdb2/boot
     220sudo cp -av ~/sysroot/* /media/sdb2
     221}}}
     222
     223Install bootloader:
     224{{{
     225sudo mount --bind /dev /media/sdb2/dev
     226sudo mount --bind /proc /media/sdb2/proc
     227sudo mount --bind /sys /media/sdb2/sys
     228sudo chroot /media/sdb2
     229cp /usr/lib/grub/i386-pc/* /boot/grub
     230wget http://web.barrett.com/support/WAM_Installer/menu.lstAtom -O /boot/grub/menu.lst
     231grub
     232 find /grub/grubenv
     233 root (hd1,0)
     234 setup (hd1)
     235 quit
     236
     237# Erase unused sectors (for better drive image compression)
     238# Takes up to 30 minutes. Only do this if you plan on imaging the drive.
     239dd if=/dev/zero of=delme bs=8M; rm delme
     240
     241# Exit the chroot environment and unmount everything
     242exit
     243sudo umount /media/sdb2/dev
     244sudo umount /media/sdb2/proc
     245sudo umount /media/sdb2/sys
     246sudo umount /media/sdb2/boot
     247sudo umount /media/sdb2
     248}}}
     249
     250Boot into new system
     251{{{
     252Remove disk from host PC
     253Install disk in target PC
     254Boot target PC
     255}}}
     256
     257Compile and test Xenomai runtime:
     258{{{
     259cd /usr/src/xenomai
     260sudo ./configure
     261sudo make
     262sudo make install
     263bash /usr/xenomai/bin/xeno-test
     264}}}
     265
     266Install video drivers (Intel GMA500/Poulsbo)
     267{{{
     268TBD
     269}}}
     270
     271Install Barrett software
     272{{{
     273TBD
     274}}}
     275
     276Set up swap space:
     277{{{
     278Not for CF
     279}}}
     280
     281Shut down the target PC
     282{{{
     283sudo shutdown -h now
     284}}}
     285
     286!!! DONE !!!
     287
     288'''Installing fsarchiver'''
     289{{{
     290sudo add-apt-repository ppa:randomaction/ppa
     291sudo apt-get update
     292sudo apt-get install fsarchiver
     293}}}
     294
     295'''Make filesystem images using fsarchiver'''
     296{{{
     297# Unmount the new drive
     298sudo umount /media/*
     299
     300time sudo fsarchiver -v -z 7 -L "Kernel 2.6.31.4-ipipe, P3, no EDID" savefs wamBoot.fsa /dev/sdb1
     301time sudo fsarchiver -v -z 7 -L "Ubuntu 9.10, Xenomai 2.5.2, SocketCAN" savefs wamRoot.fsa /dev/sdb2
     302}}}
     303
     304'''Restore filesystem images to a new disk using fsarchiver'''
     305{{{
     306# Unmount the new drive
     307sudo umount /media/*
     308
     309# Use parted to partition the disk
     310sudo parted -s /dev/sdb mklabel msdos
     311sudo parted -s /dev/sdb mkpart primary 0 64
     312sudo parted -s /dev/sdb mkpart primary 64 8192
     313sudo parted -s /dev/sdb set 1 boot on
     314
     315# Restore the filesystem images
     316time sudo fsarchiver -v restfs wamBoot.fsa id=0,dest=/dev/sdb1
     317time sudo fsarchiver -v restfs wamRoot.fsa id=0,dest=/dev/sdb2
     318
     319# Mount the new system
     320sudo mkdir -p /media/sdb2/boot
     321sudo mount /dev/sdb2 /media/sdb2
     322sudo mount /dev/sdb1 /media/sdb2/boot
     323
     324# Install the bootloader
     325sudo grub-install --root-directory=/media/sdb2/ hd1
     326
     327# Unmount
     328sudo umount /media/sdb2/boot
     329sudo umount /media/sdb2
     330}}}
     331
     332'''Make a disk image using dd'''
     333{{{
     334# Read from the CompactFlash
     335# Takes about 30 min for an 8GB CF disk, be patient
     336sudo dd if=/dev/sdb bs=1k |gzip >cf.img.gz
     337}}}
     338
     339'''Restore a disk image to a new disk using dd'''
     340{{{
     341# Write to the CompactFlash
     342# Can take >> 30 min for an 8GB CF disk, be patient
     343zcat cf.img.gz | sudo dd of=/dev/sdb bs=1k
     344}}}
     345
     346Shrink an ext2 filesystem to its minimum size:
     347{{{
     348tune2fs -O ^has_journal /dev/sda1 (dash cap oh) (ext3->ext2, delete journal)
     349fsck.ext2 -f /dev/sda1 (check filesystem)
     350resize2fs -M /dev/sda1 (shrink filesystem)
     351}}}
     352
     353Take 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).
     354
     355Shrink the partition (for efficient imaging):
     356{{{
     357fdisk /dev/sda
     358  d <delete existing>
     359  n <new primary> 1, start cyl = 1, size = +x (calculated above)
     360  a <make it bootable> 1
     361  w <write the new partition table>
     362  q <quit>
     363}}}