Setting up a native-compilation toolchain

From SamyGO
Jump to: navigation, search

This page is a brief summary of the cross-compilation discussion on the SamyGO forum. Main contributors to this information are cowenchicken. The information in this page pertains to the building of a toolchain, based on the source code as stored in the file, available from Samsung.

-This informations are verified on Debian lenny.-

Before start ing, please check this packages are installed on your system:

   apt-get install deboostrap nfs-kernel-server nfs-common portmap

On a non-debian system download and install the debootstrap package manually

Installing Debian Lenny in an NFS chroot

First Stage debootstrap

Run the following on your debian based (or debootstrap ready) workstation

   debootstrap --verbose --arch armel --foreign lenny /armel-chroot

This gives you first stage linux image to /armel-chroot directory.

NFS export the chroot directory

I use the following options, not really sure all of them are relevant, but they work. edit "/etc/exports" file as /armel-chroot <server-domain, like>/,sync,insecure,no_subtree_check,no_root_squash)

Than execute command of

   exportfs -a

This will apply changes to system. You might need restart nfs and portmap services after change too.

Mount the NFS chroot share on the TV

At this stage, you needed to mount NFS directory to TV for continue debootstrap's second stage.

   export chroot_share=<server>:/path/to/armel-chroot
   export armel_chroot=/dtv/usb/sda2/armel-chroot
   mkdir -p $armel_chroot
   mount -o rw,soft,udp,async,nolock,rsize=32768,wsize=32768 $chroot_share $armel_chroot

Second Stage debootstrap

This step takes longer time mainly because of TV's processing speed.

   export busybox=/dtv/usb/sda2/busybox
   $busybox chroot $armel_chroot /debootstrap/debootstrap --second-stage

On some Linux distributions like ubuntu, you can get error at:

   I: Configuring mount...
   I: Configuring initscripts...
   I: Configuring sysvinit...
   W: Failure while configuring required packages.

If you have this error, than Edit /var/lib/dpkg/info/sysvinit.postinst

   #you have to comment them using # in front of them
   rm -f $INITCTL
   mkfifo -m 600 $INITCTL

than inside your chroot and run dpkg --configure -a (or something like this), you should get ride of this error and would be able to continue using apt-get/aptitude.

Getting into the chroot

You can use the following script to get into the chroot

   export chroot_share=<server>:/path/to/armel-chroot
   export armel_chroot=/dtv/usb/sda2/armel-chroot
   export busybox=/dtv/usb/sda2/busybox
   #mount the chroot nfs share
   mount -o rw,soft,udp,async,nolock,rsize=32768,wsize=32768 $chroot_share $armel_chroot
   #mount some important dirs
   mount -o bind /dev $armel_chroot/dev
   mount -o bind /dev/sam $armel_chroot/dev/sam
   mount -o bind /dev/pts $armel_chroot/dev/pts
   mount -o bind /proc $armel_chroot/proc
   mount -o bind /proc/bus/usb $armel_chroot/proc/bus/usb
   mount -o bind /sys $armel_chroot/sys
   #bind resolv.conf
   mount -o bind /etc/resolv.conf $armel_chroot/etc/resolv.conf
   #start the chroot
   $busybox chroot $armel_chroot /bin/bash --login
   umount $armel_chroot/sys
   umount $armel_chroot/proc/bus/usb
   umount $armel_chroot/proc
   umount $armel_chroot/dev/pts
   umount $armel_chroot/dev/sam
   umount $armel_chroot/dev
   umount $armel_chroot/etc/resolv.conf
   umount $armel_chroot

Installing additional packages within the chroot

Make sure your /etc/apt/sources.list contains the following lines

   deb lenny main contrib non-free
   deb-src lenny main contrib non-free
   deb lenny/updates main contrib non-free

Than you can install anything you like, e.g.

   apt-get update
   apt-get install strace