Summer Nights

Let's make the world a better place using digital technologies!

Install Eclipse CDT on Ubuntu

sudo su
cd /usr/src
apt-get install sun-java6-jdk
update-alternatives --config java

Download eclipse cdt from
tar -xf eclipse-cpp-europa-winter-linux-gtk.tar.gz
cd eclipse

Create and build a “Hello World” project. Click on project -> new and follow simple instruction.
Build and execute the project. Simple.

Continue Reading

Howto: Build a gcc 4.2.3 based Coldfire Toolchain

You should have ample free space on your disk and I assume you are root.

  • Become root
    sudo su
  • Install the tools:
    apt-get install gcc g++ build-essential gcc-3.4 automake autoconf gdb bzip2 texinfo patch flex bison subversion
  • Make required folders:
    mkdir /usr/local/coldfire
    mkdir /usr/local/coldfire/source
    cd /usr/local/coldfire/source
  • Get and build binutils:
    bzcat binutils-2.17.tar.bz2 | tar -xf -
    mkdir build_binutils
    cd build_binutils
    ../binutils-2.17/configure --prefix=/usr/local/coldfire --target=m68k-elf --enable-multilib
    make -j2
    make install
    cd ..
  • Make and install gmp and mpfr libraries:
    cd /usr/src
    tar -xvf gmp-4.2.2.tar.gz
    cd gmp-4.2.2
    make -j 2
    make install
    cd ..

    bzcat mpfr-2.3.1.tar.bz2 | tar -xf -
    cd mpfr-2.3.1
    make -j 2
    make install
    cd ..

  • Update library configuration:
    depmod -a
  • Download newlib and gcc:
    tar -xzf newlib-1.16.0.tar.gz

    bzcat gcc-4.2.3.tar.bz2 | tar -xf -

  • mkdir build_gcc
    cd build_gcc
    export LD_LIBRARY_PATH=/usr/local/lib
  • cp -r /usr/include /usr/local/coldfire/m68k-elf/include
    (to solve ..
    ./tsystem.h:79:19: stdio.h: No such file or directory
    ./tsystem.h:82:23: sys/types.h: No such file or directory
    ./tsystem.h:85:19: errno.h: No such file or directory
    ./tsystem.h:92:20: string.h: No such file or directory
    ./tsystem.h:93:20: stdlib.h: No such file or directory
    ./tsystem.h:94:20: unistd.h: No such file or directory
    ./tsystem.h:100:18: time.h: No such file or directory

  • Configure gcc:
    ../gcc-4.2.3/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=m68k-elf \
    --disable-libmudflap --disable-libssp --disable-libgomp --enable-threads \
    --enable-languages=c --disable-checking --disable-shared --with-newlib\
    --with-bugurl= --with-pkgversion=HIRTS-0.1 \
    --disable-nls --prefix=/usr/local/coldfire --with-headers=/usr/src/linux/include \
    --enable-poison-system-directories --with-build-time-tools=/usr/local/coldfire/bin
  • Notes:
    1. with-arch=cf would make only coldfire-based binaries, but is not supported in 4.2.3.
    2. c++ does not work as well for some issue with libstdc++
    3. /usr/src/linux should refer to the current linux kernel sources.
    4. make -j4 CFLAGS="-I/usr/local/coldfire/source/newlib-1.16.0/newlib/libc/include does not work because of incompatible headers in newlib/libc
  • Make gcc:
    make -j6
    You may like to time the build using:
    time make -j6 (3m8.346s on my core 2 duo machine)
    make install
    cd ..
  • Make and install newlib
    cd newlib-1.16.0
    ./configure --target=m68k-elf --prefix=/usr/local/coldfire
    make -j6
    make install
    cd .
  • Check the toolchain:
    m68k-elf-gcc -v
    Using built-in specs.
    Target: m68k-elf
    Configured with: ../gcc-4.2.3/configure –build=i686-pc-linux-gnu –host=i686-pc-linux-gnu –target=m68k-elf –disable-libmudflap –disable-libssp –disable-libgomp –enable-threads –disable-libstdcxx-pch -disable-threads –enable-languages=c –disable-checking –with-gnu-as –with-gnu-ld –with-bugurl= –disable-shared –with-newlib –with-pkgversion=HIRTS-0.1 –disable-nls –prefix=/usr/local/coldfire –with-headers=/usr/src/linux/include –enable-poison-system-directories –with-build-time-tools=/usr/local/coldfire/bin
    Thread model: single
    gcc version 4.2.3
  • Compile s simple hello world program:
    cd /tmp
    emacs hello_world_m68k.c

    Enter the following simple program:
    #include <stdio.h>
    int hello_world (int argc, char *argv[])
    int i;
    printf ("Hello World\n");
    return (0);

    Press C-x C-s to save and C-x C-c to exit
    Compile the program:
    m68k-elf-gcc -g -c hello_world.c

Any feedback or comments are welcomed.

Continue Reading

Compiling and Installing new Linux Kernel on Ubuntu

  • sudo su
    apt-get install build-essential libncurses5-dev linux-kernel-devel
    cd /usr/src
  • Goto and download the latest kernel. At the time of writing:
  • Unzip the kernel source:
    bzcat linux- | tar -xf -
    Make a symbolic link to linux tree:
    ln -s /usr/src/linux- /usr/src/linux
  • Copy the old kernel .config file to the new kernelÅ› folder:
    cp /boot/config-2.6.24-16-generic linux/.config
    cd linux
    make oldconfig
    make menuconfig
  • Make kernel packages using debian tool:
    CONCURRENCY_LEVEL=2 (To compile kernel on dual core processor, optional)
    make-kpkg --initrd --revision=homebrew0.1 kernel_image kernel_headers
    Compile time: 47m55.465s on my Core 2 Duo
  • Add modules so that splash screen/console can load at boot
    echo vesafb | tee -a /etc/initramfs-tools/modules
    echo fbcon | tee -a /etc/initramfs-tools/modules
  • Install the new kernel
    dpkg -i linux-image-
    If you have already installed the same kernel, and are now rebuilding, you should do the following:
    mv /lib/modules/2.6.<KERNEL_VERSION> /lib/modules/2.6.<KERNEL_VERSION>_old
    This would make sure that older modules won’t be loaded after the new installation.
    dpkg -i linux-headers-
  • Reboot the system and select the freshly brewed kernel from the top of the list.
    Caution: If you have ndiswrapper running on your system for wireless connectivity, it will not work after installing the new kernel. Once the new kernel has booted, you may want to follow instructions here to re-install ndiswrapper. I have to investigate further to find out if it is possible to install ndiswrapper for other-than-running kernel.
Continue Reading

Batch Resizing of Images using Adobe Photoshop

In Adobe Photoshop:
File->Scripts->Image Processor

  • Select the source folder where the pictures are located.
  • Select the destination folder where the pictures will be stored after resizing.
  • Click Run to start batch processing.
Continue Reading

Copy files between local and remote systems

#rcp ~

will copy the file to the home folder of the local user. A . is not appropriate as that would refer to the remote location resulting in a remote duplicate.
rcp abc.tar
would copy the local file to a remote system. You shall be asked for a password during copy operation.

Continue Reading

Building RTEMS (Real-Time Executive for Multiprocessor Systems) for Coldfire using Opensource Tools

It really took me a couple of days to set things straight for a successful build. Here are the steps that I followed. Before starting, make sure you have ca. 1GB free space as the temporary files can easily consume a lot of space. I built everything on andLinux running on a Windows XP host.

  • Create necessary folders:
    mkdir /usr/local/rtems/source
    mkdir /usr/local/rtems/source/tools
    mkdir /usr/local/rtems/rtems-4.8
  • Add the path:
  • Install the pre-requisites:
    apt-get install automake gdb bzip2 texinfo autoconf patch
  • Get and build the development tools:
    cd /usr/local/rtems/source/tools

    Unzip the files:
    bzcat binutils-2.18.tar.bz2 | tar xf -
    tar -xvzf newlib-1.15.0.tar.gz
    bzcat gcc-4.2.2.tar.bz2 | tar xf -

    Get and apply the patches:

    cd binutils-2.18
    patch -p1 <../binutils-2.18-rtems4.8-20071104.diff cd ..

    cd newlib-1.15.0
    patch -p1 <../newlib-1.15.0-rtems4.8-20071221.diff cd ..

    cd gcc-4.2.2
    patch -p1 <../gcc-core-4.2.2-rtems4.8-20071127.diff rm -rf newlib ln -s ../newlib-1.15.0/newlib newlib cd ..

    Make and instal necessary libraries

    tar -xvf gmp-4.2.2.tar.gz
    cd gmp-4.2.2
    make install
    cd ..

    bzcat mpfr-2.3.1.tar.bz2 | tar -xf -
    cd mpfr-2.3.1
    make install
    cd ..

    Make a temporary build folder:
    rm -rf build
    mkdir build
    cd build

    ../binutils-2.18/configure -target=m68k-rtems4.8 -prefix=/usr/local/rtems/rtems-4.8
    make -w all install
    cd ..

    If you want to get the latest version of CVS-head you may use:
    cd /usr/src/rtems-4.9-9MAY08/source
    cvs -d login

    (Press ENTER for password)
    cvs -d -z 9 co -P rtems
    cd rtems
    (This will generate the configure script)
    cd ..
    In this case, however, the instructions given here may not apply exactly as they are.

    Clean the build folder:
    rm -rf build
    mkdir build
    cd build

    Now configure the gcc:
    ../gcc-4.2.2/configure -target=m68k-rtems4.8 \
    -prefix=/usr/local/rtems/rtems-4.8 \
    -with-gnu-as -with-gnu-ld -with-newlib -verbose \
    -with-system-zlib -disable-nls \
    -enable-version-specific-runtime-libs \
    -enable-threads=rtems \

    make -w all (It can take about an hour and newlib will also be compiled along with)
    make -w install
    cd ..\..
    (pwd: source)

  • Get and build RTEMS-4.8

    bzcat rtems-4.8.0.tar.bz2 | tar -xf -

    Make a clean build folder:
    rm -rf build
    mkdir build
    cd build

    Configure the rtems:
    ../rtems-4.8.0/configure -target=m68k-rtems4.8 \
    -prefix=/usr/local/rtems/rtems-4.8 \
    -enable-cxx -disable-tests -enable-networking \
    (-enable-docs is broken, results in @include `version.texi': No such file or directory.)

    Make the kernel for a given target:
    make -w RTEMS_BSP="av5282" install

    make RTEMS_BSP="uC5282" does not succeed because of the following gcc-4.2.2 error:
    ../../../../../../rtems-4.8.0/c/src/../../cpukit/shttpd/log.c: In function '_shttpd_log_access':
    ../../../../../../rtems-4.8.0/c/src/../../cpukit/shttpd/log.c:139: error: insn does not satisfy its constraints:
    (insn 74 158 159 10 ../../../../../../rtems-4.8.0/c/src/../../cpukit/shttpd/log.c:117 (set (mem/c:SI (plus:SI (reg/f:SI 14 %a6)
    (reg:SI 1 %d1)) [57 D.6862+0 S4 A16])
    (mem/s:SI (plus:SI (reg/v/f:SI 10 %a2 [orig:48 c ] [48])
    (const_int 220 [0xdc])) [2 S4 A16])) 34 {*movsi_cf} (nil)
    ../../../../../../rtems-4.8.0/c/src/../../cpukit/shttpd/log.c:139: internal compiler error: in reload_cse_simplify_operands, at

    Install RTEMS:
    make -w install

  • Build Addon Packages For Command Line Utilities

    Set the RTEMS_MAKEFILE_PATH variable to the BSP location:
    export RTEMS_MAKEFILE_PATH=/usr/local/rtems/rtems-4.8/m68k-rtems4.8/av5282
    cd /usr/local/rtems/source/rtems-addon-packages-4.8.0

    (If you have more than one targets, this needs to be done for each of them)
    Make the add-on tools
    sh bit

Continue Reading

Using the Ubuntu mirrors closest to you

You need to edit /etc/apt/sources.lst file.

  • First of all, find a mirror closes to you, which you know is also fastest for you, from the list of Ubuntu mirrors at Ubuntu Wiki. There are tools to benchmark the server speed, e.g., see netselect.
  • Copy the link of your selected mirror and change appropriately the sources.lst file.
  • As an example, have a look at my sources.lst file below with only Swiss mirrors used:

    deb gutsy main restricted
    deb gutsy-updates main restricted
    deb gutsy-security main restricted

    deb gutsy universe multiverse
    deb gutsy-updates universe multiverse
    deb gutsy-security universe multiverse

Continue Reading

Increasing the disk size in andLinux

  1. Stop the andLinux service and make sure no colinux daemon is running.
  2. Download dd for windows and put in the same folder as base.drv or wherever your “/” drive image is located.
  3. The following command extends a 4 GB partition to 16 GB:
    dd bs=16384 if=/dev/zero of=base.drv seek=262144 count=786432
  4. The seek=262144 tells dd that it should start filling zeros starting from this address which is the size of your 4GB image divided by 16384. In my case it is
    4294967296/16384=262144 number of 16K blocks.
  5. The count=786432 tells dd that it should fill 12GB of zeros. This is just (1024)^3/16384 number of blocks.
  6. After it has increased the file size, start the andLinux service and at the command prompt in Linux, type the following:
    apt-get install ext2resize
    ext2online /dev/cobd0
  7. Now you should have the new expanded hard disk image. To check, type:
    at the command prompt and you will see that /dev/cobd0 is now new size.
Continue Reading

andLinux Error: “cannot connect to X server”

If you encounter this error, you should check the following:

  • that the given IP address, which indicates your display, is reachable, either using ping, telnet, or some other approach
  • that Xming.exe is running. You can check it using Windows Task Manager.
  • If everything seems working, then you may try killing the Xming.exe from Task Manager and restarting it using the following command:
    <PATH-TO>\Xming.exe :0 -dpi 85 -clipboard -notrayicon -c -multiwindow -reset -terminate -unixkill -logfile Xming.log
    It solved this problem for me.
Continue Reading

Installing QEMU on andLinux

Follow these steps:

apt-get install gcc-3.4
ln -s /usr/bin/gcc-3.4 /usr/bin/gcc34
cd /usr/src
apt-get install libsdl1.2-dev
apt-get install libsdl1.2debian-all
tar -xvzf qemu-0.9.1.tar.gz
cd qemu-0.9.1
./configure (This selects all available targets)
make install

Continue Reading