メッセージ欄

分類 【Raspberry Pi】 で検索

一覧で表示する

Raspberry Piのブートプロセスを想像する
2012/09/02(日) 20:41 Raspberry Pi はてブ情報 はてブに登録 はてブ数

Raspberry PiのLinuxイメージの中身をみて、どういう仕組みでブートしていたのかを想像していたときの記録が出てきたのでメモとして残しておきます。

disklabeはこんな感じ。MSDOSとext2パーティションが見えています。
#        size    offset     fstype [fsize bsize cpg/sgs]
 d:  32235520         0     unused      0     0        # (Cyl.      0 -  15739)
 e:    114688      8192      MSDOS                     # (Cyl.      4 -     59)
 f:   3665920    122880 Linux Ext2      0     0        # (Cyl.     60 -   1849)
MS-DOSパーティションをマウントして中を見てみます。
# ls /mnt
arm128_start.elf          cmdline.txt               kernel_emergency.img
arm192_start.elf          config.txt                loader.bin
arm224_start.elf          issue.txt                 start.elf
arm240_start.elf          kernel.img
bootcode.bin              kernel_cutdown.img
テキストファイルの中身を見ていきましょう。

cmdline.txtはLinuxカーネルに与えるパラメータを書いているようです。
# cat cmdline.txt 
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
少し見やすくしてみます。
dwc_otg.lpm_enable=0 
console=ttyAMA0,115200 
kgdboc=ttyAMA0,115200 
console=tty1 
root=/dev/mmcblk0p2 
rootfstype=ext4 
elevator=deadline 
rootwait
config.txtは何でしょうね。このファイルを変更すると、HDMIの設定やフレームバッファの設定が変更できるのでしょうか。オーバークロックの設定もあって、気になります。
# cat config.txt 
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# for more options see http://elinux.org/RPi_config.txt
issue.txtはこのカーネルが作られたときの情報なのでしょうかね。URLを見てみると、spindleというのはRaspberry Piのイメージを作るプロジェクトのようですね。
# cat issue.txt 
Raspberry Pi reference 2012-08-16 (armhf)
Generated using spindle, http://asbradbury.org/projects/spindle/, f85b818, stage4-lxde-edu.qed
バイナリファイルはfileコマンドでさらっと。

たくさんあるarmXXX_start.elfは搭載メモリによって用意されているようなのですが良くわかりません。readelf -aしてみると、エントリポイント含めたアドレスだけが違っているようです。startっていう名前からして、いかにも最初に呼ばれそうな感じがしますが、ELFを解釈できる誰かが動いてから最初に、っていう感じですかね。
# file *.elf
arm128_start.elf: ELF 32-bit LSB executable, version 1 (SYSV), statically linked, stripped
arm192_start.elf: ELF 32-bit LSB executable, version 1 (SYSV), statically linked, stripped
arm224_start.elf: ELF 32-bit LSB executable, version 1 (SYSV), statically linked, stripped
arm240_start.elf: ELF 32-bit LSB executable, version 1 (SYSV), statically linked, stripped
start.elf:        ELF 32-bit LSB executable, version 1 (SYSV), statically linked, stripped
IMGファイルは名前のとおりカーネル本体なのでしょう。標準カーネルと軽量カーネルと緊急用カーネルといったところでしょうか。
# file *.img
kernel.img:           DBase 3 index file
kernel_cutdown.img:   DBase 3 index file
kernel_emergency.img: DBase 3 index file
BINファイルはARMのbinaryファイルなのでしょう。この二つのbinaryファイルがLinuxカーネルを呼んでいるんでしょうねぇ。さっきのstart.elfはどう絡むんでしょうか。
# file *.bin
bootcode.bin: data
loader.bin:   data