Development for Korebot with kernel 2.6 and the Cross-compiler from x86-linux to arm-linux, full version K-Team S.A, J. Tharin Full version of the development tools for the Korebot, kernel 2.6.x version: 0.1: beta test March, 31th 2008 0.1b: ktboot updated: multi USB patched April, 21th 2008 only one master USB was working 0.1c: added wpa encryptions details 1.0: 2008.11.26: full version 1.1: 2009.02.12 : modified directory name in (C) 2. linux-2.6.23.1-kb1-usb -> linux-2.6.23.1-kb1 1.2: 2009.02.26 : added instructions for loading Wifi module automatically 1.3: 2009.03.02 : added required package mtd-tools 1.4: 2009.03.03 : added details about kernel install; modified build order (image fs after camera driver) 1.5: 2009.03.06 : corrected instructions with newest kernel install (added A.4 b)); corrected wpa-tkip encryption support 1.6 2009.11.18 : added the misssing "dist" package ( point A) 4) ) tested on linux releases Ubuntu 7.10 required hardware: KorebotLE usb camera (Webcam) (optional) Wireless compact flash card (optional) required softwares: from the full_toolchain directory: tool for executing tasks: bitbake-1.8.8.tar.gz development tools: korebot-oetools-full-1.0-kb1.tar.bz2 distrubution modules dirextory: dist.tar.bz2 from the common_files directory: development directory: development_lightV0.1_kernel2.6.tar.bz2 kernel: linux-2.6.23.1-kb1-usb.tar.bz2 kernel 2.6 and root filesystem image: ktboot-1.6-beta20080409.tar.bz2 camera driver: gspcav1-20071224-kb1.tar.bz2 (optional) java application for viewing camera: WebCamApplet.tar.bz2 (optional) various: korebot-various-1.0.tar.bz2 required Linux packages: (must be installed, not included above) picocom expect lrzsz mtd-tools (for the program mkfs.jffs2: builds .jffs2 images) ====== Introduction ======================================================================= The new version of this environment tool is based on the embedded Linux distribution called "Angström" coming from OpenEmbedded tools. Check out for more information: http://www.angstrom-distribution.org/ You have to execute the following steps (A) to (F) in order for a proper installation. ====== (A) Install the development tools ====================================================== 1) Extract the file development_lightV0.1_kernel2.6.tar.bz2 in your home directory and enter in the directory development_lightV0.1_kernel created just before, which will be your development directory, named (*) below. 2) Modify the KTEAM_HOME variable in the file env.sh to point to your development directory. 3) Extract the development tools korebot-oetools-full-1.0-kb1.tar.bz2 in /usr/local. You will want to set user permissions on these files, so you don’t need to be root to work. 4) Extract the files "korebot-various-1.0.tar.bz2" and dist.tar.bz2 in your development directory. 5) Modify in the file /usr/local/korebot-oetools-1.0/create-image.sh the variable ROOTFS_MODULES_SRC to point to your development directory (*) a). And check kernel version of the depmod line b). Pay attention to the last part "2.6.23.1-kb1", which is your kernel version of your Korebot. a) (e.g.) ROOTFS_MODULES_SRC="/home/jtharin/projects/kernel2.6/development/dist/lib/module s/2.6.23.1-kb1" b) (e.g.) /sbin/depmod -a -b build/tmp/rootfs 2.6.23.1-kb1 6) Install bitbake: a) install the following linux packages: (for Ubuntu use the command "sudo apt-get install") bison m4 patch libc6-dev subversion help2man diffstat texi2html texinfo cvs gawk automake b) extract bitbake-1.8.8.tar.gz; enter in it's directory and execute: sudo ./setup.py install --prefix=/usr/local ====== (B) Install the cross compiler ====================================================== 1) Create a symlink using this command in your development directory (*): ln -s /usr/local/korebot-oetools-1.0/build/tmp/cross 2) Modify the KTEAM_HOME variable in the file env.sh to point to your development directory(*). ====== (C) Build the kernel ================================================================ 1. Extract the kernel file into your development directory (*): (pay attention to the directory name: should be linux-2.6.23.1-kb1, or the one corresponding to your current kernel version) tar -xjf linux-2.6.23.1-kb1-usb.tar.bz2 2. Type the following command to have access to the cross-compiler source env.sh 3. Change to extracted directory linux-2.6.23.1-kb1 4. Then use the usual commands to configure, compile the kernel and copy the modules: make menuconfig (Linux Kernel Configuration is displayed: exit) make -j3 make modules_install (DO NOT run make install). Your kernel has been built. And the kernel modules are copied in (*)/dist. ====== (D) Build the Camera driver ============================ 1. Extract the following files in your development directory: gspcav1-20071224-kb1.tar.bz2 2. Type the following commande to have access to the cross-compiler source env.sh 3. In gspcav1-20071224-kb1, execute make clean make make install ====== (E) Build the Korebot image ============================================================ 1. Go to the directory /usr/local/korebot-oetools-1.0/ 2. Then run ./create-image.sh In case the process complains about some missing files during the build process, you might want to remove relevant packages in the ASSUME PROVIDED variable in build/conf/local.conf. This list helps speeding up a little the building process on my system, but might break it on yours. If you want to add a package to the system, modify custom/packages/images/korebot-image.bb. A list of packages is available in org.openembedded.dev/packages/*/*.bb, in case you want to create custom packages, you can put your own bitbake recipes in custom/packages. If everything goes well, you will get 12Mb fs jffs2.img file in the directory. ====== (F) Upload the kernel, modules and the root filesystem(Korebot image) to the Korebot ============================ 1) Extract the file ktboot-1.6-beta20080328.tar.bz2 in your development directory. 2) Connect the Korebot to the computer. Edit the script picocom in your development directory to match your serial port connection and run it (./picocom). Reboot the KoreBot, then press a key when U-Boot asks for autoboot. Type Ctrl-y Ctrl-x to exit picocom. 3) Then change directory to ktboot-1.6, edit the Makefile and modify the variable "SDEV = /dev/ttyS0" to match your serial port connection, and type to flash the kernel (~2min): make flashk 4) to flash the root file system (~30min), type : make flashd 5) to configure the kernel boot parameters (~10s), type: make bootargs 6) reboot the Korebot. The login is root, without password. 7) upload the modules to the Korebot with the script in (*): - establish a connection between the korebot and the computer via an network through usb (see chapter "Connecting to the Korebot with network over usb cable") - In the dist folder of your development directory execute the following command to upload the modules to the korebot: ./tx-ssh 8) update the modules dependencies by taping at the Korebot prompt: depmod -a ====== Packages management ================================================== With OpenEmbedded you can easily cross-compile existing packages or add your own: Existing packages: Check if the package is already in /usr/local/korebot-oetools-1.0/org.openembedded.dev/packages If it is present, you can compile it by running in the /usr/local/korebot-oetools-1.0 directory: ./start-build ./start-build.sh build PACKAGE_NAME The package will be created in on the folders in /usr/local/korebot-oetools-1.0/build/tmp/deploy/glibc/ipk Transfert the package to the korebot (with Minicom or ssh): (see chapter "Transfering files using scp (ssh)" Then install it: ipkg install PACKAGE_NAME.ipk ====== Development ========================================================== You can start developing with the template program in libkorebot-1.11-kb1/template as follow: a) enter bash shell by executing: bash b) set environment by executing in the shell: source ../env.sh c) build your program with the make -e command The -e forces make to consider environment variables set by env.sh. This works as long as you kept the same variable names as in korebot-template (i.e. CC, INCPATH,LIBPATH). ====== Using a Wireless compact flash card ================================== 1) insert a Wireless compact flash card in the Korebot 2) load the module by typing: modprobe pxa2xx_cs You may load the Wifi module automatically by adding pxa2xx_cs in the file /etc/modules. You can use the following command echo to add the module name to the file: echo pxa2xx_cs>>/etc/modules 3) - i) WEP support a) for configuring the wifi connection, type: iwconfig wlan0 essid YOUR_SSID_OF_NETWORK b) if the network is secured, enter the key by typing : iwconfig wlan0 key YOUR_KEY c) then set an ip address to the korebot: ifconfig wlan0 YOUR_IP_ADDRESS d) configure the gateway by entering the gateway ip: route add default gw YOUR_GATEWAY_IP wlan0 e) insert the local domain name in /etc/resolv.conf echo search YOUR_LOCAL_DOMAIN_NAME>> /etc/resolv.conf f) and the dns server echo nameserver YOUR_DNS_SERVER_IP_ADDRESS>> /etc/resolv.conf You can also create a file in /etc/network/if-pre-up.d named wireless to have these settings saved and put the following into it: #!/bin/sh ifconfig wlan0 up iwconfig wlan0 essid YOUR_SSID_OF_NETWORK iwconfig wlan0 key s:YOUR_KEY ifconfig wlan0 YOUR_IP_ADDRESS route add default gw YOUR_GATEWAY_IP wlan0 and the following in a file named /etc/resolv.conf: search YOUR_LOCAL_DOMAIN_NAME nameserver YOUR_DNS_SERVER_IP_ADDRESS ii) WEP, WPA and other encryptions: a) create a file named /etc/wpa_supplicant/wpa_supplicant.conf and insert your selected wireless encryption: WEP #Shared WEP key connection (no WPA): network={ ssid="YOUR_SSID" key_mgmt=NONE wep_key0="YOUR_WEP_KEY" auth_alg=SHARED wep_tx_keyidx=0 priority=5 } WPA-TKIP: - see instructions at : http://ftp.k-team.com/korebot/kernel/modules/wpa-tkip/wpa-tkip_support.txt #/etc/wpa_supplicant/wpa_supplicant.conf #with WPA-PSK TKIT: network={ ssid="YOUR_SSID" psk="YOUR_PASS_KEY" key_mgmt=WPA-PSK group=TKIP pairwise=TKIP proto=WPA priority=5 } You can check the following link for other encryptions: http://hostap.epitest.fi/wpa_supplicant/ b) run the daemon controlling the wireless connection with the following command: wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0 -Dwext -B You can also add the command above to a file in /etc/network/if-pre-up.d named wireless: #!/bin/sh ifconfig wlan0 up ifconfig wlan0 YOUR_IP_ADDRESS route add default gw YOUR_GATEWAY wlan0 wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0 -Dwext -B ====== Connecting to the Korebot with network over usb cable ================= a) launch the usb module on the Korebot: modprobe g_ether b) connect the computer to the Korebot USB slave port with an USB cable c) configure the usb port on the Korebot: ifconfig usb0 10.0.0.2/24 d) on the computer, configure also the usb port (you must be root, or use sudo): ifconfig usb0 10.0.0.1/24 ====== Transfering files using scp (ssh) ====================================== 1) Establish a network connection between the computer and the korebot (using Wifi see chapter "Using a Wireless compact flash card", or using ethernet over usb see chapter "Connecting to the Korebot with network over usb cable" 2) Execute the following command, where FILE, is the file to transfer, KOREBOT_IP the korebot ip address (see 1) ) scp FILE root@KOREBOT_IP:/home/root ====== Using an USB Camera ================================================== 1) connect a Webcam to a master USB port of the Korebot 2) run the webserver on the Korebot by typing: camsource 3) connect to the Korebot using the network through an usb connection a) see chapter "Connecting to the Korebot with network over usb cable" b) you can access to the image at the URL http://10.0.0.2:9192/largequal This capture pictures at low resolution (160x120) by default, you can change the configuration file /etc/camsource.conf to get higher resolution, at the price of much lower frame rate (the webcam then compresses the image, and decompressing it on the ARM is relatively slow). You can also use WebCamApplet. You can run it as a standalone application, with a command like this (change port 8888 to 8889 for high resolution images): java WebCam 10.0.0.2 8888 352 288 It will print picture interval in ms everytime a picture is acquired (1000/the value gets the number of frames per second). You can also capture snapshots using this command (stop the camsource server first): wcggrabber --size=max > output.ppm ====== Using bluetooth ================================================== a) Plug in a supported Bluetooth USB dongle. b) Then run: hcitool scan which should return something like this if you have some discoverable devices in your neighbourhood: Scanning ... 00:16:CB:10:XX:XX BlueZ (0) 00:16:B8:7D:XX:XX W710i c) Then you can easily send a file using a command such as: obextool push cap.jpg 00:16:B8:7D:XX:XX 6