** Wed Sep 5 20:57:12 MDT 2007 ** ---------------------------------------- How to get the RooStick USB->Serial device working: -------------------- Excerpt: http://todbot.com/blog/2006/05/26/roombadevtools-roostick/ The RooStick is a USB-to-Serial adapter with a Mini DIN 7-pin socket on it that matches the SCI connector on the Roomba. It is an unencased circuit board with a USB connector soldered on one end and the Mini DIN on the other. The circuit consists of a CP2103 USB-to-UART chip and a couple of LEDs. While RoombaDevTools doesnÕt advertise it because they are focusing on the Windows crowd, the CP2103 has drivers for other OSes. You have to hunt around the Silicon Labs site, but under the USB-to-UART Virtual COM Port (VCP) drivers page you can find drivers for all the other OSes. Of course, like all USB-to-serial drivers, they require a reboot. [update: The SiLabs site doesnÕt have a link to Linux drivers because the driver is already in the Linux kernel. ItÕs called Òcp2101? and should auto-load if you have USB hotplug correctly configured (like Ubuntu does)] -------------------- GNU/Linux (Ubuntu 7.04) Plugged in RooStick to USB port, and dmesg reads: [86202.740000] usbcore: registered new interface driver usbserial [86202.744000] drivers/usb/serial/usb-serial.c: USB Serial support registered for generic [86202.744000] usbcore: registered new interface driver usbserial_generic [86202.744000] drivers/usb/serial/usb-serial.c: USB Serial Driver core [86202.784000] drivers/usb/serial/usb-serial.c: USB Serial support registered for cp2101 [86202.788000] cp2101 1-2:1.0: cp2101 converter detected So it was automatically detected, and driver installed. In an xterm, set device setting with: stty -F /dev/ttyUSB0 57600 raw -parenb -parodd cs8 -hupcl -cstopb clocal And test commands to drive (though need to pick it up to stop it due to cable length): printf "\x80" > /dev/ttyUSB0 printf "\x82" > /dev/ttyUSB0 printf "\x89\x00\xc8\x80\x00" > /dev/ttyUSB0 Worked, but I had to send the last line a few times before it seemed to take. Maybe the sequence got messed up and it took a while to coordinate what the first byte was. -------------------- Mac OSX 10.3 First needed to download and install the USB driver: https://www.mysilabs.com/public/documents/software_doc/drivers/Microcontrollers/Interface/en/Mac_OSX_VCP_Driver.zip Needed to restart. Device now shows up as: /dev/cu.SLAB_USBtoUART /dev/tty.SLAB_USBtoUART Next, needed to get and unzip RoombaComm java library in src/roombacom. Needed to initialize something with respect to the rxtxlib that java code calls out to. % ./rxtxlib/macosx_setup.command Also needed to restart after this. Power on manually roomba, then run this: % sh runit.sh roombacomm.SimpleTest /dev/cu.SLAB_USBtoUART And it worked. ---------------------------------------- How to get the RooTooth Bluetooth->Serial device working: Plugged in RooTooth to Roomba, but problem trying to connect to Mac OSX because my version 10.3.9 does not allow non-numeric bluetooth passkeys and the passkey on the RooTooth is 'default'. I read that the iStumbler program would all doing this, but I downloaded and installed and the Bluetooth plugin did not show up. Make the modem command 'ATSP' allows setting the password to a non-numeric key, but I don't know how to do that. ATSP,, Set Personal Identification Number (PIN) Set PIN, Max alphanumeric characters (16) includes spaces (CAPS sensitive). WARNING: Be careful when entering a new PIN. There is no way to obtain PIN status after it is changed. EXAMPLE: Change PIN from default to 1234567890123456 TYPE : ATSP,1234567890123456,default REPLY: OK I got a newer mac, connectd with rootooth 'default' passkey, installed zterm, set terminal to 9600 baud, 8n1 and then issued the command: ATSP,12345678,default and this seemed to work to change the passkey to a numeric one. Next issue was setting up the serial port in OSX panther. I found this: RE: ÔThere is another issue with panter. After I changed the key I tried to setup the serial port. But under panter the required button is missing.Õ In step 6 above, Panther does not allow you to Òedit serial portsÓ so you can access the ÒBluetooth Serial UtilityÓ found in your Ò/Applications/UtilitiesÓ folder. You can then select ÒnewÓ and set up your serial port. Select your BlueRadio device and click ÒeditÓ then set your Òport typeÓ to RS-232? ---------------------------------------- WiPort Config First thing I did was connect to adhoc wifi network LTRX_IBSS, then did a broadcast ping to foind the IP of the WiPort device: ping 169.254.255.255 Then telnet to the device: telnet 169.254.x.x 9999 Then enter to enter setup mode. I first configured it to join SSID: sparky02 at 192.168.202.0, but now moving it to the normal 192.168.200.0 network. When moved to 192.168.200.0 network, it would not work without enabling ssid broadcast. I did also have to add its MAC address into the MAC filter list: 00:20:4A:89:88:68 I set it to have the static IP 192.168.200.222 The used the PHP web page to control it: roombacmd.php ---------------------------------------- Installing GNU/Linux on Linksys WRTSL54GS Get openwrt firmware for router/AP: http://downloads.x-wrt.org/xwrt/firmware_images/whiterussian/0.9/latest-daily-build/default/openwrt-wrtsl54gs-squashfs.bin http://downloads.x-wrt.org/xwrt/firmware_images/whiterussian/0.9/latest-daily-build/default/openwrt-brcm-2.4-squashfs.trx NOTE: Version without web interface can be found at openwrt.org, but has exactly the same name, so I added x-wrt to the file name I downloaded. Powered on router/AP Connected Ubuntu (penguin) machine to wired port Visit web interface at 192.168.1.1 with: username: admin password: admin Go to menu choice: Administration->Firmware Upgrade Browse to: proj/roomba/downloads/openwrt-wrtsl54gs-2.4-squashfs.x-wrt.org.bin Click upgrade button and wait. When upgraded, telnet: # telnet 192.168.1.1 Set root password with 'passwd' to disable telnet and enable ssh. Connected WAN side to regular main wireless router hooked to cable modem so we can gte external access to update the package manager. Updated the package management stuff: # ipkg update Changed via web console settings to make this a client instead of an router/AP: hostname: sparky01 timezone: mountain NTP server: pool.ntp.org # after install NTP client via button WAN config: disabled/none LAN IP: 192.168.200.200 LAN gateway: 192.168.200.1 LAN DNS: 192.168.200.1 Wireless channel: auto Wireless Mode: client Wireless broadcast: off Wireless SSID: boulder-g Wireless Encryption: WEP WEP Key 1: Review and apply web console changes. Reconfigure network cables so a LAN port goes to LAN port on main wireless router network. NOTE: I had to manually tweak /tmp/resolv.conf ---------------------------------------- To get USB drive to work: ipkg install kmod-usb-core ipkg install kmod-usb2 ipkg install kmod-usb-storage ipkg install kmod-vfat (kamikaze name: kmod-fs-vfat, where kmod-nls-base is a dep.) With whiterussian: insmod scsi_mod insmod sd_mod insmod sg insmod fat insmod vfat insmod usbcore insmod usb-storage Insert USB stick: # mkdir /usbdrive # mount /dev/scsi/host0/bus0/target0/lun0/part1 /usbdrive # df -h Check it out: Filesystem Size Used Available Use% Mounted on /dev/scsi/host0/bus0/target0/lun0/part1 967.7M 3.0M 964.7M 0% /usbdrive ---------------------------------------- To add camera: NOTE: kamikaze didn't work, had to use whiterussian, presumably because the spca5xx_lite module was built for 2.4 kernel white kamikaze has 2.6 Following Roomba hacking book directions (with some module name chanes that seemed to happen, mostly having to add kmod to package name): # ipkg install kmod-videodev # wget 'http://roombahacking.com/software/openwrt/spca5xx_lite.o.gz' # gunzip spca5xx_lite.o.gz # cp spca5xx_lite.o /lib/modules/`uname -r` # echo "spca5xx_lite" > /etc/modules.d/70-spca5xx_lite # insmod videodev # insmod spca5xx_lite # echo "videodev" >> /etc/modules.d/70-videodev # echo "spca5xx_lite" >> /etc/modules.d/75-spca5xx_lite Plugged in the camera and got: # dmesg hub.c: new USB device 01:02.2-1.4, assigned address 4 spca_core.c: USB SPCA5XX camera found. Type Creative Instant P0620 Note that the camera is a creative model VF-0040 with usb IDS: vendor=0x041e product=0x4034 Note that this page has some direct info about the spca5xx driver: http://mxhaard.free.fr/spca5le.html ---------------------------------------- Using camera tools Get utils: http://roombahacking.com/software/openwrt/spcacat.gz Copy to router: # scp spcacat.gz root@192.168.200.201:/tmp Install on router: # gunzip spcacat.gz # chmod +x spcacat # cp spcacat /usr/bin # ipkg install libpthread # ipkg install libgcc # ipkg install libusb # ipkg install lsusb # ipkg install kmod-usb2 # ipkg install kmod-usb-ohci # ipkg install kmod-usb-core # ln -s /dev/v4l/video0 /dev/video0 This will take a snapshot each second and put it in the file SpcaPict.jpg: # spcacat -d /dev/video0 -g -f jpg -p 1000 -o A problem I have now is that the camera works if hooked directly up to the router, but spcacat cannot open the devide if it is conected to the 4 port hub. ---------------------------------------- Wireless client setup I couldn't see to set it from the web interface. Setup Wireless Interface Similarly, the wireless interface (eth1) can be configured: nvram set wifi_ifname=eth1 nvram set wifi_proto=static nvram set wifi_ipaddr=10.60.68.234 nvram set wifi_netmask=255.255.255.252 nvram set wifi_gateway=10.60.68.233 nvram set wifi_dns=10.60.68.233 ---------------------------------------- Switching regulator can replace 7805 http://www.dimensionengineering.com/DE-SW050.htm ---------------------------------------- building firmware and prep for adding modules and developmnent: # ipkg install kmod-usb-serial RooStick uses CP2103 chip which works with the cp2101 USB serial driver vendor=0x10c4 product=ea60 Here's the backport of the cp210x driver for 2.4 kernels: cp210x_v0.10_2.4-backport.patch from http://www.microtron.org.uk/~craig/Projects/CP2101Driver/ Also got patch 2.6 kernel in case I need that. -------------------- These are the whiterussian/linux-2.4 specific instructions for building the cp210x USB serial module that the roostick uses. This is the command to patch a kernel from the top-level kernel source: # Patch the kernel and enable as loadable module: # $ cd ~/proj/openwrt/buildroot/whiterussian/openwrt/build_mipsel/linux-2.4-brcm/linux-2.4.30 $ patch -p1 < ~/proj/openwrt/extra-source/cp210x_v0.10_2.4-backport.patch patching file Documentation/Configure.help Hunk #1 succeeded at 15593 (offset 96 lines). patching file drivers/usb/serial/Config.in patching file drivers/usb/serial/cp210x.c patching file drivers/usb/serial/Makefile $ make menuconfig # # # This leads to the kernel config var: CONFIG_USB_SERIAL_CP210X=m $ cp .config ../../../target/linux/linux-2.4/config/brcm # Prepare for openwrt config stuff: # $ cd ~/proj/openwrt/buildroot/whiterussian/openwrt/ # Add this to target/linux/Config.in # # config BR2_PACKAGE_KMOD_USB_SERIAL_CP210X # tristate "Support for CP210X USB-to-serial converter" # default m # depends BR2_PACKAGE_KMOD_USB_SERIAL # Add this to target/linux/linux-2.4/Makefile # # # $(eval $(call KMOD_template,USB_SERIAL_CP210X,usb-serial-cp210x,\ # $(MODULES_DIR)/kernel/drivers/usb/serial/cp210x.o \ # ,CONFIG_USB_SERIAL_CP210X,kmod-usb-serial,61,cp210x)) # Create target/linux/control/kmod-usb-cp210x.control with content: # # Package: kmod-usb-serial-cp210x # Priority: optional # Section: sys # Maintainer: Tony Cassandra # Source: buildroot internal # Description: Kernel Support for USB Serial Devices CP210X # make sure it shows up in menuconfig under kernal config and is a module: # $ make menuconfig # Rebuild: # $ make dirclean && make Yuck, the 'dirclean' wiped out the patch to the kernel. Repatching, kernel menuconfig again, then just openwrt 'make' without a dirclean, but still the module is not getting compiled. arc@penguin openwrt $ find . -name "*belkin*" ./bin/packages/kmod-usb-serial-belkin_2.4.30-brcm-5_mipsel.ipk ./target/linux/control/.svn/text-base/kmod-usb-serial-belkin.control.svn-base ./target/linux/control/kmod-usb-serial-belkin.control ./build_mipsel/linux-2.4-brcm/modules/lib/modules/2.4.30/kernel/drivers/usb/serial/belkin_sa.o ./build_mipsel/linux-2.4-brcm/linux-modules/ipkg/usb-serial-belkin ./build_mipsel/linux-2.4-brcm/linux-modules/ipkg/usb-serial-belkin/etc/modules.d/61-usb-serial-belkin ./build_mipsel/linux-2.4-brcm/linux-modules/ipkg/usb-serial-belkin/lib/modules/2.4.30/belkin_sa.o ./build_mipsel/linux-2.4-brcm/linux-2.4.30/include/config/usb/serial/belkin.h ./build_mipsel/linux-2.4-brcm/linux-2.4.30/include/config/usb/serial/belkin ./build_mipsel/linux-2.4-brcm/linux-2.4.30/drivers/usb/serial/belkin_sa.c ./build_mipsel/linux-2.4-brcm/linux-2.4.30/drivers/usb/serial/belkin_sa.o ./build_mipsel/linux-2.4-brcm/linux-2.4.30/drivers/usb/serial/belkin_sa.h -------------------- For doing this in kamikaze # Add this to the file: package/kernel/modules/usb.mk # define KernelPackage/usb-serial-cp210x $(call usbdep,kmod-usb-serial) TITLE:=Support for CP210X usb-to-serial devices KCONFIG:=CONFIG_USB_SERIAL_CP210X FILES:=$(LINUX_DIR)/drivers/usb/serial/cp210x.$(LINUX_KMOD_SUFFIX) AUTOLOAD:=$(call AutoLoad,65,cp210x) endef define KernelPackage/usb-serial-cp210x/description Kernel support for CP210X USB-to-Serial converters endef $(eval $(call KernelPackage,usb-serial-cp210x)) zzzz # make gspcav1 "Generic Softwares Package for Camera Adapters" version 1.00.18 date: 08/05/2007 for kernel up from 2.6.11 : gspcav1-20070508.tar.gz for kernel below 2.6.11: spca5xx version 0.60.00-1: spca5xx-v4l1goodbye.tar.gz zzzzzzzz Hello, The module you need is found in kernel/drivers/usb/serial/cp2101. Kernel 2.6.17 was the first to include the device id for the Pololu USB Serial Adapter, so your options are to either upgrade to the latest kernel or add our device id to the table in cp2101.c. Specifically, you need to put Code: { USB_DEVICE(0x10C4, 0x803B) }, /* Pololu USB-serial converter */ in the usb_device_id id_table. Recompile that module and the device should automatically be recognized. zzzzzzz zzzzzzzz http://forum.sparkfun.com/viewtopic.php?=&p=26786 The beta Linux source package is available on our ftp site: ftp://ftp.silabs.com user : cp210x_linux password : linuxdriver The Linux source package contains the complete source code for the CP210x Linux VCP drivers. This code can be compiled for various Linux 2.4.x kernel versions without "tainting" the Linux kernel. The zip file contains source files, Makefile and driver load scripts, a Readme with instructions, and a tar file that contains the driver binary files. To use the CP210x on Linux: 1) gunzip the files 2) untar the files 3) load the driver (using "load_mcci_usb" on an account with administrative privileges) 4) the CP210x has to be plugged in for "mcci_x" to appear in /proc 5) the command "cat /proc/mcci_x" lists the device, which should look like ttyUSB# 6) set the serial port device in the appropriate application to "/dev/ttyUSB#" ---------------------------------------- Good tutorial on writing serial applications (C) http://www.faqs.org/docs/Linux-mini/IO-Port-Programming.html http://www.easysw.com/~mike/serial/ ---------------------------------------- To reflash firmware from existing openwrt: # wget http://downloads.x-wrt.org/xwrt/kamikaze/7.07/brcm-2.4/openwrt-brcm-2.4-squashfs.trx # scp openwrt-brcm-2.4-squashfs.trx root@192.168.201:/tmp # mtd -r write /tmp/openwrt-brcm-2.4-squashfs.trx linux ---------------------------------------- De-bricking: I compiled two successful versions of kamakaize, and flashed the RAM. Then, attempting to get more modules compiled for it, I made an image that, when flashed, very shortly abort the flash, leaving me with a bricked router. Thinking maybe this was a glitch, and not a bad image, I (ill-advisedly) tried it on the other router, proving it was abad image. Left with two bricked routers, and trying all sorts of combinaions of tft and reset button did nothing for me. Last resort was to make an unbuffered JTAG cable and try the HairDairyMaid's debrick utility. First attempt would not work, and then found out the 25-port parallel port connector alternates the wires 1-13 and 14-25....I mistakenly assumedn they would be in numeric order. In trying to remove the JTAG cable from the router, I pulled up the PCB wire, which I think means this router is completely hosed up. Trying on the other router went better, but still not successful. Here's a summary of unbricking with the parallel port JTAG cable. Make JTAG cable Solder JTAG cable to router PCB (super tricky) http://wiki.openwrt.org/OpenWrtDocs/Customizing/Hardware/JTAG_Cable Download unbrick program: HairyMaid_WRT54G_Debrick_Utility_v45.zip . unzip and compile unbrick program Get known good firmware, either: WRTSL54GS_2.06.0_US_code.bin (linksys orginal) or openwrt-wrtsl54gs-2.4-squashfs.x-wrt.org.bin.whiterussian Copy firmare to pwd of debrick with: cp openwrt-wrtsl54gs-2.4-squashfs.x-wrt.org.bin.whiterussian WHOLEFLASH.BIN make sure printer not grabbing parallel port: sudo rmmod lp Type this command without ENTER in terminal: ./wrt54g -flash:wholeflash /skipdetect /instrlen:8 Note from newgroups: "HairyDairyMaid's debricker is working, but currently requires /skipdetect and instrlen:8 options since the 4704 isn't in the list of supported processors. The 28F640J3 flash in the SL is in the known part list of the debricker." Turn power on router and immediately hit enter. Flashing the whole ting take a very lobng time (hours) First attempt failed. I found this: debrick-4_6.tar.bz2.for-wrtsl54gs, which says it's patched for the wrtsl54gs, so now trying this, along with the original linksys firmaware instead of the whiterussian I tried before. References: WRT Specs on wrtsl54gs: http://wiki.openwrt.org/OpenWrtDocs/Hardware/Linksys/WRTSL54GS WRT troubleshooting: http://wiki.openwrt.org/OpenWrtDocs/Troubleshooting JTAG cables: http://wiki.openwrt.org/OpenWrtDocs/Customizing/Hardware/JTAG_Cable Discussions: http://forum.openwrt.org/viewtopic.php?pid=29482 http://www.linksysinfo.org/forums/showthread.php?p=278887 http://forum.openwrt.org/viewtopic.php?id=3529&p=3 Autopsy: WRTSL54GS: http://www.linksysinfo.org/forums/showthread.php?t=47389 The Wrt54g Revival Guide http://www.freewebs.com/wrt54grevival/wrt54grevial.htm.html CFE Docs: http://wiki.openwrt.org/OpenWrtDocs/Customizing/Firmware/CFE ---------------------------------------- Serial Port Info http://www.linksysinfo.org/forums/showthread.php?t=43413&page=12 http://wiki.openwrt.org/OpenWrtDocs/Customizing/Hardware/Serial_Console ---------------------------------------- Pan/Title Servos and Controller After installing the setserial program on ubuntu, it save this in the file /var/lib/setserial/autoserial.conf: /dev/ttyS0 uart 16550A port 0x03f8 irq 4 baud_base 115200 spd_normal skip_test Querying: $ setserial /dev/ttyS0 -a /dev/ttyS0, Line 0, UART: 16550A, Port: 0x03f8, IRQ: 4 Baud_base: 115200, close_delay: 50, divisor: 0 closing_wait: 3000 Flags: spd_normal skip_test Somewhat odd, I get this from stty: $ stty -F /dev/ttyS0 -a speed 9600 baud; rows 0; columns 0; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ; eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke The SSC-32 controller uses 115.2K Baud (settable on jumpers) and 8n1 8 data bits, no parity, 1 stop bit. Anyway, I did this: And this work to center them and move them to a few places: printf '#0 P1500 #1 P1500 T3000\n' > /dev/ttyS0 printf '#0 P1900 #1 P1900 T3000\n' > /dev/ttyS0 printf '#0 P1900 #1 P1100 T3000\n' > /dev/ttyS0 The camera works by default in ubuntu (spca driver). Downloaded and compiled spcacat from http://mxhaard.free.fr/spca50x/Download/ spcaview-20061208.tar.gz Had libsdl libpthread dependency to compile: $ sudo apt-get install libsdl-image1.2 libpthread-dev $ cc -o spcacat spcacat.c picture.c encoder.c spcav4l.c utils.c avilib.c huffman.c quant.c marker.c -lpthread To take picture each second and dump to same file: # spcacat -d /dev/video0 -g -f jpg -p 1000 -o Streaming output from webcam: sudo apt-get install vlc following script will start the http server. it will start listing for requests for http streaming on your linux machine (IP-192.168.91.77) on 8080 port. It will not stream start sending packets on network until it gets a request from a client. now to test this, open vlc player on any other machine and try carpturing the network stream by typing http://192.168.91.77:8080. you should see webcam frames. #!/bin/bash /etc/init.d/httpd restart vlc -vvv v4l:/dev/video0:norm=secam:frequency=543250:size=640x480:channel=0:adev=/dev/dsp:audio=0 --sout '#transcode{vcodec=mp4v,acodec=mpga,vb=3000,ab=256,vt=800000,keyint=80,deinterlace}:std{access=http,mux=ts,dst=192.168.200.105:8080}' --ttl 12 here is a webpage I created in /var/www/html/ to embed vlc player in webpage which will capture the same network stream mentioned above. (Ref- vlc documentation) Webcam Streaming

Webcam Streaming


Play Pause Stop Fullscreen now restart the http server with above script. on client machine you should have vlc plugin in mozilla firefox webbrowser. type the server IP and u should see the embedded vlc player capturing webcam stream. This requires installing the plugin: $ sudo apt-get install mozilla-plugin-vlc http://www.videolan.org/vlc/download-macosx.html It kind of works... sudo apt-get install mozilla-plugin-vlc http://75.71.18.113/webcam.html This can play a video file via web I think: sudo apt-get install gnump3d Other camera progs? gqcam, kopete ---------------------------------------- Misc. Getting into safe mode with OpenWRT: nc -l -p 4919 -u since it will UDP broadcast the point where pressing the reset button will get into failsafe mode Quick table of GPIO functions: GPIO pin 0 DMZ (disable=on,enable=off) 1 power (disable=blink,enable=on) 2 ? 3 ? 4 SES button (00=pressed,01=not pressed) 5 SES white LED (disable=on, enable=off) 6 reset button (00=pressed,01=not pressed) 7 SES orange LED (disable=on,enable=off) 8 ? 9 ? ------------------------------------------------------------ ------------------------------------------------------------ ------------------------------------------------------------ ------------------------------------------------------------ ** Sun Oct 28 10:24:33 MDT 2007 ** Got my third wrtsl54gs router, and going to try to be more conservative about flashing the firmware. Got the kamaikaze pre-build image with the 2.4 kernel, build dated 9/30/2007. Powered on router/AP Connected Ubuntu (penguin) machine to wired LAN port #1 Visit web interface at 192.168.1.1 with: username: admin password: admin Go to menu choice: Administration->Firmware Upgrade Browse to: ~/proj/roomba/downloads/openwrt-kamikaze-7.09/openwrt-wrtsl54gs-2.4-squashfs.bin Click upgrade button and wait. Note that when web page gives screen that says 'Upgrade Successful', it is lying. The firmware upgrade is still in progress, as can be seen by flashing light. Wait sufficiently long until light stops flashing. When upgraded, telnet: # telnet 192.168.1.1 Set root password with 'passwd' to disable telnet and enable ssh. Connected WAN side to regular main wireless router hooked to cable modem so we can get external access to update the package manager. Updated the package management stuff: # ipkg update Now we want to configure the network so this is a client, not a router. Want to set it up in bridged client mode, so wifi client is on same network as LAN ports. #-------------------- # /etc/config/wireless config wifi-device wl0 option type broadcom option channel 2 # Uncomment to disable wifi # option disabled 1 config wifi-iface option device wl0 option network wan option mode sta option ssid boulder-g option encryption wep option key 1 option key1 f45e78d99c31b58a01bdaefdf9 #-------------------- # /etc/config/network config switch eth0 option vlan0 "0 1 2 3 4 5u" config interface loopback option ifname "lo" option proto static option ipaddr 127.0.0.1 option netmask 255.0.0.0 config interface lan option type bridge option ifname "eth0" option macaddr "00:1c:10:be:2f:45" option proto static option ipaddr 192.168.1.1 option netmask 255.255.255.0 config interface altwan option ifname "eth1" option macaddr "00:1c:10:be:2f:46" option proto dhcp config interface wan option ifname "wl0" option macaddr "00:10:18:90:20:db" option proto static option ipaddr 192.168.200.203 option netmask 255.255.255.0 option gateway 192.168.200.1 option dns 192.168.200.1 After this I could ssh to 192.168.1.1 from LAN ports and 192.168.200.101 (dhcp) from WAN port, but coukld not ssh to WiFi port at 192.168.200.203, presumably because of iptables firewall rules for 'wan' which is the logical name associated with wl0 now. Added line to /etc/firewall.user: iptables -t nat -A prerouting_wan -p tcp --dport 22 -j ACCEPT iptables -A input_wan -p tcp --dport 22 -j ACCEPT Then restart firewall: /etc/init.d/firewall restart Now I can ssh to 192.168.200.203. #################### # Adding camera ipkg install kmod-usb-core kmod-usb2 ipkg install kmod-videodev # This is for whiterussion, but doesn't work on kamikaze: # # wget 'http://roombahacking.com/software/openwrt/spca5xx_lite.o.gz' # gunzip spca5xx_lite.o.gz # cp spca5xx_lite.o /lib/modules/`uname -r` # echo "spca5xx_lite" > /etc/modules.d/70-spca5xx_lite # insmod spca5xx_lite # This is supposed to be for kamikaze, but it too did not detect the # camera when plugged in: # # ipkg install http://eko.one.pl/openwrt/kamikaze/kmod-usb-spca5xx-le_2.4.34-brcm-1_mipsel.ipk Found a kamikaze compiled thing here: http://forum.openwrt.org/viewtopic.php?pid=57775 which linked to: ftp://ftp.tuebingen.mpg.de/kyb/towolf/leer/spca5xx-57.08LE+spcatools20061208.tar.gz Tried installing these modules but still did not detect camera until I installed this: ipkg install kmod-usb-ohci Lack of this was also causing other USB weirdness where pluggin in camera resulted in subsequent USB devices not being detected. . For spcacat video capture tools, need these: ipkg install libpthread libgcc libusb cp spcacat cpcaserv /usr/bin ln -s /dev/v4l/video0 /dev/video0 To take periodic pictures every 1000 ms: # spcacat -d /dev/video0 -g -f jpg -p 1000 -o I still have the problem that the video capture does not work if camera hooked to hub, but works if hooked directly. #################### # Camera Setup Refinements Making symlinks create automatically on reboot. Added these to /etc/init.d/done ln -s /dev/v4l/video0 /dev/video0 ln -s /dev/v4l/video1 /dev/video1 Setting up webserver to be able to deliver images. One issue is that the /www area is in the limited-write RAM, so will make symlinks to areas where camera writes files. cd /www ln -s /tmp/video0 video0 ln -s /tmp/video1 video1 Need to open up port 80 on the firewall, which means adding this to /etc/config/firewall: # Enable webserver access accept:proto=tcp dport=80 I created a script 'camera-server.sh' which will run the spcacat program in the background, while listening to control files poked into either /tmp/video0 or /tmp/video1. e.g., camera-server.sh 0 Then to start capture: touch /tmp/video0/0.RUN To stop capture: rm /tmp/video0/0.RUN To shutdown server: touch /tmp/video0/0.SHUTDOWN This is the main command it runs to start the periodic capture: # spcacat -d /dev/video0 -g -f jpg -p 1000 -o #################### # Serial Ports # This shows the two serial ports, which I think are at /dev/tts/0 and /dev/tts/1: cat /proc/tty/driver/serial Did this in case I'll need it. ipkg install setserial The serial ports are on the board as empty holes, so will need to hook up my own serial port connector, and I have this thing that has the port and also does the 3.3V to 12V conversion that is neede to convert the WRTSL54GS 3.3V level serial port into normal 12V serial port. Soldered an IDC 10 pin connector to router, then have the JP3 serial port going to the SparkFun RS232 shifter, and then made a M-M DB-9 cable to connect this to the SSC-32 servo controller. # cat /proc/tty/driver/serial serinfo:1.0 driver:5.05c revision:2001-07-08 0: uart:16550A port:B8000300 irq:3 baud:114583 tx:241 rx:0 RTS|DTR 1: uart:16550A port:B8000400 irq:3 tx:0 rx:0 CTS|DSR|CD # setserial /dev/tts/0 /dev/tts/0, UART: 16550A, Port: 0x0000, IRQ: 3 # setserial /dev/tts/1 /dev/tts/1, UART: 16550A, Port: 0x0000, IRQ: 3 setserial /dev/tts/0 The SSC-32 controller uses 115.2K Baud (settable on jumpers) and 8n1 8 data bits, no parity, 1 stop bit. Doing this: printf '#1 P1500 T3000\n' > /dev/tts/0 printf '#1 P2000 T3000\n' > /dev/tts/1 I see that JP3 serial port connects to /dev/tts1 because LEDs on the RS232 shifter blink. However, the SSC-32 doesn't do anything, including having the LED go out to indcate it got its first command. Good chance I should not have crossed the RX and TX in the cable I made, since working from laptop, it was a straight through connection. I uncrossed the wires, but still get the same effect of the rs232 shuter LED flashing, but no acknowledgement from SSC-32. Maybe I have the port settings wrong. setserial -a /dev/tts/1 /dev/tts/1, Line 1, UART: 16550A, Port: 0x0000, IRQ: 3 Baud_base: 4125000, close_delay: 50, divisor: 0 closing_wait: 3000 Flags: spd_normal Did this, but still nothing: setserial /dev/tts/1 baud_base 115200 skip_test but then again, maybe I do need the TX/RX lines crossed. Crossed the wires back over, set the baud rate same story...but with a twist. After a echoes, the LED on the rs232 shifter would no longer come on. not sure what the next steps are....will think ######################################## ** Sat Nov 10 14:56:29 MST 2007 ** Using one of the bricked wrtsl54gs caes, I mounted the power distribution board and the SSC-32 servo copntroller board imnside, and the servos to the top. I also screwed the camera directly into the pan tilt head, and the WiMicro board is velcroed to the top. Now things are in a much cleaner, more compact and stable package. Now trying to tighten up and unify the functions I have now. Re-organizing files stored on sparky03, so that src/sparky03 is like the root dir on the device itself. Adding the USB flash drive for extra storage since it says you need 50-100 MB of space for php. The /tmp flash partition is only 16MB. Made the script 'mount-usbdrive.sh' and adding to init scripts: Adding the camera-server.sh to the init.script too. The proper way to do this is to create the init.d script, making usre it runs wrapped in the /etc/rc.common script, then execute: /etc/init.d/camerad enable which creates the symlink in /etc/rc.d for you. CGI script work if in /www/cgi-bin, so I symlinked that to a usbdrive area. Now installing perl, but really microperl: ipkg install microperl Worried that microperl might not be functional enough, I am going to try directly writing a C program using the SDK. This is the best source for info of doing this I found: http://people.bu.edu/ebishop/openwrt-programming.html cd package mkdir 00-helloworld This failed to build with a message "ELF: not found". Maybe because this was for x86_64? Trying the whiterussian 0.9 SDK now...Yes, much better. After the helloworld program, I made a hellosparky program using sockets to send pan-tilt commands. This worked on the dev machine and then also on sparky. very sweet. I then used the basic C library from the author of "Hacking Roomba", and modified it to be able to operate over a socket. ---------------------------------------- ** Mon Nov 12 20:13:44 MST 2007 ** Researching image libraries for grabbing frames and processing them in C: Potential library to epxlore (migth depend on X though): http://antonym.org/libfg -> libfg-0.3.1.tar.gz Very simple example of grabber a frame in PPM format: http://www.tazenda.demon.co.uk/phil/vgrabber.c This msounds the best so far, API with few depenedncies: http://paginas.terra.com.br/informatica/gleicon/video4linux/videodog.html Working on seeing if I can build videodog in the openwrt SDK: o Need to comment out the HASJPEG stuff from the Makefile It builds, but trying to run it: root@sparky:~# videodog -x 320 -y 240 -w 3 -d /dev/video0 -p -f /tmp/test.pnm ioctl VIDIOCMCAPTURE: Invalid argument Maybe the spcaserv/spcacat things have enough functions for now? | How can i run spcaserv servfox ? | There are a README file in the package to know all parameters setting. | spcaserv -h or servfox -h give you usefull informations to :) | | servfox -d /dev/video0 -s 320x240 -w 7070 | run servfox on the first video node available with 320x240 framesize and listen to port 7070 | spcaserv -d /dev/video0 -f yuv -s 352x288 -w 7070 | run spcaserv on the first video node with a frame size of 352x288, palette yuv420p, listen on port 7070 So in theory, I could run this: spcaserv -d /dev/video0 -s 320x240 -w 10111 and have a client connect to port 10111. The reality is it a starts, the dies with: cmcapture: Invalid argument Format asked 15 check -1 Couldnt set videopict params with VIDIOCSPICT But adding '-f jpg' did seem to make it work. spcaserv -d /dev/video0 -s 320x240 -f jpg -w 10111 So now the key would be how to write a client, and then after that, how to proces the image in some interesting way. Looking at the source code for spcaview might help: the spcaClient() routine in spcaview.c looks promising, and within that readjpeg(). Next up would be to try to grab snippets from spcaview and write my own simple client. If that works, then understanding the jpeg format would be next. For testing and dev, I am going to run the spcaserv on the ubuntu laptop. Using the spcaview source code, I build just the target 'spcaserv' and 'spcacat' (since other things required SDL and such) and this is exactly what I have on the openwrt box. Maybe just teaking the spcacat code is the way to go. Trying to extract the subset of spcacat files from the full spcaview code. Ok, reducing the code and compiling standalone within the SDK worked. Now to probe into the spcacode to see if I can do some very basic image manipulations. A good video4linux tutorial/explanation by author of videodog: http://64.233.167.104/search?q=cache:0YQGafwk9_EJ:paginas.terra.com.br/informatica/gleicon/video4linux/p.gz+processing+frame+video4linux&hl=en&ct=clnk&cd=14&gl=us&client=firefox-a Situation: - spcacat compiles and grabs video - it *seems* to grab it in jpeg format - bare bones example from tutorial compiles - bare bones works up to a point and always dies in ioctl call for VIDIOCAPTUE: Invalid Argument - I've tried adjusting the frame numbers, the format number and the height and width with no luck Two directions: - understand how bare bones is different from what spcacat is doing in the VIDOCMCAPTURE - use spcacat and figure out the format the data is in in the frame buffer This page seems to imply thqat the camera grabs jpeg natively. If so, no matter what approach I go with, I need to be able to convert the Jpeg format ro something more useful, or else have knowldeg how to process the jpeg image. http://mxhaard.free.fr/sview.html Scratch that I think... Turns out the spcacta is using the regular file read, not the mmap method of grabbing a frame, which explains why tings wre different. In addition, by using gdb and tracing through, I found it is grabbing a simple WxHXxD RGB frame and then encoding it as jpeg (in encoder.c). So I now think I can tweak spcacat to serve my purposes of video processing. I found that the frames are processes continually and output according to input params. A paper in references on wikipedia 'facial detection page' is a good starting point for this task. See this too: http://www.facedetection.com/ Also look at optical flow, edge detection algorithms. This is C++ but looks like possibly a great reference for not having to re-implement the standard image processing things: http://sourceforge.net/projects/opencvlibrary/ Indeed, I downloaded the source code and the docs seem to show it does the things I need and much more. ** Thu Nov 15 19:34:40 MST 2007 ** Got sofware from Colorada state university at: http://www.cs.colostate.edu/~ross/scripts/getit.php There is a facedetect.c in the opencv librray, goin gto run with that. Here is a commented version of the code with instructions for using it. http://opencvlibrary.sourceforge.net/FaceDetection ** Sat Dec 1 11:47:29 MST 2007 ** Replacing wireless WiMicro board with wired version Micro 100. First hook it up to main router and it gets a DHCP address, then change it's configuration to use a static IP address: telnet 192.168.200.104 9999 Choose the 'server' option, then set the network config to be: ip=192.168.1.203 gw=192.168.1.1 maskbits=8 Serial Port configs: Channel 1: Roomba uses 9600 Baud 8 data bits, no parity, 1 stop bit. Channel 2: The SSC-32 controller uses 115.2K Baud (settable on jumpers) and 8n1 8 data bits, no parity, 1 stop bit. ** Sat Dec 1 15:10:37 MST 2007 ** Back to working on image processing. Trying to merge the spcacat code with the opencv image libraries as package imaged in OpenWRT SDK. ./imaged -d /dev/video0 -g -f r24 -p 10000 -o Needed the libuClibc++ packge for the opencv c++ stuff ipkg install libstdcpp Getting a seg fault and doing this to force a core dump: ulimit -c unlimited Copied core to dev platform and did: ./staging_dir_mipsel/bin/mipsel-linux-uclibc-gdb -c /tmp/core Getting gdbserver to work? http://forum.openwrt.org/viewtopic.php?pid=29712 cd /tmp wget -O - 'http://www.uclibc.org/downloads/root_fs_mipsel.ext2.bz2' bunzip2 root_fs_mipsel.ext2.bz2 sudo mount -o loop root_fs_mipsel.ext2 /mnt cd /mnt sudo tar -czf /tmp/gdbserver.tgz usr/bin/gdbserver lib/libthread_db-0.9.27.so lib/libthread_db.so.1 lib/libgcc_s.so lib/libgcc_s.so.1 scp /tmp/gdbserver.tgz root@192.168.200.203:/tmp cp /tmp/gdbserver.tgz ~/proj/roomba/openwrt-sdk/ Target side: gdbserver 127.0.0.1:1234 /usr/bin/myprog myargs Host side: Need to run the mips version of gdb, not the native one: ./staging_dir_mipsel/bin/mipsel-linux-uclibc-gdb (gdb) cd /home/arc/proj/roomba/OpenWrt-SDK-Linux-i686-1/build_mipsel/imaged (gdb) set solib-absolute-prefix /home/arc/proj/roomba/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel (gdb) target remote 192.168.200.203:1234 (gdb) break main To enable core dumps: ulimit -c 2000000 (gdb) target core /tmp/core Program received signal SIGSEGV, Segmentation fault. 0x00510cb8 in CvType::~CvType () (gdb) bt #0 0x00510cb8 in CvType::~CvType () #1 0x00411010 in __do_global_dtors_aux () #2 0x0055e3e4 in _fini () ** Mon Dec 3 20:16:30 MST 2007 ** Tried making a pared down version of the opencv+ spcacat program, but it still immediatrly seg faults with a corrupted stack when run on the router, though it runs locally. Going to mull this one and start developing some software. I realized that if I port forward the 10001 and 10002 on sparky to the SSC-32 I can run the code on the laptop and issue the commands. This allows me to have off-board processing until I figure out how to get this running on the router. The forward the ports, edit /etc/config/firewall to add: # Forward for Micro100 ethernet to serial port device forward:dport=9999-10002:192.168.1.203 Then issue: /etc/init.d/firewall reload The one last piece is to access the camera image from the router. Before owrrying about this, I will hook he camera up to the laptop to try to do a simple face tracking program. ** Wed Dec 5 20:55:36 MST 2007 ** Got basic face detction and tracking working. Next up is to integrate the spca server functions as an alternate to writing files. Then connect with the spcaview program, then add other feature detections. ** Sat Dec 15 18:14:12 MST 2007 ** Trying another code for face detection from CMU: http://vasc.ri.cmu.edu/NNFaceDetector/download.html This code worked well at integrating. Abandoning the opencv thing for now. Formula to convert RGB to geyscale intensity (the cmu code mostly cares about b/w images): grey=0.3*R+0.59*G+0.11*B I should experiemtn with this and a simple average. The former is better for human perception, but maybe the latter is better for the face detection algorithms. Ugh....trying to get this running on the router, and going through all the remote debugging hoops I find the behavior to be almost identical to the issues I had with opencv. The only diff is that this dies with 'Aborted' instead of SEGFAULT, but attching the debugger, or examining core dump yields same issue. I think it must alll lie in the space of the cross-compiler assumptions on libraries and what it actually finds on the router. Getting the libuClibc++ is done with: ipkg install uclibcxx but I think that is only needed on whiterussian, and that on kamikaze, you just install: ipkg install libstdcpp Option: Use llvm to compile c++ into llvm bit code, then use the llvm utility 'llc -march=c' to turn that bitcode into C code. I downloaded the llvm source and am compiling it on ubuntu machine. It's a big build. http://llvm.cs.uiuc.edu/releases/2.1/llvm-2.1.tar.gz http://llvm.cs.uiuc.edu/releases/2.1/llvm-gcc4.0-2.1.source.tar.gz http://llvm.cs.uiuc.edu/releases/2.1/llvm-gcc4.0-2.1-x86-linux-RHEL4.tar.gz Need the gcc front-end I think. First trying the redhat binary on ubntu: Set these: export CC=/home/arc/proj/roomba/src/llvm-gcc4.0-2.1-x86-linux-RHEL4/bin/llvm-gcc export CXX=/home/arc/proj/roomba/src/llvm-gcc4.0-2.1-x86-linux-RHEL4/bin/llvm-g++ Then reconfigure and build llvm: cd llvm-2.1 ./configure --prefix=/usr/local make sudo make install Now try to compile (normally) C++ code: export PATH=$PATH:/home/arc/proj/roomba/src/llvm-gcc4.0-2.1-x86-linux-RHEL4/bin cd /home/arc/proj/roomba/OpenWrt-SDK-Linux-i686-1/package.old/10-facetrack4/src/cmu-face-detect-c++ llvm-g++ -c *.cc Now to build the llvm bit codes: for f in *.cc ; do objf=`echo $f | sed 's/.cc$/.bc/'` llvm-g++ -emit-llvm -c -o $objf $f done for f in *.bc ; do objf=`echo $f | sed 's/.bc$/.c/'` llc -march=c -o $obf $f done Did this, but this is not going to be useful. It does not retain the function and variable names making it pointless. This C++ to C conversion is only good if you convert the whole program to an llvm file, then convert the whole thing to one big C program to compile: i.e., you have no C++ compiler. Back to the drawing board. Here's a summary of the various facetrack packages and their diffs: facetrack - spca code + scaled down opencv (mopencv) as linked .a lib facetrack2 - spca code + cmu face-dectect code as linked .a lib facetrack3 - spca code + cmu face-dectect directed linked .o files facetrack4 - spca code + cmu face-dectect converted to C from C++ via llvm Connecting to server to view image stream: ./spcaview -w 127.0.0.1:7070 ./spcaview -w 192.168.200.203:7070 zzzzzzz SONGS to program: - close encounters - willy wonka oopa loompa whistle - r2d2 sound streamer zzzzzzzz Looking into getting PHP to run on openwrti and starting with this: http://www.macsat.com/OpenWRT/lighttpd.php zzzzzzzzz ipkg install rsync