備忘録

趣味に生きるオタクの備忘録

Raspi4B+ Boot Sequence の再整理とBoot LoaderのUART出力(補訂)

前の記事(Raspi4B+ Boot Sequence の再整理とBoot LoaderのUART出力 - 備忘録)で書いた、

start4.elfのログはもしかたら出せるんでしょうかね?もう少し調べてみましょう。

の件ですが、あっさり(?)見ることが出来ましたのでメモしておきます。

いじる場所

config.txtでした。下記公式サイトにconfig.txtのBoot関連の機能エントリがありますが、気づいてませんでした()
config.txt - Raspberry Pi Documentation

具体的には、

uart_2ndstage=1

を/bootパーティションのconfig.txtに記載すればOKです。そうするとPi4の場合はstart4.elfのログ出力が見えるようになります。

ログ出力

下記にminicomの出力をべた張りします。

# おそらくこの辺はEEPROMのBootloaderですね #
[2021-02-24 23:06:36.476] PM_RSTS: 0x00001000
[2021-02-24 23:06:36.477] RPi: BOOTLOADER release VERSION:c305221a DATE: Sep  3 2020 TIME: 13:11:46 BOOTMODE: 0x00000006 part: 0 BUILD_TIMESTAMP=1599135103 0x26eeacfe 0x00c0312
[2021-02-24 23:06:36.492] uSD voltage 3.3V
[2021-02-24 23:06:36.504] Initialising SDRAM 'Micron' 16Gb x2 total-size: 32 Gbit 3200
[2021-02-24 23:06:38.173] XHCI-STOP
[2021-02-24 23:06:38.174] xHC ver: 256 HCS: 05000420 fc000031 00e70004 HCC: 002841eb
[2021-02-24 23:06:38.179] xHC ports 5 slots 32 intrs 4
[2021-02-24 23:06:38.185] Reset USB port-power 1000 ms
[2021-02-24 23:06:39.322] Boot mode: SD (01) order f4
[2021-02-24 23:06:39.327] SD HOST: 250000000 CTL0: 0x00000000 BUS: 100000 Hz actual: 100000 HZ div: 2500 (1250) status: 0x1fff0000 delay: 1080
[2021-02-24 23:06:39.342] SD HOST: 250000000 CTL0: 0x00000f00 BUS: 100000 Hz actual: 100000 HZ div: 2500 (1250) status: 0x1fff0000 delay: 1080
[2021-02-24 23:06:39.353] CID: 00744a6055534455310267202cfa0108
[2021-02-24 23:06:39.356] CSD: 400e00325b590000ec5d7f800a400000
[2021-02-24 23:06:39.360] SD: bus-width: 4 spec: 2 SCR: 0x02358003 0x00000000
[2021-02-24 23:06:39.365] SD HOST: 250000000 CTL0: 0x00000f04 BUS: 50000000 Hz actual: 41666666 HZ div: 6 (3) status: 0x1fff0000 delay: 2
[2021-02-24 23:06:39.375] MBR: 0x00002000,  524288 type: 0x0c
[2021-02-24 23:06:39.378] MBR: 0x00082000,61429760 type: 0x83
[2021-02-24 23:06:39.381] MBR: 0x00000000,       0 type: 0x00
[2021-02-24 23:06:39.385] MBR: 0x00000000,       0 type: 0x00
[2021-02-24 23:06:39.388] lba: 8192 oem: 'mkfs.fat' volume: ' boot       '
[2021-02-24 23:06:39.392] rsc 32 fat-sectors 4033 c-count 516190 c-size 1 r-dir 2 r-sec 0
[2021-02-24 23:06:39.447] PM_RSTS: 0x00001000
[2021-02-24 23:06:39.448] Partition: 0
[2021-02-24 23:06:39.449] lba: 8192 oem: 'mkfs.fat' volume: ' boot       '
[2021-02-24 23:06:39.454] rsc 32 fat-sectors 4033 c-count 516190 c-size 1 r-dir 2 r-sec 0
[2021-02-24 23:06:39.465] Read config.txt bytes     1815 hnd 0x00000005 hash 'ddef6979a38b8f1f'      << # EEPROMのBootloaderもconfig.txtを見るんですね。SD(config.txt)を見つけられない場合はどうするんだろう?
[2021-02-24 23:06:39.480] recover4.elf not found (6)
[2021-02-24 23:06:39.486] recovery.elf not found (6)
[2021-02-24 23:06:40.482] Read start4.elf bytes  2227200 hnd 0x000135a2 hash '0e07ea2d056832e8'
[2021-02-24 23:06:40.560] Read fixup4.dat bytes     5430 hnd 0x00017fef hash 'c2eb2ff734648cae'
[2021-02-24 23:06:40.565] 0x00c03112 0x00000000 0x0000003f
[2021-02-24 23:06:40.568] MEM GPU: 76 ARM: 948 TOTAL: 1024
# ここからがstart.4.elf (Firmware)かな? #
[2021-02-24 23:06:40.782] Starting start4.elf @ 0xfec00200 partition 0
[2021-02-24 23:06:40.786] 
[2021-02-24 23:06:41.187] MESS:00:00:05.470880:0: arasan: arasan_emmc_open
[2021-02-24 23:06:41.341] MESS:00:00:05.624425:0: brfs: File read: /mfs/sd/config.txt
[2021-02-24 23:06:41.346] MESS:00:00:05.627650:0: brfs: File read: 1815 bytes
[2021-02-24 23:06:41.413] MESS:00:00:05.695883:0: brfs: File read: /mfs/sd/config.txt      << # config.txtをなぜか2回読んでますね?
[2021-02-24 23:06:41.431] MESS:00:00:05.714530:0: brfs: File read: 1815 bytes
[2021-02-24 23:06:41.913] MESS:00:00:06.195860:0: gpioman: gpioman_get_pin_num: pin DISPLAY_DSI_PORT not defined
[2021-02-24 23:06:41.920] MESS:00:00:06.203149:0: *** Restart logging
[2021-02-24 23:06:41.925] MESS:00:00:06.208440:0: hdmi: HDMI:hdmi_get_state is deprecated, use hdmi_get_display_state instead
[2021-02-24 23:06:41.934] MESS:00:00:06.217793:0: hdmi: HDMI:hdmi_get_state is deprecated, use hdmi_get_display_state instead
[2021-02-24 23:06:41.943] MESS:00:00:06.223724:0: HDMI0: hdmi_pixel_encoding: 300000000
[2021-02-24 23:06:41.948] MESS:00:00:06.229192:0: HDMI1: hdmi_pixel_encoding: 300000000
[2021-02-24 23:06:41.956] MESS:00:00:06.239395:0: dtb_file 'bcm2711-rpi-4-b.dtb'
[2021-02-24 23:06:41.964] MESS:00:00:06.247180:0: brfs: File read: /mfs/sd/bcm2711-rpi-4-b.dtb      << # デバイスツリー
[2021-02-24 23:06:41.970] MESS:00:00:06.250427:0: Loading 'bcm2711-rpi-4-b.dtb' to 0x100 size 0xbd2d
[2021-02-24 23:06:41.986] MESS:00:00:06.269580:0: brfs: File read: 48429 bytes
[2021-02-24 23:06:42.001] MESS:00:00:06.284124:0: brfs: File read: /mfs/sd/overlays/overlay_map.dtb
[2021-02-24 23:06:42.066] MESS:00:00:06.349758:0: brfs: File read: 1523 bytes
[2021-02-24 23:06:42.071] MESS:00:00:06.354006:0: brfs: File read: /mfs/sd/config.txt
[2021-02-24 23:06:42.076] MESS:00:00:06.357282:0: dtparam: audio=on
[2021-02-24 23:06:42.087] MESS:00:00:06.370409:0: brfs: File read: 1815 bytes
[2021-02-24 23:06:42.103] MESS:00:00:06.386564:0: brfs: File read: /mfs/sd/overlays/vc4-fkms-v3d.dtbo
[2021-02-24 23:06:42.124] MESS:00:00:06.407474:0: Loaded overlay 'vc4-fkms-v3d'
[2021-02-24 23:06:42.165] MESS:00:00:06.448819:0: brfs: File read: 1446 bytes
[2021-02-24 23:06:42.170] MESS:00:00:06.452630:0: brfs: File read: /mfs/sd/cmdline.txt
[2021-02-24 23:06:42.175] MESS:00:00:06.455987:0: Read command line from file 'cmdline.txt':
[2021-02-24 23:06:42.181] MESS:00:00:06.461865:0: 'console=serial0,115200 console=tty1 root=PARTUUID=9dae15ae-02 rootfstype=ext4 elevator=deadline rootwait initcall_debug'      << # kernel command lineはちょっといじってます
[2021-02-24 23:06:43.206] MESS:00:00:07.489338:0: brfs: File read: 120 bytes
[2021-02-24 23:06:43.762] MESS:00:00:08.045031:0: brfs: File read: /mfs/sd/kernel7l.img      << # Linux Kernelのバイナリ
[2021-02-24 23:06:43.767] MESS:00:00:08.047671:0: Loading 'kernel7l.img' to 0x8000 size 0x65d6a8
[2021-02-24 23:06:43.773] MESS:00:00:08.053928:0: Device tree loaded to 0x2eff3e00 (size 0xc1bf)
[2021-02-24 23:06:43.779] MESS:00:00:08.061949:0: uart: Set PL011 baud rate to 103448.300000 Hz
[2021-02-24 23:06:43.786] MESS:00:00:08.069239:0: uart: Baud rate change done...
[2021-02-24 23:06:43.790] MESS:00:00:08.071262:0:
# ここからLinux Kernelの出力 #
[    0.000000] Booting Linux on physical CPU 0x0
[2021-02-24 23:06:47.145] [    0.000000] Linux version 5.10.11-v7l+ (dom@buildbot) (arm-linux-gnueabihf-gcc-8 (Ubuntu/Linaro 8.4.0-3ubuntu1) 8.4.0, GNU ld (GNU Binutils for Ub1
[2021-02-24 23:06:47.162] [    0.000000] CPU: ARMv7 Processor [410fd083] revision 3 (ARMv7), cr=30c5383d
[2021-02-24 23:06:47.170] [    0.000000] CPU: div instructions available: patching division code
[2021-02-24 23:06:47.176] [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
[2021-02-24 23:06:47.183] [    0.000000] OF: fdt: Machine model: Raspberry Pi 4 Model B Rev 1.2
:

少しBootの手順がダルで、Kernel Initの開始まで10-11秒くらいを要しています。シーケンス的にはいろいろ改善の余地はありそうです。
問題としてはbootcodeとGPU Firmware(start4.elf)等が公開されてないので、ちょっと難易度は高め(というかムリ?)な予感がしています。