Friday, July 12, 2013

uboot - For beagleboard XM

The configuration for BeagleBoard and BeagleBoard-xM is omap3_beagle. The configuration for BeagleBone is am335x_evm.
To rebuild:
  • Install ARM cross-compiler. On Ubuntu:
    • sudo opkg install gcc-arm-linux-gnueabi
  • git clone git://git.denx.de/u-boot.git && cd u-boot
  • ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make am335x_evm_config|omap3_beagle_config
  • ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make
Typical boot process for BeagleBoard using U-Boot includes two U-Boot phases:
  1. The BeagleBoard ROM bootloader first loads a file called "MLO" from the SD card. This requires special formatting of the SD card and copying of the "MLO" file to the SD card. The "MLO" file is provided by U-Boot's Secondary Program Loader (SPL) functionality. It is placed into the u-boot folder upon build.
  2. The U-Boot SPL configures the off-chip memory and then loads the full U-Boot. The file is typically called "u-boot.img" and SPL will typically look for it in the root folder of a FAT partition, but other options are possible
 Note: It seems that the latest u-boot clone from denx packaged with the latest buildroot supplies 'SPL' support in the menuconfig. From what I understand SPL ( named MLO ) now replaces xloader as the second stage bootloader after the OMAP 1st stage loader in ROM. Long story short enable SPL (MLO) support from u-boot and build with the omap3_beagle defconfig and everything works just fine!

serial boot: http://elinux.org/BeagleBoard#USB-to-Serial_Converter 

Beagleboard - Notes


Linux on BeagleBoard Xm
       Version 1.5 [J512]

Details
1. Introduction 3
2. Do this (Practical Notes) 3
2.1 How to Create Root File System (RAMDISK) using BusyBox? 4
2.2 How to Cross Compile a module? 8
2.3 How to enable Ethernet(SMSC9514) in Linux 3.0.4 for BeagleBoard Xm? 9
2.4 How to flash(blink) an LED in BeagleBoard? 10
2.5 How to run a web server in BeagleBoard? 14
2.6 How to mount the root file system over NFS? 14
2.7 How to boot kernel using initramfs for root file system? 15
2.8 How to enable core dump? 16
2.9 How to create cscope database for a particular kernel build? 16
3. ToolChain 16
4. Cross-Compiling Linux 16
5. Cross-Compiling BusyBox 17
6. Cross-Compiling U-Boot 18
7. Making Root File System 19
8. Links 19
9. Notes 20


1. Introduction


The following components are required (obvious) for booting BeagleBoard Xm with Linux.
      1. Tool chain
      2. U-Boot Boot loader
      3. Root File System (BusyBox)
            1. Ramdisk { Section 2.1 }
            2. NFS { Section 2.6 }
            3. initramfs { Section 2.7 }
            4. JFFS2 { MTD,NAND }
            5. ROMFS/CRAMFS { Read Only File System }
      4. Linux Kernel
      5. Tftp and nfs servers on the host system

2. Do this (Practical Notes)


Two important files: /etc/inittab & /etc/init.d/rcS
Exactly follow this excellent link: http://processors.wiki.ti.com/index.php/Creating_a_Root_File_System_for_Linux_on_OMAP35x



To make RAMDISK WORK after fresh busybox compilation:
1. Replace /etc/inittab with working version
2. Replace /etc/init.d/rcS with working version
3. Populate /lib with all the require so(shared object files) libraries
[NOTE: Also available in arm-unknown-linux-gnueabi/sys-root/lib/]
4. For kernel 3.0 -->
setenv bootargs console=ttyO2,115200n8 root=/dev/ram0 rw ramdisk_size=32768 initrd=0x81600000,32M For kernel 2.6.36 -->
setenv bootargs mem=88M ip=172.16.9.111 console=ttyS2,115200n8 root=/dev/ram0 rw initrd=0x81600000,16M ramdisk_size=16384

2.1 How to Create Root File System (RAMDISK) using BusyBox?

STEP 1: Build busybox[Normal user OK]

$ mkdir /home/vinod/tgt
Goto busybox source & build & last step: make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- CONFIG_PREFIX=/home/vinod/tgt install
This would install 3 dirs in tgt folder
$ cd /home/vinod/tgt

[3 Points here → (1) Create some dirs (2) Create some files (3) Copy the sharel libraries]

STEP 2: Create required dirs for root file system [Do this as root]

mkdir dev;
mknod dev/console c 5 1;
mkdir dev/pts;
mkdir etc;
mkdir etc/init.d;
mkdir lib;
mkdir mnt;
mkdir opt;
mkdir proc;
mkdir root;
mkdir sys;
mkdir tmp;
mkdir var;
mkdir var/log;
mkdir debug

STEP 3: Populating the required shared libraries {Do this as ROOT}
$ cd /home/vinod/tgt/lib
$ cp -r /home/vinod/cctools/build/target/arm-unknown-linux-gnueabi/sys-root/lib/* .

Use the following command for a CodeSourcery cross-compiler.
[cp -r /home/vinuz/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/libc/lib/* .]

STEP 4: Populate other required files
$ cd etc/
$ vi fstab
proc /proc proc defaults 0 0
none /tmp tmpfs defaults 0 0
none /dev/pts devpts gid=5,mode=622 0 0
$ vi group
root:x:0:root
$ vi passwd
root::0:0:root:/root:/bin/ash [NOTE: Have seen /bin/bash also]
$ vi hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost

$ vi inittab
# /etc/inittab

# System configuration/initialization script.
# This is run first except when booting in single-user mode
#
::sysinit:/etc/init.d/rcS

# Start an "askfirst" shell on the console
::askfirst:-/bin/sh

# Things to do when restarting the init process
::restart:/sbin/init

# Things to do before rebooting
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a


==========================================================
$ vi init.d/rcS

#!/bin/sh
# ---------------------------------------------
# Common settings
# ---------------------------------------------
HOSTNAME=beagleboard_vinod
VERSION=0.90

hostname $HOSTNAME

# ---------------------------------------------
# Prints execution status.
#
# arg1 : Execution status
# arg2 : Continue (0) or Abort (1) on error
# ---------------------------------------------
status ()
{
if [ $1 -eq 0 ] ; then
echo "[SUCCESS]"
else
echo "[FAILED]"
if [ $2 -eq 1 ] ; then
echo "... System init aborted."
exit 1
fi
fi

}

# ---------------------------------------------
# Get verbose
# ---------------------------------------------
echo ""
echo " $HOSTNAME (v$VERSION) : System initialization..."
echo ""
echo " Kernel release : `uname -s` `uname -r`"
echo " Kernel version : `uname -v`"
echo ""


# ---------------------------------------------
# MDEV Support
# (Requires sysfs support in the kernel)
# ---------------------------------------------
echo -n " Mounting /proc : "
mount -n -t proc /proc /proc
status $? 1

echo -n " Mounting /sys : "
mount -n -t sysfs sysfs /sys
status $? 1

echo -n " Mounting /dev : "
mount -n -t tmpfs mdev /dev
status $? 1

echo -n " Mounting /dev/pts : "
mkdir /dev/pts
mount -t devpts devpts /dev/pts
status $? 1

echo -n " Enabling hot-plug : "
echo "/sbin/mdev" > /proc/sys/kernel/hotplug
status $? 0

echo -n " Populating /dev : "
mkdir /dev/input
mkdir /dev/snd

mdev -s
status $? 0


# ---------------------------------------------
# Mount the default file systems
# ---------------------------------------------
echo -n " Mounting other filesystems : "
mount -a
status $? 0


# ---------------------------------------------
# Set PATH
# ---------------------------------------------
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin


# ---------------------------------------------
# Start other daemons
# ---------------------------------------------
echo -n " Starting syslogd : "
/sbin/syslogd
status $? 0

echo -n " Starting telnetd : "
/usr/sbin/telnetd
status $? 0
echo -n 0 > /sys/power/fb_timeout_value
mkdir /dev/v4l
ln -s /dev/video1 /dev/v4l/video1
ln -s /dev/video2 /dev/v4l/video2

# ---------------------------------------------
# Done!
# ---------------------------------------------
echo ""
echo "System initialization complete Mr.Vinod ."
==========================================================

$ vi mdev.conf
audio 0:5 0666
console 0:5 0600
control.* 0:0 0660 @/bin/mv /dev/$MDEV /dev/snd/
dsp 0:5 0666
event.* 0:0 0600 @/bin/mv /dev/$MDEV /dev/input/
fb 0:5 0666
nfs 0:5 0770
null 0:0 0777
pcm.* 0:0 0660 @/bin/mv /dev/$MDEV /dev/snd/
rtc 0:0 0666
tty 0:5 0660
tty0* 0:5 0660
tty1* 0:5 0660
tty2* 0:5 0660
tty3* 0:5 0660
tty4* 0:5 0660
tty5* 0:5 0660
tty6* 0:5 0660
ttyS* 0:5 0640
urandom 0:0 0444
zero 0:0 0666

NOTE: chmod a+x /home/vinod/tgt/etc/init.d/rcS

STEP 5: Creating & booting a RAMDISK
============================= ==
dd if=/dev/zero of=rd-ext2.bin bs=1k count=16384
mke2fs -F -m0 rd-ext2.bin
mount -t ext2 rd-ext2.bin /mnt -o loop
tar -C tgt -cf - . | tar -C /mnt -xf -
umount /mnt
cp rd-ext2.bin /tftpboot
============================= ==

STEP 6: Give this bootargs in uboot prompt
1. setenv ipaddr 172.16.9.111; setenv serverip 172.16.9.110; usb reset;
2. setenv bootargs mem=88M ip=172.16.9.111 console=ttyO2,115200n8 root=/dev/ram0 rw initrd=0x81600000,16M ramdisk_size=16384
3. tftp 81600000 rd-ext2.bin
4. tftp 80000000 uImage
5. bootm

For 2.6.36 kernel: setenv bootargs mem=88M ip=172.16.9.111 console=ttyS2,115200n8 root=/dev/ram0 rw initrd=0x81600000,16M ramdisk_size=16384
For 3.0.4 kernel: setenv bootargs console=ttyO2,115200n8 root=/dev/ram0 rw ramdisk_size=32768 initrd=0x81600000,32M

As the Ramdisk size increases the corresponding change should be reflected in:
(This happens when files get added to the target root file system.)
      1. bootargs { mem and ramdisk_size parameters }
      2. kernel compilation { Main menu – Device Drivers – Block devices - RAM block device support - Default RAM disk size (kbytes) }
(Use the arm-none-linux-gnueabi-strip program to strip off unneeded headers and debug information once an application or driver has been fully debugged and ready for inclusion in the image. )
(Ramdisk is treated as a block device)

2.2 How to Cross Compile a module?



$ sudo su
$ export ARCH=arm
$ export CROSS_COMPILE=arm-unknown-linux-gnueabi-
$ export PATH="/home/vinod/cctools/build/target/bin":$PATH
$ make


Makefile
obj-m+=hi.o
all:
make -C /home/vinod/files/beagle/linux-3.0.4/ M=$(shell pwd) modules
hi.c
#include
#include

static int __init hello_init(void)
{
printk(KERN_INFO "Hello example init \n");
return 0;
}

static void __exit hello_exit(void)
{
printk(KERN_INFO "Hello example exit \n");
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Vinod");
MODULE_DESCRIPTION("Simple test module");

2.3 How to enable Ethernet(SMSC9514) in Linux 3.0.4 for BeagleBoard Xm?




https://github.com/nguillaumin/beagle-carputer/wiki/system-Customise-Kernel
https://bugs.launchpad.net/linux-linaro/+bug/622429


[Driver Files: drivers/net/usb/smsc95xx.c, drivers/net/usb/usbnet.c]
While compiling the kernel select the following two options as compile time modules:
      1. The BeagleBoard-xM Ethernet adapter is in fact an Ethernet to USB adapter provided by an SMSC LAN9514:
        Device Drivers – Network Device support – USB Network Adapters - SMSC LAN95XX based USB 2.0 10/100 ethernet devices
      2. Enable support for USB 2.0 HUBs, the adapter being connected to the HUB:
        Device Drivers – USB Support - EHCI HCD (USB 2.0) support


Check on Target: ifconfig, ipaddr, ping 172.16.9.110
{ To fix the ip address: ifconfig eth0 172.16.9.111 up }


[NOTE: The same method didn't work with 2.6.36 kernel]

2.4 How to flash(blink) an LED in BeagleBoard?



sysfs is a virtual file system. sysfs exposes the drivers for the hardware.


GPIO interfacing from userspace
gpio-sysfs (/sys/class/gpio) is the preferred method of gpio interfacing from userspace.
Getting access to a GPIO:
The GPIO number should be used.
{ For example the usr1 led gpio number is 150 in BeagleBoard. }
$ echo 150 > /sys/class/gpio/export [To get control]
$ echo 150 > /sys/class/gpio/unexport [To give out control]
Getting and setting direction:
echo "out" > /sys/class/gpio/gpio150/direction [Set as o/p]
cat /sys/class/gpio/gpio150/direction
Getting and setting state(value):
echo "1" > sys/class/gpio/gpio150/value
echo "0" > sys/class/gpio/gpio150/value




Note
(150 is usr1 LED, 149 is usr0 ... You can also access expansion port GPIO that way, say 168 for pin 24)
cd /sys/class/gpio
echo 150 > export [A new dir named gpio150 is created]
cd gpio150/
echo "high" > direction
echo "low" > direction
OR
echo "out">direction
echo "1">value
echo "0">value
Unmount the device:
cd /sys/class/gpio/
echo 150 > unexport


Links


C – Source Code
/*
* Blink usr1 led on BeagleBoard - Pin number 150
* Author: Vinod Sasidharan
* Wednesday, Nov 2, 2011
*/


#include
#include
#include


FILE *fp;


void writefile(FILE *myfp,char *s,int num);


void writefile(FILE *myfp,char *s,int num)
{
//Set pointer to begining of the file
rewind(myfp);
//Write our value to the file
fwrite(s, sizeof(char), num, myfp);
fclose(myfp);
}


int main()
{
char setval[4];
int toggle = 0;


printf("\n========================================\n");
printf(" Blink usr1(PIN 150) led @ 1Hz ");
printf("\n========================================\n");


/*
* 1. Using sysfs write 150 to /sys/class/gpio/export.
* 2. This would create the folder gpio150.
*/
if( (fp = fopen("/sys/class/gpio/export","ab")) == NULL)
{
printf("Cannot open export file...\n");
exit(1);
}


strcpy(setval,"150"); /* Write 150 to the file */
writefile(fp,(char *) &setval,3);
printf("Export file accessed, new pin 150 now accessible...\n");


/* Set DIRECTION */
if ((fp = fopen("/sys/class/gpio/gpio150/direction", "rb+")) == NULL)
{
printf("Cannot open direction file.\n");
exit(1);
}
//Write our value of "out" to the file
strcpy(setval,"out");
writefile(fp, (char *)&setval,3);
printf("Direction set to output...\n");
//SET VALUE
//Open the LED's sysfs file in binary for reading and writing, store file pointer in fp
if ((fp = fopen("/sys/class/gpio/gpio150/value", "rb+")) == NULL)
{
printf("Cannot open value file.\n");
exit(1);
}
//Write our value of "1" to the file
strcpy(setval,"1");
writefile(fp, (char *)&setval,1);
printf("Value set to 1...\n");
//-------------------------------------------------------------
//Run an infinite loop - will require Ctrl-C to exit this program
while(1)
{
if ((fp = fopen("/sys/class/gpio/gpio150/value", "rb+")) == NULL)
{
printf("Cannot open value file.\n");
exit(1);
}
toggle = !toggle;
if(toggle)
{
//Write our value of "1" to the file
strcpy(setval,"1");
writefile(fp, (char *)&setval,1);
printf("Value set to 1...\n");
}
else
{
//Write our value of "0" to the file
strcpy(setval,"0");
writefile(fp, (char *)&setval,1);
printf("Value set to 0...\n");
}
//Pause for one second
sleep(1);
}
//-------------------------------------------------------------


return 0;
}


ON HOST
$ arm-unknown-linux-gnueabi-gcc-4.3.5 -o blink blink.c
ON TARGET
$ tftp -g -r blink 172.16.9.110
$ chmod a+x blink
$ ./blink {ctrl + c to exit}


2.5 How to run a web server in BeagleBoard?



On target { with IP Address – 172.16.9.111 }:
$ cd /opt
$ mkdir www
$ cd www
$ vi index.html
Welcome to busybox – By Vinod
$ busybox httpd -h /opt/www


On Host:
Open web browser and type: http://172.16.9.111


LINKS



2.6 How to mount the root file system over NFS?



Enable ethernet driver for target
While compiling the kernel enable the ethernet drivers properly before trying NFS. See section 2.3 “How to enable ethernet for beagle”.



On Host
Install and run the nfs server. The nfs directory is set as “/home/vinod/tgt” and root file system has been installed into this.
Update the exports file with the following line:
$ vi /etc/exports
/home/vinod/tgt *(rw,insecure,no_root_squash,no_subtree_check)
For Ubuntu's NFS server:
$ service nfs-kernel-server status
$ /etc/init.d/nfs-kernel-server status


On Target
STEPS: Type these in uboot prompt
  1. setenv ipaddr 172.16.9.111; setenv serverip 172.16.9.110; usb reset;
  2. setenv bootargs console=ttyO2,115200n8 root=/dev/nfs rw nfsroot=172.16.9.110:/home/vinod/tgt ip=172.16.9.111::255.255.255.0 nolock,rsize=1024,wsize=1024 rootdelay=2
  3. tftp 80000000 uImage
  4. bootm


2.7 How to boot kernel using initramfs for root file system?



A system using initramfs as its root file system doesn't even need a single file system driver built into the kernel, because there are no block devices to interpret as file systems. Just files living in memory.
The initramfs enables initial file system and init program to reside in kernel memory cache, rather than on a ramdisk, as with initrd filesystems.


On Host
NOTE: To be able to detect initramfs by kernel properly, the top level directory in the root file system (/home/vinod/tgt) has to contain a program called init. For example, this can be done by using a soft link from top level init to ./bin/busybox (assuming you are using BusyBox in your initramfs)system
$ cd /home/vinod/tgt
$ ln -s ./bin/busybox init


$ cd ~/files/beagle/linux-3.0.4/ { Target Linux source code directory }
$ make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- menuconfig
General setup - Initial RAM filesystem and RAM disk (initramfs/initrd) support - Initramfs source file(s) - “/home/vinod/tgt”
$ make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- uImage -j3
$ du -h arch/arm/boot/uImage
7.0M arch/arm/boot/uImage
$ cp arch/arm/boot/uImage /tftpboot




On Target
STEPS: Type these in uboot prompt
      1. setenv ipaddr 172.16.9.111; setenv serverip 172.16.9.110; usb reset;
      2. tftp 80000000 uImage
      3. bootm


LINKS

2.8 How to enable core dump?



The core dump can be enabled by:
$ ulimit
$ ulimit -a
$ ulimit -c unlimited

When the Segmentation fault (SIGSEGV: A Linux kernel signal that is generated on illegal memory access by a user process.) occurs, if the core dumping feature is enabled, a file named core would be obtained in the same directory.

Core dump analysis using gdb:
$ gcc -g -o hi hi.c
$ ./hi
Segmentation fault (core dumped)
$ gdb hi core

Commands used in gdb:
l(list), p(print) ptr, bt(backtrace), frame 0/1/2 (stack frame related),


2.9 How to create cscope database for a particular kernel build?



The Linux kernel Makefile supports building the database that cscope (GUI: cbrowser) uses:

$ make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- cscope


3. ToolChain

http://permalink.gmane.org/gmane.linux.busybox/31535
http://elinux.org/ARMCompilers
Use Cross-Tool Ng for creating the toolchain
http://www.labbookpages.co.uk/electronics/beagleBoard/custom.html http://linuxdeveloper.blogspot.com/2011/08/build-your-own-cross-compilation-tool.html




Steps:

4. Cross-Compiling Linux

git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git
[ Linux 3.0.4 → omap2plus_defconfig ]
export CROSS_COMPILE=arm-unknown-linux-gnueabi-
export ARCH=arm
make omap2plus_defconfig/spear300_defconfig

[copies default board configuration from "arch/arm/configs/" to .config]
make menuconfig/oldconfig/xconfig
make uImage
-----------------------------

# just to make sure everything is clean
1) make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- distclean
2) make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- omap2plus_defconfig

#change config, if needed
3) make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- menuconfig
4) make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- uImage

Adding Kernel driver modules to the root file system:
5) make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- modules
6) make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- INSTALL_MOD_PATH=/home/vinod/tgt modules_install
{ The kernel modules would be copied to the /home/vinod/tgt/modules directory}
$ cd /home/vinod/tgt/modules
$ arm-none-linux-gnueabi-strip `find . -name "*.ko"` {To remove the debug info}
du -h “ & sdiff have been used to see the differences in size after and before using strip.
The total size of the modules folder has been reduced to 1.8MB from 22MB.



http://elinux.org/BeagleBoardLinuxKernel







5. Cross-Compiling BusyBox




 git clone git://busybox.net/busybox.git
[http://www.busybox.net/source.html]



http://rcs.uncc.edu/wiki/index.php/Creating_Root_File_System#Using_BusyBox



Once the Cross Compiler is set you can setup BusyBox with the following commands:
  1. make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- defconfig
  2. make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- menuconfig
    • This opens a commandline menu, make the following changes:
      • BusyBox Settings --> Installation Options --> BusyBox Installation Prefix:
        • ../rootfs
          {clean, mrproper, distclean}
  3. make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi-
    • Compiles the executables
  4. make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- CONFIG_PREFIX=/home/vinod/tgt install
    • Copies the executables to the rootfs directory



LINKS
      1. http://www.ibm.com/developerworks/library/l-busybox/

6. Cross-Compiling U-Boot



$ git clone git://git.denx.de/u-boot.git u-boot-main [Source Code]
$ cd u-boot-main
make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- distclean
make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- omap3_beagle_config
make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi-


[arm-none-linu-gnueabi - if CodeSourcery cross compiler is used]




NOTE: With the above compilation u-boot gets loaded properly, but the tftpboot command is not present. Hence do the following steps:
$ vi include/configs/omap3_beagle.h {and define the following}
#define CONFIG_USB_ETHER 1
#define CONFIG_USB_USBNET 1
#define CONFIG_CMD_NET { #undef CONFIG_CMD_NET could be present}
#define CONFIG_CMD_PING


To enable ethernet in u-boot & boot linux for beagle
setenv usbethaddr 0:0:1:2:3:4
setenv ipaddr 192.168.1.6
setenv serverip 192.168.1.2
usb reset
ping 192.168.1.2
setenv bootargs mem=88M ip=172.16.9.111 console=ttyO2,19200n8 root=/dev/ram0 rw initrd=0x81600000,16M ramdisk_size=16384
tftp 81600000 rd-ext2.bin
tftp 80000000 uImage
bootm

7. Making Root File System


http://processors.wiki.ti.com/index.php/Creating_a_Root_File_System_for_Linux_on_OMAP35x



Bootargs for RFS
1.
NAND(JFFS2): root=/dev/mtdblock4 rw rootfstype=jffs2
2.
RAMDISK: root=/dev/ram0 rw ramdisk_size=32768 initrd=0x81600000,32M
3.
MMC/SD: root=/dev/mmcblk0p2 rw rootwait
4.
NFS: root=/dev/nfs rw nfsroot=172.16.9.110:/home/vinod/tgt ip=172.16.9.111::255.255.255.0 nolock,rsize=1024,wsize=1024 rootdelay=2Creating RAMDISK
dd if=/dev/zero of=ramdisk bs=1k count=32768
mkfs.ext2 ramdisk
mount -o loop ramdisk /mnt
tar -xvjf fs.tar.bz2 -C /mnt
{Other methods to copy may be fine}
umount /mnt
gzip ramdisk



8. Links

  1. http://beagleboardxm.blogspot.com/
  2. http://processors.wiki.ti.com/index.php/Creating_a_Root_File_System_for_Linux_on_OMAP35x
  3. http://rcs.uncc.edu/wiki/index.php/Creating_Root_File_System#Using_BusyBox
  4. http://old.nabble.com/-U-Boot--BeagleBoard-xM%3A-Ethernet-over-USB-supported---td30851592.html
  5. https://github.com/nguillaumin/beagle-carputer/wiki/system-Customise-Kernel
  6. http://elinux.org/Category:ECE497
  7. http://elinux.org/EBC_Embedded_Beagle_Class_Topics
  8. https://groups.google.com/forum/?hl=en#!msg/beagleboard/20rM-r8C2YY/hVZiN2ahI8YJ [Beagle Board GPIO]
  9. http://elinux.org/ECE497_-_32-bit_Embedded_Linux,_Rose-Hulman



9. Notes

Usage of tar
Compress contents of directory tgt to fs.tar.bz2:

cd tgt
tar cjfv fs.tar.bz2 .
Extract contents of fs.tar.bz2 to directory vin:
tar xjfv fs.tar.bz2 -C vin


Usage of tftp in busybox (To download a file hi.ko from host)
tftp -g -r hi.ko 172.16.9.110

Create a soft link (Create a soft link named init to ./bin/busybox)
ln -s ./bin/busybox init




Change permission of all files in a folder
chmod -R 777 myfolder/

Removing lock of serial port
(e.g.: When minicom shows the error "Device /dev/ttyS0 is locked." )
rm /var/lock/LCK..ttyS0
Setting static ip
ifconfig eth0 172.16.9.110 netmask 255.255.255.0 up


10. New toolchain & os-less experiments




The new toolchain from codesourcery(now mentor graphics) is being used.






11. Require tools for cross-compiling on Ubuntu
  • automake
  • bison
  • curl
  • cvs
  • flex
  • g++
  • gawk
  • libncurses5-dev
  • libtool
  • texinfo


12. How to avoid "mkimage" command not found - U-Boot images will not be built error while cross-compilig linux kernel?
Install uboot-mkimage package to avoid this error.


13. How to cross-compile X-Loader?
git clone git://gitorious.org/x-load-omap3/mainline.git x-loader
As above mentioned, the SRAM in beagleboard-xm is very tiny as 64K, the u-boot image size is almost 196K, so beagleboard-xm can not use u-boot as MLO. The x-load is used here, which can be considered as u-boot loader, and it’s size is around 24K.
Get mainline x-load source code from
git clone git://gitorious.org/x-load-omap3/mainline.git
make CROSS_COMPILE=arm-none-linux-gnueabi- omap3530beagle_config
make CROSS_COMPILE=arm-none-linux-gnueabi-
Although beagleboard-xm use DM3735 process, there is updated config file in x-load mainline’s tree. So it is ok for reuse omap3530beagle_config file.
  • Generate MLO file
After building, x-load.bin is generated as raw executable binary. As above mentioned about non-XIP image format, the size and address should be added at image’s first 16 bytes. So use signGP scipt to do it. The source code of signGP is http://beagleboard.googlecode.com/files/signGP.c



 $ ./signGP ./x-load.bin
The signGP tool will create a .ift file, rename the x-load.bin.ift to MLO 
 $ mv x-load.bin.ift MLO

Arm Tool chain 2009:
https://sourcery.mentor.com/GNUToolchain/release858?lite=arm
  1. How to load files(rd-ext2.bin & uImage) from mmc card and boot Linux?


In u-boot:
mmc rescan
fatload mmc 0:1 81600000 rd-ext2.bin


setenv bootargs mem=88M ip=172.16.9.111 console=ttyO2,19200n8 root=/dev/ram0 rw initrd=0x81600000,16M ramdisk_size=16384


fatload mmc 0:1 80000000 uImage
bootm