2010-02-24
uC/OS, The Real-Time Kernel
http://download.csdn.net/down/501748/qiulin6822
A free Borland C++ 3.1
http://www.pudn.com/downloads54/sourcecode/compiler/detail187860.html
Sample code
http://www.cevx.com/bbs/viewthread.php?tid=10412&page=1
2010-02-17
Build Qt as Static Library
A static built Qt application is faster. According to the artical "Qt Performance Tuning":
"A lot of CPU and memory is used by the ELF (Executable and Linking Format) linking process. Significant savings can be achieved by using a static build of the application suite; rather than having a collection of executables which link dynamically to Qt's libraries, all the applications is built into into a single executable which is statically linked to Qt's libraries."
First of all, you need to build Qt as a static library. See the thread http://lists.trolltech.com/qt-interest/2003-05/thread00396-0.html
./configure -thread -static (makes libqt-mt.a)Then, add the necessary plugins. See the artical http://doc.trolltech.com/4.6/plugins-howto.html#static-plugins.
./configure -static (makes libqt.a)
./configure (makes libqt.so)
./configure -thread (makes lib-mt.so)
Finally, deploy your application. See the artical http://doc.trolltech.com/4.6/deployment.html.
References:
2010-02-16
Useful Tar Commands
>
tar -tvf file.tar
List the contents of a tar.gz file>tar -ztvf file.tar.gz
tar all .cc and .h files into a tar file named foo.tgz use
>tar cvzf foo.tgz *.cc *.h
extract only one (or several) files
>tar xvzf foo.tgz
extract only one (or several) files
>tar xvzf foo.tgz anagram.cc
extract bz2 tar ball
>tar -jxvf filename.tar.bz2
extract bz2
>bunzip filename.bz2
Virtualization vs. Emulation
"Emulation involves emulating the virtual machines hardware and architecture. Microsoft's VirtualPC is an example of an emulation based virtual machine. It emulates the x86 architecture, and adds a layer of indirection and translation at the guest level, which means VirtualPC can run on different chipsets, like the PowerPC, in addition to the x86 architecture. However, that layer of indirection slows down the virtual machine significantly."
"Virtualization, on the other hand, involves simply isolating the virtual machine within memory. The host instance simply passes the execution of the guest virtual machine directly to the native hardware. Without the translation layer, the performance of a virtualization virtual machine is much faster and approaches native speeds. However, since the native hardware is used, the chipset of the virtual machine must match. Usually, this means the Intel x86 architecture. VMWare is an example of this type of application for Windows."
Reference:2010-02-15
Setup sb2 enviroment for mini2440
2) Extract the tar ball and arm-2009q3 is generated
>tar -jxvf arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
3) Extract the root_qtopia root
>mkdir root_qtopia
>cd root_qtopia
>tar xvfz ../root_qtopia.tar.gz
4) Copy following directory to root_qtopia
>cp -a $HOME/arm-2008q3/arm-none-linux-gnueabi/libc/{lib,etc,usr} ${root_qtopia}5) Generate sb2 target
>cd ${root_qtopia}
>sb2-init mini2440_qtopia /disk1/packages/arm-2009q3/bin/arm-none-linux-gnueabi-gcc
>sb2-config -d mini2440_qtopia
6) Compile an example code test.c
#include <stdio.h>
int factorial(int n)
{
if (n == 0) return 1;
return n * factorial (n - 1);
}
int main () {
int i;
int n;
for (i = 0; i < 10; ++i) {
n = factorial (i);
printf ("factorial(%d) = %d\n", i, n);
}
return 0;
}
>sb2
>gcc test.c -o test
7) To execute it, you need install qemu-arm
>git clone git://git.savannah.nongnu.org/qemu.git
>cd qemu
>./configure --target-list=arm-linux-user
>make
>make install
>make && make install
Then /usr/local/bin/qemu-arm is installed.
8) Try to execute
>sb2 test
/bin/bash: ./factorial: No such file or directory
9) run sb2-show to find out a library is missing in path
>sb2-show
sb2-show: error while loading shared libraries: libsb2.so.1: cannot open shared object file: No such file or directory,
due to the bug of sb2 package in debain
Solution: download the newest version and reinstall sb2
... to be continued
Filesystem Hierarchy Standard (FHS)
A FHS standard compatible root has the following structure:
===========================================
bin | Essential command binaries |
boot | Static files of the boot loader |
dev | Device files |
etc | Host-specific system configuration |
lib | Essential shared libraries and kernel modules |
media | Mount point for removeable media |
mnt | Mount point for mounting a filesystem temporarily |
opt | Add-on application software packages |
sbin | Essential system binaries |
srv | Data for services provided by this system |
tmp | Temporary files |
usr | Secondary hierarchy |
var | Variable data |
/usr hierarchy
===============================
bin | Most user commands |
include | Header files included by C programs |
lib | Libraries |
local | Local hierarchy (empty after main installation) |
sbin | Non-vital system binaries |
share | Architecture-independent data |
Reference:
http://proton.pathname.com/fhs/pub/fhs-2.3.html
Buildroot vs OpenEmbedded
"Writing of BitBake recipes is more easy and more intuitive than writing Makefiles while providing higher flexibility. This allows you to tweak specific recipes for your very special needs and to add new recipes very fast. You can build toolchains, Software Distribution Kits (SDKs), complete Distributions or just single packages. The flexibility of OpenEmbedded allows you to reuse the once written recipes for many different purposes. OpenEmbedded provides everything buildroot will be able to provide. But in contrast to buildroot OpenEmbedded will allow you to achieve what you really want to achieve. You can add new package formats, new filesystems, new output formats easily. OpenEmbedded will suit your need."
Evolution of build tools
- The process of building a computer program is usually managed by a build tool
- Build Tool: program that coordinates and controls other programs
- The build utility needs to compile and link the various files, in the correct order
Make->Ant->Maven->BuiltRoot->BitBake
Nice introduction:
slurchin.googlecode.com/files/OpenEmbeddedv1.ppt
pre-built toolchains for arm
- Pre-built toolchains:
- CodeSourcery: This cross-compiler is used by almost all developers/companies using ARM devices. However, they only provide cross-compilers that work on x86/i386.
- Emdebian: This cross-compiler is used by Debian. Available for amd64/x86_64 and i386/x86.
- Angstrom
- Tools for creating cross-compilers:
- Crosstool-ng: Builds a cross-compiler from source. Non-distribution specific.
- Crossdev: Gentoo's cross-compiler builder. Needs Gentoo.
- Emdebian: Emdebian also provides ways to build your own toolchain.
Reference:
http://www.plugcomputer.org/plugwiki/index.php/Scratchbox2_based_cross_compiling
Check needed Dynamical Libraries in Linux
libglib-2.0.so.0 => /usr/local/lib/libglib-2.0.so.0 (0x00000000)
libc.so.6 => /lib/libc.so.6 (0x00000000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00000000)
2010-02-12
Scratchbox2
"Scratchbox provides a sandboxed build environment which offers a controlled set of tools and utilities needed for cross-compilation"
As shown in above, sb2 is a virtual execution environment, which requires two things:
- cross-compiler toolchain
FHS compliant target directory structure
- build source code for target system
- execute code in target system
- manage pacakges in target system.
Reference:
2010-02-10
Add Code to Blogger
<target name="compile" depends="init"
description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="classpath"/>
</target>
ElementType FrontAndDequeue(Queue Q) {
ElementType X = 0;
if (IsEmpty(Q)) {
Error("FrontAndDequeue Error: The queue is empty.");
} else {
Q->Size--;
X = Q->Array[Q->Front];
Q->Front = Succ(Q->Front, Q);
}
return X;
}
ls ./include/*.h | while read file; do
echo ${file} ...
( cat header.in; cat ${file} ) > ${file}.new
sed "s/\[filename\]/$file/g" ${file}.new
rm ${file}
mv ${file}.new ${file}
done
Remove the Kernal Package is Dangerous
>
apt-get remove kernel-image-2.4.27-2-386
Afterwards, the Debain cannot startup any more. :( If you check /boot/* and find out that vmlinux disappeared. Thus gnub cannot load kernel and the following error showed up:
grub error 8 kernel must be loaded before booting
2010-02-05
rename prefix of files
coDbRetrieverBase.h renamed as daDbRetrieverBase.h
coDbRetrieverById.h renamed as daDbRetrieverById.h
coDbRetrieverHeaderInfo.h renamed as daDbRetrieverHeaderInfo.h
coDbRetrieverImage.h renamed as daDbRetrieverImage.h
coDbRetrieverIngredients.h renamed as daDbRetrieverIngredients.h
coDbRetrieverProcedures.h renamed as daDbRetrieverProcedures.h
coDbRetrieverSortedNameIdPairs.h renamed as daDbRetrieverSortedNameIdPairs.h
coDbSqlReader.h renamed as daDbSqlReader.h
coDbTextSearchEngine.h renamed as daDbTextSearchEngine.h
2010-02-04
Recursively delete .svn directories
rm -rf `find . -type d -name .svn` Reference: http://www.anyexample.com/linux_bsd/bash/recursively_delete__svn_directories.xml
Install Correct Kernel Header for insmod
http://tldp.org/LDP/lkmpg/2.6/html/lkmpg.html#AEN128. However, the HelloWorld module is successfully built, but insmod failed.
> insmod hello-1.ko
insmod: error inserting 'hello-1.ko: -1 Invalid module format
After googling some time, Max figured out his Debian may have installed incorrect kernel header.
Check the running kernel by
>uname -r
2.6.26-2-686
First remove incorrect kernel header package by 'apt-get remove'
Install the following three packages:
- linux-headers-2.6.26-2-common
- linux-kbuild-2.6.26
- linux-headers-2.6.26-2-686
>dpkg-query --show | grep -i linux-
linux-headers-2.6.26-2-686 2.6.26-21
linux-headers-2.6.26-2-common 2.6.26-21
linux-kbuild-2.6.26 2.6.26-3
Now the hello-1.c can be build and loaded.
Reference:
2010-02-03
Build Qt State Machine Framework as a Static Library
- >wget ftp://ftp.trolltech.com/qt/solutions/lgpl/qtstatemachine-1.1-opensource.tar.gz
- >tar xvfz qtstatemachine-1.1-opensource.tar.gz
- >edit buildlib/buildlib.pro change CONFIG += dll to CONFIG +=staticlib
- >qmake qtstatemachine.pro
- >make
- static library is build at lib/libQtSolutions_StateMachineFramework-1.1.a.
2010-02-02
build yaffs2
- Download tarball of yaffs2 (http://www.aleph1.co.uk/cgi-bin/viewcvs.cgi/)
- >tar xvfz yaff2.tar.gz -C /opt
- >make (fails with the following messages)
make -C /lib/modules/2.6.26-2-686/build M=/opt/yaffs2 modules
make: *** /lib/modules/2.6.26-2-686/build: No such file or directory. Stop.
make: *** [modules] Error 2
The reason is the installation of kernel header didn't create a symbol link.
- >apt-get install build-essential (first check if your kernal header is installed)
- >ln -s /usr/src/linux-headers-2.6.26-1-686 /lib/modules/2.6.26-2-686/build (Then create a symbol link by)
- >make (build yaffs2 again)