Friday, April 5, 2013

Creating and Flashing UBIFs on MINI2416

UBIFS creation took me a while to understand and execute,it proved  a worthwhile experience.
my objective was to create 2 volume of UBIFS,one for rootfs and other for data.
since the uboot I was using did not support UBIFS I choosed to write from linux with the help 
of tools available with mtd-utilities.

About UBIFS on web

Software used to accomplish this activity 
linux 2.6.39 configured for mtd support ported on MINI2416 with 128Mb Nand flash
precompiled tool chain and rootfs avilable on denx site
rootfs with mtd-utilites compiled
install mtd-util on host ubuntu machine 
I created core-image-minimal-mtdutils on USB-Stick on ext2 partition,once the linux is up. 

use mtdinfo -a to list the info on mtd partitions for the board,usefull for creating ubifs image.

Name:                           UBOOT
Type:                           nand
Eraseblock size:                131072 bytes, 128.0 KiB
Amount of eraseblocks:          8 (1048576 bytes, 1024.0 KiB)
Minimum input/output unit size: 2048 bytes
Sub-page size:                  512 bytes
OOB size:                       64 bytes
Character device major/minor:   90:0
Bad blocks are allowed:         true
Device is writable:             true

Name:                           kernel
Type:                           nand
Eraseblock size:                131072 bytes, 128.0 KiB
Amount of eraseblocks:          24 (3145728 bytes, 3.0 MiB)
Minimum input/output unit size: 2048 bytes
Sub-page size:                  512 bytes
OOB size:                       64 bytes
Character device major/minor:   90:2
Bad blocks are allowed:         true
Device is writable:             true

Name:                           ROOTFS
Type:                           nand
Eraseblock size:                131072 bytes, 128.0 KiB
Amount of eraseblocks:          992 (130023424 bytes, 124.0 MiB)
Minimum input/output unit size: 2048 bytes
Sub-page size:                  512 bytes
OOB size:                       64 bytes
Character device major/minor:   90:4
Bad blocks are allowed:         true
Device is writable:             true

Preparing NAND partition 
we used mtd2 partition for ubifs image.
root@generic-armv5te:~#flash_eraseall /dev/mtd2

Creating UBIFS image

mkfs.ubifs -r basicrootfs/  -m 2048 -e 126976 -c 200 -F -o basicrootfs.ubi
mkfs.ubifs -r data/  -m 2048 -e 126976 -c 792 -F -o data.ubi

To flash image to Nand from From Linux,we require to ubinize  tool on the host machine.

ubinize -vv -o basicrootfs.ubi -m 2048 -p 128KiB ./ubirootfs.cnf 

ubirootfs.cnf file captures the details of two volume created is as below.

Flash the UBI file system image (ubi.img) to MTD partition "X"
ubiformat /dev/mtd2 -f basicrootfs1.ubi -s 512 -O 2048 

Changes in u-boot enviroment  to set boot arguments.
setenv bootargs 'console=ttySAC1,115200n8 noinitrd  rootwait=2 ubi.mtd=2,2048 rootfstype=ubifs root=ubi0:rootfs'

mounting the data volume
mount -t ubifs ubi0:data /media/data

Monday, September 26, 2011

Scratch Box2 , Qemu with ELDK tool chain

1 Compile and Install Qemu
a) Download qemu-0.14.1.tar.gz ,use the this link
b) extract the qemu, tar -xvzf qemu-0.14.1.tar.gz
c) configure Qemu source.
./configure --prefix=$HOME/qemu --target-list=arm-linux-user
d) Compile and Install the binaries.
e)make install

2 Compile and install sbox2
a) git clone git://
cd sbox2
b) sbox2 gives compilation error patch the source with the file given in the link below.
patch -p1 -i /PATH-TO-PATCH/sbox2.patch
c)run ./ to create a configuration file.
d) ./configure --prefix=$HOME/sb2
e) make install
f) PATH=$PATH:$HOME/sb2/bin

Target creation.
I have a ELDK toolchain installed on /opt/eldk, so:
cd /opt/eldk/arm
sb2-init -c /opt/qemu/bin/qemu-arm armv4 /opt/eldk/usr/bin/arm-linux-gnueabi-gcc
Once sb2-init is successfully installed,we can use it for cross-compiling source.
glib cross-compiling.
Download glib-2.24.0.tar.bz2
sb2 ./configure --prefix=/opt/gst --disable-static --with-html-dir=/tmp/dump
sb2 make install

Wednesday, July 27, 2011

GTK+ DirectFB cross compilation

GTK+, or the GIMP Toolkit, is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets. GTK+ is suitable for projects ranging from small one-off tools to complete application suites.

I have download the below softwares to start with.
















With scratchbox2 and qemu on the host machine cross compiling was straightforward.

Cross compiling order

1) tslib
sb2 ./configure --prefix=/opt/gtkfb
sb2 make install

2) zlib
since glib require zlib
sb2 ./configure --prefix=/opt/gtkfb --shared
sb2 make install

3) glib
LDFLAGS=-L/opt/gtkfb/lib CPPFLAGS=-I/opt/gtkfb/include/ sb2 ./configure --prefix=/opt/gtkfb --disable-static --with-html-dir=/tmp/dump
sb2 make install

4) atk
export PKG_CONFIG_PATH=/opt/gtkfb/lib/pkgconfig
LDFLAGS=-L/opt/gtkfb/lib CPPFLAGS=-I/opt/gtkfb/include/ sb2 ./configure --prefix=/opt/gtkfb --disable-glibtest
sb2 make install

5) jpeg-8b
sb2 ./configure --prefix=/opt/gtkfb --enable-shared --enable-static
sb2 make install

6) libpng
LDFLAGS=-L/opt/gtkfb/lib CPPFLAGS=-I/opt/gtkfb/include/ sb2 ./configure --prefix=/opt/gtkfb
sb2 make install

7) expat-2.0
sb2 ./configure --prefix=/opt/gtkfb
sb2 make install

8) freetype
sb2 ./configure --prefix=/opt/gtkfb
sb2 make install

LDFLAGS=-L/opt/arm/gst/lib CPPFLAGS=-I/opt/arm/gst/include/ sb2 ./configure --prefix=/opt/gtkfb --without-python
sb2 make install

LDFLAGS=-L/opt/arm/gst/lib CPPFLAGS=-I/opt/arm/gst/include/ sb2 ./configure --prefix=/opt/gtkfb --with-freetype-config=/opt/gtkfb/bin/freetype-config

11) tiff -- not used gcc 4.3.2
LDFLAGS=-L/opt/arm/gst/lib CPPFLAGS=-I/opt/arm/gst/include/ sb2 ./configure --prefix=/opt/gtkfb --enable-shared
sb2 make install

12) DirectFB
LDFLAGS=-L/opt/arm/gst/lib CPPFLAGS=-I/opt/arm/gst/include/ sb2 ./configure --prefix=/opt/gtkfb --with-gfxdrivers=none --with-inputdrivers=all --enable-png --enable-jpeg --enable-tiff=no --enable-zlib --enable-sdl=no --enable-gif=no --disable-x11
sb2 make install

13) pixman-0.18.2
LDFLAGS=-L/opt/arm/gst/lib CPPFLAGS=-I/opt/arm/gst/include/ sb2 ./configure --prefix=/opt/gtkfb --disable-gtk

14) cairo
LDFLAGS=-L/opt/gtkfb/lib CPPFLAGS=-I/opt/gtkfb/include/ sb2 ./configure --prefix=/opt/gtkfb --without-x --disable-xlib --disable-xlib-xrender --enable-directfb --enable-freetype --disable-win32 --enable-pdf --enable-ps --enable-svg --enable-png

15) Pango
LDFLAGS=-L/opt/gtkfb/lib CPPFLAGS=-I/opt/gtkfb/include/ sb2 ./configure --prefix=/opt/gtkfb --without-x

16 gtk
LDFLAGS=-L/opt/gtkfb/lib CPPFLAGS=-I/opt/gtkfb/include/ sb2 ./configure --prefix=/opt/gtkfb --with-gdktarget=directfb --without-x --without-libtiff --disable-glibtest --disable-cups

Now to compile a simple helloworld.c pro-gramme with these libraries.
export PKG_CONFIG_PATH=/opt/gtkfb/lib/pkgconfig
arm-linux-gcc -Wall -g helloworld.c -o helloworld `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` -Wl,-O1 -Wl,-rpath,/opt/gtkfb/lib

Monday, May 2, 2011

mini2440 as USB mass storage gadget device

To make mini2440 as USB mass storage device,I needed to check both the schematics and source code. I am not sure the reason GPG12 GPIO port pin is used by touch screen, however this is not captured in schematics. also referred link to establish this task.

Step 1:
so the first step is to disable the touch screen driver in the kernel source tree.

step 2:
--- USB support
[*] USB device filesystem
<*> USB Gadget Support --->
File-backed Storage Gadget

step 3:
cross compile the kernel,boot the new kernel and filesystem. go to compiled linux source tree and download g_file_storage.ko to mini2440.

step 4:
Creating a backing storage file
since the mini2440 has 64 MB flash, I allocated 10MB space for backup storage file.
bash# dd bs=1M count=10 if=/dev/zero of=/root/backing_file

step 5:

Partitioning the backing storage

     bash# fdisk /root/backing_file
Device contains neither a valid DOS partition table, nor Sun or SGI disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

You must set heads sectors and cylinders.
You can do this from the extra functions menu.

Command (m for help):

Give the "x" (eXpert or eXtra) command:

Command (m for help): x
now select Heads, Sectors, and Cylinders
g_file_storage uses a sector size of 512 bytes, so 8 sectors/track will give us 4096 bytes
per track
Expert command (m for help): s
Number of sectors (1-63): 8
Warning: setting sector offset for DOS compatiblity

With 4 KB per track, 16 heads will give us a total of 64 KB per cylinder
Expert command (m for help): h
Number of heads (1-256): 16

Since we've got 64 KB per cylinder and 10 MB total, we need to use 320
Expert command (m for help): c
Number of cylinders (1-131071): 320

Now return to the normal menu (the "r" command):
Expert command (m for help): r

creating a primary partition

     Command (m for help): n
Command action
e extended
p primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-1024, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1024, default 1024):
Using default value 1024

Since you want to use the gadget with a Windows host, you should change the
partition type (the "t" command) to FAT32 (code "b")
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): b
Changed system type of partition 1 to b (Win95 FAT32)

Finally write out ("w") the partition table to the backing storage:
Command (m for help): w
The partition table has been altered!

Adding a filesystem
   You use the losetup program to set up the loop
device driver with the proper offset:

# losetup -o 4096 /dev/loop0 /root/backing_file

and then you can mount it:

# mount -t vfat /dev/loop0 /mnt/loop

is mapped to the partition within the backing
storage. You can create a filesystem on it:
# mkdosfs /dev/loop0

now do "insmod
g_file_storage file=/root/backing_file" on mini2440,then connect mini2440 to host PC.
the FAT32 partition with will be visible as storage device on Host system

Wednesday, March 31, 2010

ELDK on mini2440

The Embedded Linux Development Kit (ELDK) includes the GNU cross development tools, such as the compilers, binutils, gdb, different Target architecture including arm.

Download link

Creating enviroment on host PC.
linuxhost > mkdir eldk
linuxhost > mkdir install_mount
linuxhost > cd eldk/
linuxhost/eldk > su
linuxhost/eldk # mount -o loop,exec ../arm-2007-01-21.iso ../install_mount/
linuxhost/eldk # exit

linuxhost/eldk > ls ../install_mount/
. arm ELDK_FIXOWNER etc install RPMS tools
.. common ELDK_MAKEDEV icons README.html sys version

linuxhost/eldk > ../install_mount/install arm
linuxhost/eldk > chmod u+x eldk_init

now unmount the ISO image as root

linuxhost/eldk > ./eldk_init arm
export these variable to environment,or include them as part of .bashrc file.

Using ELDK for mini2440

compiling the Kernel...
Error found while compiling the kernel
kernel/bounds.c:1: error: invalid ABI option: -mabi=aapcs-linux
Fix is to un select Kernel Features ---> [ ] Use the ARM EABI to compile the kernel
Now do make in kernel source,the kernel is successfully build on ELDK.

Building the Root file system
untar the root_qtopia.tar.gz which is available on CD.
cd root_qtopia
rm bin sbin lib usr -rf
cp /opt/ELDK/arm/lib . rf

BusyBox combines tiny versions of many common UNIX utilities into a single small executable,I have used busybox-1.16.0 for my filesystem.
compilation is very straightforward. make menuconfig,
In BusyBox Settings -->Build Options , use 'arm-linux-' as cross compiler prefix.
In Installation Options-> , update the BusyBox Installation prefix
busybos build will create 'bin','sbin','usr' folders in its installation folder.
copy these folders to root_qtopia/
cp /{bin,sbin,usr} root_qtopia/ -rf

now yaffs2 image for root_qtopia and upload it to mini2440 board.

mkyaffs2image root_qtopia rootfs.img

Thursday, March 25, 2010

QT Media Player on mini2440

To run the media player example in QT we require cross-compile Gstreamer as back-end
cross compiling gstreamer was made comparatively easy for me,thanks to Mr. Felipe Contreras blog.

This is the link to his blog.

For my board mini2440 I cross compiled the following source and installed in "/opt/gst" in my root filesystem.
  • glib
  • gstreamer
  • liboil
  • gst-plugin-base
  • gst-plugin-good
  • gst-plugin-ugly

Now you cross compile QT4.6 with phonon enabled,and linking the gstreamer library.

export PKG_CONFIG_PATH=/opt/gst/lib/pkgconfig

./configure -prefix /opt/qt-4.6/build -debug -shared -fast -pch -no-qt3support -qt-sql-sqlite -no-libtiff -no-libmng -qt-libjpeg -qt-zlib -qt-libpng -qt-freetype -no-openssl -nomake examples -nomake demos -nomake tools -optimized-qmake -no-nis -no-opengl -no-cups -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-xkb -no-feature-CURSOR -no-sm -no-xinerama -no-xshape -webkit -no-separate-debug-info -xplatform qws/linux-arm-g++ -embedded arm -depths 16 -no-qvfb -qt-gfx-linuxfb -no-gfx-qvfb -no-kbd-qvfb -no-mouse-qvfb -qt-kbd-tty -confirm-license -qt-mouse-tslib -phonon -I /opt/gst/lib/glib-2.0/include -I /opt/gst/include/glib-2.0 -I /opt/gst/include/gstreamer-0.10/gst -L /opt/gst/lib -L /opt/gst/lib/gstreamer-0.10 -force-pkg-config -v

After doing 'make install' the libraries are installed on '/opt/qt-4.6/build'

create '/opt/qt-4.6/build' in mini2440 filesystem copy QT related libraries.
create '/opt/gst/lib' in mini2440 copy the contents of the '/opt/gst/lib' on PC to mini2440 filesystem's '/opt/gst/lib'

once this is done cross compile the QT MediaPlayer example in QT Source tree, and copy it on the board and run it.

please don't forget to update the 'LD_LIBRARY_PATH' in the environment variable.

export LD_LIBRARY_PATH=$QTDIR/lib:/opt/gst/lib

Please see my previous blog on crosscompiling QT for mini2440 board for details.

Wednesday, February 10, 2010

Adding new driver on Linux2.6.30 source tree


This section deals with adding new driver onto the Linux source tree,I have added Lumidigm Venus Driver as character driver.

step 1: copy the driver source code(vcom.c) and into character folder of Linux source tree.

step 2: Edit the Kconfig file in the char folder and add the following line.
bool "Limidigm fingerprint USB driver"
depends on ARCH_S3C2440
default m if ARCH_S3C2440
say Y here to select,otherwise say N.
The Above configuration will give the option to the user for select/deselect Lumidigm driver,for S3C2440 Architecture with default as driver selected.
And help will display "say Y here to select,otherwise say N."

step 3: Edit Makefile in the char folder and add the following line
obj-$(CONFIG_LUMIDIGM) += vcom.o
prefix "CONFIG_" before "LUMIDIGM" flag as set in KConfig file.
save the configuration and do a menuconfig to verify the changes.

on menuconfig we will see the "[*] Limidigm fingerprint USB driver" in Device Drivers ---> Character devices --->