2010年3月1日 星期一

Porting MINI2440

Mini2440 FriendlyARM for Embedded Developer

Startup Introduction

Mini2440 is an ARM9 architecture device providing embedded RISC Microprocessor solution empower from the Samsung S3C2440 CPU, the device has a 64M RAM and 128M Flash memory, equip with 3.5 inch TFT LCD, Ethernet interface, SD card, USB host and slave, a serial COM port and other ranges of hardware features.

This board comes with a BIOS (when switch to NOR BOOT) which can be used to format the NAND Flash, download image file into the memory, to boot up the system and etc, it is also preinstalled with a supervivi bootloader that will start up the Linux system (when switch to NAND BOOT) and showcase a front-end GUI Qt/Embedded applications.


Source Package

Open source code is provided with the bootloaders from vboot, vivi and u-boot-1.1.6, a copy of linux-2.6.29 source kernel, busybox-1.13.3 toolchains, Qtopia-2.2.0 development toolkit and the arm-linux-gcc-4.3.2 cross-compiler.

In addition, there are backup image of supervivi bootloader, kernel zImage and a copy of the root filesystem which contains all the Qtopia demo applications, it can be used to restore the original system in case of system crash.


System Setup

The host machine is install with a Fedora package and the Mini2440 is connect to the host system with a serial COM Port.

An Ethernet hub is also use to configure a client server network where by the NFS service is use to export the shared directory to the target system.



Doing the Work

The source kernel, compiler and toolkit provided is quite some times ago which i will upgrade the software to the current release.

Besides, the supervivi bootloader is a proprietary software base on vivi, but i prefer to use u-boot which is an open source program with proper documentations and lots of tutorial on the internet.

All the compiled programs will be installed in the NFS shared directory, when boot up from the target system the shared directory will be mounted to run the programs.


1. Install Cross Compiler

Download a copy of Sourcery G++ from codesourcery into the /usr/local/arm directory and decompress the zip file.

bzip2 -dc arm-2009q3.tar.bz2 |tar xvf -

Check what is the compiler version number.

/usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-gcc --version
arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q3-67) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.>

Optionally, make a reference link to the compiler directory.

ln -s arm-2009q3 4.4.1

Create soft link for all the bin files below.

cd 4.4.1/bin
ln -s arm-none-linux-gnueabi-addr2line arm-linux-addr2line
ln -s arm-none-linux-gnueabi-ar arm-linux-ar
ln -s arm-none-linux-gnueabi-as arm-linux-as
ln -s arm-none-linux-gnueabi-c++ arm-linux-c++
ln -s arm-none-linux-gnueabi-c++filt arm-linux-c++filt
ln -s arm-none-linux-gnueabi-cpp arm-linux-cpp
ln -s arm-none-linux-gnueabi-gcov arm-linux-gcov
ln -s arm-none-linux-gnueabi-gdb arm-linux-gdb
ln -s arm-none-linux-gnueabi-gdbtui arm-linux-gdbtui
ln -s arm-none-linux-gnueabi-gprof arm-linux-gprof
ln -s arm-none-linux-gnueabi-ld arm-linux-ld
ln -s arm-none-linux-gnueabi-nm arm-linux-nm
ln -s arm-none-linux-gnueabi-objcopy arm-linux-objcopy
ln -s arm-none-linux-gnueabi-objdump arm-linux-objdump
ln -s arm-none-linux-gnueabi-ranlib arm-linux-ranlib
ln -s arm-none-linux-gnueabi-readelf arm-linux-readelf
ln -s arm-none-linux-gnueabi-size arm-linux-size
ln -s arm-none-linux-gnueabi-sprite arm-linux-sprite
ln -s arm-none-linux-gnueabi-strings arm-linux-strings
ln -s arm-none-linux-gnueabi-strip arm-linux-strip

Create shell script for the bin files below with a 'armv4t' machine option.

echo arm-none-linux-gnueabi-g++ -march=armv4t $@ > arm-linux-g++
echo arm-none-linux-gnueabi-gcc -march=armv4t $@ > arm-linux-gcc
echo arm-none-linux-gnueabi-gcc-4.4.1 -march=armv4t $@ > arm-linux-gcc-4.4.1


Change the shell scripts attribute to executable mode.

chmod +x arm-linux-g++
chmod +x arm-linux-gcc
chmod +x arm-linux-gcc-4.4.1


Export the bin directory to the environment PATH variable.

Note, this line is necessary whenever logon to a new terminal, you may add it into your user profile to run this cmd automatically.

export PATH=/usr/local/arm/4.4.1/bin:$PATH

Test the shell script if it's working.

arm-linux-gcc -v

When successful the output result is display below.
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/julian/2009q3-respin-linux-lite/src/gcc-4.4/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite-multilibs --with-arch=armv5te --with-gnu-as --with-gnu-ld --with-specs='%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables} %{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --enable-shared --disable-lto --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 2009q3-67' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/julian/2009q3-respin-linux-lite/install/arm-none-linux-gnueabi/libc --with-gmp=/scratch/julian/2009q3-respin-linux-lite/obj/host-libs-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/julian/2009q3-respin-linux-lite/obj/host-libs-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-ppl=/scratch/julian/2009q3-respin-linux-lite/obj/host-libs-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/julian/2009q3-respin-linux-lite/obj/host-libs-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/julian/2009q3-respin-linux-lite/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/julian/2009q3-respin-linux-lite/install/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.4.1 (Sourcery G++ Lite 2009q3-67)

2. Build Boot-loader Image

Download a source copy from the mini2440 u-boot project into the /usr/src/bootloader directory and decompress the zip file.

gzip -cd dev-mini2440-stable.tar.gz |tar xvf -

A new directory 'mini2440' is created.

Optionally, change the directory name and make a reference link to the bootloader directory.

mv mini2440 mini2440-1.3.2
ln -s mini2440-1.3.2 u-boot


Create a u-boot configuration file for the target system.

cd u-boot
make clean
ARCH=arm make mini2440_config


Build the bootloader image

ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make
cp -rf u-boot.bin /var/lib/tftpboot


When finish without errors, the u-boot.bin file will be used to flash the u-boot image.


3. Build Kernel Image

Download a source copy from mini2440 kernel project into the /usr/src/kernels directory and decompress the zip file.

gzip -cd mini2440-stable.tar.gz |tar xvf -

A new directory 'mini2440' is created.

Optionally, change the directory name and create a reference link to the kernel directory.

mv mini2440 mini2440-2.6.32.7
ln -s mini2440-2.6.32.7 arm-linux


Create a kernel configuration file base on the old config_mini2440_n35 file from an earlier version eg. linux-2.6.29 from the Mini2440 package.

cd arm-linux
make clean
cp /usr/src/kernels/linux-2.6.29/config_mini2440_n35 ./.config
ARCH=arm make oldconfig


Press enter to select all the default settings, when finish a new .config file is generated while the old one is save in the .config.old.

Optionally, create a default configuration file if you don't have an existing .config file, this will produce the largest general-purpose configuration.

ARCH=arm make mini2440_defconfig

Change the kernel configuration setting below.

ARCH=arm make menuconfig

Go to 'File Systems' --> 'Network File Systems' --> Select 'NFS client support for NFS' and 'Root file system on NFS'

--- Network File Systems
<*> NFS client support
[*] NFS client support for NFS version 3
[*] NFS client support for the NFSv3 ACL protocol extension
[*] NFS client support for NFS version 4 (EXPERIMENTAL)
[ ] NFS client support for NFSv4.1 (DEVELOPER ONLY)
[*] Root file system on NFS
< > NFS server support


Go to 'Networking Support' --> 'Networking Options' --> Select the 'IP: kernel level autoconfiguration

[*] IP: kernel level autoconfiguration
[*] IP: DHCP support
[*] IP: BOOTP support
[*] IP: RARP support


Go to 'File System' --> 'Pseudo filesystems' --> Select 'Virtual memory file system support'

[*] /proc file system support
[*] Sysctl support (/proc/sys)
[*] Enable /proc page monitoring
[*] sysfs file system support
[*] Virtual memory file system support (former shm fs)
[*] Tmpfs POSIX Access Control Lists


Build the kernel image.

ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make zImage
cp -rf arch/arm/boot/zImage /var/lib/tftpboot


Build the kernel modules, if there are modules setup in the configuration file.

ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make modules
ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- make modules_install


Finally, compressed the kernel image to include checksum and header records require for use with u-boot.

mkimage -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 -d ./zImage ./uImage

Image Name:
Created: Tue Mar 2 22:51:28 2010
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2053096 Bytes = 2004.98 kB = 1.96 MB
Load Address: 30008000
Entry Point: 30008000

When finish without errors, the uImage file will be used to flash the kernel image.


4. Build System Tools and Utilities

Download a source copy from busybox into the /usr/src/toolchain directory and decompress the zip file.

cd /usr/src/toolchain bzip2 -dc busybox-1.16.0.tar.bz2 |tar xvf -

A new directory 'busybox-1.16.0' is created.

Make a reference link to the busybox directory.

ln -s busybox-1.16.0 busybox

Create a busybox configuration file base on the old fa.config file from an earlier version eg. busybox-1.13.3 from the Mini2440 package.

cd busybox
make clean
copy /usr/src/toolchain/busybox-1.13.3/fa.config ./.config
ARCH=arm CC=arm-linux-gcc-4.4.1 make oldconfig


Press enter to select all the default settings, when finish a new .config file is generated while the old one is save in the .config.old.

Optionally, create a default configuration file if you don't have an existing fa.config file, this will produce the largest general-purpose configuration.

ARCH=arm CC=arm-linux-gcc-4.4.1 make oldconfig

Change the configuration setting below.

make menuconfig

Go to 'Busybox Settings' --> 'Installation Options' --> Change the busybox installation prefix to './_install'

[ ] Don't use /usr
Applets links (as soft-links) --->
(./_install) BusyBox installation prefix


Go to 'Busybox Settings' --> 'Build Options' --> Change the cross compiler prefix to 'arm-linux'

[ ] Build BusyBox as a static binary (no shared libs)
[ ] Build BusyBox as a position independent executable
[ ] Force NOMMU build [ ] Build shared libbusybox
[*] Build with Large File Support (for accessing files > 2 GB)
(arm-linux-) Cross Compiler prefix
() Additional CFLAGS


Build the busybox system.

ARCH=arm CC=arm-linux-gcc-4.4.1 make
ARCH=arm CC=arm-linux-gcc-4.4.1 make install


When finish without errors, the _install system folder will be used to build the root filesystem.



More Information

Furthre Reading

7 則留言:

  1. hi charles

    its an interesting blog but I want to know more about the NOR boot and the NAND boot

    回覆刪除
  2. Hi charles
    Its really an interesting blog, but I want to know how can I run my X application such xcalc,etc with touchscreen interface. I can run ts_* binaries. But now I have added some graphical application. But I am not able to get touchscreen effect. please help me...

    回覆刪除
  3. Hi charles!! I have a problem with mini2440-friendlyArm
    I can not run spectrum QT demo on it,because can not load module audio device
    how to fix it?? please

    回覆刪除
  4. So nice Document ...!!

    I am working on mini2440 arm board. I want to increase board freq. upto 500Mhz. Using google get some idea. now i want to increase using uboot loader.

    Do u know how to do ?

    Give me direction. i am new on that.
    My mail id is chaudharyparesh1986@gmail.com

    回覆刪除
  5. Hello,

    I have the mini2440 board with 64MB flash. I am having difficulty playing audio.

    # aplay -l
    aplay: device_list:223: no soundcards found...

    Upon booting, it appears I have the same boot sequence as you do, but I think I am missing something perhaps in my rootfs that is required for ALSA and madplay to detect my sound card.


    # cat /proc/asound/cards
    0 [S3C24XXUDA134X ]: UDA134X - S3C24XX_UDA134X
    S3C24XX_UDA134X (UDA134X)
    # ll /proc/a
    /proc/apm /proc/asound/
    # ll /proc/asound/
    total 0
    dr-xr-xr-x 5 root root 0 Dec 31 17:04 ./
    dr-xr-xr-x 46 root root 0 Dec 31 17:00 ../
    lrwxrwxrwx 1 root root 5 Dec 31 17:04 S3C24XXUDA134X -> card0/
    dr-xr-xr-x 4 root root 0 Dec 31 17:04 card0/
    -r--r--r-- 1 root root 0 Dec 31 17:04 cards
    -r--r--r-- 1 root root 0 Dec 31 17:04 devices
    dr-xr-xr-x 2 root root 0 Dec 31 17:04 oss/
    -r--r--r-- 1 root root 0 Dec 31 17:04 pcm
    dr-xr-xr-x 2 root root 0 Dec 31 17:04 seq/
    -r--r--r-- 1 root root 0 Dec 31 17:04 timers
    -r--r--r-- 1 root root 0 Dec 31 17:04 version
    #

    All appears OK, but I also get


    # madplay /usr/bin/1.wav
    MPEG Audio Decoder 0.15.2 (beta) - Copyright (C) 2000-2004 Robert Leslie et al.
    ALSA lib pcm_hw.c:1399:(_snd_pcm_hw_open) Invalid value for card
    audio: No such file or directory

    Please advise.


    All the best,

    Vince.

    回覆刪除
  6. I have the mini2440 the board with 1GB flash and LCD w35. My mini 2440 have installed with linux platform and i have tried program with Qt. i have a problem when i am booting with NOR flash and it appear only black screen. Could you help me to my email iqbalhabibie@gmail.com

    回覆刪除
  7. Hello,
    em2440 bios list is not getting displayed
    how to solve it

    回覆刪除