明日にはでっかい太陽が昇るかもしれません。

「覚悟」とは!! 暗闇の荒野に!!進むべき道を切り開く事だッ!

U-Boot (aarch64) on Qemu を動作させたい (5)

u-boot.bin をダンプすると、 init_sequence_f のアドレスには関数ポインタが格納されていることを確認した。

0004cb70  1c 07 09 00 00 00 00 00  48 9c 09 00 00 00 00 00  |........H.......|
0004cb80  00 08 09 00 00 00 00 00  38 2d 08 00 00 00 00 00  |........8-......|
0004cb90  d4 08 09 00 00 00 00 00  08 08 09 00 00 00 00 00  |................|
0004cba0  b8 08 09 00 00 00 00 00  34 34 08 00 00 00 00 00  |........44......|
0004cbb0  e8 4e 0b 00 00 00 00 00  44 27 09 00 00 00 00 00  |.N......D'......|
(gdb) p setup_mon_len
$1 = {int (void)} 0x9071c <setup_mon_len>
(gdb) p initf_malloc
$2 = {int (void)} 0x99c48 <initf_malloc>
(gdb) p initf_console_record
$4 = {int (void)} 0x90800 <initf_console_record>

と、ここで気づいたが、エラーになるからと、 u-boot.bin ではなく、 u-boot (elf) を -kernel に渡していたが、結構ファイルサイズが違うことに気づく。

もしかして、と、 u-boot の init_sequence_f あたりをダンプすると、

0005cb70  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
0005cd70  00 00 00 00 00 00 00 00  01 00 00 00 01 00 00 00  |................|
0005cd80  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0005cd90  00 00 00 00 00 00 00 00  01 00 00 00 00 00 00 00  |................|
0005cda0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

なんか、すごく見覚えがあるデータ配置 (ところどころの 1 具合が) 出たので、間違いない気がする。

CONFIG_REMAKE_ELF を追加して、 u-boot.elf を作成し、同じアドレスをダンプすると、

0005cb70  1c 07 09 00 00 00 00 00  48 9c 09 00 00 00 00 00  |........H.......|
0005cb80  00 08 09 00 00 00 00 00  38 2d 08 00 00 00 00 00  |........8-......|
0005cb90  d4 08 09 00 00 00 00 00  08 08 09 00 00 00 00 00  |................|

となり、期待通りの結果になった!

エラーは残っているものの、無事、 U-Boot (aarch64) on Qemu を動作させることができた。 u-boot / qemu の動作およびデバッグについてもいい勉強になった。

U-Boot 2016.09-dirty (Oct 10 2017 - 04:57:49 +0900)                                                                                                           [51/18819]

DRAM:  960 MiB
RPI 3 Model B (0xa32081)
MMC:   bcm2835_sdhci: 0
Card did not respond to voltage select!
** Bad device mmc 0 **
Using default environment

In:    serial
Out:   lcd
Err:   lcd
Net:   Net Initialization Skipped
No ethernet found.
starting USB...
USB0:   Core Release: 0.000
SNPSID invalid (not DWC2 OTG device): 00000000
Port not available.
Hit any key to stop autoboot:  0 
Card did not respond to voltage select!
starting USB...
USB0:   Core Release: 0.000                                                                                                                                   [25/18819]
SNPSID invalid (not DWC2 OTG device): 00000000
Port not available.
No ethernet found.
missing environment variable: pxeuuid
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000                                                                                                                              [4/18819]
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm-bcm283x
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default
No ethernet found.
Config file not found
starting USB...
USB0:   Core Release: 0.000
SNPSID invalid (not DWC2 OTG device): 00000000
U-Boot> print
arch=arm
baudrate=115200
board=rpi
board_name=3 Model B
board_rev=0x8
board_rev_scheme=1
board_revision=0xA32081

ただ、 UART については raspi3 で有効になる CONFIG_BCM283X_MU_SERIAL の動かし方がわからないので CONFIG_PL01X_SERIAL を有効にしてしのいでいる。

 /* Console UART */
 #ifdef CONFIG_BCM2837
-#define CONFIG_BCM283X_MU_SERIAL
+#define CONFIG_PL01X_SERIAL
 #else
 #define CONFIG_PL01X_SERIAL
 #endif