Showing posts with label Pandaboard. Show all posts
Showing posts with label Pandaboard. Show all posts

Sunday, July 1, 2012

Getting Fedora-17 ARM images to understand booting LVM volumes

In order to get your uInitrd to understand booting from a LVM volume, you need to regenerate the initramfs and uInitrd images with the LVM bits.  To do so, follow these steps (substitute your versions as necessary):
  1. Install LVM (yum -y install lvm2)
  2. Update initramfs image (in /boot run dracut -f initramfs-3.3.6-3.fc17.armv5tel.kirkwood.img 3.3.6-3.fc17.armv5tel.k
    irkwood)
  3. Update uInitrd image (in /boot/uboot run mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 -n initramfs -d /boot/ini
    tramfs-3.3.6-3.fc17.armv5tel.kirkwood.img uInitrd-kirkwood)
So now you're wondering how to do this if you don't already have a running system?  Well, in theory you can run dracut and mkimage from a host system, but I've been unsuccessful getting a working image that way.  So to create my bootstrap uInitrd, I built a throwaway system, then used uInitrd to boot my LVM enabled system. 

The easiest approach would be to do the above steps, the move the boot media to a another computer, and copy the root filesystem to a temporary file, delete the partition with the root filesystem, and add it to a volume group (as a PV) and create a LV and copy the root filesystem back.  It sounds complicated but it's not.

Monday, January 2, 2012

Fedora 14 ARM on Pandaboard, part 3

Now that you have a Pandaboard booting Fedora 14 ARM, there are still some cleanup tasks to do.

Set the system time and install the ntp daemon.

# date 123017102011                                         
Fri Dec 30 17:10:00 EST 2011                                                   
# yum install ntp ntpdate
Loaded plugins: presto
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ntp.armv5tel 0:4.2.6p2-7.fc14 set to be installed
---> Package ntpdate.armv5tel 0:4.2.6p2-7.fc14 set to be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package         Arch             Version                  Repository      Size
================================================================================
Installing:
 ntp             armv5tel         4.2.6p2-7.fc14           fedora         573 k
 ntpdate         armv5tel         4.2.6p2-7.fc14           fedora          73 k

Transaction Summary
================================================================================
Install       2 Package(s)

Total download size: 645 k
Installed size: 1.7 M
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 645 k
(1/2): ntp-4.2.6p2-7.fc14.armv5tel.rpm                   | 573 kB     00:18   
(2/2): ntpdate-4.2.6p2-7.fc14.armv5tel.rpm               |  73 kB     00:01   
--------------------------------------------------------------------------------
Total                                            30 kB/s | 645 kB     00:21   
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing     : ntpdate-4.2.6p2-7.fc14.armv5tel                          1/2
  Installing     : ntp-4.2.6p2-7.fc14.armv5tel                              2/2

Installed:
  ntp.armv5tel 0:4.2.6p2-7.fc14        ntpdate.armv5tel 0:4.2.6p2-7.fc14     

Complete!
#
Turn on ntpd and start it.

# chkconfig ntpd on
# service ntpd start
Starting ntpd:                                             [  OK  ]
#


Enable LVM monitoring service (this is one of the %post failures during the LVM installation)

# chkconfig lvm2-monitor on                                 
# service lvm2-monitor start                                
Starting monitoring for VG panda:   1 logical volume(s) in volume group "panda"
monitored                                                                      
[  OK  ]                                                                       
#


Lock the guest account.

# usermod -L guest                                          
#

Add /boot/uboot as an entry in fstab.  The entry should look like this:

LABEL="uboot"           /boot/uboot             vfat    defaults,noauto 0 0
You also will want to update the / entry in fstab to mount the filesystem ext4 since that's what we formatted it as (mounting as ext3 is perfectly valid but will use none of the ext4 capabilities or features).  That line will now look like:

LABEL="rootfs"            /                       ext4    defaults        1 1

Additional items you might want to address:
  1. Change the root password
  2. Add swap (create lvol, mkswap, and enable it)
  3. Install openssh-clients for ssh support
  4. Change the hostname (/etc/sysconfig/network) 
  5. Set the timezone (it's currently in EST)

Well, that should be enough to get started.

    Sunday, January 1, 2012

    Fedora 14 ARM on Pandaboard, part 2

    From my previous entry, you'll have already created a bootable SD card.  Yeah, it doesn't boot much and ends with a kernel panic, but that's just what we need so far to get Fedora 14 on the Pandaboard.

    Install a different u-boot.bin

    Unfortunately the u-boot.bin on the validation image doesn't read boot.scr (autoboot script) and the settings are hard-coded.  In order to get a more flexible u-boot.bin, we'll borrow from Jon Master's previous Fedora 13 Pandaboard image.  Download the fedora_arm_image_pandaboard-uboot-20110622-0.tar.xz file, extract u-boot.bin, and copy it to the uboot filesystem:


    # tar -x uboot/u-boot.bin -f fedora_arm_image_pandaboard-uboot-20110622-0.tar.xz
    # ls uboot
    u-boot.bin
    # mount /dev/sde1 /mnt/tmp
    # cp uboot/u-boot.bin /mnt/tmp/
    cp: overwrite `/mnt/tmp/u-boot.bin'? y
    # umount /mnt/tmp


    Download Fedora 14 ARM image and install the root filesystem


    Go ahead and download the F14 ARM RC1 minimal image previously referenced.

    Insert the SD card and wait until the card is recognized.  Then create the physical volume, volume group, logical volume, root filesystem, and install the files to the root filesystem.

    # pvcreate /dev/sde2
      Writing physical volume data to disk "/dev/sde2"
      Physical volume "/dev/sde2" successfully created
    # vgcreate panda /dev/sde2
      Volume group "panda" successfully created
    # lvcreate -L 2G -n root panda
      Logical volume "root" created
    # mkfs -t ext4 -L rootfs /dev/mapper/panda-root
    mke2fs 1.41.14 (22-Dec-2010)
    Filesystem label=rootfs
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    131072 inodes, 524288 blocks
    26214 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=536870912
    16 block groups
    32768 blocks per group, 32768 fragments per group
    8192 inodes per group
    Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

    Writing inode tables: done                           
    Creating journal (16384 blocks): done
    Writing superblocks and filesystem accounting information: done

    This filesystem will be automatically checked every 38 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
    # mount /dev/mapper/panda-root /mnt/tmp
    # tar -xf rootfs-f14-minimal-RC1.tar.bz2 -C /mnt/tmp
    One thing that I haven't mentioned is that the minimal image doesn't contain lvm2, which we're going to need.  Go ahead and install that (and its dependencies) now:

    # rpm -ivh --ignorearch --root=/mnt/tmp http://dl.fedoraproject.org/pub/fedora-secondary/releases/14/Everything/arm/os/Packages/lvm2-2.02.73-3.fc14.armv5tel.rpm http://dl.fedoraproject.org/pub/fedora-secondary/releases/14/Everything/arm/os/Packages/lvm2-libs-2.02.73-3.fc14.armv5tel.rpm http://dl.fedoraproject.org/pub/fedora-secondary/releases/14/Everything/arm/os/Packages/device-mapper-1.02.54-3.fc14.armv5tel.rpm http://dl.fedoraproject.org/pub/fedora-secondary/releases/14/Everything/arm/os/Packages/device-mapper-event-1.02.54-3.fc14.armv5tel.rpm http://dl.fedoraproject.org/pub/fedora-secondary/releases/14/Everything/arm/os/Packages/device-mapper-event-libs-1.02.54-3.fc14.armv5tel.rpm http://dl.fedoraproject.org/pub/fedora-secondary/releases/14/Everything/arm/os/Packages/device-mapper-libs-1.02.54-3.fc14.armv5tel.rpm
    Retrieving http://dl.fedoraproject.org/pub/fedora-secondary/releases/14/Everything/arm/os/Packages/lvm2-2.02.73-3.fc14.armv5tel.rpm
    Retrieving http://dl.fedoraproject.org/pub/fedora-secondary/releases/14/Everything/arm/os/Packages/lvm2-libs-2.02.73-3.fc14.armv5tel.rpm
    Retrieving http://dl.fedoraproject.org/pub/fedora-secondary/releases/14/Everything/arm/os/Packages/device-mapper-1.02.54-3.fc14.armv5tel.rpm
    Retrieving http://dl.fedoraproject.org/pub/fedora-secondary/releases/14/Everything/arm/os/Packages/device-mapper-event-1.02.54-3.fc14.armv5tel.rpm
    Retrieving http://dl.fedoraproject.org/pub/fedora-secondary/releases/14/Everything/arm/os/Packages/device-mapper-event-libs-1.02.54-3.fc14.armv5tel.rpm
    Retrieving http://dl.fedoraproject.org/pub/fedora-secondary/releases/14/Everything/arm/os/Packages/device-mapper-libs-1.02.54-3.fc14.armv5tel.rpm
    Preparing...                ########################################### [100%]
       1:device-mapper-libs     ########################################### [ 17%]
    warning: %post(device-mapper-libs-1.02.54-3.fc14.armv5tel) scriptlet failed, exit status 127
       2:device-mapper          ########################################### [ 33%]
       3:device-mapper-event-lib########################################### [ 50%]
    warning: %post(device-mapper-event-libs-1.02.54-3.fc14.armv5tel) scriptlet failed, exit status 127
       4:device-mapper-event    ########################################### [ 67%]
       5:lvm2-libs              ########################################### [ 83%]
    warning: %post(lvm2-libs-2.02.73-3.fc14.armv5tel) scriptlet failed, exit status 127
       6:lvm2                   ########################################### [100%]
    warning: %post(lvm2-2.02.73-3.fc14.armv5tel) scriptlet failed, exit status 127
    #


    You can ignore the %post errors as %post is simply trying to run ldconfig to update the dynamic linker/loader cache or chkconfig to enable a service.

    Now there is still one problem with getting LVM to work:  The generated initramfs files have no LVM support.   This is a huge problem (the system will not be able to detect the root filesystem which is on a logical volume).  It's also a huge pain to fix it as dracut did not generate a bootable image when I tried to update the initramfs on my host system.  Because of that, I've made it easy on you - here is an initramfs with LVM support included.  Let's install that:

    # cp initramfs-2.6.40.3-0.fc14.armv7l.omap.img /mnt/tmp/boot/
    cp: overwrite `/mnt/tmp/boot/initramfs-2.6.40.3-0.fc14.armv7l.omap.img'? y
    #


    The next thing we'll need to do is update the boot files stored in the uboot filesystem (mkimage is in the uboot-tools package if it's not installed on your system).
    # mkdir /mnt/tmp/boot/uboot
    # mount /dev/sde1 /mnt/tmp/boot/uboot
    # mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 -n 2.6.40.3.fc14.armv7l.omap -d /mnt/tmp/boot/vmlinuz-2.6.40.3-0.fc14.armv7l.omap /mnt/tmp/boot/uboot/uImage
    Image Name:   2.6.40.3.fc14.armv7l.omap
    Created:      Fri Dec 30 16:44:41 2011
    Image Type:   ARM Linux Kernel Image (uncompressed)
    Data Size:    3919956 Bytes = 3828.08 kB = 3.74 MB
    Load Address: 80008000
    Entry Point:  80008000
    # mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 -n initramfs -d /mnt/tmp/boot/initramfs-2.6.40.3-0.fc14.armv7l.omap.img /mnt/tmp/boot/uboot/uInitrd
    Image Name:   initramfs
    Created:      Fri Dec 30 16:46:50 2011
    Image Type:   ARM Linux RAMDisk Image (uncompressed)
    Data Size:    8043128 Bytes = 7854.62 kB = 7.67 MB
    Load Address: 00000000
    Entry Point:  00000000
    #
    In order to boot, we'll need to also create a boot script and compile it.

    # echo "setenv bootargs 'console=ttyO2,115200n8 ro rootwait root=/dev/mapper/panda-root init=/sbin/init earlyprintk rd_NO_PLYMOUTH'" > /mnt/tmp/boot/uboot/boot.cmd
    # echo "setenv bootcmd 'mmc init; fatload mmc 0:1 0x80300000 uImage; fatload mmc 0:1 81600000 uInitrd; bootm 80300000 81600000'" >> /mnt/tmp/boot/uboot/boot.cmd
    # echo "boot" >> /mnt/tmp/boot/uboot/boot.cmd
    # mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Pandaboard boot script" -d /mnt/tmp/boot/uboot/boot.cmd /mnt/tmp/boot/uboot/boot.scr
    Image Name:   Pandaboard boot script
    Created:      Fri Dec 30 16:49:18 2011
    Image Type:   ARM Linux Script (uncompressed)
    Data Size:    257 Bytes = 0.25 kB = 0.00 MB
    Load Address: 00000000
    Entry Point:  00000000
    Contents:
       Image 0: 249 Bytes = 0.24 kB = 0.00 MB
    #
    Create the klist.txt file that contains the list of installed kernels.  This is actually not needed in this case since there is no xpfa repository with an updated grubby that can use it.  I'm just doing it for completeness.

    # echo "2.6.40.3.fc14.armv7l.omap" > /mnt/tmp/boot/uboot/klist.txt
    #

    This should be all that's required.  Let's unmount these filesystems, deactivate the volume group, eject the media, and try booting on the Pandaboard.



    # umount /mnt/tmp/boot/uboot /mnt/tmp
    # vgchange -an panda
      0 logical volume(s) in volume group "panda" now active
    # eject /dev/sde
    #

    If all has gone well, you're now sitting at the login prompt.  The root password is "fedoraarm".

    Next post will be dedicated to a few cleanup items.

    Friday, December 30, 2011

    Fedora 14 ARM on Pandaboard

    Jon Masters has provided a Pandaboard Fedora 13 image which mostly works great (the MLO appears to not work on the new ES model, but you can strip the MLO from the Pandaboard validation image and use it instead).

    However, if you have the desire to stay current, you might want to try a little newer version of Fedora.  I expect the floodgates to open shortly as the Fedora ARM team is working on bootstrapping Fedora 15, but in the meantime, Peter Robinson has provided a Fedora 14 ARM image.  No, it's not specific to the Pandaboard, but we can get it working anyway with a little elbow grease.  And if we leverage the work of others, we won't even have to do any compiling!

    Partitioning & formatting your SD card

    This is perhaps the most critical step - and one with many nuances and folklore.  The image provided by Peter is "generic" in the fact that it doesn't have Pandaboard specific files or image layout.  What this means is that we'll have to provide an additional partition: the MLO/uboot partition for Pandaboard.

    There have been some reported problems with specific SD cards, so I would suggest using a high quality SD card (I have used both Micro Center "generic" card and a PNY professional card without issues).  If there is any doubt about the card, try the validation image first.

    Once you have the card in hand, you can insert it into your computer and examine /var/log/messages to determine which device is assigned by the kernel.  In my case, this is what was reported:

    sd 4:0:0:2: [sde] 15644672 512-byte logical blocks: (8.01 GB/7.45 GiB)

    Also, it's worth noting that if there are mountable filesystems, they are probably mounted.  That's not what we want, so be sure to unmount any mounted filesystems from this card.

    Now I use fdisk to create two partitions:
    1. The uboot/MLO partition sized at about 64 MB.
    2. The rest of the card for the system.
    There is two things worth mentioning here.  Most people also create a separate swap, boot, and root partitions.  I'm not going to do that here.  I'm going to instead create a 2nd partitions to use as a PV (Physical Volume) for LVM.  I will then later create Logical Volumes for swap and root filesystems.  I will not be creating a separate /boot filesystem.  The reason that this is many times distinct from the root filesystem is because it makes recovery easier if you can mount up root and make changes.  Since the /uboot partition/filesystem will be copies of files from /boot, I won't make it separate - the /uboot filesystem will contain the important files.

    Now create the two partitions:

    # fdisk /dev/sde

    Command (m for help): c
    DOS Compatibility flag is set (DEPRECATED!)

    Command (m for help): o
    Building a new DOS disklabel with disk identifier 0xaa802e39.
    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 (with command 'c').
    Command (m for help): n
    Partition type:
       p   primary (0 primary, 0 extended, 4 free)
       e   extended
    Select (default p): p
    Partition number (1-4, default 1): 1
    First sector (62-15644671, default 62): 63
    Last sector, +sectors or +size{K,M,G} (63-15644671, default 15644671): +64M

    Command (m for help): t
    Selected partition 1
    Hex code (type L to list codes): 6
    Changed system type of partition 1 to 6 (FAT16)

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

    Command (m for help): p

    Disk /dev/sde: 8010 MB, 8010072064 bytes
    247 heads, 62 sectors/track, 1021 cylinders, total 15644672 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xaa802e39

       Device Boot      Start         End      Blocks   Id  System
    /dev/sde1   *          63      131135       65536+   6  FAT16
    Partition 1 does not end on cylinder boundary.

    Command (m for help): n
    Partition type:
       p   primary (1 primary, 0 extended, 3 free)
       e   extended
    Select (default p): p
    Partition number (1-4, default 2): 2
    First sector (62-15644671, default 62): 131136
    Last sector, +sectors or +size{K,M,G} (131136-15644671, default 15644671):
    Using default value 15644671

    Command (m for help): t
    Partition number (1-4): 2
    Hex code (type L to list codes): 8e
    Changed system type of partition 2 to 8e (Linux LVM)

    Command (m for help): p

    Disk /dev/sde: 8010 MB, 8010072064 bytes
    247 heads, 62 sectors/track, 1021 cylinders, total 15644672 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xaa802e39

       Device Boot      Start         End      Blocks   Id  System
    /dev/sde1   *          63      131135       65536+   6  FAT16
    Partition 1 does not end on cylinder boundary.
    /dev/sde2          131136    15644671     7756768   8e  Linux LVM
    Partition 2 does not end on cylinder boundary.

    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.
    #
    You'll notice that I forced the 1st partition to start at sector 63 even though this was listed as no longer a requirement.  For whatever reason, I was unable to get a starting sector of 2048 (the default when not using DOS-compatability mode) to work.  Your mileage may vary.

    We'll want to format that first partition too:

    # mkfs -t vfat -F 16 -n uboot /dev/sde1
    mkfs.vfat 3.0.12 (29 Oct 2011)
    #
    Installing the boot files

    Now to save some time creating the boot partition, we're going to borrow MLO and uboot binaries from the Pandaboard validation image and a previous Fedora-13 Pandaboard image.  Download this image and copy the binaries to your local directory.  Now let's discover how the image is laid out:

    # fdisk -l validation-19102011.img

    Disk validation-19102011.img: 83 MB, 83886080 bytes
    255 heads, 63 sectors/track, 10 cylinders, total 163840 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

                      Device Boot      Start         End      Blocks   Id  System
    validation-19102011.img1   *          63       80324       40131    c  W95 FAT32 (LBA)
    validation-19102011.img2           80325      144584       32130   83  Linux
    #
    From this, we can know that the uboot filesystem is located at 512 bytes per sector x 63 sectors = 32256 bytes.  Let's mount it and copy out the files we need.  All we really need is MLO and u-boot.bin, but we'll go ahead and grab the uImage for some quick testing too.

    # mkdir tmp
    # losetup --offset 32256 --show --find ./validation-19102011.img
    /dev/loop0
    # mount /dev/loop0 ./tmp
    # ls tmp
    MLO  u-boot.bin  uImage
    # cp tmp/MLO tmp/u-boot.bin tmp/uImage .
    # umount ./tmp
    # losetup -d /dev/loop0
    # rmdir tmp
    #


    Now, let's copy the MLO, u-boot.bin, and uImage files to the flash.  The MLO must be the first file written, and never be re-written, so we have to take special precautions to make sure that this happens correctly with no other writes.

    # mount /dev/sde1 /mnt/tmp
    # cp MLO /mnt/tmp/
    # sync
    # umount /mnt/tmp
    # mount /dev/sde1 /mnt/tmp
    # cp u-boot.bin uImage /mnt/tmp/
    # umount /mnt/tmp
    So this should be enough to at least test and make sure we laid it out right.  Let's eject the media and try booting it on the Pandaboard.

    # eject /dev/sde
    #
     A quick test

    Welcome to minicom 2.5

    OPTIONS: I18n
    Compiled on Apr  6 2011, 07:59:07.
    Port /dev/ttyUSB0

    Press CTRL-A Z for help on special keys



    Texas Instruments X-Loader 1.41 (Sep 29 2011 - 10:43:53)
    OMAP4460: 1.2 GHz capable SOM
    Starting OS Bootloader from MMC/SD1 ...


    U-Boot 1.1.4-gc1cd80bc-dirty (Oct 12 2011 - 17:56:27)

    Load address: 0x80e80000
    DRAM:  1024 MB
    Flash:  0 kB
    Using default environment

    In:    serial                                                                  
    Out:   serial                                                                  
    Err:   serial                                                                  
    Hit any key to stop autoboot:  0                                               
    mmc read: Invalid size                                                         
                                                                                   
    4020344 bytes read                                                             
    ## Booting image at 82000000 ...                                               
       Image Name:   Linux-3.0.4+                                                  
       Image Type:   ARM Linux Kernel Image (uncompressed)                         
       Data Size:    4020280 Bytes =  3.8 MB                                       
       Load Address: 80008000                                                      
       Entry Point:  80008000                                                      
       Verifying Checksum ... OK                                                   
    OK                                                                             
                                                                                   
    Starting kernel ...                                                            
                                                                                   
    Uncompressing Linux... done, booting the kernel.                               
    [    0.000000] Linux version 3.0.4+ (danders@ccd-dev) (gcc version 4.3.3 (Sourc1
    [    0.000000] CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c5387f
    ...
    [    8.663208] Waiting 3sec before mounting root device...                     
    [   12.223846]   b301           65536 mmcblk0p1 00000000-0000-0000-0000-00000001
    [   12.233856]   b302         7756768 mmcblk0p2 00000000-0000-0000-0000-00000002
    [   12.242279] No filesystem could mount root, tried:  ext3                    
    [   12.242279] Kernel panic - not syncing: VFS: Unable to mount root fs on unkn)
    ...

    If you saw your board get at least to the point of trying to mount the root and failing, this is a good sign.  This means that the MLO, u-boot.bin, and uImage files are all functional.

    Next step is to get it booting a Fedora image - that's the next post.