u-boot:启动内核时的内存分配难题

问题描述 投票:0回答:1

我正在使用 petalinux 2023.2 在 FPGA 板上运行带有 Soft microblaze 的 Linux。我有一个关于 u-boot 在可能的内存分配方面的行为的问题。该板/设计具有 2GiB DDR,物理范围从

0x8000_0000
0xffff_ffff

petalinux 命令启动 u-boot,然后通过 JTAG 启动内核的操作如下(如

petalinux-boot --verbose
选项所示,行号是我添加的):

 1 targets -set -nocase -filter {name =~ "microblaze*#0"}
 2 puts stderr "INFO: Downloading ELF file: /home/bruin/work/linux_mb/images/linux/u-boot.elf to the target."
 3 dow  "/home/bruin/work/linux_mb/images/linux/u-boot.elf"
 4 con
 5 
 6 after 1000; stop
 7 puts stderr "INFO: Loading image: /home/bruin/work/linux_mb/images/linux/linux.bin.ub at 0x80000000"
 8 dow -data  "/home/bruin/work/linux_mb/images/linux/linux.bin.ub" 0x80000000
 9 puts stderr "INFO: Loading image: /home/bruin/work/linux_mb/images/linux/system.dtb at 0x81e00000"
10 dow -data  "/home/bruin/work/linux_mb/images/linux/system.dtb" 0x81e00000
11 puts stderr "INFO: Loading image: /home/bruin/work/linux_mb/images/linux/rootfs.cpio.gz.u-boot at 0x82e00000"
12 dow -data  "/home/bruin/work/linux_mb/images/linux/rootfs.cpio.gz.u-boot" 0x82e00000
13 puts stderr "INFO: Loading image: /home/bruin/work/linux_mb/images/linux/boot.scr at 0xff200000"
14 dow -data  "/home/bruin/work/linux_mb/images/linux/boot.scr" 0xff200000
15 
16 con
17 exit

如上图:

  • 第3~4行将
    u-boot.elf
    加载到ddr然后开始执行。
    u-boot.elf
    位于DDR的什么地方?如下图,从
    0x8010_0000
    开始。
xsct% dow u-boot.elf
Downloading Program -- /home/bruin/work/linux_mb/images/linux/u-boot.elf
        section, .text: 0x80100000 - 0x80148c7f
        section, .rodata: 0x80148c80 - 0x80156d1f
        section, .dtb.init.rodata: 0x80156d20 - 0x80159d3f
        section, .data: 0x80159d40 - 0x8015c35f
        section, .got: 0x8015c360 - 0x8015df13
        section, __u_boot_list: 0x8015df14 - 0x8015f00b
        section, .bss: 0x8015f3b4 - 0x801662c7
        section, .rela.dyn: 0x8015f00c - 0x8015f3b3
100%    0MB   0.2MB/s  00:01
Setting PC to Program Start Address 0x80100000
  • 由于 u-boot 在启动 kenrel 之前有默认的 4 秒延迟,因此第 6 行会在这 4 秒延迟期间暂停 u-boot 的执行。

  • 然后第8/10/12/14行下载4个数据到ddr到各自的位置。

  • 第 16 行继续执行 u-boot,读取

    boot.scr
    来执行命令
    bootm 0x80000000 0x82e00000 0x81e00000
    来启动到内核。

我的问题是关于第7行:

linux.bin.ub
(带有u-boot标头的内核映像)的加载地址是
0x8000_0000
linux.bin.ub
的大小约为10MiB。但是
u-boot.elf
文本在这个内存区域内...怎么可能?

u-boot
1个回答
0
投票

但是 u-boot.elf 文本就在这个内存区域内...怎么可能?

在初始化期间,U-Boot 会将自身重新定位到高端内存,以最大化连续可用内存量。
请参阅 arch/microblaze/cpu/relocate.c

© www.soinside.com 2019 - 2024. All rights reserved.