Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Beacon EmbeddedWorks support staff and engineers participate, Beacon EmbeddedWorks does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Beacon EmbeddedWorks engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Beacon EmbeddedWorks product download, please subscribe to the TDG Forum of interest.

TDG Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 05 Nov 2013 10:13 AM by  Seth Berardinelli
boot from sd??
 7 Replies
Sort:
You are not authorized to post a reply.
Author Messages
Seth Berardinelli
New Member
New Member
Posts:13


--
22 Oct 2013 08:03 PM

    I'm sort of new to this embedded linux environment. I understand how to set up linux via fdisk and mkfs, using grub or syslinux. How does one set up an SD Card to boot the kernel from the SD Card and mounting multiple partitions? A step-by-step would be nice. I'm interested in using the SD Card like a normal hard disk and uboot/logicloader as though I were using grub/syslinux (if I am even equating the properly). The labs seem to generate a ramdisk for the SD Card, and I am not interested in that.

    steven.eckhoff
    Basic Member
    Basic Member
    Posts:192


    --
    23 Oct 2013 11:46 AM

    Seth,

     The following is from a Beagleboard wiki page. This guide will walk you through creating a FAT boot partition with partition geometries that are readable by the boot ROM. Then it shows how to create a separate partition that can have other file systems that Linux will be able to mount.

     

    Introduction

     

    This guide is meant for those looking to create a dual-partition card, booting from a FAT partition that can be read by the OMAP3 ROM bootloader and Linux/Windows, then utilizing an ext3 partition for the Linux root file system.

    Details

     

    Text marked with shows user input.

    Determine which device the SD Card Reader is on your system

     

    Plug the SD Card into the SD Card Reader and then plug the SD Card Reader into your system. After doing that, do the following to determine which device it is on your system.

    $ [dmesg | tail]
    ...
    [ 6854.215650] sd 7:0:0:0: [sdc] Mode Sense: 0b 00 00 08
    [ 6854.215653] sd 7:0:0:0: [sdc] Assuming drive cache: write through
    [ 6854.215659]  sdc: sdc1
    [ 6854.218079] sd 7:0:0:0: [sdc] Attached SCSI removable disk
    [ 6854.218135] sd 7:0:0:0: Attached scsi generic sg2 type 0
    ...

     

    In this case, it shows up as /dev/sdc (note sdc inside the square brackets above).

    Check to see if the automounter has mounted the SD Card

     

    Note there may be more than one partition (only one shown in the example below).

    $ [df -h]
    Filesystem            Size  Used Avail Use% Mounted on
    ...
    /dev/sdc1             400M   94M  307M  24% /media/disk
    ...

     

    Note the "Mounted on" field in the above and use that name in the umount commands below.

    If so, unmount it

    $ [umount /media/disk]

    Start fdisk

     

    Be sure to choose the whole device (/dev/sdc), not a single partition (/dev/sdc1).

    $ [sudo fdisk /dev/sdc]

    Print the partition record

     

    So you know your starting point. Make sure to write down the number of bytes on the card (in this example, 2021654528).

    Command (m for help): [p]

    Disk /dev/sdc: 2021 MB, 2021654528 bytes
    255 heads, 63 sectors/track, 245 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

       
    Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1   *           1         246     1974240+   c  W95 FAT32 (LBA)
    Partition 1 has different physical/logical endings:
         phys
    =(244, 254, 63) logical=(245, 200, 19)

    Delete any partitions that are there already

    Command (m for help): [d]
    Selected partition 1

    Set the Geometry of the SD Card

     

    If the print out above does not show 255 heads, 63 sectors/track, then do the following expert mode steps to redo the SD Card:

    • Go into expert mode.
    Command (m for help): [x]
    • Set the number of heads to 255.
    Expert Command (m for help): [h]
    Number of heads (1-256, default xxx): [255]
    • Set the number of sectors to 63.
    Expert Command (m for help): [s]
    Number of sectors (1-63, default xxx): [63]
    • Now Calculate the number of Cylinders for your SD Card.
    #cylinders = FLOOR (the number of Bytes on the SD Card (from above) / 255 / 63 / 512 )

    So for this example:  2021654528 / 255 / 63 / 512 = 245.79.  So we use 245 (i.e. truncate, don't round).
    • Set the number of cylinders to the number calculated.
    Expert Command (m for help): [c]
    Number of cylinders (1-256, default xxx): [enter the number you calculated]
    • Return to Normal mode.
    Expert Command (m for help): [r]

    Print the partition record to check your work

    Command (m for help): [p]

    Disk /dev/sdc: 2021 MB, 2021654528 bytes
    255 heads, 63 sectors/track, 245 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

       
    Device Boot      Start         End      Blocks   Id  System

    Create the FAT32 partition for booting and transferring files from Windows

    Command (m for help): [n]
    Command action
       e   extended
       p   primary partition
    (1-4)
    [p]
    Partition number (1-4): [1]
    First cylinder (1-245, default 1): [(press Enter)]
    Using default value 1
    Last cylinder or +size or +sizeM or +sizeK (1-245, default 245): [+50]

    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))

    Mark it as bootable

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

    Create the Linux partition for the root file system

    Command (m for help): [n]
    Command action
       e   extended
       p   primary partition
    (1-4)
    [p]
    Partition number (1-4): [2]
    First cylinder (52-245, default 52): [(press Enter)]
    Using default value 52
    Last cylinder or +size or +sizeM or +sizeK (52-245, default 245): [(press Enter)]
    Using default value 245

    Print to Check Your Work

    Command (m for help): [p]

    Disk /dev/sdc: 2021 MB, 2021654528 bytes
    255 heads, 63 sectors/track, 245 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

       
    Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1   *           1          51      409626    c  W95 FAT32 (LBA)
    /dev/sdc2              52         245     1558305   83  Linux

    Save the new partition records on the SD Card

     

    This is an important step. All the work up to now has been temporary.

    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.

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

    Format the partitions

     

    The two partitions are given the volume names LABEL1 and LABEL2 by these commands. You can substitute your own volume labels.

    $ [sudo mkfs.msdos -F 32 /dev/sdc1 -n LABEL1]
    mkfs
    .msdos 2.11 (12 Mar 2005)

    $
    [sudo mkfs.ext3 -L LABEL2 /dev/sdc2]
    mke2fs
    1.40-WIP (14-Nov-2006)
    Filesystem label=
    OS type
    : Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    195072 inodes, 389576 blocks
    19478 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=402653184
    12 block groups
    32768 blocks per group, 32768 fragments per group
    16256 inodes per group
    Superblock backups stored on blocks:
           
    32768, 98304, 163840, 229376, 294912

    Writing inode tables: done                            
    Creating journal (8192 blocks): done
    Writing superblocks and filesystem accounting information:
    Seth Berardinelli
    New Member
    New Member
    Posts:13


    --
    24 Oct 2013 09:27 AM

    Thanks for the response.

    I already understand the steps to set up the sd card. I need to provide the boot partition with the proper files( for example an initramfs and the proper uImage) How do I use the ltib script, or sequence of commands, to set up the kernel so I can mount and boot from the sd card? 

    steven.eckhoff
    Basic Member
    Basic Member
    Posts:192


    --
    24 Oct 2013 10:01 AM
    Seth,

    Please see the DM37xx Linux BSP User's Guide [1]. This will show you how to use LTIB and the options to build different images.

    [1] http://support.logicpd.co...talid=0&EntryId=1392
    Seth Berardinelli
    New Member
    New Member
    Posts:13


    --
    29 Oct 2013 06:43 PM

    I have it booting from the SD Card, but it appears the console or the tty02 isn't outputting out serial anymore.  If the ramdisk is allowing console and I just change the boot parameters,  why would this be happening?

    Seth Berardinelli
    New Member
    New Member
    Posts:13


    --
    29 Oct 2013 07:19 PM

    Maybe I should be specific, my apologies. 

    mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "boot-script" -d bootcmd boot.scr -> boot.scr

    bootcmd
    ------------------
    setenv bootargs 'console=tty02,115200n8 root=/dev/mmcblk0p2 rw rootdelay=1'
    fatload mmc 0 0x80008000 uImage
    bootm 0x80008000
    boot

     

     

     

    steven.eckhoff
    Basic Member
    Basic Member
    Posts:192


    --
    30 Oct 2013 09:52 AM
    Seth,

    I didn't realize that I copied over the bootloader settings from that guide. There is no need to change the console settings for your new partitions. They should be as they were before.

    console=ttyO0,115200n8 
    Seth Berardinelli
    New Member
    New Member
    Posts:13


    --
    05 Nov 2013 10:13 AM

    Okay, thanks. However, this still is not working.

    I have two partitions on my SD Card

     

    BOOT: fat32
    -----------------
    boot.scr
    initramfs.cpio.gz.uboot
    linux.config
    MLO
    System.map
    u-boot
    u-boot.bin
    u-boot.bin.ift
    uImage

     

    rootfs: ext4

    ---------------

    (all of the rootfs/*)

     

    -> My boot.scr was generated with this command "$mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "boot-script" -d bootcmd boot.scr"

    ->  My bootcmd looks like this:

    setenv bootargs 'console=ttyO0,115200n8 root=/dev/mmcblk0p2 rw rootdelay=1'
    fatload mmc 0 0x80008000 uImage
    bootm 0x80008000
    boot

    ->  I am using ./ltib -c with the initram configuration

    What am I doing wrong? I feel like I am missing something simple.


    p.s.

    This is the output before I lose the console:

    -----------------------------------------------------------

    Texas Instruments X-Loader 1.42 BSP-dm37x-2.3-2 for dm3730logic (2013-08-20 17:58:11)
    DRAM: 512MB (MT29C4G48MAZAPAKQ5)
    Starting U-boot on MMC
    Reading boot sector
    454256 bytes read from MMC to 80400000


    U-Boot 2011.06 BSP-dm37x-2.3-2 (Oct 29 2013 - 16:09:27)

    OMAP3630/3730-GP ES2.1, CPU-OPP2, L3-200MHz, Max CPU Clock 1 Ghz
    Logic DM37x/OMAP35x reference board + LPDDR/NAND
    I2C:   ready
    DRAM:  256 MiB
    Board: DM37xx Torpedo
    Enable battery backup charger (BB_CFG = 0x1c)
    NAND:  512 MiB
    NAND: Internal to NAND ECC selected
    Found '15' display panel
    In:    serial
    Out:   serial
    Err:   serial
    Read production data: done
    Die ID #67ea00029ff800000168300f0a022029
    OTG_SYSCONFIG: 00001008 - needs to be 00002001
    Part Number  : 1022102
    Model Name   : SOMDM3730-20-2780AGCR-B
    Serial Number: 0313M00855
    Data (writethrough) Cache is ON
    Net:   smc911x-0
    Hit any key to stop autoboot:  0

    == Checking mmc1 for alternate boot script boot.scr ==
    mmc1 is available
    reading boot.scr

    202 bytes read

    == Found script on mmc 1, starting ==
    ## Executing script at 80ff0000
    reading uImage

    3972700 bytes read
    ## Booting kernel from Legacy Image at 80008000 ...
       Image Name:   Linux-3.0.0-BSP-dm37x-2.3-2
       Image Type:   ARM Linux Kernel Image (uncompressed)
       Data Size:    3972636 Bytes = 3.8 MiB
       Load Address: 80008000
       Entry Point:  80008000
       Verifying Checksum ... OK
       XIP Kernel Image ... OK
    OK

    Starting kernel ...

    You are not authorized to post a reply.