Monday, January 25, 2010

VNC, Self-Powered USB Hub & Squid(?) for BeagleBoard




Once the Ethernet over USB between your System and BeagleBoard is established , it is time to see the BeagleBoard Desktop first hand.

Download and install some VNC utility(Virtual Network Client) TigerVNC in my case.

Launch VNC , and in the window in which it asks for address for VNC Server , enter the IP of BeagleBoard i.e. in our case 192.168.1.1  .

Since I still don't have a Powered USB Hub in place for hooking up keyboard or mouse, after connecting the BeagleBoard through VNC, I connect the DVI-D connector to the LCD Monitor.

This arrangement is as good as it gets :)

The only bottom side is that the connection hangs up once we try to transfer a large file.


ScreenShot of VNC on Fedora Desktop


My USB Hub Attempts

Wanting to connect keyboard and mouse to BeagleBoard, the first attempts to directly plug USB Optical Mouse didn't even power up the LED on the bottom of mouse, signifying the insufficient power being supplied to the Mouse.
To supply enough juice to the Mouse, I made a small PCB , in which the USB connection coming from the BeagleBoard is connected to USB wires of the device as follows:-

USB from BeagleBoard          USB of Device               Status of the connection

GND                                     GND                               Connected
D+                                        D+                                 Connected
D-                                          D-                                  Connected
Vcc                                       Vcc                                 Not Connected

[ The Vcc of the device is powered through external 5V, and the Vcc from BeagleBoard is left unconnected] 

But unfortunately this also does not seems to produce any results apart from displaying the message

Device Not enumerated

I can only speculate here that maybe, the high Speed USB Host is not enumerating the Low Speed USB Device ?



Using Squid to provide internet Connectivity to BeagleBoard(?)

Once the connection to Laptop through USB is established, I reasoned that if I could configure my Laptop as a proxy server for the BeagleBoard , then it would be possible to provide Internet connection to BeagleBoard through my Laptop. Thinking on these lines , I found Squid Proxy Server to be a tools to do just that. After investing a lot of time making change in the config file of Squid , Now it seems that Squid can't possibly do this sort of networking , since the Laptop and BeagleBoard are on a seperate network.
Sigh !!Sigh !!  , I do have to purchase a USB dongle .


..

Ethernet over USB-OTG for BeagleBoard

Once Beagleboard is up and running with Angstrom OS and a serial port connectivity , we next turn to get ethernet connectivity over the USB OTG cable.

You will need a USB Type-A to USB Type-A mini connector for this purpose.

Configuring in the BeagleBoard
After you have logged in as root, go to directory /lib/modules/2.6.29-omap1/kernel/drivers/usb/gadget .
In this you will find a driver named g_ether.ko. At this point of time issue command

root@beagleboard:/lib/modules/2.6.29-omap1/kernel/drivers/usb/gadget# lsmod
Module Size Used by
g_ether 29376 0
ircomm_tty 36148 0
ircomm 21292 1 ircomm_tty
irda 186816 2 ircomm_tty,ircomm
ipv6 275228 12

This will tell you the driver currently loaded. If you don't find the module g_ether in the above output, then you need to load this driver to enable Ethernet over USB OTG.

root@beagleboard:/lib/modules/2.6.29-omap1/kernel/drivers/usb/gadget# insmod g_ether.ko
[ 218.496032] g_ether gadget: using random self ethernet address
[ 218.503570] g_ether gadget: using random host ethernet address
[ 218.534881] usb0: MAC 26:25:a1:4e:cf:55
[ 218.565948] ADDRCONF(NETDEV_UP): usb0: link is not ready
[ 218.572082] usb0: HOST MAC ae:c2:3b:52:78:5a
[ 218.587066] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
[ 218.627716] g_ether gadget: g_ether ready
[ 218.632476] musb_hdrc musb_hdrc: MUSB HDRC host driver
[ 218.654815] musb_hdrc musb_hdrc: new USB bus registered, assigned bus number 2
[ 218.694671] usb usb2: configuration #1 chosen from 1 choice
[ 218.722137] hub 2-0:1.0: USB hub found
[ 218.739471] hub 2-0:1.0: 1 port detected

This will load the driver.

Now go back to root and configure the Ethernet connection of your BeagleBoard.
In the BeagleBoard Validation site it is adviced that the IP address be set to 192.168.1.1 and netmask be set to 255.255.255.0 , we do this here

root@beagleboard:/# ifconfig 192.168.1.1 netmask 255.255.255.0

Configuring Your System

[root@shubham shubham]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:19:B9:5F:09:A2
inet addr:10.2.36.221 Bcast:10.2.36.255 Mask:255.255.255.0
inet6 addr: fe80::219:b9ff:fe5f:9a2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:113982 errors:0 dropped:0 overruns:0 frame:0
TX packets:28358 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:35000144 (33.3 MiB) TX bytes:5238712 (4.9 MiB)
Interrupt:17

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:24 errors:0 dropped:0 overruns:0 frame:0
TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1520 (1.4 KiB) TX bytes:1520 (1.4 KiB)

wlan0 Link encap:Ethernet HWaddr 00:19:D2:BC:26:38
UP BROADCAST 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)

wmaster0 Link encap:UNSPEC HWaddr 00-19-D2-BC-26-38-A1-D1-00-00-00-00-00-00-00-00
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)

This will show you the network devices active, here we don't see a USB0(which will represent the connection to BeagleBoard )
Once you have configured the connection in BeagleBoard , then issue 'ifconfig' command , you will find one more device

usb0 Link encap:Ethernet HWaddr 4A:00:09:5E:78:15
inet6 addr: fe80::4800:9ff:fe5e:7815/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2056 (2.0 KiB) TX bytes:670 (670.0 b)

Now configure this device by the command

[root@shubham shubham]# ifconfig usb0 192.168.1.5 netmask 255.255.255.0

This will lead to an Ethernet over USB OTG being established, to test your connection ping any of the devices.

[root@shubham shubham]# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.536 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.482 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.479 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.354 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=0.355 ms
^C
--- 192.168.1.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4882ms
rtt min/avg/max/mdev = 0.354/0.441/0.536/0.074 ms

This checks that you connection is good.
You can send file to-and-fro BeagleBoard – your System using ssh command like :

[root@shubham shubham]# ssh test.txt root@192.168.1.1:




..

Serial Port Setup in BeagleBoard



[Italics shows the actual commands]

After the Memory Card has been formatted and Angstrom OS files loaded , it is time to configure the Serial Port connection to your Laptop.


We need Serial-to-USB Adapter like the one using PL-2303 from Prolific Inc. In latest Linux distribution the driver of PL-2303 is provided and is loaded automatically on detecting the device.
Also we need a 10 pin Flat Cable to connect to 10 pin box Serial connector on the BeagleBoard.
To connect the 10 pin Flat Cable to Serial-USB Adapter we made a small PCB.


The connection are as follows -
BeagleBoard                     Serial Port Connector
Pin No – 2(RxD)                Pin No - 3(TxD)
Pin No – 3 (TxD)               Pin No - 2(RxD)
Pin No – 5(Gnd)                Pin No - 5(Gnd)

The PCB for connecting 10-pin connector to DB9 and the powered USB device arrangement which didn't work :(






After connecting the USB connector of Serial-USB Adapter in your Laptop , it is time to configure the virtual serial port.


[root@shubham shubham]# dmesg
......
pl2303 ttyUSB1: pl2303 converter now disconnected from ttyUSB1
......


This will give a long output and among them try to find the line which has the mention of PL2303. This tells us that the name of serial device is ttyUSB1 .


Use a serial port utility like Minicom (you can install that on Fedora system using Yum )
Open the Serial Port Setup


[root@shubham shubham]# minicom -s


+-----[configuration]------+
| Filenames and paths    |
| File transfer protocols |
| Serial port setup          |
| Modem and dialing      |
| Screen and keyboard   |
| Save setup as dfl          |
| Save setup as..             |
| Exit                               |
| Exit from Minicom       |
     +--------------------------+


Select option Serial Port Setup by using cursor.


Change the name of Serial port device to represent /dev/ttyUSB1,which was found using dmesg command. Make the other setting of Baud Rate, number of bits, one error bit by setting it to 115200 8N1


+-----------------------------------------------------------------------+
| A - Serial Device : /dev/ttyUSB1                      |
| B - Lockfile Location : /var/lock                      |
| C - Callin Program :                                         |
| D - Callout Program :                                       |
| E - Bps/Par/Bits : 115200 8N1                         |
| F - Hardware Flow Control : No                     |
| G - Software Flow Control : No                       |
|                                                                           |
| Change which setting?                                     |
+-----------------------------------------------------------------------+


Save these settings and exit.
Now Launch the Minicom using


[root@shubham shubham]# minicom





Serial Connection to BeagleBoard




Now power up the BeagleBoard and you will see the Booting up:-



Notes :-

  1. We observed that USB OTG does not always supply sufficient power so if the booting fails again and again . Try using DC power using Barrel Connector. But make sure it is exactly 5V.


  2. An indication of BeagleBoard being booted properly is that LEDs USR0 and USR1 keeps glowing intermittently.

    ..


Thursday, January 14, 2010

Installation - Fedora 11, ffmpeg, OpenCV

Before starting with Computer Vision , I had to install OpenCV on my Laptop.
I decided to reformat my whole dual-boot OS , installing Vista after backing up my data was a straight deal. Then I installed Fedora - 11 on a different partition.
The slightly tricky thing in the otherwise simple Fedora installation is getting yum working. In my case I was able to connect to internet directly but on running
# yum list all
I continuously got error like
# [Errno 4] IOError : < urlopen error (111, 'Connection refused') >

after looking around a bit on forums and making changes in these files /etc/yum.repos.d/fedora.repo and /etc/yum.repos.d/fedora-updates.repo  as given here 
as well as changing the /etc/hosts file to include the extra mirror sites.
In my case I added the mirror site of IIT-K as it being the nearby server.
But the same error persisted, some more searching and a quick-fix to the problem was found. The problem being of yum being not able to access the servers through default proxy server, hence to just correct the proxy problem, we do
# export http_proxy=xxx.xxx.xx.xxx:8080

So this finally worked and Yum started to install. later I added the proxy setting in .bashrc file.


Now for OpenCV,  FFmpeg is to be installed before that. Since I had a new installation of Fedora , so first I installed gcc and gcc-c++ compiler through Yum , to be able to install FFmpeg & OpenCV. The process of installation of later is as follows(Courtsey: Gaganpreet)

[ the ftp is on IIIT's Intranet , so is not accessible outside]
A small modification is mentioned at the end of these instructions


wget ftp://10.3.3.52/ffmpeg.tar.bz2ftp://10.3.3.52/opencv-1.0.0.tar.gz
tar xvjf ffmpeg.tar.bz2
cd ffmpeg
mkdir /home/{ffmpeg,opencv}
./configure --prefix=/home/ffmpeg/ --enable-shared
make
make install
export LD_LIBRARY_PATH=/home/ffmpeg/lib

wget 
tar xvzf opencv-1.0.0.tar.gz
cd opencv-1.0.0/ 
 
./configure --prefix=/home/opencv CXXFLAGS=-fno-strict-aliasing 
CFLAGS=-I/home/ffmpeg/include/ CPPFLAGS=-I/home/ffmpeg/include/ LDFLAGS=-L/home/ffmpeg/lib/ 
 
make
 
I got an error at this point 
# ../../cxcore/include/cxmisc.h:133:6: error: #elif with no expression
to fix that goto the file /cxcore/include/cxmisc.h, line no 133  and
change the routine to [note the extra +/- sign and else statement added] 
 
#include 
#elif defined HAVE_ALLOCA
     #include 
-#elif
+#else
     #error
 #endif 
 
You will get errors like: cvcap_ffmpeg.cpp: cvcap_ffmpeg.cpp: error:
integer constant is too large for 'long' type etc.
For that do:

vim otherlibs/highgui/cvcap_ffmpeg.cpp

Add these two lines to the beginning:

#define INT64_C
#define __STDC_CONSTANT_MACROS

and change this line:
url_fclose(&mywriter->oc->pb);
to
url_fclose(mywriter->oc->pb);

make install


To compile a code now:
export LD_LIBRARY_PATH=/home/ffmpeg/lib:/home/opencv/lib    #You can
put this in ~/.bashrc
gcc code.c -lcv -lhighgui -I/home/opencv/include/
-I/home/ffmpeg/include/ -L/home/ffmpeg/lib/ -L/home/opencv/lib/


This will install FFmpeg and OpenCV in your Linux , enjoy :-)