[[bc10/Software]]

- Contents
#contents

* Summary [#x7a308ba]
>~
This section explains the boot process of bc10. It covers the basic knowledge of the boot process from~
turning on the power to starting up the OS. It takes three steps to complete the boot process: bootROM,~
X-Loader, and U-Boot. bootROM is factory preconfigured, and this section briefly explains the function~
of it. The The detail information of X-Loader and U-Boot is individually published at [[bc10/x-loader]] and~
[[bc10/u-boot]], respectively.~

* Boot Sequence [#se04ae6f]
>~
As bc10 ([[OMAP3530:http://focus.ti.com/docs/prod/folders/print/omap3530.html]]) boots into Linux, the
order of the boot sequence in bc10 is described as below. The~
boot process starts right after power is turned on.~
+ BootROM
+ X-Loader
+ U-Boot
+ uImage (Linux kernel)

* BootROM [#oab27cef]
>~
OMAP3530 contains BootROM, which includes the code that handles the first boot step. As power is on, because~
of the code, BootROM start scanning the devices for the bootloder. BootROM only scans bootable devices and~
directly accesses the devices. The devices that BootROM can access and scan the bootloader are listed below.~
- NAND Flash
- MMC/SD card
- USB
- Serial~

>BootROM looks at the '''sys_boot''' pins to determine the order of scanning devices as power is on. As the~
setting of the '''sys_boot''' pins is rearranged, the order of scanning can be altered.~

** Scanning Order [#e32e3d00]
>~
bc10 and BeagleBoard have the same configuration for the scanning order. There are two patterns of the scanning~
order. While power is turned on (pressing RESET button), the order of scanning can be changed, depending on whether~
USER button is pressed or not.~
- USER button is NOT pressed as RESET button is pressed~
-- ''NAND -> USB -> UART -> MMC/SD''~
- USER button is pressed as RESET button is pressed~
-- ''USB -> UART -> MMC/SD -> NAND''~

>(Pressing RESET button means that power is turned on.)

>~
If BootROM cannot find the bootloader in one device, then it automatically shifts to the next device and starts~
scanning it.~
>
The two sets of the scanning order are very useful and practical. Usually, the bootloders are contained in NAND,~
do not be necessary to press USER button. However, in some situations, for example, a new bootloader is tested,~
NAND does not work appropriately, or NAND is blank since it is the factory default condition, press USER~
button, and access bootloaders in the SD card.~

* X-Loader [#rb30f24e]
>~
X-Loader is the first bootloader whose objective is to search for U-Boot and to boot it. To search for U-Boot image,~
X-Loader access the devices in such order.~
+ MMC/SD card
+ NAND Flash

>For the information of how to build X-Loader from the source code,  please visit at [[bc10/x-loader]] for the details.~

* U-Boot [#z6e34fcb]
>~
U-Boot is the second bootloader. This is a multifunctional bootloader and capable of booting OS and initializing~
hardware. U-Boot is equipped with the command line interface, can access to the file system of MMC/SD, and read~
and write in NAND. Since U-Boot is highly functional, any set-up for booting can be handled. For farther information,~
please look at [[bc10/u-boot]].~

* Linux Kernel [#qb5bb6c4]
>
Linux kernel image file is named '''uImage''', and '''uImage''' can be used for both OpenEmbedded Linux environment and~
Android environment. To build Linux kernel ('''uImage''') from source code, please look at [[bc10/kernel-2.6.32]].~


* Create bootable SD card [#mef5758b]

** Outline [#e00adbcd]
>
This section explains how to create a bootable SD card, which contains X-Loader and U-Boot. Creating a bootable SD~
is the easiest way to boot bc10 since NAND Flash of bc10 is empty when it is shipped from the factory. By the design~
of bc10, it cannot be booted from the microSD card slot. bc10 is only booted from the SD card slot. This article~
assumes that the OS which U-Boot boot up is Linux and that the SD card becomes a dual-partition card. The first partition~
contains the tools for booting, and the second partition has root file system of Linux. The structure of the SD card and~
contents of each partition are described as below.~
- FAT32 partition
-- X-Loader
-- U-Boot
-- Linux kernel
- Linux partition
-- Linux toot file system

>It is assumed that working environment is Linux. ~
The order of the instructions is shown below.~
+ Initialization and setting of partitions
+ Format the bootlorder file system
+ Placing the bootlorder files

>The instruction is originally listed at [[LinuxBootDiskFormat (code.google.com):http://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat]], and this section is quoted and rearranged.~
For the convenience of the explanation for the command lines,  user inputs are also shown, and user inputs are written~
inside squire brackets [ ]. This is an example, and the directory and the location of device file may vary. These are~
highly dependent on SD cards.~

** Unmount SD card [#o84d4969]
>Unmount is required for creating partitions and formatting the SD card.  If the automounter mounts the SD card, unmount~
the SD card.~
>
Assume that presently a SD card is mounted as it is described below.~
 $ [df -h]
 Filesystem            Size  Used Avail Use% Mounted on
 ...
 /dev/sdc1             400M   94M  307M  24% /media/disk
 ...
>
The name of the SD card is '''disk''', and the SD card is currently situated the directory '''/media/disk'''.~
Unmount the SD card.~
 $ [umount /media/disk]

** Initialization and configuration of partitions [#o5b41862]
>Execute '''fdisk''' command. The parameter of '''fdisk''' is the starting point of the SD card, in which the device file of the SD~
card is located. The directory may differ, depending on SD cards. Please check before start this task.~
 $ [sudo fdisk /dev/sdc]
 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)

>Write down the number of bytes on the SD card. The number will use later. (in this example 2021654528)~
Delete any partitions that already exist in the SD card.
Delete all partitions that already exist in the SD card.
 Command (m for help): [d]
 Selected partition 1

>Change to 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]

>The number of cylinders is differ, and it is dependent on SD cards. This is how to calculate the number of cylinders.~
The outcome is truncated, do not be rounded.
 #cylinders = FLOOR (the number of Bytes on the SD Card (from above) / 255 / 63 / 512 )

>The number of cylinders for the SD card used here is calculated as described below.
 2021654528 / 255 / 63 / 512 = 245.79
 -> 245

>Set the number of cylinders, The number of cylinders is 245 for this example.
 Expert Command (m for help): [c]
 Number of cylinders (1-256, default xxx): [enter the number calculated above]

>Return to normal mode.
 Expert Command (m for help): [r]

>Create FAT32 partition in the SD card.
 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))

>Set up the boot flag in the first partition, and make it bootable.
 Command (m for help): [a]
 Partition number (1-4): [1]

>Create the second partition for the root file system of Linux.
 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

>Check up configurations of the newly created partitions.
 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 changes in the partition table.
 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 file system [#fa62126f]

>Format the FAT32 partition and the Linux partition.~
In the example described below, '''LABLE1''' and '''LABEL2''' are given by the commands. The names of the partitions are~
freely decided. Input the names of the partitions.~
 $ [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: 

** Place the image files of bootloaders [#g3d0d8f1]
>The image files of  bootloaders are set into the SD card.~
First, remount the SD card. (Gently push the SD card into its holder, then the card pops out, and reinsert the~
SD card into its folder again.) The mount point of SD card is highly dependent on system. Change the mount point~
which is suitable to its system.~

>X-Loader, the first bootloader, does have strict requirements for its placement on the SD card. Please follow~
the direction described below.~
- X-Loader is placed right after formatting FAT32 partition is completed.
- It places the top directly of the partition.
- The name of the file is set as ''MLO''.~

>
 $ [cp x-load.bin.ift /media/LABEL1/MLO]

>Then, U-Boot, the second boot loader, is placed into the SD card.
- The file name is changed as '''u-boot.bin'''.

>
 $ [cp u-boot.bin /media/LABEL1/u-boot.bin]

>Place Linux kernel
- Change the name of Linux kernel image to '''uImage'''.

>
 $ [cp uImage /media/LABEL1/uImage]

>To make mistakes on the order of placing files and/or in the process of placing a file, the most certain way to~
fix the mistakes is to redo from the reformatting the partition of FAT32.~

>Now, complete the whole process, and unmount the SD card and remove it from the socket.

* Boot up from SD card [#a2e3923a]
>~
Insert the SD card in which the bootloaders are installed, into bc10.~
Set up the scanning order of BootROM. To put the SD card is higher order than NAND, please press USER button while~
power is turned on. bc10 boots up from the SD card.~

* Reference [#id8c89d9]

-This explains how to change the boot order of bootROM.
--http://e2e.ti.com/support/dsp/omap_applications_processors/f/447/p/30142/105090.aspx
-Please look at BootROM section for the details
--http://elinux.org/BeagleBoard#BootRom
-This is the reference of the whole boot process for BeagleBoard as well as bc10
--http://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat~

* Revision History [#ja9665cf]
- 2010/10/20 This article is originally uploaded
- 2011/01/14 The information of Linux kernel is added


Front page   Edit Diff Backup Upload Copy Rename Reload   New List of pages Search Recent changes   RSS of recent changes