Summer Nights

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

Continue Reading

Get all files of a given type linked on a webpage using wget

wget is a command line utility to download files from internet. You can use it to get all files or of a given type linked on a webpage. e.g, use:
wget -r -l1 -H -t1 -nd --limit-rate=8k -N -np -A.pdf -erobots=off
to download all pdf files linked on somepage.asp.

-r makes it recursive, -l1 is to allow 1-level deep recursion, -H allows it to span hosts while doing recursion. -t1 stands for number of re-tries (here “1”), -nd for no-directory structure, -N to enable time stamping so that only newer same files are overwritten, -np for no-parent retrieval, -A to enforce certain filers, and the rate is limited to 8 KBytes/sec.

This functionality is also available in GUI form in firefox using an addon called downthemall.

Continue Reading

Checking Memory Leaks in Visual Studio C/C++ Programs

Add the following to the top of the file containing main function:
#include <stdlib.h>
#include <crtdbg.h>

Add following line before the end of the main function, or wherever the main can return:

Compile as debug and execute. Memory leaks will be printed on the output window which can be clicked to point the problem location.

Continue Reading

Howto: Installing AWSTATS on Apache

  • Download AWStats from
  • Unzip the file to a temporary folder, e.g., tar -xvzf awstats-6.7.tar.gz
  • Create a folder /var/www/awstats
  • From the awstats file you unzipped in step 2 copy the “js”, “classes”, “css” and “icon” folders (located in the wwwroot folder) to the “/var/www/awstats” folder you just created in your website directory.
  • Copy the contents of the “cgi-bin” folder into your cgi-bin website directory (/usr/lib/cgi-bin). This is selected in a default way, as specified in your /etc/apache2/apache2.conf or /etc/apache2/sites-enabled/000-default or your own configuration file by the following directives:
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all

    You may also need to add:
    AddHandler cgi-script .cgi .pl
    in your /etc/apache2/apache2.conf file as well as
    Options FollowSymLinks +ExecCGI +SymLinksIfOwnerMatch in the <Directory /> section.
  • Copy the awstats.model.conf file to in the cgi-bin directory and change the following parameters:
    LogFile = "../www/log.%YYYY%MM" (assuming your log files are being placed in the www root directory).
    SiteDomain = ""
    DirIcons = "TO YOUR NEEDS "
    AllowToUpdateStatsFromBrowser = 1
  • Use ./ -update to update the stats manually from the command prompt.
    To add the awstats update to cron jobs, do:
    crontab -e -u root
    00 * * * * /usr/lib/cgi-bin/ -update >/dev/null 2>&1
    C-o to save C-x to exit
    This shall add a cron job that will run at 00 of every hours, i.e., every hour.
  • If, while updating using web-interface, you see the following error:
    Cannot generate update files from the webpage
    Error: Couldn’t open server log file “/var/log/apache2/access.log” : Permission denied

    You need to change permissions on log files. Issue:
    chmod -R 755 /var/log/apache2
    to solve it.
Continue Reading

Howto: Build a boot image for Coldfire using U-Boot

  • Get the git:
    apt-get install git-core
  • Get latest u-boot sources for coldfire:
    cd /usr/src
    mkdir u-boot && cd u-boot
    git-clone git://
    cd u-boot-coldfire
  • Make u-boot for M5282EVB evaluation board. A list of available boards can be found under board/ folder and of cpus under cpu/. Now make the images:
    make M5282EVB_config
  • You might encounter the error:

    start.S: Assembler messages:
    start.S:143: Error: operands mismatch — statement `movec %d0,%RAMBAR1′ ignored
    start.S:169: Error: operands mismatch — statement `movec %d0,%RAMBAR1′ ignored
    make[1]: *** [start.o] Error 1
    make[1]: Leaving directory `/usr/src/u-boot/u-boot-coldfire/cpu/mcf52x2′

    To correct this error:
    emacs /usr/src/u-boot/u-boot-coldfire/cpu/mcf52x2/start.S
    On lines 143 and 169, change RAMBAR1 to RAMBAR0

  • At the end of compilation you will get the following files that can be used to boot an M5282EVB coldfire board:
    u-boot u-boot.bin u-boot.srec
Continue Reading

Howto: Building gcc/g++ toolchain for Motorola Coldfire/M68K Processors (II)

In a previous post, I have described how to make a coldfire toolchain using gcc 4.2.3. In this post, we shall see how we can use the latest cvs trunks to build the toolchain based on latest sources.

You should have ample free space (ca. 3GB) on your hard 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 cvs
  • Make required folders:
    mkdir /usr/local/coldfire
    mkdir /usr/local/coldfire/source
    cd /usr/local/coldfire/source
  • Get and build binutils:
    mkdir binutils
    cd binutils
    cvs -z 9 -d login

    Enter “anoncvs” as password.
    cvs -z 9 -d co binutils
    mkdir build_binutils
    cd build_binutils
    ../src/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 and uncompress latest gcc sources, at the time of writing:
    bzcat gcc-4.3.1-RC-20080523.tar.bz2 | tar -xf gcc-4.3.1-RC-20080523.tar.bz2
  • Get newlib and link to gcc:
    mkdir newlib
    cd newlib
    cvs -z 9 -d co newlib

    Enter "anoncvs" as the password.
    cd ../gcc-4.3.1-RC-20080523
    rm -rf newlib
    ln -s ../newlib/src/newlib newlib
    cd ..
  • Make and install gcc:
    mkdir build_gcc
    cd build_gcc
    export LD_LIBRARY_PATH=/usr/local/lib

    Configure the toolchain:
    ../gcc-4.3.1-RC-20080523/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,c++ --disable-checking --disable-shared --with-newlib \
    --with-bugurl= --with-pkgversion=HIRTS-0.1 \
    --disable-nls --prefix=/usr/local/coldfire --enable-poison-system-directories \ --with-build-time-tools=/usr/local/coldfire/bin

    Make and install the toolchain (can take ca. 1 hour on most computers!):
    make -j4
    make install

  • Add the tools to your path:
    emacs /etc/profile
    Add /usr/local/coldfire/bin to the end of PATH
    Press C-x C-s to save, C-x C-c to exit. Enter:
    source /etc/profile
    to load the new path information.
    This will add it to all the users' path except root. If you want to add it to root's path as well, you need to edit .bashrc file in /root folder by adding the following:
  • Check the toolchain:
    m68k-elf-gcc -v
    Using built-in specs.
    Target: m68k-elf
  • Compile a 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 -mcpu=5282 hello_world_m68k.c

Feedback/comments are welcomed.

Continue Reading

Installing Netgear WG11T Wi-Fi Stick in Ubuntu 7.04, Kernel

  • First of all, clear any traces of previous installs, if any:

    sudo su
    apt-get remove ndiswrapper-utils
    cd /usr/src/ndiswrapper
    make uninstall
    make clean
    rm -r /etc/ndiswrapper/
    rm -r /etc/modprobe.d/ndiswrapper
    cd ..
    rm -rf ndiswrapper
  • Get, unzip, make and install new ndiswrapper:
    tar -xzf ndiswrapper-1.52.tar.gz
    cd ndiswrapper-1.52
    make install
  • Install the WG11T drivers:
    Copy the windows xp drivers of WG11T to /usr/src/wlandrivers. Then,
    cd /usr/src/wlandrivers
    ndiswrapper -i athfmwdl.inf
    ndiswrapper -i netwg11t.inf

    modprobe ndiswrapper
    should make the adapter active, some leds may flash
  • ndiswrapper -m
    will include the module in the auto-load at bootup sequence.
Continue Reading

Installing Xenomai on Ubuntu with Linux Kernel 2.6.25

You should have ~2-3GB free space to make the kernel and must have root privileges.

  • sudo su
    apt-get install subversion
    mkdir /usr/src/xenomai
    cd /usr/src/xenomai
    svn co svn:// xenomai
  • Goto and download the latest kernel. At the time of writing:
    bzcat linux- | tar -xf -
    ln -s linux- linux
  • cd xenomai
    ./configure --help
    to see the options and parameters.
    scripts/ --linux=/usr/src/xenomai/linux
  • Configure the Linux kernel
    cd ../linux
    Copy the old configuration file, you may need to change the name depending on your kernel version:
    cp /boot/config- .config
    make menuconfig

    I chose the following options. Dis means pressing “n”(for no), and En means pressing “y” (for yes). When you get into Real-time sub-system section, you should closely read the messages on top. It will indicate if some un-recommended/conflicting options are set.

    Dis: Kernel IRQ Balancing
    Dis: APM
    Dis: CPU Freq Scaling
    Dis: CPU Idle PM Support
    Dis: Legacy Power Management
    Dis: HPET Timer
    Dis: ACPI Processor
    Dis: all deprecated from ACPI
    Dis: WMI
    Dis: Power Management Timer Support
    Dis: ACPI Container Driver
    En: Enable Periodic Timing -> RT Subsystem
    En: Scalability -> 0(1) Scheduler
    En: Enable SMI Workaround
    En: Globally Disable SMI
    En: POSIX API all enable
    En: Select support for RTDM file descriptors
    En: Serial Driver -> Any access mode
    Dis: Check for non-fatal errors on AMD Athlon/Duron / Intel Pentium 4
    Dis: check for P4 thermal throttling interrupt.
    Dis: Enable kernel irq balancing
    Dis: Power Management Timer Support
    Dis: APM (Advanced Power Management) BIOS suppor
    Dis: All Interfaces except Native API and POSIX

  • make-kpkg clean
  • Make the new kernel, can take ca. 1 hour:
    CONCURRENCY_LEVEL=2 (on dual core processors)
    make-kpkg --initrd --append-to-version=-rtosx --revision=0.1 kernel_image kernel_headers

    Note:Do not use xeno in --append-to-version option as linux disregards xeno in some of its operations which creates a chaotic situation when finding proper /lib/modules/kernel_version folder.
  • 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 newly built kernel and headers:
    dpkg -i linux-image-
    dpkg -i linux-headers-
  • Type:
    cat /etc/grub/menu.lst
    to confirm that the new kernel has been properly entered into the list. If not, you may need to add it manually.
  • Boot with the new kernel:
    shutdown -r now
  • Build and install xenomai user-space components:
    cd /usr/src/xenomai
    mkdir build_root && cd build_root
    ../xenomai/configure --enable-x86-sep --enable-smp
    make -j4
    make install
  • Test the new Xenomai RTOS:
    cd /usr/xenomai/bin

    At the end of some tests, you should see the user-space RT latencies. Press Ctrl-C to exit the test.
Continue Reading

Resize, Rename and Compress Images on the Fly

Issue the following command in the folder where *.JPG files are located:
for i in *.JPG; do convert -resize 800x600 -quality 90 $i s_$i; tar --remove-files -rvf pics.tar s_$i; done
The files will be resized, renamed with a prefix of s_ and will be added to the pics.tar.
tar -tvf pics.tar
to see the contents of the created archive.
If zip is required, then use:
for i in *.JPG; do convert -resize 800x600 -quality 90 $i s_$i; zip -m s_$i; done

Continue Reading

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