Setting up a native compiling toolchain

Ideas and dreaming will go this forum

nbd
Posts: 160
Joined: Wed Jan 13, 2010 12:02 pm

Re: Setting up a native compiling toolchain

Post by nbd »

1) worked

I mounted the qemu image in my linux box with the -o loop directly to the nfs export path and then from TV I can mount the nfs share and can chroot into it.

Things to note:

- Better to quit qemu before mounting the hda.img
- Apt-get busybox-static from Lenny's repositories gave the version 1.10 and it did not work from the TV, complained about missing LIBC6>=2.7 (although I had, at that point, qemu running and had mounted the same image with -o loop and I think I messed the filesystem somehow by copying files directly to the image through the -o loop mount). After I fixed the filesystem from qemu (few iterations of fsck) I installed the 1.14.2 version manually and it worked.
User avatar
juusso
SamyGO Moderator
Posts: 10129
Joined: Sun Mar 07, 2010 6:20 pm

Re: Setting up a native compiling toolchain

Post by juusso »

Native compiling toolchain you can download from here (thanx to nbd)
This post is summary of few first posts and wiki page, i spent a lot of time to get it working from scratch, but this way with prepared image is easier, quicker, (safer?). At the end i write some example how to compile samygo apps, because here isn`t any info how to do that, at least i didn`t find it (or info is poor and dropped on few topics). If you find mistakes/errors, please correct me.
I`ll update wiki, but to let you know, i`ll write here first. :)

On PC:
1. Enter as root (sudo su) and install debootstrap:

Code: Select all

apt-get install deboostrap nfs-kernel-server nfs-common portmap 
2. Create /armel-chroot directory on Ubuntu (i use vmware virtual image)
3. Mount image from archive:

Code: Select all

mount -o loop,offset=32256 /usr/hda2.img /armel-chroot
4. Export this directory as NFS share.

Code: Select all

nano /etc/exports 
4.1. Edit IP of TV and subnet mask:

Code: Select all

# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
/armel-chroot 192.168.1.102/255.255.255.0(rw,sync,insecure,no_subtree_check,no_root_squash) 
4.2 Renew nfs exports:

Code: Select all

exportfs -ra 

On TV
5. Download custom (chroot applet is needed) busybox and place it to /mtd_rwarea/bin
5.1 Export busybox settings:

Code: Select all

export busybox=/mtd_rwarea/bin/busybox 
6. Export other settings (change <server>:/path/to/armel-chroot to your settings first)

Code: Select all

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 
7. Make script to enter toolchain easier:

Code: Select all

vi /mtd_rwarea/toolchain.sh

Code: Select all

#!/bin/sh
#options
export chroot_share=192.168.1.107:/armel-chroot
export armel_usb=/dtv/usb/sda2
export armel_chroot=/dtv/usb/sda2/armel-chroot
export busybox=/mtd_rwarea/bin/busybox
#====================================================================
#Create Folder for Mountpoints
#====================================================================
if [ `mount | grep -c $armel_usb` == 0 ]; then
    mkdir -p $armel_usb
fi   

#====================================================================
# Mounting the chroot nfs share
#====================================================================
if [ `mount | grep -c $armel_chroot` == 0 ]; then
    echo "Mounting: chroot"
  mkdir -p $armel_chroot
    mount -o rw,soft,udp,async,nolock,rsize=32768,wsize=32768 $chroot_share $armel_chroot -t nfs
  else
  echo "$armel_chroot: already Mounted"
fi
 
#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
$busybox chroot $armel_chroot /bin/bash --login
   
#umount
umount $armel_chroot/sys
echo "/sys unmounted"
umount $armel_chroot/proc/bus/usb
echo "/proc/bus/usb unmounted"
umount $armel_chroot/proc
echo "/proc unmounted"
umount $armel_chroot/dev/pts
echo "/dev/pts unmounted"
umount $armel_chroot/dev/sam
echo "/dev/sam unmounted"
umount $armel_chroot/dev
echo "/dev unmounted"
umount $armel_chroot/etc/resolv.conf
echo "/etc/resolv.conf unmounted"
# umount $armel_chroot 
where 192.168.1.107 - IP of my Ubuntu mashine.
7.1 Change permissions:

Code: Select all

chmod 755 /mtd_rwarea/toolchain.sh
8. To start compilator, run this script:

Code: Select all

#/mtd_rwarea/toolchain.sh
Mounting: chroot
root@localhost:/# 
8.1. To exit compilator and get back to TV`s console just enter:

Code: Select all

exit
8.2. NFS /armel_chroot is still mouted, you can find your directory under /dtv/usb/sda2/armel_chroot

How to compile ?
9. I give an example with samygo Channelinfo.
9.1. Download the app source (it is usually placed inside the src directory) and place it somewhere inside compilation environment. (for example in /usr/src/apps)
9.2. Go to required direcotory:

Code: Select all

cd /usr/src/apps/channelinfo 
9.3. If here is file, named make.sh - run it and wait for result.
9.4. To compile manually:

Code: Select all

export PATH=$PATH:/usr/bin
arm-linux-gnueabi-gcc -O2 -c info.c -o loader.o
arm-linux-gnueabi-gcc -shared -Wl -o loader.so loader.o 
9.5. Compiled file loader.so is ready to use.
10. To compile with SDL, you need download and copy to right places missing libraries.
LE40B653T5W,UE40D6750,UE65Q8C
Have questions? Read SamyGO Wiki, Search on forum first!
FFB (v0.8), FFB for CI+ . Get root on: C series, D series, E series, F series, H series. rooting K series, exeDSP/exeTV patches[C/D/E/F/H]

DO NOT EVER INSTALL FIRMWARE UPGRADE
c4xpbv
Posts: 1
Joined: Sun Aug 28, 2011 11:39 am

Re: Setting up a native compiling toolchain

Post by c4xpbv »

Hi juuso,
Your scripts worked perfectly with a little comment:
line 37-38:

Code: Select all

#$busybox
chroot $armel_chroot /bin/bash --login
should be changed into :

Code: Select all

$busybox chroot $armel_chroot /bin/bash --login
Thanks for a nice step by step tutorial :)
User avatar
juusso
SamyGO Moderator
Posts: 10129
Joined: Sun Mar 07, 2010 6:20 pm

Re: Setting up a native compiling toolchain

Post by juusso »

erdem_ua wrote:Problems that I found:

Code: Select all

mkdir -p /dtv/usb/sda2/armel-chroot
#required dir init

mount -t nfs <server>:/armel-chroot /dtv/usb/sda2/armel-chroot
# -o nolock required!

/dtv/usb/sda2/busybox chroot /dtv/usb/sda2/armel-chroot /debootstrap/debootstrap --second-stage
#Gives Error:
#mknod: `//test-dev-null': Operation not permitted
#E: Cannot install into target '/' mounted with noexec or nodev
Erdem, today i tried to up the native toolchain from scratch and got same error.
The solution was simple: you have to edit your NFS exports and add no_root_squash option for your armel-chroot dir.
Notice for future users, might anyone gets this error too.
for example:

Code: Select all

/armel-chroot 192.168.1.102/255.255.255.0(rw,sync,insecure,no_subtree_check,no_root_squash) 
LE40B653T5W,UE40D6750,UE65Q8C
Have questions? Read SamyGO Wiki, Search on forum first!
FFB (v0.8), FFB for CI+ . Get root on: C series, D series, E series, F series, H series. rooting K series, exeDSP/exeTV patches[C/D/E/F/H]

DO NOT EVER INSTALL FIRMWARE UPGRADE

Post Reply

Return to “[B] Brainstorm”