Getting Started on LPC313x Linux with ELDK Guide


Introduction

As per http://www.denx.de/wiki/DULG/ELDK, ELDK is explained as:

The Embedded Linux Development Kit (ELDK) includes the GNU cross development tools, such as the compilers, binutils, gdb, etc., and a number of pre-built target tools and libraries necessary to provide some functionality on the target system. It is provided for free with full source code, including all patches, extensions, programs and scripts used to build the tools. Some versions of ELDK are available in two versions, which use Glibc or uClibc as the main C library for the target packages. Packaging and installation is based on the RPM package manager.

This quick-start guide explains the steps necessary to get Linux up and running on the Embedded Artist’s LPC313x/4x/5x board using ELDK frameworks. This guide is meant for users new to Linux or as a method to get a Linux image up and running fast. The current LPC313x Linux BSP supports all the following chips:

  • LPC313x series (LPC3131 / LPC3130) : Tested on EA3131 board.
  • LPC314x series (LPC3143 / LPC3141) : Tested on NXP internal VAL314x board.
  • LPC315x series (LPC3154 / LPC3152) : Tested on EA3152 board.

There are many steps along the way, and it is nearly impossible to cover them all in depth, but we will try to provide all necessary information to get a LPC313x based embedded Linux system running from scratch. This includes all the tools you will probably need to configure, build and run U-Boot and Linux.

Setting up Host Development System

You will need a host machine running Linux to build the LPC313x version of Linux. This can either be a dedicated PC that boots and runs Linux (Ubuntu or Fedora etc) or a virtual machine (such as the Sun Virtualbox) running under Windows. A Linux distribution, such as Ubuntu or Fedora will need to be installed on the host machine.

Now we need to setup development area and install ELDK on the system.

Setting up the development area

For ease of development following directory structure is suggested. Rest of the sections assumes this directory structure in its command illustrations. Create the following structure in your development area. Note, '_user_' should be replaced by the current Linux users home directory:

  • /home/< user >/projects/eldk42
  • /home/< user >/projects/lpc313x
    • /home/< user >/projects/lpc313x/apex
      • /home/< user >/projects/lpc313x/apex/work_1.6.8 <-- this will hold the current working sources for apex
    • /home/< user >/projects/lpc313x/uboot
    • /home/< user >/projects/lpc313x/uboot/work_2009.11 <-- this will hold the current working sources for u-boot
    • /home/< user >/projects/lpc313x/kernel
    • /home/< user >/projects/lpc313x/kernel/work_2.6.28.2 <-- this will hold the current working sources for Linux
    • /home/< user >/projects/lpc313x/patches
    • /home/< user >/projects/lpc313x/temp_dir
    • /home/< user >/projects/lpc313x/downloads <--- put all tarballs etc you download from internet here

Examples and directory paths in the rest of the guide below will assume 'nxp' as the default user.

Installing the ELDK

  • Download the latest ELDK for ARM from http://www.denx.de/wiki/DULG/ELDK. From the webpage, locate the site for the FTP server and download the latest arm-linux-x86 version of the ELDK iso file. As of now, this file is arm-2008-11-24.iso.
  • The documentation for the ELDK can be found in the distribution folder of the arm-linux-x86 area. Follow the instruction listed for ELDK 4.2.

The basic procedure is repeated here:

  • Mount the .iso file using the following syntax:
mkdir temp_dir
$ sudo mount -o loop downloads/arm-2008-11-24.iso temp_dir
  • Change the working directory to the temp_dir directory and run the install script. The install script is passed an argument where the ELDK tools should be installed.
$ cd temp_dir
$ sudo ./install -d /home/nxp/projects/eldk42

Building U-boot

$ cd uboot
$ tar -xjf ../downloads/u-boot-2009.11.tar.bz2
$ mv u-boot-2009.11 work_2009.11

  • Get the latest u-boot patches for LPC313x from WebHome#LPC313xDownloads site.
  • Untar the patch files into /home/< user >/projects/lpc313x/patches directory.
  • Apply the LPC313x uboot patch to the u-boot source code.

$ cat ../patches/u-boot-lpc313x-2009.11.patch | (cd work_2009.11; patch -p1)

  • Prior to building u-boot, add the ELDK tool binaries to your path. From the bash shell:

$ source ../../eldk42/eldk_init arm

  • Build u-boot (assuming pwd = /home/nxp/projects/lpc313x/uboot)

$ make -C work_2009.11 lpc3131ea_config
make: Entering directory `/home/nxp/projects/lpc313x/uboot/work_2009.11'
Configuring for lpc3131ea board...
make: Leaving directory `/home/nxp/projects/lpc313x/uboot/work_2009.11'

$ make -C work_2009.11 

  • You can also build u-boot using the following command without modifying the environment.
$ make ARCH=arm CROSS_COMPILE=<Toolchain path>/arm-linux-gnu distclean
$ make EA3131_config
$ make ARCH=arm CROSS_COMPILE=<Path of Tool chain>/arm-linux-gnu- 

  • Once the build completes, the u-boot binary image for deployment can be found at uboot/work_2009.11/u-boot.bin.

Creating u-boot initial section image

  • For UART boot and USB-DFU boot, the image has to be sliced into two
    1. initial section image (init-u-boot.bin ) and
    2. main image
  • For this procedure, NXP provides a utility in form of a C file called mkimage.c. One should compile this tool on their Linux host machine and use the output file.
$ cp <u-boot_release_dir>/makebootimage.c  /home/nxp/projects/lpc313x/uboot
$ cd  home/nxp/projects/lpc313x/uboot 
$ gcc -o mkbootimg makebootimage.c
$ ./mkbootimg work_2009.11/u-boot.bin work_2009.11/init-u-boot.bin
copy_len: 14a00 

  • Or you could use “dd” command as below
$ dd if=work_2009.11/u-boot.bin of=work_2009.11/init-u-boot.bin bs=1024 count=78

  • For more details about the u-boot boot process on LPC313x, see section “5. Boot process using U-boot boot loader”.
  • Note, to build u-boot image for EA3152 boards use ‘make EA3152_config’. When ea31xx.h is modified always do “make clean” before building u-boot.bin.

Creating a DFU bootable u-boot image

LPC313x/4x/5x boot ROM supports booting images via Device Firmware Upgrade (DFU) protocol over USB interface. For security reasons, the boot ROM expects the DFU download image to be TEA encrypted. See LPC313x/4x/5x user manual for more details. NXP provides a Linux command line tool called unsimgcr to encrypt boot images as per boot ROM requirements. To encrypt the initial u-boot section image, issue the following commands on a Linux PC.

$ tools/unsimgcr -pd uboot/work_2009.11/init-u-boot.bin uboot/work_2009.11/init-u-boot.rom

$ ./unsimgcr
LPC3130/31/41/52 Un-Secure Image Creator Utility v1.1
Command error: need an input & output file names
   Wrong number of input parameters!

Usage: UnsImgCr [options] inputfile outputfile
 -pd             Creates image for USB boot mode.
 -pc             Creates image with CRC check boot mode.
 -p              [default] Creates image with no-CRC check boot mode.
<inputfile> is treated as the LPC31xx image. The signed/encrypted image is written to the specified output file. It is assumed that the <inputfile> contains uninitialized header that will be overwritten with header data.

Build Apex boot-loader

$ cd apex
$ tar -xzf ../downloads/apex-1.6.8.tar.gz
$ mv apex-1.6.8 work_1.6.8

  • Apply the LPC313x apex patch to the Apex source code.
$ cat ../patches/apex-1.6.8_lpc313x.patch | (cd work_1.6.8; patch p1)

  • Prior to building apex, add the ELDK tools to your path. From the bash shell:
$ export ARCH=arm 
$ export CROSS_COMPILE=arm-linux-
$ export PATH=/home/nxp/projects/eldk42/usr/bin:/home/nxp/projects/eldk42/bin:$PATH

  • Build apex (assuming pwd = /home/nxp/projects/lpc313x)
$ make -C apex/work_1.6.8 ea313x_v1_config apex.bin

  • Once the build completes, the apex binary image for deployment can be found at apex/work_1.6.8/apex.bin
  • For systems with version 2.0 I/O boards, use ea313x_v2_config.
  • To change apex the configuration, issue the following command.

$ make -C apex/work_1.6.8 ea313x_v1_config menuconfig

  • Don’t forget to backup the modified config.
$ cp apex/work_1.6.8/.config apex/work_1.6.8/src/mach-lpc313x/myconfig
$ make -C apex/work_1.6.8 myconfig apex.bin

Building the Linux kernel

$ cd kernel
$ tar -xjf ../downloads/linux-2.6.28.2.tar.bz2
$ mv linux-2.6.28.2 work_2.6.28.2
  • Apply the LPC313x kernel patch to the Linux kernel source code
$ cat ../patches/linux-2.6.28.2_lpc313x.patch | (cd work_2.6.28.2; patch p1)
  • Prior to building the kernel, add the ELDK tools to your path. From the bash shell:
$ export ARCH=arm
$ export CROSS_COMPILE=arm-linux-
$ export PATH=/home/nxp/projects/eldk42/usr/bin:/home/nxp/projects/eldk42/bin:$PATH
  • Build kernel (assuming pwd = /home/nxp/projects/lpc313x)
$ make -C kernel/work_2.6.28.2 ARCH=arm CROSS_COMPILE=arm-linux- ea313x_defconfig zImage
  • Once the build completes, the kernel binary image for deployment can be found at kernel/work_2.6.28.2/arch/arm/boot/zImage
  • To change the kernel configuration, issue the following command.
$ make -C kernel/work_2.6.28.2 ARCH=arm CROSS_COMPILE=arm-linux- ea313x_defconfig menuconfig
  • Don’t forget to backup the modified config.
$ cp kernel/work_2.6.28.2/.config kernel/work_2.6.28.2/arch/arm/configs/myconfig
$ make -C kernel/work_2.6.28.2 ARCH=arm CROSS_COMPILE=arm-linux- myconfig zImage

Root File system

As stated before, embedded Linux system is composed of three main components boot-loader, kernel and root file system (RFS). The ELDK framework includes a pre-built root file system composed of busybox and several other utilities. Because this is already provided by ELDK, there is nothing to build. Based on the root device and boot loader, there are multiple root file system images in ELDK.

  • The most common root devices used is a ramdisk, and the pre-built ramdisk is located at:
/home/nxp/projects/eldk42/arm/images/ramdisk_image.gz

  • A u-boot downloadable ramdisk image is also available. This image is the same image as the ramdisk_image.gz above, but has an extra header that is used by u-boot.
/home/nxp/projects/eldk42/arm/images/uRamdisk

  • A Network Filesystem Share (NFS) flat directory image is at the path below.
/home/nxp/projects/eldk42/arm

Based on the deployment method you use for the root filesystem, one of these root filesystem images should be used in the deployment section below.

Deployment

After building the necessary components, the images have to be programmed into the boot devices for proper Linux system boot. Deploying LPC313x Linux systems can be divided into following three independent stages.

  1. Deploying boot-loaders
  2. Deploying kernel
  3. Deploying root file-system

Depending on end-user system any combination of deployment options of the above three stages could be used.

Deploying boot-loaders

The LPC313x has a on chip boot ROM which loads properly formatted images from multiple sources, including SPI Flash, NOR Flash, UART, USB, SD Card, and NAND Flash. The boot interface is selected based on the states of GPIO0, GPIO1 and GPIO2 pins at reset. See LPC313x user manual for more details. The boot-loader images (apex.bin or u-boot.bin) built in previous steps has the proper image header needed for the boot ROM to load the image. Check the following table for instruction on programming these devices.

Boot Device Using U-boot Using Apex
NAND flash LPC313xUbootNand LPC313xApexNand
SPI-NOR flash LPC313xUbootSpi LPC313xApexSpi
SD/MMC card LPC313xUbootMci LPC313xApexMci
UART LPC313xUbootUart LPC313xApexUart
USB DFU class LPC313xUbootUsb LPC313xApexUsb?
Parallel NOR flash Not supported

Deploying kernel

Depending on the boot-loader, various kernel deployment option exist.

Boot Device Using U-boot Using Apex
NAND flash LPC313xUbootNand LPC313xApexNand
SPI-NOR flash LPC313xUbootSpi LPC313xApexSpi
SD/MMC card LPC313xUbootMci LPC313xApexMci
UART LPC313xUbootUart LPC313xApexUart
USB gadget LPC313xUbootUsb (DFU Class) LPC313xApexUsb? (MSC class)
USB host LPC313xUbootUsbHost Not Supported
Ethernet LPC313xUbootEther LPC313xApexEther

Deploying root file-system

The LPC313x root file system (RFS) can be deployed on various root devices. The following section covers only the most commonly used RFS deployment methods.

Ramdisk

Deploying the RFS using ramdisk is simple and most widely used method. Ramdisik is a single compressed file which can be deployed on any media from where boot-loader can copy it to systems memory. Check links in following table for more details on deploying ramdisk on corresponding interface.

Boot Device Using U-boot Using Apex
NAND flash LPC313xUbootNand#Ramdisk LPC313xApexNand#Ramdisk
SPI-NOR flash LPC313xUbootSpi#Ramdisk LPC313xApexSpi#Ramdisk
SD/MMC card LPC313xUbootMci#Ramdisk LPC313xApexMci#Ramdisk
UART LPC313xUbootUart#Ramdisk LPC313xApexUart#Ramdisk
USB gadget LPC313xUbootUsb#Ramdisk (DFU Class) LPC313xApexUsb#Ramdisk? (MSC class)
USB host LPC313xUbootUsbHost#Ramdisk Not Supported
Ethernet LPC313xUbootEther#Ramdisk LPC313xApexEther#Ramdisk

JFFS2 root file system installation

The root file system used by the Linux kernel can be stored and accessed from a partition in NAND FLASH using the Journaling FLASH File System 2 (JFFS2). The procedure on this page will explain the process of building a JFFS2 deployment image using LTIB, setting up the JFFS2 partition using u-boot, and setting up the Linux kernel to use the partition. Before using the procedure, it is assumed you have built a kernel with MTD, NAND, and JFFS2 support.

_NAND FLASH devices for the boards vary in page size and partitioning information. When using NAND FLASH in a writable configuration, it's important to safely shutdown the system so any data in the systems memory is correctly flushed to the NAND devices. Failure to safely shutdown the system when using NAND may lead to eventual NAND data errors. The 'poweroff' and 'reboot' commands can be used from the kernel prompt to safely shutdown or restart the system. _

JFFS2 root file system image setup

Bring up the LTIB main menu using the './ltib --config' command. Select the Target Image Generation Options ---> menu item. Select the Target image option to being up the available deployment options. Select jffs2 from the menu and the root file system setup options will appear. Most of the options here control the size of the generated root file system. Most of the defaults can be used for now. Select the 'jffs2 erase block size in KB' from the menu. This will bring up a box where you need to enter the size of a NAND block for the device in KBytes. The block size is the number of pages per block times the size of a page. For the EA3131 board, the page size is 2048 bytes with 64 pages per block. This gives a block size of 128KB. Enter the block size in KBytes for NAND FLASH. Select exit from the menu until it asks to save your configuration and select yes to save your configuration. LTIB will start building the root file system can will generate a JFFS2 image file when it's complete. The JSS2 image will be located at./ltib/rootfs.jffs2.
    Arrow keys navigate the menu.  <Enter> selects submenus --->.  Highlighted letters are
    hotkeys.  Pressing <Y> selectes a feature, while <N> will exclude a feature.  Press
    <Esc><Esc> to exit, <?> for Help.  Legend: [*] feature is selected  [ ] feature is excluded 

               --- Choose your root filesystem image type          
                   Target image: (jffs2)  --->                                      
               [ ] Run a command after building the target image                       
               (128) jffs2 erase block size in KB                                       
               [ ] Pad out image size                                                
               [ ] read-only root filesystem                                       
               (512k) tmpfs size                                                        
               (/tmp /var) Place these dirs in writable RAM                   
               ()  rootfs target directory                                            
               [ ] Keep temporary staging directory                              
               [ ] Convert hard links to symbolic links                                 
               [*] remove man pages etc from the target image                             
               [*] remove the /boot directory                                             
               [*] remove the /usr/src/ directory                                        
               [*] remove the /usr/include directory                                       
               [*] remove the /usr/share/locale directory                                  
               ()  remove these directories                                               
               ()  remove these files                                                    
               [*] remove the static libraries                                            
               (/var/lib/rpm) remove target rpm database                                  
               [*] strip any remaining binaries or libraries in the target image            
               [ ]   strip binaries more aggressively                               

JFFS2 partition setup from u-boot

To program the JFFS2 image into FLASH, you will need to know the location and size of the MTD partition used for the Linux kernel. On the EA3131 board, the Linux partition used for the root file system starts at block offset 166. For a block of 128KBytes, this gives an MTD offset of (128 * 1024 * 166) = 0x014C0000 bytes. The size of the partition is the remainder of the NAND device starting at block offset 166. The 'nand info' command can be used to determine the total NAND size.
LPC3131EA-NXP # nand info

Device 0: NAND 256MiB 1,8V 8-bit, sector size 128 KiB
LPC3131EA-NXP #

The size of the partition is the total size of the device (256MiB) minus the offset to the start of the partition. Partition size = 0x10000000 - 0x014C0000 = 0x0EB40000 bytes.

Start by using the erase command in u-boot to erase the partition used for the JFFS2 image. Use the offset and size from the computations above.

LPC3131EA-NXP # nand erase 0x014C0000 0x0EB40000

NAND erase: device 0 offset 0x14c0000, size 0xeb40000
Skipping bad block at  0x04140000
Skipping bad block at  0x0ff80000
Skipping bad block at  0x0ffa0000
Skipping bad block at  0x0ffc0000
Skipping bad block at  0x0ffe0000

OK
LPC3131EA-NXP #

The transfer the rootfs.jffs2 image to memory on the EA3131 board using TFTP, ymodem, or an SD card. TFTP is used below. The images is loaded to memory address 0x30008000. Be sure to record the size of the transfer when complete.

LPC3131EA-NXP # tftpboot 0x30008000 192.168.1.41:rootfs.jffs2
dm9000 i/o: 0x20020000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:08:1e:0d:c6:f0
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.41; our IP address is 192.168.1.194
Filename 'rootfs.jffs2'.
Load address: 0x30008000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #######################################
done
Bytes transferred = 6291456 (600000 hex)
LPC3131EA-NXP #

Write the loaded image from memory into NAND at the offset used for the root file system (0x014C0000) using the size of the loaded image (0x00600000). The image is loaded from memory at address 0x30008000 - the saem address used with the 'tftpboot' command above.

LPC3131EA-NXP # nand write.jffs2 0x30008000 0x014C0000 0x00600000

NAND write: device 0 offset 0x14c0000, size 0x600000
 6291456 bytes written: OK
LPC3131EA-NXP #

JFFS2 root file system boot setup

To setup the kernel to boot the JFFS2 partition in NAND FLASH, the command line passed to the kernel needs to be changed. The root= option needs to be changed to the MTD partition mapped to the address in NAND the root file system has been mapped to by changing the bootargs u-boot environment variable. For the EA3131 board, MTD partition 0 maps to address 0x014C0000 in NAND. The bootargs environment variable should be changed as follows:
LPC3131EA-NXP # setenv jffs2_boot 'dhcp; run jffs2args; bootm 31000000'
LPC3131EA-NXP # setenv jffs2args 'setenv bootargs console=ttyS0,115200n8 root=/dev/mtdblock0 rw rootfstype=jffs2 ip=dhcp loglevel=7'
LPC3131EA-NXP # setenv bootcmd 'run jffs2_boot'
LPC3131EA-NXP # saveenv
Saving Environment to SPI Flash...
Erasing SPI flash...Writing to SPI flash...done
LPC3131EA-NXP #

If the root file system still fails to mount make sure the MTD partition used for the kernel matches the location the root file system image was written using u-boot.

NAND device: Manufacturer ID: 0x2c, Chip ID: 0xaa (Micron NAND 256MiB 1,8V 8-bit)
Creating 1 MTD partitions on "lpc313x_nand":
0x0000014c0000-0x000010000000 : "lpc313x-rootfs"

Setting up NFS as the root file system mount

Using NFS to mount the root file system is probably the most easiest and quickest way to debug and test applications. The root file system is stored on the host machine and the target machine remote mounts the root file system on the board using NFS. With this method, the root file system doesn't need to be re-programed to FLASH or updated on the root file system storage device. This procedure shows how to setup the kernel to use NFS to mount the root file system. Before using the procedure, it is assumed you have built a kernel with NFS client support.

NFS directory setup on the host machine

Since the root file system directory will reside on the host machine, it needs to be setup on the host prior to access from the board. Regardless of whether your using LTIB or the ELDK, a flat root file system tree i already present for NFS moutning. For LTIB users, this is located in the ./rootfs directory in the ./ltib directory. For ELDK users, this is usually the ./eldk42/arm directory.

If this is the first time your using NFS with this root file system directory, add the root file system path to the /etc/exports file on your host machine and restart the NFS server. See the FAQ on the forums tab for more information on setting up NFS. On my board using LTIB or the ELDK, the entries in the exports file appears as follows:

/home/usb10132/dev/ltib/rootfs 192.168.1.*(rw,no_root_squash,no_subtree_check,sync)
/home/usb10132/projects/eldk42/arm 192.168.1.*(rw,no_root_squash,no_subtree_check,sync)

Setting up the kernel to use the NFS directory

The kernel needs to be told to use NFS as the root file system using the root= and nfsroot= arguments in the bootargs environment variable. The change is made in u-boot as below to use the same directory added in the host machine exports file with an NFS server located at IP address 192.168.1.41. Be sure the save the environment after making the change using saveenv.
LPC3131EA-NXP # setenv net_boot 'dhc; run nfsargs; bootm 31000000'
LPC3131EA-NXP # setenv nfsargs 'setenv bootargs console=ttyS0,115200n8 root=/dev/nfs rw nfsroot=${serverip}:${rootpath} ip=dhcp loglevel=7'
LPC3131EA-NXP # setenv bootcmd 'run net_boot'
LPC3131EA-NXP # setenv serverip 192.168.1.41
LPC3131EA-NXP # setenv rootpath /home/usb10132/dev/ltib/rootfs
LPC3131EA-NXP # saveenv
Saving Environment to SPI Flash...
Erasing SPI flash...Writing to SPI flash...done
LPC3131EA-NXP #

After the changes are made, the kernel will attempt to mount the root file system using NFS.

Using an SD card (EXT2) for the root filesystem

The root file system used by the Linux kernel can be stored and accessed from a partition in on the SD card using EXT2. The procedure here will explain the process of re-partitioning an SD card, deploying the root file system image to it, and then setting up the Linux kernel to use the SD card for the root file system. To change the SD partitioning scheme, you will need an SD card, a Linux host machine, and a memory card reader that supports SD cards. Note that this will erase anything on the card.

Before using the procedure, it is assumed you have built a kernel with the SD card driver (static) and support for the EXT2 file system. The EA3131 board can boot from the SD card. It you need to continue booting from the SD card, you will need to dual partition your SD card with firth partition used for EXT2 and the 2nd partition used for bootp.

Partitioning the SD card

Insert the SD card into the Linux host machine. Open a shell and switch to the root user in the shell. Type 'dmesg' to determine which device node the SD card was installed on. If the card automatically mounts, you will need to unmount it prior to doing these steps.

[root@usb10132 usb10132]# dmesg -c
sd 8:0:0:2: [sde] 15523840 512-byte logical blocks: (7.94 GB/7.40 GiB)
sd 8:0:0:2: [sde] Assuming drive cache: write through
sd 8:0:0:2: [sde] Assuming drive cache: write through
 sde: sde1
[root@usb10132 usb10132]# 

In the above example, the SD card is located on /dev/sde. Use fdisk to re-partition the device. Make sure you partition the correct device. If you pick the wrong device, you might kill your system.

[root@usb10132 usb10132]# fdisk /dev/sde

The number of cylinders for this disk is set to 242560.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): 

Use the 'p' command to dump the current partitions. If your card is new, you'll probably have at least one FAT or VFAT partition. Delete the partiton with the 'd' command.

Command (m for help): p

Disk /dev/sde: 7948 MB, 7948206080 bytes
4 heads, 16 sectors/track, 242560 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1      242560     7761912   83  Linux

Command (m for help): d
Selected partition 1

Create 1 new Linux partition on your device. Use the 'p' command to print the new partition information.

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-242560, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-242560, default 242560): 
Using default value 242560

Command (m for help): p

Disk /dev/sde: 7948 MB, 7948206080 bytes
4 heads, 16 sectors/track, 242560 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1      242560     7761912   83  Linux

Command (m for help):

Use the 'w' command to save the new partition data on the card. If you see error messages, one of your partitions is probably still mounted.

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
[root@usb10132 usb10132]# 

The new partition now needs to be formatted for EXT2 using mkfs.

[root@usb10132 ltib]# mkfs -t ext2 /dev/sde1
mke2fs 1.41.9 (22-Aug-2009)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
485760 inodes, 1940478 blocks
97023 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1988100096
60 block groups
32768 blocks per group, 32768 fragments per group
8096 inodes per group
Superblock backups stored on blocks: 
   32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@usb10132 ltib]#

Copy the root file system to the EXT2 partition on the SD card

The root file system now needs to be copied to the EXT2 partition of the SD card. Start by removing and re-inserting the SD card into the host machine. You can use dmesg to determine which device node is used with the card. In the example below, the card is on /dev/sde with the EXT2 partition on /dev/sde1. Mount the SD card partition on your system.

[root@usb10132 usb10132]# mkdir /mnt/sd
[root@usb10132 usb10132]# mount /dev/sde1 /mnt/sd

Copy the root file system to the mounted card. The example below is for LTIB, but ELDK uses can cpoy the directory at ./eldk42/arm.

[root@usb10132 ltib]# cp -a rootfs/* /mnt/sd/

After the copy is complete, unmount the card and plug it into the board.

Unmount the SD card and insert it into the board. 

Setting up u-boot to use the SD card

Boot the board to u-boot and setup u-boot to use the SD card partition 1 as the root file system mount point. The device is located at /dev/mmcblk0p1. The kernel will use the SD card as the root file system mount point by changing the root= argument in the bootargs environment variable in u-boot. Be sure to save the changes with the saveenv command after making the changes.


If the root file system doesn't mount correctly, try adding ...

Topic revision: r10 - 30 Nov 2010 - 20:56:02 - DurgeshPattamatta
 

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. Creative Commons License This site is powered by Foswiki