uboot Flattened Image Tree反编译

uboot Flattened Image Tree反编译

我在尝试为嵌入式 Linux 系统配置 bootargs 时遇到了问题。设备树被编译成与内核相同的映像。它包括 bootargs ( /chosen/bootargs )。另外,我需要在(uboot)运行时配置一些时间。这意味着我需要能够同时使用两者。我知道内核有一个配置定义(https://stackoverflow.com/a/48814885/11312396)但这仅适用于arm(我使用的是aarch64)。

我目前正在尝试使用 uboot 的 fdt 命令将设备树 bootargs 加载到 uboot 中并将它们附加到那里。然后内核使用 uboot 传递的那些。

问题在于获取设备树地址。因为它被编译成扁平化图像树,我只知道其中的基地址,所以我没有设备树 blob 本身的地址。我可以使用 uboot 命令手动找到它,iminfo但 uboot 没有工具来解析该命令的输出。

## Checking Image at 03000000 ...
FIT image found
FIT description: U-Boot fitImage for Ultra96 kernel
Image 0 (kernel@0)
 Description:  Linux Kernel
 Type:         Kernel Image
 Compression:  gzip compressed
 Data Start:   0x030000d4
 Data Size:    7399390 Bytes = 7.1 MiB
 Architecture: AArch64
 OS:           Linux
 Load Address: 0x00080000
 Entry Point:  0x00080000
 Hash algo:    sha1
 Hash value:   47edccde80d64c636a01dbf4916662e2cdbfda96
Image 1 (fdt@0)
 Description:  Flattened Device Tree blob
 Type:         Flat Device Tree
 Compression:  uncompressed
 Data Start:   0x0370e9ac
 Data Size:    41889 Bytes = 40.9 KiB
 Architecture: AArch64
 Hash algo:    sha1
 Hash value:   d977763b2ec8079aca8908b28c732c3a79e1f7ab
Default Configuration: 'conf@1'
Configuration 0 (conf@1)
 Description:  Boot Linux kernel with FDT blob
 Kernel:       kernel@0
 FDT:          fdt@0
## Checking hash(es) for FIT Image at 03000000 ...
Hash(es) for Image 0 (kernel@0): sha1+ 
Hash(es) for Image 1 (fdt@0): sha1+ 

所以我尝试自己反编译它的标头,但这超出了我的能力:

03000000: edfe0dd0 98907100 38000000 988e7100    .....q.....8.q..
03000010: 28000000 11000000 10000000 00000000    ...(............
03000020: 6c000000 608e7100 00000000 00000000    ...l.q.`........
03000030: 00000000 00000000 01000000 00000000    ................
03000040: 03000000 04000000 5c000000 e1e8455c    ...........\\E..
03000050: 03000000 23000000 00000000 6f422d55    .......#....U-Bo
03000060: 6620746f 6d497469 20656761 20726f66    ot fitImage for 
03000070: 72746c55 20363961 6e72656b 00006c65    Ultra96 kernel..
03000080: 03000000 04000000 0c000000 01000000    ................
03000090: 01000000 67616d69 00007365 01000000    ....images......
030000a0: 6e72656b 30406c65 00000000 03000000    kernel@0........
030000b0: 0d000000 00000000 756e694c 654b2078    ........Linux Ke
030000c0: 6c656e72 00000000 03000000 dee77000    rnel.........p..
030000d0: 1b000000 00088b1f 00000000 5bec0302    ...............[
030000e0: d754540d f7bfff9d 23010f86 c087c332    .TT........#2...
030000f0: 8c0199d9 59ac493a e4688106 d1a260cd    ....:I.Y..h..`..

TLDR:是否有可能从上面列出的 FIT 文件头转储到设备树的起始地址(0x0370e9ac)

答案1

不,因为它位于二进制转储的中间。

看一下这个解析示例(文件偏移量位于左侧):

00000000                 Magic: D00DFEED    FDT File OK
00000004             File Size: 002C076C
00000008      DT Struct Offset: 00000038
0000000C     DT Strings Offset: 002C0564
00000010     Mem RsvMap Offset: 00000028
00000014               Version: 00000011
00000018  Last Compatible Vers: 00000010
0000001C           Boot CPU_ID: 00000000
00000020       DT Strings Size: 0000006C
00000024        DT Struct Size: 002C052C
00000038
00000040     timestamp = 18/01/2019 12:25:33
00000050     description = Jackal Kernel Image generated with Linux kernel and FDT blob
0000009C     #address-cells = 0x00000001
000000AC     images
000000B8        kernel@1
000000C8           description = Linux kernel
000000E4           data = 2872840 Bytes [000000F0-002BD6F7]
002BD6F8           type = kernel
002BD70C           arch = arm
002BD71C           os = linux
002BD730           compression = none
002BD744           load = 0x03000000
002BD754           entry = 0x03000000
002BD764           hash@1
002BD770              value = 29684CCAA0B89E0C9B9E2AB47B120CB0
002BD78C              algo = md5
002BD7A4        fdt@1
002BD7B0           description = Device Tree
002BD7C8           data = 11376 Bytes [002BD7D4-002C0443]
002C0444           type = flat_dt
002C0458           arch = arm
002C0468           compression = none
002C047C           hash@1
002C0488              value = 062502B2C222FE1547BDA6118C6FC1EE
002C04A4              algo = md5
002C04C0     configurations
002C04D4        default = config@1
002C04EC        config@1
002C04FC           description = Boot Linux kernel with FDT blob
002C0528           kernel = kernel@1
002C0540           fdt = fdt@1

相关内容