You are here: LinuxDevTools Web>ScratchBoxQEMU (23 Mar 2009)

Building Debian Packages For ARM ABI (EABI, armel) Using Scratchbox

Thanks to all developers who provided the software mentioned below.......

Why

  • Use Debian because - see Reasons To Use Debian
  • Build for ARM ABI because - see Debian EABI page
  • Use Scratchbox because cross compiling is not always easy....
  • Use qemu-system-arm as a sbrsh target (rather than qemu) because scratchbox qemu-8.2 is not quite fully ABI compatible.
    qemu-system-arm can run a linux image which provides full ABI support, without itself requiring ABI support.
  • Use qemu-system-arm, rather than a real board running a kernel with EABI support because it's cheaper.

How

Read This First

General scratchbox Tips & Tricks

Install/Build Software

Record of another installation

Additions to default installation were
  • VMWare && linux machine installed to WinXP host
    • Configure the machine ethernet as Custom/VMnet4.
    • Share some directory with the host for data transfer.
  • Scratchbox installed on VMWare machine
    • None
  • qemu built & installed on VMware machine
    • Additional packages
      • texi2html
      • SDL
      • bridge-utils
      • sysfsutils
  • Patch & build the linux kernel
    • Configure the kernel under block devices to support initrd rootfs
      • Add root=/dev/ram0 to the kernel command line
      • Ensure the initrd size is sufficient for the root file system
    • Full kernel command line used in this example was "console=ttyAMA0 mem=128M root=/dev/ram0"
  • Construct a file system using the AEL File System Configurator
    • Include the necessary sbrsh files from scratchbox by inserting them in the ARM_Embedded_Linux-2.3.0/imports directory
      • /etc/init.d/sbrshd
      • /etc/sbrshd.conf
      • /usr/sbin/sbrshd
  • Construct an initrd file system from this - see below
    • Make sure you make a file system big enough for the untarred files....
  • Prepare & configure the tap0 bridge for the model - see below
  • Prepare the model networking script /etc/qemu-ifup - see below
  • Set up the VMware NFS to export
    • Scratchbox directories
    • A directory which can be mounted on the model to allow intercommunication of files
      - or you could make sure ftp is working between the VMware host & the model.
      - see below
  • [Set up (or turn off if you feel safe) any firewall on the VMware host - see below]
  • Start the model (TODO Fix sudo so we don't have to do this as root) - see below
  • Setup model ethernet, check and then start sbrshd - see below
  • Login to scratchbox and set up a target
    • sbrsh configuration requires that you have know the model ip
    • Check with the hello-world app
  • Enjoy

Where

Builds were performed on

WinXP/VMware

  • Intel Pentium 4 3GHz 1GB RAM
  • running WinXP SP2
  • running VMWare WorkStation 5.5.3 build 34685
  • running Linux version 2.6.9-5.EL (bhcompile@decompose.build.redhat.com) (gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)) #1 Wed Jan 5 19:22:18 EST 2005
  • running Scratchbox Apophis (core 1.0.7, toolchain arm-linux-2006q3-27)
  • sbrsh target qemu-linux-arm from qemu-0.9.0
  • running a VersatilePB image constructed from linux-2.6.19 sources patched and configured using downloads from ARM Linux Operating System Downloads. See above for additional kernel configuration data. Host toolset used was CodeSourcery arm-2006q3-27-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
  • running an initrd file system constructed from the packages downloaded from ARM Linux Operating System Downloads.

RedHat

  • Intel Pentium III 700KHz 256KB cache
  • running Linux version 2.4.20-8 (bhcompile@porky.devel.redhat.com) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #1 Thu Mar 13 17:54:28 EST 2003
  • running Scratchbox Apophis r2
  • sbrsh target qemu-linux-arm from qemu-0.9.0
  • running a VersatilePB image constructed from linux-2.6.19 sources patched and configured using downloads from ARM Linux Operating System Downloads. See above for additional kernel configuration data. Host toolset used was CodeSourcery arm-2006q3-27-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
  • running an initrd file system constructed from the packages downloaded from ARM Linux Operating System Downloads.
RedHat Network/Scratchbox Connection Details
The model was not bridged as described elsewhere on this page.
It was used with the default network setup (-net user -net nic) with the ports used by scratchbox redirected:
 
qemu-system-arm -M versatilepb -kernel model/2619vpb/zImage -append "console=ttyAMA0 mem=128M root=/dev/ram0" 
-initrd model/2619vpb/model.bin -nographic -redir tcp:2049::2049 -redir udp:2049::2049 -redir tcp:1202::1202

Useful Links

What

Speed

ncurses-5.4

Scratchbox Scratchbox Host Scratchbox Target Time (minutes)
Scratchbox Apohis r2 Linux version 2.4.20-8 (bhcompile@porky.devel.redhat.com) Pentium III 750MHz VersatilePB926EJS board 30
Scratchbox Apohis r2 Linux version 2.4.20-8 (bhcompile@porky.devel.redhat.com) Pentium III 750MHz qemu-system-arm 0.9 Versatile model 25
Scratchbox Apophis r4 Linux version 2.6.9-5.EL (bhcompile@decompose.build.redhat.com) on VMware 5.5.3 on WinXP Pentium 4 3GHz qemu-system-arm 0.9 Versatile model 15

Example Logs

YMMV

Constructing an initrd file system

You must be root, or running (for the complete sequence of operations) under fakeroot, or have sudo permission for these operations.
mkdir /tmp/initrd
dd if=/dev/zero of=2619vpb/model.img bs=1k count=16384
/sbin/mke2fs -F -v -m0 2619vpb/model.img
mount -o loop 2619vpb/model.img /tmp/initrd
tar -C /tmp/initrd -xvzf /mnt/hgfs/vmware_share/model.tgz
umount /tmp/initrd
gzip -9 < 2619vpb/model.img > 2619vpb/model.bin

Bridging The Host And Target Ethernets

Although the commands here turn off most, if not all, available timings the resulting bridge seems to have an initial delay (minutes) before it operates.
Whatever data is set up appears to be lost after a while (minutes), so that the next host/target interaction again delays.
Running continous both way pings may help.....
And set the scratchbox mounts to never expire.
[The /proc/sys/net/bridge writes are to ensure no packet filtering is done]
 
[root@localhost ppearse]# /usr/sbin/brctl addbr br0
[root@localhost ppearse]# /usr/sbin/brctl addif br0 eth0
[root@localhost ppearse]# /sbin/ifconfig eth0 0.0.0.0
[root@localhost ppearse]# /sbin/ifconfig br0 201.201.201.201
[root@localhost ppearse]# /usr/sbin/brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.000c29eda49b       no              eth0
      < Start model >
[root@localhost ppearse]# /usr/sbin/brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.000c298ae366       no              eth0
                                                        tap0
[root@localhost ppearse]#cd /proc/sys/net/bridge
[root@localhost bridge]#for f in bridge-nf-*; do cat $f; done
[root@localhost bridge]# /usr/sbin/brctl setfd br0 0
[root@localhost bridge]# /usr/sbin/brctl sethello br0 0
[root@localhost bridge]# /usr/sbin/brctl setpathcost br0 tap0 1
[root@localhost bridge]# /usr/sbin/brctl setpathcost br0 eth0 1
[root@localhost bridge]# /sbin/ifconfig
br0       Link encap:Ethernet  HWaddr 00:0C:29:8A:E3:66
          inet addr:201.201.201.201  Bcast:201.201.201.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe8a:e366/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:117785 errors:0 dropped:0 overruns:0 frame:0
          TX packets:133804 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:20554141 (19.6 MiB)  TX bytes:46235890 (44.0 MiB)

eth0      Link encap:Ethernet  HWaddr 00:0C:29:8A:E3:66
          inet6 addr: fe80::20c:29ff:fe8a:e366/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1221 errors:0 dropped:0 overruns:0 frame:0
          TX packets:94543 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:101356 (98.9 KiB)  TX bytes:30226707 (28.8 MiB)
          Interrupt:10 Base address:0x1400

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1164587 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1164587 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:100558770 (95.9 MiB)  TX bytes:100558770 (95.9 MiB)

tap0      Link encap:Ethernet  HWaddr 00:FF:A1:09:95:E1
          inet addr:201.201.201.202  Bcast:201.201.201.255  Mask:255.255.255.0
          inet6 addr: fe80::2ff:a1ff:fe09:95e1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:36257 errors:0 dropped:0 overruns:0 frame:0
          TX packets:42849 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:7011568 (6.6 MiB)  TX bytes:13618302 (12.9 MiB)
[root@localhost bridge]# /usr/sbin/brctl showstp br0
br0
 bridge id              8000.000c298ae366
 designated root        8000.000c298ae366
 root port                 0                    path cost                  0
 max age                  19.99                 bridge max age            19.99
 hello time                0.00                 bridge hello time          0.00
 forward delay             0.00                 bridge forward delay       0.00
 ageing time               0.00
 hello timer               0.00                 tcn timer                  0.00
 topology change timer     0.00                 gc timer                58074.97
 flags


eth0 (1)
 port id                8001                    state                forwarding
 designated root        8000.000c298ae366       path cost                  1
 designated bridge      8000.000c298ae366       message age timer          0.00
 designated port        8001                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.41
 flags                  CONFIG_PENDING

tap0 (2)
 port id                8002                    state                forwarding
 designated root        8000.000c298ae366       path cost                100
 designated bridge      8000.000c298ae366       message age timer          0.00
 designated port        8002                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.90
 flags                  CONFIG_PENDING

The qemu-system Network Script

Make the tap, then add it into the bridge
[root@localhost emulator]# cat /etc/qemu-ifup
#!/bin/sh
# TODO set up sudo - must run model as root at present
# sudo -p "Password for $0:" /sbin/ifconfig $1 172.20.0.1
/sbin/ifconfig $1 201.201.201.202
# Add into the pre-existing bridge
/usr/sbin/brctl addif br0 $1

Exporting the scratchbox directories from the VMware host to the target (the model)

File contents shown with cat. Note the additional directory, mountable by the model for communication.... Command restarts nfs using that file.
[root@localhost bridge]# cat /etc/exports
/exports/communication                                     201.201.201.0/255.255.255.0(async,insecure,no_auth_nlm,rw,no_root_squash)
/scratchbox/users/ppearse/targets/2006q3_model  201.201.201.0/255.255.255.0(async,insecure,no_auth_nlm,rw,no_root_squash)
/scratchbox/users/ppearse/home                         201.201.201.0/255.255.255.0(async,insecure,no_auth_nlm,rw,no_root_squash)
[root@localhost bridge]# /etc/init.d/nfs restart 

Stop the Vmware Host Firewall

This allows the scratchbox mounting on the model.
(TODO - Be secure; set up iptables correctly.) See also the /proc/sys/net/bridge writes.
[root@localhost bridge]# /etc/init.d/iptables status
Firewall is stopped.

Start the Model

Model pauses (max 120 seconds) at:
  • "input: AT Raw Set 2 keyboard as /class/input/input0"
  • "Configuring network interfaces... "
qemu-system-arm -M versatilepb -kernel images/2619vpb/zImage  -append "console=ttyAMA0 mem=128M root=/dev/ram0" -initrd images/2619vpb/model.bin -nographic -net nic -net tap
or with NFS
qemu-system-arm -M versatilepb -kernel zImage -append "console=ttyAMA0 mem=128M root=/dev/nfs nfsroot=10.1.77.36:/work/exports/exported_sb ip=dhcp"  -nographic -net nic -net tap

Set up the Model Ethernet and sbrshd

The model starts without an ethernet connection.
eth0 is configured, then tested with both way ping.
sbrshd is started with permanent mounting for the scratchbox directories.
~ # ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
~ # ifconfig eth0 201.201.201.222
eth0: link up
~ # ping 201.201.201.222
PING 201.201.201.222 (201.201.201.222): 56 data bytes
64 bytes from 201.201.201.222: icmp_seq=0 ttl=64 time=2.372 ms
64 bytes from 201.201.201.222: icmp_seq=1 ttl=64 time=1.518 ms
64 bytes from 201.201.201.222: icmp_seq=2 ttl=64 time=1.019 ms
--- 201.201.201.222 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 1.019/1.636/2.372/0.559 ms
~ # ping 201.201.201.201
PING 201.201.201.201 (201.201.201.201): 56 data bytes
64 bytes from 201.201.201.201: icmp_seq=0 ttl=64 time=2.636 ms
64 bytes from 201.201.201.201: icmp_seq=1 ttl=64 time=2.111 ms
64 bytes from 201.201.201.201: icmp_seq=2 ttl=64 time=1.344 ms
--- 201.201.201.201 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 1.344/2.030/2.636/0.531 ms
~ # export EXPIRATION=none
~ # /etc/init.d/initrd start
/verbatim>
<verbatim>
qemu-system-arm -M versatilepb -kernel images/2619vpb/zImage -initrd images/2619vpb/model.bin -nographic -net nic -net tap
</verbatim>

-- Main.PeterPearse - 28 Mar 2007
Topic revision: r14 - 23 Mar 2009 - 09:12:42 - JacobBramley
 
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback
This page took 3.68 joules of energy to render (zen4 : 1.47 secs : 4 sessions : 0.83 amps) More Info