Changes between Initial Version and Version 1 of BuildingAPC/PreciseCF

Jul 12, 2013, 3:47:26 PM (10 years ago)



  • BuildingAPC/PreciseCF

    v1 v1  
     1= Install Barrett System to a CF Card =
     2= WARNING: These instructions are not (yet) functional. DO NOT USE! =
     4Install bootstrap system:
     6# Get the core system (on any Linux system)
     8# Unzip it
     9sudo tar xvjf sysroot1204.tar.bz2
     13# Use debootstrap (on an existing Ubuntu 12.04 system)
     14sudo apt-get install debootstrap
     15mkdir sysroot
     16sudo debootstrap precise sysroot
     17sudo chroot sysroot
     18apt-get clean
     20sudo tar cvjf sysroot1204.tar.bz2 sysroot
     23Switch to the bootstrap system (chroot):
     25sudo chroot sysroot
     26cd /dev
     27MAKEDEV generic
     30Add packages:
     32# Add security update repository
     33echo "deb precise-security main" >> /etc/apt/sources.list
     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
     39Optional (for GUI desktop):
     40 # Repository for flashplugin-nonfree
     41 echo "deb karmic multiverse" >> /etc/apt/sources.list
     43 # Repository for meld, eclipse, geany, vlc, midori
     44 echo "deb karmic universe" >> /etc/apt/sources.list
     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
     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>
     54 # wget ~/.gnome2/nautilus-scripts/CompareUsingMeld
     57Install Xenomai kernel:
     59# Get a tarfile of all preconfigured kernel sources and binaries
     61tar xvjf ubuntu910xen252.tar.bz2
     62rm ubuntu910xen252.tar.bz2
     66cd /usr/src
     67# Get the base kernel
     70# Get the Ubuntu 9.10 kernel patches
     73# Get Xenomai
     76# Get the Barrett-modified Adeos patch to support Ubuntu's instead of the default
     79# Unzip the kernel source
     80tar xvjf linux-2.6.31.tar.bz2
     82# Make a handy link
     83ln -sf linux-2.6.31 linux
     85# Unzip the Xenomai sources
     86tar xvjf xenomai-2.5.2.tar.bz2
     88# Make a handy link
     89ln -sf xenomai-2.5.2 xenomai
     91# Change to the linux source directory
     92cd linux
     94# Apply Ubuntu patches
     95gunzip ../linux_2.6.31-14.48.diff.gz -c |patch -p1
     97# Apply Adeos patch
     98patch -p1 < ../adeos-ipipe-
     100# Apply Xenomai patches
     101../xenomai-2.5.2/scripts/ --linux=/usr/src/linux --arch=i686
     103# Grab the default Ubuntu kernel config to use as a starting point
     104cp /boot/config-2.6.31-20-generic .config
     106# Update the config with the newly-patched features (accept all defaults)
     107yes "" |make oldconfig
     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
     118# Build the kernel and associated driver modules
     119make; make install; make modules_install
     121# Create the initial ramdisk
     122update-initramfs -c -k
     124# Save the config
     125cp .config config-xenomai
     127# Remove the object files to save space
     128make mrproper
     131If you are installing this on a running system:
     133# Exit the chroot environment
     135sudo umount sysroot/dev
     136sudo umount sysroot/proc
     137sudo umount sysroot/sys
     139# Copy the new kernel, related modules, and source
     140sudo cp sysroot/boot/*ipipe /boot
     141sudo cp -a sysroot/lib/modules/ /lib/modules
     142sudo cp -a sysroot/usr/src/* /usr/src
     144# Create a group for users allowed to execute realtime tasks
     145sudo addgroup xenomai (take note of the group ID assigned)
     147# Add yourself to the xenomai group
     148sudo usermod -aG xenomai <username>
     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
     155# Reboot, then skip down to "Compile and test Xenomai runtime"
     158If this is a new install to be copied to a fresh disk, set up initial environment:
     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
     168# Set the host name
     169echo 'WAM' > /etc/hostname
     171# Set the localhost entry
     172echo ' localhost WAM' > /etc/hosts
     174# Set up the time zone
     175echo 'America/New_York' > /etc/timezone
     176dpkg-reconfigure -f noninteractive tzdata
     178# Clear the apt package cache
     179apt-get clean
     181# Get the file system table
     182wget -O /etc/fstab
     184# Get the network interface config file
     185wget -O /etc/network/interfaces
     187# Get the modules file
     188wget -O /etc/modules
     190# Get the rc.local file
     191wget -O /etc/rc.local
     193# wget /etc/conky/conky.conf
     196sudo umount sysroot/dev
     197sudo umount sysroot/proc
     198sudo umount sysroot/sys
     201Format new disk (use the 9.10 install CD if your parted does not support ext4):
     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)
     216Copy system to new disk:
     218sudo mount /dev/sdb2 /media/sdb2
     219sudo mkdir /media/sdb2/boot
     220sudo mount /dev/sdb1 /media/sdb2/boot
     221sudo cp -av sysroot/* /media/sdb2
     224Install bootloader:
     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 -O /boot/grub/menu.lst
     233 find /grub/grubenv
     234 root (hd1,0)
     235 setup (hd1)
     236 quit
     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
     242# Exit the chroot environment and unmount everything
     244sudo umount /media/sdb2/dev
     245sudo umount /media/sdb2/proc
     246sudo umount /media/sdb2/sys
     247sudo umount /media/sdb2/boot
     248sudo umount /media/sdb2
     251Boot into new system
     253Remove disk from host PC
     254Install disk in target PC
     255Boot target PC
     258Compile and test Xenomai runtime:
     260cd /usr/src/xenomai
     261sudo ./configure
     262sudo make
     263sudo make install
     264bash /usr/xenomai/bin/xeno-test
     267Install video drivers (Intel GMA500/Poulsbo)
     272Install Barrett software
     277Set up swap space:
     279Not for CF
     282Shut down the target PC
     284sudo shutdown -h now
     287!!! DONE !!!
     289'''Installing fsarchiver'''
     291sudo add-apt-repository ppa:randomaction/ppa
     292sudo apt-get update
     293sudo apt-get install fsarchiver
     296'''Make filesystem images using fsarchiver'''
     298# Unmount the new drive
     299sudo umount /media/*
     301time sudo fsarchiver -v -z 7 -L "Kernel, 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
     305'''Restore filesystem images to a new disk using fsarchiver'''
     307# Unmount the new drive
     308sudo umount /media/*
     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
     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
     320# Mount the new system
     321sudo mount /dev/sdb2 /media/sdb2
     322sudo mkdir /media/sdb2/boot
     323sudo mount /dev/sdb1 /media/sdb2/boot
     325# Install the bootloader
     326sudo grub-install --root-directory=/media/sdb2/ hd1
     328# Unmount
     329sudo umount /media/sdb2/boot
     330sudo umount /media/sdb2
     333'''Make a disk image using dd'''
     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
     340'''Restore a disk image to a new disk using dd'''
     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
     347Shrink an ext2 filesystem to its minimum size:
     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)
     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).
     356Shrink the partition (for efficient imaging):
     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>