My favorites | Sign in
Project Home Downloads Wiki
Search
for
Linux_Tutorial  
Updated May 7, 2011 by dave_fes...@hotmail.com

Compiling the kernel, installing kernel modules and making a JFFS2 rootfs for the Friendlyarm 64M dev board

Download toolchain, u-boot and kernel

Go to:

http://code.google.com/p/mini2440/downloads/list and download:

mini2440-bootstrap-v2.sh

Study this script.

In your [home] directory do a <Save file> from the Wiki Downloads page:

http://friendlyarm.googlecode.com/files/file-download.sh

and run it:

sudo ./file-download.sh

This script will get you the toolchain, the latest kernel, u-boot, compile u-boot and set-up the required directories. Note: there are some issues with u-boot, please see other posts on resolving this issue. I use an old version u-boot.bin as I am running a 64M dev board.

Place in .profile on your Linux host

  • export PATH=/home/user/mini2440-bootstrap/arm-2008q3/bin:$PATH
  • CROSS_COMPILE=arm-none-linux-gnueabi-
  • CC=”${CROSS_COMPILE}gcc –march=armv4t –mtune=arm920t”
  • export CROSS_COMPILE
  • export CC

Depending on permission’s sudo may be required on some commands.

Compile the kernel

(cd to mini2440-bootstrap)

[mini2440-bootstrap] # cd kernel/mini2440
[mini2440] # make ARCH=arm O=../../kernel-bin/ mrproper
[mini2440] # make ARCH=arm O=../../kernel-bin/ mini2440_defconfig
[mini2440] # make ARCH=arm O=../../kernel-bin/ menuconfig

At this point <Load an alternative configuration file> , for example ../config_mini2440_n35 . N.B. this will create a YAFFS2 file system.

  • configure the kernel to support the wanted file systems and MTD
  • select built-in and loadable kernel modules

When finished making changes <Save as an alternative configuration file> with the name .config . Select <Exit> and the compilation should proceed. When compilation finishes you can save your .config file as something unique for later use.

[mini2440] # make ARCH=arm O=../../kernel-bin/ -j4
[mini2440] # make ARCH=arm O=../../kernel-bin/ -j4 modules

If this fails and/or you want to start from a clean base do a make ARCH=arm distclean .

now, install the kernel modules
[mini2440] # sudo make ARCH=arm O=../../kernel-bin/ INSTALL_MOD_PATH=/home/user/mini2440-bootstrap/target/ modules_install
strip debug info, if you are worried about the size
# cd /home/user/mini2440-bootstrap/target/lib/modules

[modules] # /home/user/mini240-bootstrap/arm-2008-q3/arm-none-linux-gnueabi/bin/strip `find . –name “*.ko”`
(note: two back ticks)

Change target directory file permission’s

[mini2440-bootstrap] # sudo chown -R 0:0 /home/user/mini2440-bootstrap/target

Makes all files in [target] owned by root.

Make the uImage

[mini2440-bootstrap] # sudo ./uboot/mini2440/tools/mkimage –A arm –O linux -T kernel -C none –a 0x30008000 –e 0x30008000 -d kernel-bin/arch/arm/boot/zImage output/uImage

Compile Busybox

I started by compiling Busybox as static. When things are working properly you may want to re-compile as dynamic.

[busybox-1.13.3] # make defconfig
[busybox-1.13.3] # make ARCH=arm menuconfig
[busybox-1.13.3] # make clean
[busybox-1.13.3] # make ARCH=arm
[busybox-1.13.3] # make ARCH=arm CONFIG_PREFIX=/home/user/mini2440-bootstrap/target install 

Configure the New Target Root File System

Following the tutorial: http://wiki.davincidsp.com/index.php/Creating_a_Root_File_System_for_Linux_on_OMAP35x

check that the following are in [target] :

[target] # ls -la
bin, linuxrc-> bin/busybox, sbin and usr

Create the following directories:

[target] # mkdir –p dev
[target] # mkdir –p etc
[target] # mkdir –p lib
[target] # mkdir –p mnt
[target] # mkdir –p opt
[target] # mkdir –p proc
[target] # mkdir –p sys
[target] # mkdir –p tmp
[target] # mkdir –p var
[target] # mkdir –p var/log
[target] # mknod dev/null c 2 2  (chmod 777)
[target] # mknod dev/console c 5 1 (chmod 600)

I suspect that the two mknod entries are not required as mdev.conf (in the following example) seems to either create these or over-write them.

Use the /etc directory from this example rootfs.

http://friendlyarm.googlecode.com/files/rootfsjffs2.gz

Note: /etc gets mounted into ram so don’t expect any changes you make to files in /etc to survive a re-boot!

Don't use anything else from this file. There are probably much better ways to make a rootfs. Have a look here:

http://rootfs.wordpress.com/2010/04/23/the-busybox-file-system/

In fact he has several good tutorials.

Add the Shared Libraries Applications will Require

[mini2440-bootstrap] # cd /target
[lib] # cp –r /home/user/mini2440-bootstrap/arm-2008q3/arm-none-linux-gnueabi/libc/lib/* .

The libraries in this folder are for v5TE. For the v4T architecture I think the files wanted are:

[mini2440-bootstrap] # cd /target
[lib] # cp –r /home/user/mini2440-bootstrap/arm-2008q3/arm-none-linux-gnueabi/libc/armv4t/lib/* .

Creating a JFFS2 Root File System

Get mtd-tools and install them:

[mini2440-bootstrap] #sudo apt-get install mtd-tools

Make your rootfs.jffs2 image

[mini2440-bootstrap] # mkfs.jffs2 –lqnp –e 16 –r target –o output/my_rootfs.jffs2

Verify your rootfs on the host

Check my_rootfs.jffs2 by running the following script (mount_jffs2.sh):

N.B. ensure you have Linux line endings if doing a copy/paste!

Shell script to mount/unmount JFFS2 using kernel memory emulating MTD

#!/bin/sh
 JFFSIMG=$1 # jffs image
 MP="/media/jffs2" # mount point
 MTDBLOCK="/tmp/mtdblock0" # MTD device file
 UMNT=""

 echo "$0" | grep unmount_ >/dev/null 2>&1
 [ $? -eq 0 ] && UMNT=1
 if [ $# -gt 1 -a x"$2"x = x"unmount"x ]; then
   UMNT=1
 fi

 if [ x"${UMNT}"x = x""x ]; then
   if [ ! -b ${MTDBLOCK} ] ; then
     mknod ${MTDBLOCK} b 31 0 || exit 1
   fi
   modprobe mtdblock
   modprobe mtdram total_size=65536 erase_size=256
   modprobe jffs2
   dd if=${JFFSIMG} of=${MTDBLOCK}
   [ ! -d ${MP} ] && mkdir -p ${MP}
   mount -t jffs2 ${MTDBLOCK} ${MP}
 else
   umount ${MP}
   if [ $? -ne 0 ]; then
     echo "Cannot unmount JFFS2 at $MP" && exit 1
   fi
   modprobe -r jffs2
   modprobe -r mtdram
   modprobe -r mtdblock
 fi 

Place this script in the [mini2440-bootstrap] directory.

Make the shell script executable:

chmod a+x mount_jffs2.sh

Usage: (from [mini2440-bootstrap])

sudo ./mount_jffs2.sh output/my_rootfs.jffs2

You can also use this script to unmount and unload the non-utilized kernel modules:

sudo ./mount_jffs2.sh output/my_rootfs.jffs2 unmount

The above script was found here:

http://wiki.maemo.org/Modifying_the_root_image

Now follow Forrest Bao’s tutorial at:

http://narnia.cs.ttu.edu/drupal/node/131

I used the u-boot.bin referenced here u-boot.bin.

Substitute your own kernel image.

After you have loaded the kernel you can try the following test:

nand read 0x31000000 kernel 0x500000
bootm 0x31000000

You should observe that the kernel gets further through the boot process, possibly to the place where the file system would try to mount.

Now add your my_rootfs.jffs2 image.

Comment by abella...@gmail.com, Apr 3, 2011

This is what I get when I type the first line:

andre@ubuntu:~$ cd Downloads/
andre@ubuntu:~/Downloads$ ls
ATmega32_tft_ov7670_REV4.1
ATmega32_tft_ov7670_REV4.1.rar
Building.Embedded.Linux.Systems.pdf
file-download.sh
leopard-invoice
leopard-invoice.tar.bz2
mini2440-bootstrap-v2.sh
SD-8686-LINUX26-SYSKT-9.70.3.p24-26409.P45-GPL
SD-8686-LINUX26-SYSKT-9.70.3.p24-26409.P45-GPL.zip
andre@ubuntu:~/Downloads$ sudo ./file-download.sh 
[sudo] password for andre: 
sudo: ./file-download.sh: command not found
andre@ubuntu:~/Downloads$
Comment by pilamas...@gmail.com, Apr 12, 2011

Enter command "sudo chmod +x file-download.sh" before "sudo ./file-download.sh"

Comment by tomwestp...@gmail.com, May 10, 2011

Hi,

i tried to follow your tutorial, but when i come to the following line, i only get errors.

tom@LanqLin?:~/mini2440-bootstrap/kernel/mini2440$ sudo make ARCH=arm O=../../kernel-bin/ -j4

GEN /home/tom/mini2440-bootstrap/kernel-bin/Makefile
scripts/kconfig/conf -s arch/arm/Kconfig
CHK include/linux/version.h UPD include/linux/version.h GEN /home/tom/mini2440-bootstrap/kernel-bin/Makefile CHK include/linux/utsrelease.h UPD include/linux/utsrelease.h SYMLINK include/asm -> include/asm-arm Generating include/asm-arm/mach-types.h Using /home/tom/mini2440-bootstrap/kernel/mini2440 as source for kernel HOSTCC scripts/kallsyms HOSTCC scripts/pnmtologo CC scripts/mod/empty.o
cc1: error: unrecognized command line option "-mlittle-endian" cc1: error: unrecognized command line option "-mno-thumb-interwork" /home/tom/mini2440-bootstrap/kernel/mini2440/scripts/mod/empty.c:1:0: error: unknown ABI (aapcs-linux) for -mabi= switch /home/tom/mini2440-bootstrap/kernel/mini2440/scripts/mod/empty.c:1:0: error: bad value (armv4t) for -march= switch /home/tom/mini2440-bootstrap/kernel/mini2440/scripts/mod/empty.c:1:0: error: bad value (arm920t) for -mtune= switch make3?: [scripts/mod/empty.o] Fehler 1 make2?: [scripts/mod] Fehler 2 make2?: Warte auf noch nicht beendete Prozesse... /home/tom/mini2440-bootstrap/kernel/mini2440/scripts/kallsyms.c: In function ‘read_symbol’: /home/tom/mini2440-bootstrap/kernel/mini2440/scripts/kallsyms.c:112:9: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result
CC kernel/bounds.s
cc1: error: unrecognized command line option "-mlittle-endian" cc1: error: unrecognized command line option "-mno-thumb-interwork" /home/tom/mini2440-bootstrap/kernel/mini2440/kernel/bounds.c:1:0: error: unknown ABI (aapcs-linux) for -mabi= switch /home/tom/mini2440-bootstrap/kernel/mini2440/kernel/bounds.c:1:0: error: bad value (armv4t) for -march= switch /home/tom/mini2440-bootstrap/kernel/mini2440/kernel/bounds.c:1:0: error: bad value (arm920t) for -mtune= switch make2?:
[kernel/bounds.s] Fehler 1 make1?: prepare0? Fehler 2 make1?: Warte auf noch nicht beendete Prozesse... make1?: scripts? Fehler 2 make: [sub-make] Fehler 2

i tried the toolchain which comes with file-download.sh, tried an own CodeSourcery? Installation and the ToolChain? from FriendlyARM.net.

they all bring up the same error, which i cannot explain to myself. all these command line options are displayed in the gcc help.

btw: i am running this on a 32bit Ubuntu 11.04

thanks, tom


Sign in to add a comment
Powered by Google Project Hosting