OK6410A 开发板 (三) 26 u-boot-2021.01 u-boot镜像

u-boot镜像的解析

$ file u-boot
u-boot: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, not stripped
$ file u-boot.bin 
u-boot.bin: data
$ file u-boot.img 
u-boot.img: u-boot legacy uImage, U-Boot 2021.01-15955-g9f70b17-di\276, Firmware/ARM, Firmware Image (Not compressed), 253568 bytes, Thu Apr  1 07:37:20 2021, Load Address: 0x5FB00000, Entry Point: 0x5FB00000, Header CRC: 0xEDBFD035, Data CRC: 0xB02CAAA8
$ arm-linux-gnueabi-readelf -S   output/u-boot 
There are 28 section headers, starting at offset 0x1ec6a4:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .text             PROGBITS        5fb00000 010000 0006f4 00  AX  0   0 32
  [ 2] .text_rest        PROGBITS        5fb00700 010700 029284 00  AX  0   0 32
  [ 3] .rodata           PROGBITS        5fb29984 039984 009688 00   A  0   0  4
  [ 4] .hash             HASH            5fb3300c 04300c 000018 04   A 12   0  4
  [ 5] .data             PROGBITS        5fb33024 043024 0025c8 00  WA  0   0  4
  [ 6] .got.plt          PROGBITS        5fb355ec 0455ec 00000c 04  WA  0   0  4
  [ 7] .u_boot_list      PROGBITS        5fb355f8 0455f8 000aa0 00  WA  0   0  4
  [ 8] .rel.dyn          REL             5fb36098 046098 006f80 08   A 12   0  4
  [ 9] .bss_start        PROGBITS        5fb36098 04d0d4 000000 00   W  0   0  1
  [10] .bss              NOBITS          5fb36098 000000 0058e8 00  WA  0   0  4
  [11] .bss_end          PROGBITS        5fb3b980 04d0d4 000000 00   W  0   0  1
  [12] .dynsym           DYNSYM          5fb3d018 04d018 000030 10   A 13   3  4
  [13] .dynstr           STRTAB          5fb3d048 04d048 000001 00   A  0   0  1
  [14] .dynamic          DYNAMIC         5fb3d04c 04d04c 000088 08  WA 13   0  4
  [15] .ARM.attributes   ARM_ATTRIBUTES  00000000 04d0d4 000026 00      0   0  1
  [16] .comment          PROGBITS        00000000 04d0fa 000074 01  MS  0   0  1
  [17] .debug_line       PROGBITS        00000000 04d16e 0229c0 00      0   0  1
  [18] .debug_info       PROGBITS        00000000 06fb2e 0bb388 00      0   0  1
  [19] .debug_abbrev     PROGBITS        00000000 12aeb6 01da4e 00      0   0  1
  [20] .debug_aranges    PROGBITS        00000000 148908 003f58 00      0   0  8
  [21] .debug_frame      PROGBITS        00000000 14c860 00b448 00      0   0  4
  [22] .debug_str        PROGBITS        00000000 157ca8 012228 01  MS  0   0  1
  [23] .debug_loc        PROGBITS        00000000 169ed0 062a0a 00      0   0  1
  [24] .debug_ranges     PROGBITS        00000000 1cc8e0 008990 00      0   0  8
  [25] .symtab           SYMTAB          00000000 1d5270 010e90 10     26 3489  4
  [26] .strtab           STRTAB          00000000 1e6100 006494 00      0   0  1
  [27] .shstrtab         STRTAB          00000000 1ec594 000110 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  y (purecode), p (processor specific)
  • 文件数据的解析
vim u-boot 和 u-boot.bin 之后 :%!xxd 查看二进制文件
然后 发现 u-boot.bin 00000000位置的32bit数据 在u-boot 的 00010000 位置
所以如果直接烧写 u-boot 是不可以的


u-boot.bin 00000000 位置 的 32bit 数据 是 b reset 的 二进制码
但是 u-boot 的 00000 位置 是 elf 格式的格式相关码
所以 烧写的话不能烧写 u-boot


u-boot是个 elf 文件,这个elf 文件什么时候用 // ELF 是一个 标准,请查看相关标准文档
	1. 生成 .bin 用
	2. 生成 .dis 用
	3. 生成 .srec 用
	4. gdb debug 用

u-boot.img  是 在 u-boot.bin 前加了一些字节, 供 spl 解析
一般的spl加载u-boot 流程中需要用u-boot.img 

在ok6410a 的u-boot-2021.01,烧写的 是 u-boot.bin 文件,是因为 不是用的标准的 spl加载u-boot流程



为什么linux发行版下面命令A都是 elf 格式,且可以执行
因为linux发行版中有解析 elf 格式的代码,这些代码能找到命令A的入口

参考资料
  • 链接脚本

$ cat output/u-boot.lds 
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
 . = 0x00000000;
 . = ALIGN(4);
 .text :
 {
  *(.__image_copy_start)
  *(.vectors)
  arch/arm/cpu/arm1176/start.o (.text*)
  board/samsung/ok6410a/lowlevel_init.o (.text*)
  board/samsung/ok6410a/bl2_mmc_copy.o (.text*)
 }
 .__efi_runtime_start : {
  *(.__efi_runtime_start)
 }
 .efi_runtime : {
  *(.text.efi_runtime*)
  *(.rodata.efi_runtime*)
  *(.data.efi_runtime*)
 }
 .__efi_runtime_stop : {
  *(.__efi_runtime_stop)
 }
 .text_rest :
 {
  *(.text*)
 }
 . = ALIGN(4);
 .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 . = ALIGN(4);
 .data : {
  *(.data*)
 }
 . = ALIGN(4);
 . = .;
 . = ALIGN(4);
 .u_boot_list : {
  KEEP(*(SORT(.u_boot_list*)));
 }
 . = ALIGN(4);
 .efi_runtime : {
                __efi_runtime_start = .;
  *(efi_runtime_text)
  *(efi_runtime_data)
                __efi_runtime_stop = .;
 }
 .efi_runtime_rel_start :
 {
  *(.__efi_runtime_rel_start)
 }
 .efi_runtime_rel : {
  *(.rel*.efi_runtime)
  *(.rel*.efi_runtime.*)
 }
 .efi_runtime_rel_stop :
 {
  *(.__efi_runtime_rel_stop)
 }
 . = ALIGN(4);
 .image_copy_end :
 {
  *(.__image_copy_end)
 }
 .rel_dyn_start :
 {
  *(.__rel_dyn_start)
 }
 .rel.dyn : {
  *(.rel*)
 }
 .rel_dyn_end :
 {
  *(.__rel_dyn_end)
 }
 .end :
 {
  *(.__end)
 }
 _image_binary_end = .;
 . = ALIGN(4096);
 .mmutable : {
  *(.mmutable)
 }
 .bss_start __rel_dyn_start (OVERLAY) : {
  KEEP(*(.__bss_start));
  __bss_base = .;
 }
 .bss __bss_base (OVERLAY) : {
  *(.bss*)
   . = ALIGN(4);
   __bss_limit = .;
 }
 .bss_end __bss_limit (OVERLAY) : {
  KEEP(*(.__bss_end));
 }
 .dynsym _image_binary_end : { *(.dynsym) }
 .dynbss : { *(.dynbss) }
 .dynstr : { *(.dynstr*) }
 .dynamic : { *(.dynamic*) }
 .plt : { *(.plt*) }
 .interp : { *(.interp*) }
 .gnu.hash : { *(.gnu.hash) }
 .gnu : { *(.gnu*) }
 .ARM.exidx : { *(.ARM.exidx*) }
 .gnu.linkonce.armexidx : { *(.gnu.linkonce.armexidx.*) }
}
  • u-boot 的生成过程
arm-linux-gnueabi-ld.bfd  
-pie  
--gc-sections 
-Bstatic  
--no-dynamic-linker 
-Ttext 0x5FB00000 
-o u-boot 
-T u-boot.lds 
arch/arm/cpu/arm1176/start.o 
--start-group  
arch/arm/cpu/built-in.o  arch/arm/cpu/arm1176/built-in.o  arch/arm/lib/built-in.o  arch/arm/mach-s3c64xx/built-in.o  board/samsung/common/built-in.o  board/samsung/ok6410a/built-in.o  cmd/built-in.o  common/built-in.o  disk/built-in.o  drivers/built-in.o  drivers/dma/built-in.o  drivers/gpio/built-in.o  drivers/i2c/built-in.o  drivers/net/built-in.o  drivers/net/phy/built-in.o  drivers/power/built-in.o  drivers/power/battery/built-in.o  drivers/power/domain/built-in.o  drivers/power/fuel_gauge/built-in.o  drivers/power/mfd/built-in.o  drivers/power/pmic/built-in.o  drivers/power/regulator/built-in.o  drivers/serial/built-in.o  drivers/spi/built-in.o  drivers/usb/cdns3/built-in.o  drivers/usb/common/built-in.o  drivers/usb/dwc3/built-in.o  drivers/usb/emul/built-in.o  drivers/usb/eth/built-in.o  drivers/usb/host/built-in.o  drivers/usb/mtu3/built-in.o  drivers/usb/musb-new/built-in.o  drivers/usb/musb/built-in.o  drivers/usb/phy/built-in.o  drivers/usb/ulpi/built-in.o  env/built-in.o  fs/built-in.o  lib/built-in.o  net/built-in.o 
--end-group 
arch/arm/lib/eabi_compat.o  
arch/arm/lib/lib.a 
-Map u-boot.map
  • u-boot.bin的生成过程
arm-linux-gnueabi-objcopy 
--gap-fill=0xff  
-j .text 
-j .secure_text 
-j .secure_data 
-j .rodata 
-j .hash 
-j .data 
-j .got 
-j .got.plt 
-j .u_boot_list 
-j .rel.dyn 
-j .binman_sym_table 
-j .text_rest 
-j .dtb.init.rodata  
-O binary   u-boot u-boot-nodtb.bin

cat u-boot-nodtb.bin dts/dt.dtb > u-boot.bin
  • u-boot.img的生成过程
./tools/mkimage -A arm -T firmware -C none -O u-boot -a 0x5FB00000 -e 0x5FB00000 -n "U-Boot 2021.01""-15955-g9f70b17-dirty for ok6410a board" -d u-boot.bin u-boot.img
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值