Changes between Initial Version and Version 1 of BuildingAPC/PreciseCF


Ignore:
Timestamp:
Jul 12, 2013, 3:47:26 PM (11 years ago)
Author:
bz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BuildingAPC/PreciseCF

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