Thursday, April 17, 2008
Lock free communication channel
Writer’s thread will save data into Singly Linked Lists and assign unique ID to the package. Then reader’s thread will pick packages one by one, order them by ID, and store packages in a cache list.
The cache itself could be ignored when processing is interested only in latest package – real time data. Since InterlockedPopEntrySList could read packages in random order, is considered necessary after extracting all packages from a cache to find latest one.
Singly Linked Lists are straightforward to implement and use in 32-bit code.
Monday, April 7, 2008
SQL Express failed to install
During SQL Server Express installation on Microsoft Windows XP Home Edition next unexpected error occurs:
Product: Microsoft SQL Server Native Client -- Error 1706. An installation package for the product Microsoft SQL Server Native Client cannot be found. Try the installation again using a valid copy of the installation package 'sqlncli.msi'.
Workaround:
Extract 'sqlncli.msi' file from a package and install separately, then run SQLEXPR32 again.
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
Restoring via the command line
Drop the database (optional):
Create the database:
Import the backup data:
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.
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:
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.
Operation | Cycle Number | Variable Type | Time |
+ | 100000 | long | 4 ms |
+ | 1000000 | long | 45 ms |
* | 100000 | long | 6 ms |
* | 1000000 | long | 48 ms |
+ | 100000 | float | 107 ms |
+ | 1000000 | float | 1061 ms |
* | 100000 | float | 89 ms |
* | 1000000 | float | 887 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.
Operation | Cycle Number | Variable Type | Time |
cos | 100000 | long | 6268 ms |
cos | 1000000 | long | 62681 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.
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):
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
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 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.
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:
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:/tmp> wget http://yourwebserver/hello
root:/tmp> chmod 777 hello
root:/tmp> ./hello