Wink Saville’s Blog

April 19, 2008

linux - Excessive hard disk activity (or how to execute something while booting)

Filed under: linux — wink @ 11:01 am

A common problem encountered with laptop is that there is excessive activity due to the heads being loaded and unloaded frequently as described here. The solution for my HP zv5000 laptop was to use hdparm to disable advanced power management:

hdparm -B 255 /dev/sda

Since this needs to be performed every time the system boots you need to figure out a good place for the code. For Ubuntu I chose to add it to /sbin/setup.sh which is a script exectued by the The solution I used with Ubuntu was to add the above line to /sbin/setup.sh. In my case /sbin/setup.sh didn’t exist so I created it, be sure it’s executable.

When I changed my laptop to use Fedora I found the same problem, but Fedora doesn’t exectue /sbin/setup.sh instead I found the suggested mechanism was to add the code to file /etc/rc.d/rc.local.

March 16, 2008

scm - git svn connect

Filed under: linux, scm — wink @ 9:45 pm

The following allows you to reconnect a local clone of a remote svn repo assuming a git repo exists. In my case I have a backup of the remote svn repo but its a pure git repo without any git-svn meta data. Steven Walter provided the basic instructions here.

lcl ~/ $ git clone git://srv/amc.git amc
lcl ~/ $ cd amc
lcl ~/amc $ git svn init -s http://async-msgcomp.googlecode.com/svn
lcl ~/amc $ rm -rf .git/svn
lcl ~/amc $ cp .git/refs/remotes/origin/master .git/refs/remotes/trunk
lcl ~/amc $ git svn fetch

At this point a git svn rebase should indicated “Current branch mastger is up to date.”

March 10, 2008

Linking - How to link 32bit and 64bit x86 code into one image

Filed under: linux, programming — wink @ 11:05 pm

Learned something new from TJ over at Codegen today, he solved a problem where we needed to have 32bit code linked with 64bit code but the linker wouldn’t do it. Apparently this use to work without doing anything, but with the latest linker (ld) code it doesn’t. TJ figured out all that needed to be done was use objcopy to convert the 32bit format to 64bit format:

objcopy -O elf64-x86_64 32bit.o 64bit.o

One other noteworthy element to determine the output formats that objcopy supports use objcopy –info or objcopy –help

wink@ic2d1:$ objcopy --info
BFD header file version (GNU Binutils for Ubuntu) 2.18
elf64-x86-64
 (header little endian, data little endian)
  i386
elf32-i386
 (header little endian, data little endian)
  i386
a.out-i386-linux
 (header little endian, data little endian)
  i386
efi-app-ia32
 (header little endian, data little endian)
  i386
efi-app-x86_64
 (header little endian, data little endian)
  i386
elf64-little
 (header little endian, data little endian)
  i386
elf64-big
 (header big endian, data big endian)
  i386
elf32-little
 (header little endian, data little endian)
  i386
elf32-big
 (header big endian, data big endian)
  i386
srec
 (header endianness unknown, data endianness unknown)
  i386
symbolsrec
 (header endianness unknown, data endianness unknown)
  i386
tekhex
 (header endianness unknown, data endianness unknown)
  i386
binary
 (header endianness unknown, data endianness unknown)
  i386
ihex
 (header endianness unknown, data endianness unknown)
  i386

               elf64-x86-64 elf32-i386 a.out-i386-linux efi-app-ia32
          i386 elf64-x86-64 elf32-i386 a.out-i386-linux efi-app-ia32
               efi-app-x86_64 elf64-little elf64-big elf32-little elf32-big
          i386 efi-app-x86_64 elf64-little elf64-big elf32-little elf32-big
               srec symbolsrec tekhex binary ihex
          i386 srec symbolsrec tekhex binary ihex

March 7, 2008

make - need VPATH for non-local files if implicit rules are used

Filed under: linux, programming — wink @ 5:31 pm

Ran into a strange problem today, for some reason if a file isn’t in the current directory I need to have VPATH defined so that it points to the directory that contains the file(s) if the rule is implicit. For example, with the following structure where the Makefile is in a subdirectory below the location of the source file:

wink.c
x/Makefile

and the Makefile file is:cat x/Makefile is:

wink@ic2d1:$ cat x/Makefile
#VPATH=../
wink.o: ../wink.c
clean:
      rm *.o

If I now go into x and do a make –debug the we see the following:

wink@ic2d1:$ make --debug
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-pc-linux-gnu
Reading makefiles...
Updating goal targets....
 File `wink.o' does not exist.
Must remake target `wink.o'.
Successfully remade target file `wink.o'.
make: Nothing to be done for `wink.o'.

So it knows it needs to”remake target ‘wink.o’” but then says “Successfully remade …” but it didn’t, wink.o isn’t built. If I now enable VPATH and Makefile is:

wink@ic2d1:$ cat x/Makefile
VPATH=../
wink.o: ../wink.c
clean:
      rm *.o

Now make –debug does build wink.o and the output is:

wink@ic2d1:$ make --debug
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-pc-linux-gnu
Reading makefiles...
Updating goal targets....
 File `wink.o' does not exist.
Must remake target `wink.o'.
cc    -c -o wink.o ../wink.c
Successfully remade target file `wink.o'.

If you have an explicit rule everything works as expected as well:

wink@ic2d1:$ cat Makefile
#VPATH=../
wink.o: ../wink.c
	$(CC) $(CFLAGS) -c -o $@ $<
clean:
      rm *.o

Now make –debug also builds wink.o and the output is:

wink@ic2d1:$ make --debug
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-pc-linux-gnu
Reading makefiles...
Updating goal targets....
 File `wink.o' does not exist.
Must remake target `wink.o'.
cc    -c -o wink.o ../wink.c
Successfully remade target file `wink.o'.

Another solution is don’t use Gnu Make but use pmake. Of course if the makefile isn’t compatible with pmake then this won’t work. On Ubuntu install the bin86 package via synaptic or “apt-get install pmake”.

March 3, 2008

PXE - Booting via network cards

Filed under: linux, programming, pxe — wink @ 2:08 pm

To get PXE there are several resources on the web, here and here. The sources for pxelinux.0 is in syslinux. Anyway, here’s what I did; First, to use PXE you need to have a more capable DHCP server, so I switched to dhcpd3-server on my linux:

wink@saville-server:/etc/dhcp3$ cat my-dhcpd.conf
ddns-update-style interim;
option domain-name "saville.com";
option domain-name-servers 68.87.76.178, 66.240.49.9;
default-lease-time 600;max-lease-time 7200;

log-facility local7;
subnet 192.168.0.0 netmask 255.255.255.0 {
   range 192.168.0.100 192.168.0.149;
   option routers 192.168.0.2;
}

host test1 {
   hardware ethernet 00:1D:7D:00:A3:0B;
   fixed-address 192.168.0.148;
   option host-name "test1";
   filename "pxelinux.0";
   next-server 192.168.0.99;
}

The “host” section is the important part for PXE and in particular “hardware” identifies the card via its ethernet id, “filename” defines the file that will be requested and “next-server” defines the IP address of the server that will server the file to the “test1″ client via tftp.

So the next step was to get tftp working, I did the following but obviously synaptic works also:

apt-get install tftpd-hpa

I the config file for tftpd needs a little doctoring. The defaults is not running as a daemon and the directory is /var/log/tftpboot. You need it to run as a daemon and you may want to change the directory, here is what I have:

#Defaults for tftpd-hpa
RUN_DAEMON="yes"
OPTIONS="-l -s /tftpboot"

To start/test manually run “sudo /etc/init.d/tftpd-hpa start”. You should be able to see tftp using netstat:

wink@ic2d1:$ netstat netstat -apu
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 *:32769                 *:*                                -
udp        0      0 *:32772                 *:*                                -
udp        0      0 ic2d1.local:netbios-ns  *:*                                -
udp        0      0 *:netbios-ns            *:*                                -
udp        0      0 ic2d1.local:netbios-dgm *:*                                -
udp        0      0 *:netbios-dgm           *:*                                -
udp        0      0 *:946                   *:*                                -
udp        0      0 *:tftp                  *:*                                -       
udp        0      0 *:mdns                  *:*                                -
udp        0      0 *:sunrpc                *:*                                -
udp        0      0 ic2d1.local:ntp         *:*                                -
udp        0      0 localhost:ntp           *:*                                -
udp        0      0 *:ntp                   *:*                                -
udp6       0      0 fe80::217:31ff:fee1:ntp *:*                                -
udp6       0      0 ip6-localhost:ntp       *:*                                -
udp6       0      0 *:ntp                   *:*                                -

You should now be able to add files to the directory /tftpboot such as pxelinux.0.

February 17, 2008

git - applying patches

Filed under: linux, scm — wink @ 3:49 pm

Today learned some things about git and applying patches. First when applying my trec/ace/kshmem patches to 2.6.25-rc2 they wouldn’t apply because now there only an x86 architecture (arch/x86) instead of two architectures i386 and x86_64. That was to be expected actually and there’s going to be some hand work in doing that.

To do this hand work I really need to see what my current patches look like and there isn’t quite enough context in the patch file to do that, at least for me. So I cloned the current linux-2.6 tree into a new directory linux-2.6-x and did a checkout of 2.6.21-rc6 which is what my patches should apply against.

Well almost, there was still some need for a little tweaking; First git am will take my series of patches which were generated using git format-patch and apply them extracting from the email the commit message and the patch. It then creates a commit. But if there is a problem in a series only those that applied cleanly will be committed.

The first patch that fails won’t be applied at all, for example:

error: patch failed: mm/vmalloc.c:469
error: mm/vmalloc.c: patch does not apply
Patch failed at 0002.
When you have resolved this problem run "git-am --resolved".
If you would prefer to skip this patch, instead run "git-am --skip".

At this point I was scratching my head Patch failed at 0002 and when its resolved I can say so, but how to resolve it if its not been applied to the working tree. The solution is to use “git apply”:

git apply --reject --whitespace=fix my-patches/ace2-2.6.21-rc6/0002.patch

By using “git apply” with the –reject it will apply the patch leaving bad files with “xxx.rej” in my case mm/Kconfig.rej was the culprit. I resolved the problem with mm/Kconfig. Next I tried “git am –resolved”:

wink@ic2d1:$ git am --resolved
Applying ACE implementation, conifguration and makefile
No changes - did you forget to use 'git add'?
When you have resolved this problem run "git-am --resolved".
If you would prefer to skip this patch, instead run "git-am --skip"

More head scratching, “did you forget to use ‘git add’?” …. hm Ok so I then used “git gui” to add the files (BUT DID NOT DO A COMMIT) and then did “git am –resolved”:

wink@ic2d1:$ git am --resolved
Applying ACE implementation, conifguration and makefile
Applying ACE modifications to actually use ACE
.dotest/patch:32: trailing whitespace.
warning: 1 line adds whitespace errors.
Applying ACE simple test program
.dotest/patch:130: space before tab in indent.
result ? "true" : "false", i);
.dotest/patch:138: space before tab in indent.
result ? "true" : "false", i);
.dotest/patch:146: space before tab in indent.
result ? "true" : "false", i);
.dotest/patch:233: trailing whitespace.
warning: 4 lines add whitespace errors.

That did it, so no commit was necessary, the “git am –resolved” did the commit and then continued with the other patches. Lean something new everyday!

January 17, 2008

Connecting two Androids via TCP

Filed under: Android, linux, qemu — wink @ 4:02 pm

Below is an email which I sent to android-developers concerning how to  get two Androids talking to each other. This isn’t the solution, but is a path that might lead to a solution:

Hello,

I and it seems others would like to connect two Androids via TCP a previous
attempt failed with a segfault in the emulator. Digit and Alexey helped
resolve that, thanks.

I thought I’d report my progress and hopefully enlist some more
help. As I sad, my goal is to connect two Androids via TCP my path to a solution
is to allow the emulator(s) to appear on my local network by using a
bridge running in the host and having the qemu/Android use TUN/TAP
to connect to the bridge. This comes from http://compsoc.dur.ac.uk/~djw/qemu.html.

At the moment I have made some progress, I successfully bridged the
Android to my host as well as to the internet and was able to ping from
the Android console to my host and visa-versa. I also, was able to ping
an address on the internet, so progress was made.

Here is what I’ve done to get this far: (Note; this was done on Linux box, uname -a:
Linux ic2d1 2.6.22-14-generic #1 SMP Tue Dec 18 05:28:27 UTC 2007 x86_64 GNU/Linux)
This first series of steps only a single nic is needed, the second series I
tried using two nics.

1) Setup a bridge on my host.
a) Install bridge-utils
b) Besure TUN/TAP is configured in the kernel, the following
should print CONFIG_TUN=m or CONFIG_TUN=y
grep CONFIG_TUN= /boot/config-`uname -r`
c) You also need /dev/net/tun if it doesn’t exist then:
sudo mknod /dev/net/tun c 10 200
d) Create and initialize the bridge to your host ethernet
I created a script, br0, which creates the bridge,
attaches eth0, and then uses dhcp to get an address:

#!/bin/sh
set -x
# remove br0 if it exists
ifconfig br0 down
brctl delbr br0
# remove ip address from eth0
ifconfig eth0 0.0.0.0
# create a bridge
brctl addbr br0
# add eth0 to the bridge
brctl addif br0 eth0
# get br0 an address via dhcp
dhclient3 br0

Running br0 produces the following on my system:

wink@ic2d1:$ sudo ./br0
+ ifconfig br0 down
+ brctl delbr br0
+ ifconfig eth0 0.0.0.0
+ brctl addbr br0
+ brctl addif br0 eth0
+ dhclient3 br0
There is already a pid file /var/run/dhclient.pid with pid 13709
killed old client process, removed PID file
Internet Systems Consortium DHCP Client V3.0.5
Copyright 2004-2006 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

wmaster0: unknown hardware address type 801
wmaster0: unknown hardware address type 801
Listening on LPF/br0/00:17:31:e1:ce:a3
Sending on   LPF/br0/00:17:31:e1:ce:a3
Sending on   Socket/fallback
DHCPREQUEST on br0 to 255.255.255.255 port 67
DHCPREQUEST on br0 to 255.255.255.255 port 67
DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 8
DHCPOFFER from 192.168.0.2
DHCPREQUEST on br0 to 255.255.255.255 port 67
DHCPACK from 192.168.0.2
/etc/dhcp3/dhclient-exit-hooks.d/sendmail: line 28: /usr/share/sendmail/dynamic: No such file or directory
/etc/dhcp3/dhclient-exit-hooks.d/sendmail: line 31: update_interface: command not found
/etc/dhcp3/dhclient-exit-hooks.d/sendmail: line 40: update_host: command not found
/etc/dhcp3/dhclient-exit-hooks.d/sendmail: line 46: update_sendmail: command not found
bound to 192.168.0.133 — renewal in 36889 seconds.

Using brctl and ifconfig to show the configuration

wink@ic2d1:$ brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.001731e1cea3       no              eth0

wink@ic2d1:$ ifconfig
br0       Link encap:Ethernet  HWaddr 00:17:31:E1:CE:A3          inet addr:192.168.0.133  Bcast:192.168.0.255  Mask:255.255.255.0
inet6 addr: fe80::217:31ff:fee1:cea3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:121 errors:0 dropped:0 overruns:0 frame:0
TX packets:120 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:35187 (34.3 KB)  TX bytes:15917 (15.5 KB)

eth0      Link encap:Ethernet  HWaddr 00:17:31:E1:CE:A3          inet6 addr: fe80::217:31ff:fee1:cea3/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
RX packets:10125 errors:0 dropped:0 overruns:0 frame:0
TX packets:7850 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5589385 (5.3 MB)  TX bytes:842531 (822.7 KB)
Interrupt:19

And I can still ping, so my host is OK:

wink@ic2d1:$ ping google.com
PING google.com (72.14.207.99) 56(84) bytes of data.
64 bytes from eh-in-f99.google.com (72.14.207.99): icmp_seq=2 ttl=241 time=86.9 ms
64 bytes from eh-in-f99.google.com (72.14.207.99): icmp_seq=4 ttl=241 time=92.8 ms
64 bytes from eh-in-f99.google.com (72.14.207.99): icmp_seq=5 ttl=241 time=89.4 ms
64 bytes from eh-in-f99.google.com (72.14.207.99): icmp_seq=6 ttl=241 time=96.6 ms
64 bytes from eh-in-f99.google.com (72.14.207.99): icmp_seq=7 ttl=241 time=97.8 ms

— google.com ping statistics —
8 packets transmitted, 5 received, 37% packet loss, time 7016ms
rtt min/avg/max/mdev = 86.995/92.746/97.814/4.125 ms

2) Qemu needs to connect to the TUN/TAP and it uses a
script, which by default is /etc/qemu-ifup. For these tests
I ran as root (sudo -s) as permissions are correct
but thats a problem for later

Here is /etc/qemu-ifup:

#!/bin/sh
echo Executing /etc/qemu-ifup
echo Bringing up $1 for bridged mode…
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
echo Adding $1 to br0…
sudo /usr/sbin/brctl addif br0 $1
echo Sleep a couple of secs
sleep 2
echo Complete /et/qemu-ifup

3) Execute the emulator (as root), this is the simplest set of qemu parameters
I could find that allowed the Android onto the local network and out to
the internet. NOTE: with this configuration there is only one nic, eth0.
I understand I should use two nics, see second series, but this is initially
sufficient to do something useful although adb and dns don’t work
maybe because it’s not at the expected ports/addresses

On host (as root) execute the emulator with qemu parameters:

emulator -console -qemu -net user -net nic,vlan=0 -net tap,vlan=0,ifname=tap0

From emulator console see that there is only one smc device:

# /data/busybox/ls -ld /sys/devices/platform/smc*
drwxr-xr-x    3 0        0               0 Jan 17 21:45 /sys/devices/platform/smc91x.0
#

An interesting point is that adb is working at the moment, maybe
because tap0 isn’t being used(?)

wink@ic2d1:$ adb devices
List of devices attached
1       emulator-tcp-5555       device  0

wink@ic2d1:$ adb shell
# exit
wink@ic2d1:$

4) To connect to my host’s network I then executed the following
from the Android console prompt:

ifconfig eth0 down
ifconfig eth0 192.168.0.213 up
route add default gw 192.168.0.2 dev eth0

5) ping the gateway from Android:

# ping -c 1 192.168.0.2
PING 192.168.0.2 (192.168.0.2) 56(84) bytes of data.
64 bytes from 192.168.0.2: icmp_seq=1 ttl=64 time=13.4 ms

— 192.168.0.2 ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 13.400/13.400/13.400/0.000 ms

6) ping google.com (note dns doesn’t work so use address):

# ping -c 1 72.14.207.99
PING 72.14.207.99 (72.14.207.99) 56(84) bytes of data.
64 bytes from 72.14.207.99: icmp_seq=1 ttl=241 time=87.8 ms

— 72.14.207.99 ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 87.882/87.882/87.882/0.000 ms

7) From the host ping the Android:

wink@ic2d1:$ ping -c 1 192.168.0.213
PING 192.168.0.213 (192.168.0.213) 56(84) bytes of data.
64 bytes from 192.168.0.213: icmp_seq=1 ttl=64 time=0.532 ms

— 192.168.0.213 ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.532/0.532/0.532/0.000 ms

8) Finally, although adb can see the emulator the shell hangs

wink@ic2d1:$ adb devices
List of devices attached
1       emulator-tcp-5555       device  0

wink@ic2d1:$ adb shell
<- Used CTRL-C to break out
wink@ic2d1:$

============================
Second series trying to use two nics but can’t
get packets though to the host, I’m doing
something wrong!
============================

1) Now we’ll execute with two nic’s

emulator -console -qemu -net user -net nic -net nic,vlan=1 -net tap,vlan=1,ifname=tap0

2) Verify there are two smc devices:

# /data/busybox/ls -ld /sys/devices/platform/smc*
drwxr-xr-x    3 0        0               0 Jan 17 21:45 /sys/devices/platform/smc91x.0
drwxr-xr-x    3 0        0               0 Jan 17 21:45 /sys/devices/platform/smc91x.1
#

3) Bring up eth1 and ping it

# ifconfig eth1 192.168.0.213 up
# netcfg
gre0     DOWN  0.0.0.0         0.0.0.0         0×00000080
tunl0    DOWN  0.0.0.0         0.0.0.0         0×00000080
eth1     UP    192.168.0.213   255.255.255.0   0×00001043
eth0     UP    10.0.2.15       255.255.255.0   0×00001043
lo       UP    127.0.0.1       255.0.0.0       0×00000049
#
# ping -c 1 192.168.0.213
PING 192.168.0.213 (192.168.0.213) 56(84) bytes of data.
64 bytes from 192.168.0.213: icmp_seq=1 ttl=64 time=1.15 ms

— 192.168.0.213 ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.157/1.157/1.157/0.000 ms
#
# /dev/busybox/ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:57          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:790 (790.0 B)  TX bytes:0 (0.0 B)
Interrupt:13 DMA chan:ff

eth1      Link encap:Ethernet  HWaddr 52:54:00:12:34:56          inet addr:192.168.0.213  Bcast:192.168.0.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  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:1000
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
Interrupt:12 Base address:0×2000 DMA chan:ff

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)

But I can’t get packets routed though eth1 to host

# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.2.0        *               255.255.255.0   U     0      0        0 eth0
192.168.0.0     *               255.255.255.0   U     0      0        0 eth1
default         10.0.2.2        0.0.0.0         UG    0      0        0 eth0
# route del default
# route add default gw 192.168.0.2 dev eth1
# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.2.0        *               255.255.255.0   U     0      0        0 eth0
192.168.0.0     *               255.255.255.0   U     0      0        0 eth1
default         192.168.0.2     0.0.0.0         UG    0      0        0 eth1
# ping -c 1 192.168.0.213
PING 192.168.0.213 (192.168.0.213): 56 data bytes
64 bytes from 192.168.0.213: seq=0 ttl=64 time=3.281 ms

— 192.168.0.213 ping statistics —
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 3.281/3.281/3.281 ms
# ping -c 1 192.168.0.2
PING 192.168.0.2 (192.168.0.2): 56 data bytes

— 192.168.0.2 ping statistics —
1 packets transmitted, 0 packets received, 100% packet loss

I’m guessing the problem might have to do that tap0 seems
to be connected to eth0 not eth1 as mac connected to the
bridge seems to be from eth0. Doing the following after
running the 2 nic configuration:

# export PATH=/data/busybox:$PATH
# ifconfig eth1 192.168.0.213 netmask 255.255.255.0 up
# route del default
# route add default 192.168.0.2 dev eth1
# ping -c 1 192.168.0.213

Then on the host,  look at the macs connected to the bridge:

wink@ic2d1:$ brctl showmacs br0
port no mac addr                is local?       ageing timer
1     00:16:b6:81:90:ce       no                 2.29
1     00:17:31:e1:ce:a3       yes                0.00
2     00:ff:45:7f:1d:62       yes                0.00
2     52:54:00:12:34:57       no                 0.06

We see from the ifconfig the mac addr (52:53:00:12:34:57) is from eth0
I would have expected we want it from eth1(52:54:00:12:34:56). It’s
also interesting that eth0 has mac addr :57 which is what I’d expect
eth1 to have. When running the emulator with no parameters the
mac addr for eth0 is :56.

# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:57          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:36 errors:0 dropped:0 overruns:0 frame:0
TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9762 (9.5 KiB)  TX bytes:630 (630.0 B)
Interrupt:13 DMA chan:ff

eth1      Link encap:Ethernet  HWaddr 52:54:00:12:34:56          inet addr:192.168.0.213  Bcast:192.168.0.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:320 (320.0 B)  TX bytes:126 (126.0 B)
Interrupt:12 Base address:0×2000 DMA chan:ff

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:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:544 (544.0 B)  TX bytes:544 (544.0 B)

============================

Anyway, if you got to here thanks all the more:)
If you have any suggestions they would be appreciated.

Wink Saville

December 15, 2007

Eclipse - install

Filed under: Android, Eclipse, linux, programming — wink @ 3:37 pm

To install Eclipse you need to install sun-java, the gcj version installed in Ubuntu 7.10 isn’t capable of fully supporting Eclipse. What I did was install sun-java-6-* via synaptic, but of course its not that simple.

I installed all of the sun-java6-* files via synaptic, of course that didn’t install flawlessly as you need to download jdk-6-doc.zip from here selecting download for “Java SE 6 Documentation” which was here (you need to “Accept the license agreement”) and place it in /tmp/. Next I downloaded Eclipse from here and untar’d it into /usr. I then setup a symbolic link from /usr/local/bin/eclipse to /usr/eclipse/eclipse, the I ran ecplise. It boots but said “Error creating the view”. I did a little searching, turns out had the wrong jvm. I needed to uninstall java-gc-compat and create a symbolic link from /etc/alternatives/java to /usr/lib/jvm/java-6-sun/bin/java. Then it finally ran!

The short list of instructions:

*) Download Eclipse I chose “Eclipse Classic 3.3.1.1″.
*) Download jdk-6-doc.zip and place in /tmp/
*) Uninstall java-gcj-compat via synaptic or apt
*) Install all sun-java-6-* via synaptic or apt
*) Besure there is a symbolic link from /etc/alternatives/java -> /usr/lib/jvm/java-6-sun/bin/java

sudo ln -sf /usr/lib/jvm/java-6-sun/bin/java /etc/alternatives/java

*) Untar Eclipse into /usr (creates /usr/eclipse/)

cd /usr
sudo tar -xvf ~/downloads/eclipse-SDK-3.3.1.1-linux-gtk-x86_64.tar.gz

You should now be able to run eclipse and the Welcome screen should appear, if you drop right into Eclipse and a warning that you couldn’t create a view then you’re executing the wrong jvm. Start by using the comand:

wink@ic2d1:$ which java
/usr/bin/java
wink@ic2d1:$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2007-12-04 09:55 /usr/bin/java -> /etc/alternatives/java
wink@ic2d1:$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 32 2007-12-04 20:59 /etc/alternatives/java -> /usr/lib/jvm/java-6-sun/bin/java
wink@ic2d1:$ ls -l /usr/lib/jvm/java-6-sun/bin/java
lrwxrwxrwx 1 root root 15 2007-12-04 17:53 /usr/lib/jvm/java-6-sun/bin/java -> ../jre/bin/java
wink@ic2d1:$ ls -l /usr/lib/jvm/java-6-sun/jre/bin/java
-rwxr-xr-x 1 root root 50650 2007-09-24 23:34 /usr/lib/jvm/java-6-sun/jre/bin/java

As you can see on my machine there are several links before getting to the actual executable.

December 13, 2007

scm - Build ID’s

Filed under: linux, programming, scm — wink @ 10:21 pm

A BuildID is being added to the gnu linker, ld, by Roland McGrath. I saw this mentioned in these instructions for building the Android kernel from source, which didn’t support the new switch and it had to be disabled.

Anyway, Roland had a problem where he wanted to identify exactly where the binaries came from when inspecting a post-mortem dump. Especially when the dump could have happened long after the build was actually done. While at nxp we had this problem and generally relied upon the svn release number. That worked but isn’t actually unique enough especially when a particular build might be one by a developer and not an official release.

Anyway, this looks to be a possible solution

Linux - nfs mounting

Filed under: linux — wink @ 7:06 pm

I had a little trouble doing an nfs mount today. I wanted to mount a directory on my laptop onto my desktop so I could do some backups. I modified /etc/exports on my laptop, which has successfully exported nfs mount file systems for a long time, by having /etc/exports be:

/home/wink *:(rw,no_root_squash,no_all_squash,sync,nohide)

Then on my destop I did:

mkdir mntdir
sudo mount 192.168.0.1:/home/wink mntdir

But this didn’t work it generated an error saying I was stupid:)  After trying a bunch of permutations I did some google searching and found this. Turns out that on my desktop I didn’t have portmap or nfs-common installed. After installing them all was well, and the above mount worked.

Newer Posts »

Powered by WordPress