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

Category: Real-Time Systems

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://git.denx.de/u-boot-coldfire.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.map 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 :pserver:anoncvs@sourceware.org:/cvs/src login

    Enter “anoncvs” as password.
    cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src 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
    wget http://ftp.sunet.se/pub/gnu/gmp/gmp-4.2.2.tar.gz
    tar -xvf gmp-4.2.2.tar.gz
    cd gmp-4.2.2
    make -j 2
    make install
    cd ..

    wget http://www.mpfr.org/mpfr-current/mpfr-2.3.1.tar.bz2
    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:
    wget ftp://ftp.mpi-sb.mpg.de/pub/gnu/mirror/gcc.gnu.org/pub/gcc/snapshots/4.3.1-RC-20080523/gcc-4.3.1-RC-20080523.tar.bz2
    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 :pserver:anoncvs@sources.redhat.com:/cvs/src 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=http://deneb.homedns.org/things --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 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://svn.gna.org/svn/xenomai/trunk xenomai
  • Goto www.kernel.org and download the latest kernel. At the time of writing:
    wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-
    bzcat linux- | tar -xf -
    ln -s linux- linux
  • cd xenomai
    ./configure --help
    to see the options and parameters.
    scripts/prepare-kernel.sh --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