| 1 | = Install Barrett System to a CF Card = |
| 2 | = WARNING: These instructions are not (yet) functional. DO NOT USE! = |
| 3 | |
| 4 | Install bootstrap system: |
| 5 | {{{ |
| 6 | # Get the core system (on any Linux system) |
| 7 | wget http://web.barrett.com/support/WAM_Installer/sysroot1204.tar.bz2 |
| 8 | # Unzip it |
| 9 | sudo tar xvjf sysroot1204.tar.bz2 |
| 10 | |
| 11 | -OR- |
| 12 | |
| 13 | # Use debootstrap (on an existing Ubuntu 12.04 system) |
| 14 | sudo apt-get install debootstrap |
| 15 | mkdir sysroot |
| 16 | sudo debootstrap precise sysroot http://ubuntu.media.mit.edu/ubuntu |
| 17 | sudo chroot sysroot |
| 18 | apt-get clean |
| 19 | exit |
| 20 | sudo tar cvjf sysroot1204.tar.bz2 sysroot |
| 21 | }}} |
| 22 | |
| 23 | Switch to the bootstrap system (chroot): |
| 24 | {{{ |
| 25 | sudo chroot sysroot |
| 26 | cd /dev |
| 27 | MAKEDEV generic |
| 28 | }}} |
| 29 | |
| 30 | Add packages: |
| 31 | {{{ |
| 32 | # Add security update repository |
| 33 | echo "deb http://security.ubuntu.com/ubuntu precise-security main" >> /etc/apt/sources.list |
| 34 | |
| 35 | apt-get update |
| 36 | apt-get install language-pack-en-base |
| 37 | apt-get install linux-image grub man gcc gdb patch ncurses-dev wget screen openssh-server subversion rsync lm-sensors |
| 38 | |
| 39 | Optional (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 | |
| 57 | Install Xenomai kernel: |
| 58 | {{{ |
| 59 | # Get a tarfile of all preconfigured kernel sources and binaries |
| 60 | wget http://web.barrett.com/support/WAM_Installer/ubuntu910xen252.tar.bz2 |
| 61 | tar xvjf ubuntu910xen252.tar.bz2 |
| 62 | rm ubuntu910xen252.tar.bz2 |
| 63 | |
| 64 | -OR- |
| 65 | |
| 66 | cd /usr/src |
| 67 | # Get the base kernel |
| 68 | wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.31.tar.bz2 |
| 69 | |
| 70 | # Get the Ubuntu 9.10 kernel patches |
| 71 | wget http://web.barrett.com/support/WAM_Installer/linux_2.6.31-14.48.diff.gz |
| 72 | |
| 73 | # Get Xenomai |
| 74 | wget 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 |
| 77 | wget 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 |
| 80 | tar xvjf linux-2.6.31.tar.bz2 |
| 81 | |
| 82 | # Make a handy link |
| 83 | ln -sf linux-2.6.31 linux |
| 84 | |
| 85 | # Unzip the Xenomai sources |
| 86 | tar xvjf xenomai-2.5.2.tar.bz2 |
| 87 | |
| 88 | # Make a handy link |
| 89 | ln -sf xenomai-2.5.2 xenomai |
| 90 | |
| 91 | # Change to the linux source directory |
| 92 | cd linux |
| 93 | |
| 94 | # Apply Ubuntu patches |
| 95 | gunzip ../linux_2.6.31-14.48.diff.gz -c |patch -p1 |
| 96 | |
| 97 | # Apply Adeos patch |
| 98 | patch -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 |
| 104 | cp /boot/config-2.6.31-20-generic .config |
| 105 | |
| 106 | # Update the config with the newly-patched features (accept all defaults) |
| 107 | yes "" |make oldconfig |
| 108 | |
| 109 | # Customize the kernel configuration |
| 110 | make 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 |
| 119 | make; make install; make modules_install |
| 120 | |
| 121 | # Create the initial ramdisk |
| 122 | update-initramfs -c -k 2.6.31.4-ipipe |
| 123 | |
| 124 | # Save the config |
| 125 | cp .config config-xenomai |
| 126 | |
| 127 | # Remove the object files to save space |
| 128 | make mrproper |
| 129 | }}} |
| 130 | |
| 131 | If you are installing this on a running system: |
| 132 | {{{ |
| 133 | # Exit the chroot environment |
| 134 | exit |
| 135 | sudo umount sysroot/dev |
| 136 | sudo umount sysroot/proc |
| 137 | sudo umount sysroot/sys |
| 138 | |
| 139 | # Copy the new kernel, related modules, and source |
| 140 | sudo cp sysroot/boot/*ipipe /boot |
| 141 | sudo cp -a sysroot/lib/modules/2.6.31.4-ipipe /lib/modules |
| 142 | sudo cp -a sysroot/usr/src/* /usr/src |
| 143 | |
| 144 | # Create a group for users allowed to execute realtime tasks |
| 145 | sudo addgroup xenomai (take note of the group ID assigned) |
| 146 | |
| 147 | # Add yourself to the xenomai group |
| 148 | sudo 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 | |
| 158 | If this is a new install to be copied to a fresh disk, set up initial environment: |
| 159 | {{{ |
| 160 | # Add the 'robot' user |
| 161 | adduser robot |
| 162 | password = WAM |
| 163 | addgroup xenomai |
| 164 | addgroup admin |
| 165 | echo '%admin ALL=(ALL) ALL' >> /etc/sudoers |
| 166 | usermod -G adm,cdrom,audio,video,plugdev,admin,xenomai robot |
| 167 | |
| 168 | # Set the host name |
| 169 | echo 'WAM' > /etc/hostname |
| 170 | |
| 171 | # Set the localhost entry |
| 172 | echo '127.0.0.1 localhost WAM' > /etc/hosts |
| 173 | |
| 174 | # Set up the time zone |
| 175 | echo 'America/New_York' > /etc/timezone |
| 176 | dpkg-reconfigure -f noninteractive tzdata |
| 177 | |
| 178 | # Clear the apt package cache |
| 179 | apt-get clean |
| 180 | |
| 181 | # Get the file system table |
| 182 | wget http://web.barrett.com/support/WAM_Installer/fstabAtom -O /etc/fstab |
| 183 | |
| 184 | # Get the network interface config file |
| 185 | wget http://web.barrett.com/support/WAM_Installer/interfacesAtom -O /etc/network/interfaces |
| 186 | |
| 187 | # Get the modules file |
| 188 | wget http://web.barrett.com/support/WAM_Installer/modulesAtom -O /etc/modules |
| 189 | |
| 190 | # Get the rc.local file |
| 191 | wget http://web.barrett.com/support/WAM_Installer/rcAtom -O /etc/rc.local |
| 192 | |
| 193 | # wget /etc/conky/conky.conf |
| 194 | |
| 195 | exit |
| 196 | sudo umount sysroot/dev |
| 197 | sudo umount sysroot/proc |
| 198 | sudo umount sysroot/sys |
| 199 | }}} |
| 200 | |
| 201 | Format new disk (use the 9.10 install CD if your parted does not support ext4): |
| 202 | {{{ |
| 203 | umount /media/<mountpoint> |
| 204 | sudo 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 |
| 212 | sudo mkfs.ext2 /dev/sdb1 (or wherever the first new partition is) |
| 213 | sudo mkfs.ext4 /dev/sdb2 (or wherever the second new partition is) |
| 214 | }}} |
| 215 | |
| 216 | Copy system to new disk: |
| 217 | {{{ |
| 218 | sudo mount /dev/sdb2 /media/sdb2 |
| 219 | sudo mkdir /media/sdb2/boot |
| 220 | sudo mount /dev/sdb1 /media/sdb2/boot |
| 221 | sudo cp -av sysroot/* /media/sdb2 |
| 222 | }}} |
| 223 | |
| 224 | Install bootloader: |
| 225 | {{{ |
| 226 | sudo mount --bind /dev /media/sdb2/dev |
| 227 | sudo mount --bind /proc /media/sdb2/proc |
| 228 | sudo mount --bind /sys /media/sdb2/sys |
| 229 | sudo chroot /media/sdb2 |
| 230 | cp /usr/lib/grub/i386-pc/* /boot/grub |
| 231 | wget http://web.barrett.com/support/WAM_Installer/menu.lstAtom -O /boot/grub/menu.lst |
| 232 | grub |
| 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. |
| 240 | dd if=/dev/zero of=delme bs=8M; rm delme |
| 241 | |
| 242 | # Exit the chroot environment and unmount everything |
| 243 | exit |
| 244 | sudo umount /media/sdb2/dev |
| 245 | sudo umount /media/sdb2/proc |
| 246 | sudo umount /media/sdb2/sys |
| 247 | sudo umount /media/sdb2/boot |
| 248 | sudo umount /media/sdb2 |
| 249 | }}} |
| 250 | |
| 251 | Boot into new system |
| 252 | {{{ |
| 253 | Remove disk from host PC |
| 254 | Install disk in target PC |
| 255 | Boot target PC |
| 256 | }}} |
| 257 | |
| 258 | Compile and test Xenomai runtime: |
| 259 | {{{ |
| 260 | cd /usr/src/xenomai |
| 261 | sudo ./configure |
| 262 | sudo make |
| 263 | sudo make install |
| 264 | bash /usr/xenomai/bin/xeno-test |
| 265 | }}} |
| 266 | |
| 267 | Install video drivers (Intel GMA500/Poulsbo) |
| 268 | {{{ |
| 269 | TBD |
| 270 | }}} |
| 271 | |
| 272 | Install Barrett software |
| 273 | {{{ |
| 274 | TBD |
| 275 | }}} |
| 276 | |
| 277 | Set up swap space: |
| 278 | {{{ |
| 279 | Not for CF |
| 280 | }}} |
| 281 | |
| 282 | Shut down the target PC |
| 283 | {{{ |
| 284 | sudo shutdown -h now |
| 285 | }}} |
| 286 | |
| 287 | !!! DONE !!! |
| 288 | |
| 289 | '''Installing fsarchiver''' |
| 290 | {{{ |
| 291 | sudo add-apt-repository ppa:randomaction/ppa |
| 292 | sudo apt-get update |
| 293 | sudo apt-get install fsarchiver |
| 294 | }}} |
| 295 | |
| 296 | '''Make filesystem images using fsarchiver''' |
| 297 | {{{ |
| 298 | # Unmount the new drive |
| 299 | sudo umount /media/* |
| 300 | |
| 301 | time sudo fsarchiver -v -z 7 -L "Kernel 2.6.31.4-ipipe, P3, no EDID" savefs wamBoot.fsa /dev/sdb1 |
| 302 | time 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 |
| 308 | sudo umount /media/* |
| 309 | |
| 310 | # Use parted to partition the disk |
| 311 | sudo parted -s /dev/sdb mklabel msdos |
| 312 | sudo parted -s /dev/sdb mkpart primary 0 64 |
| 313 | sudo parted -s /dev/sdb mkpart primary 64 8192 |
| 314 | sudo parted -s /dev/sdb set 1 boot on |
| 315 | |
| 316 | # Restore the filesystem images |
| 317 | time sudo fsarchiver -v restfs wamBoot.fsa id=0,dest=/dev/sdb1 |
| 318 | time sudo fsarchiver -v restfs wamRoot.fsa id=0,dest=/dev/sdb2 |
| 319 | |
| 320 | # Mount the new system |
| 321 | sudo mount /dev/sdb2 /media/sdb2 |
| 322 | sudo mkdir /media/sdb2/boot |
| 323 | sudo mount /dev/sdb1 /media/sdb2/boot |
| 324 | |
| 325 | # Install the bootloader |
| 326 | sudo grub-install --root-directory=/media/sdb2/ hd1 |
| 327 | |
| 328 | # Unmount |
| 329 | sudo umount /media/sdb2/boot |
| 330 | sudo 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 |
| 337 | sudo 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 |
| 344 | zcat cf.img.gz | sudo dd of=/dev/sdb bs=1k |
| 345 | }}} |
| 346 | |
| 347 | Shrink an ext2 filesystem to its minimum size: |
| 348 | {{{ |
| 349 | tune2fs -O ^has_journal /dev/sda1 (dash cap oh) (ext3->ext2, delete journal) |
| 350 | fsck.ext2 -f /dev/sda1 (check filesystem) |
| 351 | resize2fs -M /dev/sda1 (shrink filesystem) |
| 352 | }}} |
| 353 | |
| 354 | 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). |
| 355 | |
| 356 | Shrink the partition (for efficient imaging): |
| 357 | {{{ |
| 358 | fdisk /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 | }}} |