Wednesday, April 2, 2008

Backing up and restoring MySQL db via the command line


In Windows click Start, select Run and type cmd, then hit OK button.

Backing up via the command line

    mysqldump -a -u USERNAME -p DATABASENAME > FILENAME.sql

Restoring via the command line

Drop the database (optional):

    mysqladmin -u USERNAME -p drop DATABASENAME

Create the database:

    mysqladmin -u USERNAME -p create DATABASENAME

Import the backup data:

    mysql -u USERNAME -p DATABASENAME < FILENAME.sql

Thursday, March 27, 2008

Configure system for Android development

Development for embedded devices is always fun. With release of Google Android contest level of fun could even higher. Next steps will demonstrate a way how to configure development environment:

0. Start a Virtual PC with Windows XP. It is my favorite way to create new development environment. But it is optional.
1. Download JDK6 from http://java.sun.com/javase/downloads. It will require 300 MB on you hard drive
2. Download Eclipse IDE for Java Developers - Windows (79 MB) from lipse Europa Winter Maintenance Packages (www.eclipse.org/downloads). Nice part that Eclipse does not have an installation process. Once files have been unzipped you are done.
3. Download Android SDK from code.google.com/android/download.html. Unzip into C:\android-sdk_m5-rc15_windows and add C:\android-sdk_m5-rc15_windows\tools to My Computer->Environment Variables->System Variables->Path.
4. Start Eclipse and configure development forlder for example C:\Projects
5. Follow instraction and install Installing the Eclipse Plugin (ADT) from code.google.com/android/intro/installing
6. After restart, update your Eclipse preferences to point to the SDK directory. This could be done from Window -> Preferences -> Android -> SDK Location

Done, now system is ready for development.

Thursday, February 7, 2008

BF537 performance measurements

Customized kernel image created in previous post provides a way to measure execution / performance time. It could be done with help of oscilloscope connected to the boards ground and LED connections. Application pflags-test is executed in user space of uClinux and is using GPIO driver to enable button and LEDs processing. Code below shows in comments measured with oscilloscope execution time.


    write(fd0,"0",sizeof("0"));    // 16 microseconds
    usleep(1000);                      //   4 milliseconds
    write(fd0,"1",sizeof("1"));    // 16 microseconds
    usleep(1000);                      //   4 milliseconds

Arithmetic operations could be tested with help of cycle. This will allow having sufficient amount of time to measure as shown in the code:

    long a, c, i = 0;
    for( i = 0; i < 100000; i++)
    {
         c = i + a;
    }
    printtime();

This time measurements were done with help of system time functions and results are presented in table below.

OperationCycle NumberVariable TypeTime
+100000long4 ms
+1000000long45 ms
*100000long6 ms
*1000000long48 ms
+100000float107 ms
+1000000float1061 ms
*100000float89 ms
*1000000float887 ms

Trigonometric functions measurements could be done with adding in C file #include <math.h>, and option "-lm" to the linker command. Review previous post on details of how to configure blackfin toolkit for uClinux program compilation.


bfin-uclinux-gcc -Wl,-elf2flt perftest.c -o perftest -lm

OperationCycle NumberVariable TypeTime
cos100000long6268 ms
cos1000000long62681 ms

Thursday, January 31, 2008

Compiling the Kernel for BF537

BF537 STAMP board has buttons and LEDs provided to be accessed by software for testing purpose. In order to do that is required to have customized kernel image. Default image for BF537 has no driver for such operations.

Source code for uClinux kernel could be downloaded from blackfin site. There are an easy way to uncompress it by just right click on a file in SUSE File Browser and selecting Extract Here. Lets open this folder and configure blackfin toolkit used for kernel compilation. Details on how to do that is provided in previous post.

Next command in terminal window will invoke kernel configuration utility.

make menuconfig

Choosing BF537-STAMP in Vendor/Product Selection will produce kernel for BF537. It is important to do that, otherwise kernel image will halt on boot up execution.



Ability to add required driver is provided with selection of Customize Kernel Settings (NEW):

Kernel/Library/Defaults Selection.
Device Drivers --->
Character devices --->
[*] Blackfin BF53x Programmable Flags Driver


Exit and saving configuration will bring back the terminal console. Executing next commands will reset cached objects and make a new kernel image:

make clean
make

The compilation process will take time and could last for about 30 minutes. BF537 U-Boot loader has a nice feature of loading kernel from a network over tftp. SUSE YaST in a few steps allows to configure TFTP server and then copy kernel image into server folder with File Browser.

Now let’s jump to Windows XP host environment and start HyperTerminal application.


For tftp command to work is necessary to configure BF537 U-Boot environment with ipaddress for tftp server and BF537. Saving environment settings into flash memory is an optional step. After that is loading kernel image to memory and booting uClinux.

BF537> setenv ipaddr x.y.z.n
BF537> setenv serverip x.y.z.m
BF537> saveenv
BF537> tftp 0x1000000 linux
BF537> bootelf 0x1000000

Now everything is ready to run test application on a custom kernel image. Source code for button test application could be found in user\blkfin-test\pflags-test subfolder where kernel was compiled. Check my previous post on how to compile and download application into BF537.

Wednesday, January 23, 2008

Hello World under uClinux

Let's test Hello World application compiled in previous post under uClinux. There are many ways how to copy application file into BF537 board and one of them with help of wget command by downloading file over HTTP protocol.

This command will communicate with web server installed on development platform. Ethernet connection between board and computer is necessary.

YaST allow an easy way to verify that HTTP server is enabled and take a look on my previous post on how to configure Linux SUSE to be development platform for BF537.

Then application file has to be placed into web server working folder. That could be done from command line as well by using Cut and Paste file operation.

cp ./hello /srv/www/htdocs/hello

The natural way of running BF537 under Windows XP is with use of HyperTerminal application and serial cable. Connection setting could be found on support site. After powering up board next text will be shown in terminal window:

With DHCP server available board's network settings could be configured by:

root> dhcpcd &

Next commands will do switch to tmp folder as preferable place for this application, download file from web site, permission modification that allows program to be executed and finally now is possible to execute Hello World application

root:~> cd /tmp
root:/tmp> wget http://yourwebserver/hello
root:/tmp> chmod 777 hello
root:/tmp> ./hello

Wednesday, January 16, 2008

First program for BF537 STAMP board

BF537 STAMP board is possible to buy from Digi-Key. That is a nice board with a plenty of possibilities to create a handy functionality. I just recently got one as well. My board has newer version of software that could be found on companion CD which is dated as 2005 release, but everything could be downloaded from support web site. This wiki style site looks fresh and written for creative people, check remark about documentation.


Today’s laptops or PC are quite powerful devices and capable to run multiple OS at same time by using virtualizing software. This allows of choosing Linux as development platform even if main platform is Windows XP. Check my older post on how to install SUSE 10 on Virtual PC. One of advantage of this approach is to have less hardware on a desk and more time for development.

The STAMP board is a part of the Blackfin/uClinux open source project, and the good thing that schematics for the board available as well. Board could be accessed through serial cable by using terminal window. It has an Ethernet interface, six general-purpose LEDs and four general purpose push-buttons available for quick start hardware control programming.

To be ready for development is necessary to verify number of tools to be installed on development platform. Full list of applications could be found on support site and one of them is gcc compiler. These applications are part of a standard SUSE 10 distribution. Next in a list is latest blackfin-toolchain-07r1.1-3.i386.rpm package from Blackfin support site. Double clicking an RPM file will bring up a graphical front end for installing RPM's. Under SuSE Linux 10 this front-end is provided through YaST2.



After installing the Blackfin tool chain the environment variable PATH must be modified to include the directory where the Blackfin tool chain is installed. It could be done in File Browser by selecting File->Open In Terminal and typing next command line:

export PATH=$PATH:/opt/uClinux/bfin-uclinux/bin:/opt/uClinux/bfin-linux-uclibc/bin

At this point everything is ready for a hello world application:

#include <stdio.h>

int main() {
      printf("Hello, World\n");
      return 0;
}

Next command line will compile this file:

bfin-uclinux-gcc -Wl,-elf2flt hello.c -o hello

The output executable is 'hello' file in flat format, also it creates a file “hello.gdb” which is used for debugging. Check my next post for details on how to run this program on BF537 board.

Wednesday, January 9, 2008

SUSE Linux Desktop on Virtual PC


Jump from Windows into Linux world right away could be a big challenge. To make this smooth as possible is better to have somewhere Linux environment to play. For this task Virtual PC is a handy tool. Virtual PC 2004 SP1 is a free virtualization suite available for download from Microsoft. It runs on Windows 2000 and XP. Virtual PC 2007 is available for Windows Vista.

First step is to install Virtual PC.

Next step is to grab Linux distribution. Lets go to Novell Downloads and select SUSE Linux Enterprise Desktop 10. It is available as DVD or set of 5 CDs.

"SUSE Linux Enterprise Desktop is the most interoperable Linux desktop available today. It works seamlessly with Novell GroupWise® and Microsoft Exchange collaboration servers, and it will connect to Lotus Notes and IBM* Notes plug-in for Workplace client technology. It is also fully compatible with Microsoft Active Directory* and other networking and directory standards."

Now is possible to create a virtual machine. Following wizard select “Other” as Operating System, adjust RAM to 256 MB, and create a new virtual hard drive.

Then start this virtual machine. Under CD menu select Capture ISO image and browse for SUSE Linux Enterprise Desktop ISO image.

Complete installation procedure and start using Linux SUSE Desktop. As additional optional step I do recommend to change Display settings and use for monitor 1280x1024 and for resolution 1152x864.