Thursday, September 1, 2011

Custom Linux in BeagleBoard-xM

The golden reference:
    [labbookpages website]
    [Angstrom Linux - BeagleBoardXm]

Step1: Build the toolchain
    Use crosstool-ng
    [crosstool website]
    My version - crosstool-ng-1.9.3 [180 directories, 1227 files]
    Takes nearly 1 hour to build completely.
    At the end a set of executables viz. "arm-unknown-linux-gnueabi-gcc"
    etc. could be seen in the "x-tools/bin" directory.

Step2: Build the U-Boot
    Bootloader boots the system by copying the kernel &
    root file system to memory.
    [U-Boot website]
    [U-Boot Source Code]
    $ cd u-boot-2011.06/
    $ export CROSS_COMPILE=arm-unknown-linux-gnueabi-
    $ export PATH="/files/beagle/x-tools/bin:$PATH"
    $ make distclean [May have to be root]
    $ make omap3_beagle_config
    $ make
    "u-boot.bin" would be obtained in the same folder 'u-boot-2011.06'

Step3: Build the Xloader (MLO)
      [Xloader reference1] [Xloader reference2]

     Why xloader?
          The SRAM size in DM3730 is 64K.
          u-boot binary size is more than this.(~300K)
          x-loader binary size is lesser (~24K)
          Hence Xloader is required as the main loader
          in SRAM, which would download the u-boot image
          to main MDDR SDRAM.(512MB).
    $ git clone git://gitorious.org/x-load-omap3/mainline.git
    $ cd mainline
    $ make distclean
    $ make omap3530beagle_config
          (NOTE: config file updated in mainline
          tree for DM3730 in BeagleBoardXm)
    $ make
      The output would be "x-loader.bin"; which is in
      raw executable format.
      The size and address should be added at the
      image's first 16-bytes for non-XIP devices.
    Use signGP script [signGP Source Code]
    $ ./signGP x-load.bin
    "x-load.bin.ift" file would be created.
    $ mv x-load.bin.ift MLO

Step4: Build the Linux Kernel
    

Step5: Build the root file system


Step6: Create the boot script



Step7: Prepare the microSdCard
    5 files need to be stored in the uSd Card.
          1. MLO (Xloader)
          [ NOTE: This should be copied first to ensure that it is at the
          start of the card. After copying unmount & then re-mount  
          the card. ]
          2. u-boot.bin
          3. boot.scr (Boot script)
          4. uImage (Linux Kernel image)
          5. rootfs.ext2 (Root file system)

    Two partitions are created.
    The first is used to store the boot loader, kernel and root filing system. 
    The second partition can be used for general file storage.

    7.1 Delete existing partitions
     Remove the existing partition tables:

             root@neolappy:/files/beagle/vinchk#
             dd if=/dev/zero of=/dev/mmcblk0 bs=1024 count=1024


    7.2 Create primary partition
       
       root@neolappy:/files/beagle/vinchk# fdisk /dev/mmcblk0
    Device contains neither a valid DOS partition table, nor Sun, 
    SGI or OSF disklabel
    Building a new DOS disklabel with disk identifier 0x58bad9f5.
    Changes will remain in memory only, until you decide to write them.
    After that, of course, the previous content won't be recoverable.

    Warning: invalid flag 0x0000 of partition table 4 will be corrected 
    by w(rite)

    WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
             switch off the mode (command 'c') and change display units to
             sectors (command 'u').

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

    Command (m for help): t
    Selected partition 1
    Hex code (type L to list codes): c
    Changed system type of partition 1 to c (W95 FAT32 (LBA))

    Command (m for help): a
    Partition number (1-4): 1

    
7.2 Create the 2nd partition
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 2
    First cylinder (2050-122784, default 2050): (Press Enter)
    Using default value 2050
    Last cylinder, +cylinders or +size{K,M,G} (2050-122784,
    default 122784): (Press Enter)
    Using default value 122784

    Command (m for help): t
    Partition number (1-4): 2
    Hex code (type L to list codes): 83

    Command (m for help):

7.3 Check created partitions & write
    Command (m for help): p

    Disk /dev/mmcblk0: 4023 MB, 4023386112 bytes
    4 heads, 16 sectors/track, 122784 cylinders
    Units = cylinders of 64 * 512 = 32768 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x58bad9f5

   Device          Boot   Start    End       Blocks   Id     System
   /dev/mmcblk0p1   *     1        2049      65560    c      W95 FAT32 (LBA)
   /dev/mmcblk0p2         2050     122784    3863520  83     Linux

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

   Calling ioctl() to re-read partition table.

   WARNING: Re-reading the partition table failed with error 16:
   Device or    resource busy.
   The kernel still uses the old table. The new table will be used at
   the next reboot or after you run partprobe(8) or kpartx(8)

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

Partitions: mmcblk0
                            1. mmcblk0p1
                            2. mmcblk0p2

7.4 Create the file systems in the partitions

    Partition1: mkfs.vfat -F 32 -n "boot" /dev/mmcblk0p1
    Partition2: mke2fs -L "files" /dev/mmcblk0p2 
 
    root@neolappy:/files/beagle/vinchk# mkfs.vfat -F 32 -n "boot" /dev/mmcblk0p1
    mkfs.vfat 3.0.9 (31 Jan 2010)
 
    root@neolappy:/files/beagle/vinchk# mke2fs -L "files" /dev/mmcblk0p2 
    mke2fs 1.41.14 (22-Dec-2010)
    Filesystem label=files
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    241920 inodes, 965880 blocks
    48294 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=989855744
    30 block groups
    32768 blocks per group, 32768 fragments per group
    8064 inodes per group
    Superblock backups stored on blocks: 
        	32768, 98304, 163840, 229376, 294912, 819200, 884736

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

    This filesystem will be automatically checked every 32 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.




No comments: