Difference between revisions of "EBC Exercise 21a Boot Sequence"

From eLinux.org
Jump to: navigation, search
m
m
Line 24: Line 24:
 
  beaglebone login: '''root'''
 
  beaglebone login: '''root'''
 
  root@beaglebone:~#  
 
  root@beaglebone:~#  
 +
 +
== Shutdown ==
  
 
Now shutdown and be ready to hit return when you get the u-boot prompt.
 
Now shutdown and be ready to hit return when you get the u-boot prompt.
Line 36: Line 38:
 
  Detaching DM devices.
 
  Detaching DM devices.
 
  [  599.018005] Restarting system.
 
  [  599.018005] Restarting system.
These first messages are from the kernel shutting down.  The following messages are the boot sequence.
+
These first messages are from the kernel shutting down.   
 +
 
 +
== U-Boot Starting ==
 +
The following messages are the boot sequence.
 
  U-Boot SPL 2011.09-00053-gb423c52 (Aug 10 2012 - 11:26:55)
 
  U-Boot SPL 2011.09-00053-gb423c52 (Aug 10 2012 - 11:26:55)
 
  Texas Instruments Revision detection unimplemented
 
  Texas Instruments Revision detection unimplemented
Line 62: Line 67:
 
  U-Boot#  
 
  U-Boot#  
  
 +
== U-Boot help ==
 
You are now in the u-boot boot loader. Try '''help'''
 
You are now in the u-boot boot loader. Try '''help'''
 
  U-Boot# '''help'''
 
  U-Boot# '''help'''
Line 127: Line 133:
 
  version - print monitor, compiler and linker version
 
  version - print monitor, compiler and linker version
  
 +
== Discovering what '''boot''' does ==
 
Your goal is to discover what happens when the '''boot''' command is run.
 
Your goal is to discover what happens when the '''boot''' command is run.
  
Line 146: Line 153:
 
  ... and so on.
 
  ... and so on.
  
 +
== U-Boot print ==
 
It might be helpful to print the contents of all the variables and save it for future reference.
 
It might be helpful to print the contents of all the variables and save it for future reference.
 
  U-boot# print
 
  U-boot# print
Line 209: Line 217:
 
  stdin=serial
 
  stdin=serial
 
  stdout=serial
 
  stdout=serial
 
  
 
Based on your investigation above, predict what will happen at boot time, then boot and check yourself.
 
Based on your investigation above, predict what will happen at boot time, then boot and check yourself.
  
 +
== U-boot boot ==
 
  U-Boot# '''boot'''
 
  U-Boot# '''boot'''
 
  SD/MMC found on device 0
 
  SD/MMC found on device 0
Line 250: Line 258:
 
  Angstrom v2012.05 - Kernel 3.2.25
 
  Angstrom v2012.05 - Kernel 3.2.25
 
   
 
   
  beaglebone login:  
+
  beaglebone login: '''root'''
 +
 
 +
== Looking on the FAT partition ==
 +
The SD card you have been using has 2 partitions on it.  Partition 1 is a small FAT partition. These are the files you see appear when you first boot the bone. This contains the boot loaders.
 +
 
 +
The second partition is ext4 and contains the root file system. These are all the other files. 
 +
 
 +
You can see the FAT partition with:
 +
beagle$ '''mount /dev/mmcblk0p1 /mnt'''
 +
beagle$ '''cd /mnt'''
 +
beagle$ '''ls'''
 +
Docs    LICENSE.txt  README.htm  autorun.inf  u-boot.img
 +
Drivers  MLO          Uenv.txt    info.txt    uEnv.txt.orig
 +
 
 +
The file '''u-boot.img''' is U-Boot!.  Look in '''uEnv.txt'''
 +
beagle$ '''cat uEnv.txt'''
 +
optargs=run_hardware_tests quiet
 +
 
 +
These are the arguments that are passed to the kernel when it boots.  Try editing the file and removing '''quiet''', then reboot.  You should see many more boot messages.
  
 
{{YoderFoot}}
 
{{YoderFoot}}

Revision as of 08:40, 1 October 2012

thumb‎ Embedded Linux Class by Mark A. Yoder


Up to this point we've always booted the Beagle into Linux and worked from there. Now it's time to learn what has to happen before we can run Linux. To do this you need to look at the output of the serial port so see the boot sequence.

Booting Up

Boot up your bone and connect to the serial port using the screen command. Hit return and log in.

host$ screen /dev/ttyUSB0 115200
.---O---.                                           
|       |                  .-.           o o        
|   |   |-----.-----.-----.| |   .----..-----.-----.
|       |     | __  |  ---'| '--.|  .-'|     |     |
|   |   |  |  |     |---  ||  --'|  |  |  '  | | | |
'---'---'--'--'--.  |-----------'  '-----'-'-'-'
                -'  |
                '---'

The Angstrom Distribution beaglebone ttyO0 

Angstrom v2012.05 - Kernel 3.2.25

beaglebone login: root
root@beaglebone:~# 

Shutdown

Now shutdown and be ready to hit return when you get the u-boot prompt.

beagle$ shutdown -r now
Sending SIGTERM to remaining processes...
Sending SIGKILL to remaining processes...
Unmounting file systems.
Unmounted /dev/mqueue.
Unmounted /sys/kernel/debug.
Disabling swaps.
Detaching loop devices.
Detaching DM devices.
[  599.018005] Restarting system.

These first messages are from the kernel shutting down.

U-Boot Starting

The following messages are the boot sequence.

U-Boot SPL 2011.09-00053-gb423c52 (Aug 10 2012 - 11:26:55)
Texas Instruments Revision detection unimplemented
No daughter card present
No AC power, disabling frequency switch
OMAP SD/MMC: 0
reading u-boot.img
reading u-boot.img


U-Boot 2011.09-00053-gb423c52 (Aug 10 2012 - 11:26:55)

I2C:   ready
DRAM:  256 MiB
WARNING: Caches not enabled
No daughter card present
NAND:  HW ECC Hamming Code selected
No NAND device found!!!
0 MiB
MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
*** Warning - readenv() failed, using default environment

Net:   cpsw
Hit any key to stop autoboot:  0 
U-Boot# 

U-Boot help

You are now in the u-boot boot loader. Try help

U-Boot# help
?       - alias for 'help'
askenv  - get environment variables from stdin
base    - print or set address offset
bdinfo  - print Board Info structure
boot    - boot default, i.e., run 'bootcmd'
bootd   - boot default, i.e., run 'bootcmd'
bootm   - boot application image from memory
bootp   - boot image via network using BOOTP/TFTP protocol
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
dcache  - enable or disable data cache
dhcp    - boot image via network using DHCP/TFTP protocol
echo    - echo args to console
editenv - edit environment variable
env     - environment handling commands
exit    - exit script
ext2load- load binary file from a Ext2 filesystem
ext2ls  - list files in a directory (default /)
ext4load- load binary file from a Ext2 filesystem
ext4ls  - list files in a directory (default /)
false   - do nothing, unsuccessfully
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
go      - start application at address 'addr'
help    - print command description/usage
i2c     - I2C sub-system
icache  - enable or disable instruction cache
iminfo  - print header information for application image
imxtract- extract a part of a multi-image
itest   - return true/false on integer compare
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loady   - load binary file over serial line (ymodem mode)
loop    - infinite loop on address range
md      - memory display
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - display MMC info
mtest   - simple RAM read/write test
mw      - memory write (fill)
nand    - NAND sub-system
nandecc - Switch NAND ECC calculation algorithm b/w hardware and software
nboot   - boot from NAND device
nfs     - boot image via network using NFS protocol
nm      - memory modify (constant address)
ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
saveenv - save environment variables to persistent storage
setenv  - set environment variables
sf      - SPI flash sub-system
showvar - print local hushshell variables
sleep   - delay execution for some time
source  - run script from memory
test    - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
true    - do nothing, successfully
version - print monitor, compiler and linker version

Discovering what boot does

Your goal is to discover what happens when the boot command is run.

U-Boot# help boot
boot - boot default, i.e., run 'bootcmd'
U-boot# print bootcmd
bootcmd=if mmc rescan; then echo SD/MMC found on device ${mmc_dev}; 
if run loadbootenv; then echo Loaded environment from ${bootenv};run importbootenv;fi;
if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;
if run mmc_load_uimage_ext4; then run mmc_args;bootm ${kloadaddr};fi;fi;run nand_boot;

Figure out what's happening above by 'pretty printing' bootcmd. That is, properly format the code so you can follow the flow.

if mmc rescan; then
  echo SD/MMC found on device ${mmc_dev};  Find out what mmc_dev is and fill it in
  if run loadbootenv; then 
    echo Loaded environment from ${bootenv};
    run importbootenv;
  fi;
... and so on.

U-Boot print

It might be helpful to print the contents of all the variables and save it for future reference.

U-boot# print
autoload=yes
baudrate=115200
bootargs_defaults=setenv bootargs console=${console} ${optargs}
bootcmd=if mmc rescan; then echo SD/MMC found on device ${mmc_dev};if run loadbootenv; then echo Loaded  
 environment from ${bootenv};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run 
 uenvcmd;fi;if run mmc_load_uimage_ext4; then run mmc_args;bootm ${kloadaddr};fi;fi;run nand_boot;
bootdelay=1
bootenv=uEnv.txt
bootfile=uImage
console=ttyO0,115200n8
ethact=cpsw
ethaddr=d4:94:a1:39:ed:0c
importbootenv=echo Importing environment from mmc ...; env import -t $loadaddr $filesize
 ip_method=none
kloadaddr=0x80007fc0
loadaddr=0x82000000
loadbootenv=fatload mmc ${mmc_dev} ${loadaddr} ${bootenv}
mmc_args=run bootargs_defaults;setenv bootargs ${bootargs} root=${mmc_root} rootfstype=${mmc_root_fs_type}  
 ip=${ip_method}
mmc_boot=run mmc_args; run mmc_load_uimage_ext4; bootm ${kloadaddr}
mmc_dev=0
mmc_load_uimage=fatload mmc ${mmc_dev}:1 ${kloadaddr} ${bootfile}
mmc_load_uimage_ext4=ext4load mmc ${mmc_dev}:2 ${kloadaddr} /boot/${bootfile}
mmc_root=/dev/mmcblk0p2 ro
mmc_root_fs_type=ext4 rootwait
nand_args=run bootargs_defaults;setenv bootargs ${bootargs} root=${nand_root} noinitrd  
rootfstype=${nand_root_fs_type} ip=${ip_method}
nand_boot=echo Booting from nand ...; run nand_args; nandecc hw 2; nand read.i ${kloadaddr}  
 ${nand_src_addr} ${nand_img_siz}; bootm ${kloadaddr}
nand_img_siz=0x500000
nand_root=ubi0:rootfs rw ubi.mtd=7,2048
nand_root_fs_type=ubifs rootwait=1
nand_src_addr=0x280000
net_args=run bootargs_defaults;setenv bootargs ${bootargs} root=/dev/nfs  
nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp 
 net_boot=echo Booting from network ...; setenv autoload no; dhcp; tftp ${kloadaddr} ${bootfile}; run  
 net_args; bootm ${kloadaddr}
nfsopts=nolock
nor_args=run bootargs_defaults;setenv bootargs ${bootargs} root={nor_root} rootfstype=${nor_root_fs_type}  
 ip=${ip_method}
nor_boot=echo Booting from NOR ...; run nor_args; cp.b ${0x08080000} ${kloadaddr} ${nor_img_siz}; bootm  
 ${kloadaddr}
nor_img_siz=0x280000
nor_root=/dev/mtdblock3 rw
nor_root_fs_type=jffs2
nor_src_addr=0x08080000
rootpath=/export/rootfs
script_addr=0x81900000
spi_args=run bootargs_defaults;setenv bootargs ${bootargs} root=${spi_root} rootfstype=${spi_root_fs_type}  
 ip=${ip_method}
spi_boot=echo Booting from spi ...; run spi_args; sf probe ${spi_bus_no}:0; sf read ${kloadaddr}  
 ${spi_src_addr} ${spi_img_siz}; bootm ${kloadaddr}
spi_bus_no=0
spi_img_siz=0x380000
spi_root=/dev/mtdblock4 rw
spi_root_fs_type=jffs2
spi_src_addr=0x62000
static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off
stderr=serial
stdin=serial
stdout=serial

Based on your investigation above, predict what will happen at boot time, then boot and check yourself.

U-boot boot

U-Boot# boot
SD/MMC found on device 0
reading uEnv.txt

33 bytes read
Loaded environment from uEnv.txt
Importing environment from mmc ...
Loading file "/boot/uImage" from mmc device 0:2 xxa2
3319440 bytes read
## Booting kernel from Legacy Image at 80007fc0 ...
   Image Name:   Angstrom/3.2.25/beaglebone
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3319376 Bytes = 3.2 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
systemd-fsck[56]: Angstrom-Cloud9: clean, 51868/218592 files, 304346/873534 blocks

.---O---.                                           
|       |                  .-.           o o        
|   |   |-----.-----.-----.| |   .----..-----.-----.
|       |     | __  |  ---'| '--.|  .-'|     |     |
|   |   |  |  |     |---  ||  --'|  |  |  '  | | | |
'---'---'--'--'--.  |-----------'  '-----'-'-'-'
                -'  |
                '---'

The Angstrom Distribution beaglebone ttyO0

Angstrom v2012.05 - Kernel 3.2.25

beaglebone login: root

Looking on the FAT partition

The SD card you have been using has 2 partitions on it. Partition 1 is a small FAT partition. These are the files you see appear when you first boot the bone. This contains the boot loaders.

The second partition is ext4 and contains the root file system. These are all the other files.

You can see the FAT partition with:

beagle$ mount /dev/mmcblk0p1 /mnt
beagle$ cd /mnt
beagle$ ls
Docs     LICENSE.txt  README.htm  autorun.inf  u-boot.img
Drivers  MLO          Uenv.txt    info.txt     uEnv.txt.orig

The file u-boot.img is U-Boot!. Look in uEnv.txt

beagle$ cat uEnv.txt
optargs=run_hardware_tests quiet

These are the arguments that are passed to the kernel when it boots. Try editing the file and removing quiet, then reboot. You should see many more boot messages.




thumb‎ Embedded Linux Class by Mark A. Yoder