U-boot 找不到有效的设备树

U-boot 找不到有效的设备树

我有一个问题:我的设备(爱特梅尔 SAMA5D27 Xplained在我尝试刷新新的设备树后,板)将无法启动。

这就是我所做的(详细信息位于此消息的末尾):

  1. 我下载了来自 Github 的 Linux4SAM 源代码树(标签 linux4sam_5.3)。我使用了这个标签,因为这是我拿到设备时安装的标签。
  2. 我对文件进行了更改arch/arm/boot/dts/at91-sama5d2_xplained.dts以启用 SPI1 设备(并禁用 SDMMC1 设备,因为它与 SPI1 引脚冲突)。我将该文件保存在同一目录中at91-sama5d2_xplained_custom.dts并相应地修改了 Makefile。
  3. 我使用以下命令进行编译(从源树的根目录):$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- dtbs.生成了新的 DTB。
  4. 我用命令验证了DTB文件的大小file,得知DTB是30796字节。
  5. 我使用以下命令将 DTB 闪存到设备上SAM-BA实用程序,成功了,但报告闪存了 30976 字节。
  6. 我重新启动了设备,设备卡在了 U-boot 环境中。这是可以预料的,因为 DTB 已经改变了。我更新了bootcmd以反映 DTB 的新大小 (30796 = 0x784c),但它仍然无法启动。

这是我更新后的结果printenv(我用 保存saveenv):

=> printenv
bootargs=console=ttyS0,115200 root=/dev/mmcblk0p1 rw rootfstype=ext4 rootwait
bootcmd=sf probe 0; sf read 0x21000000 0x70000 0x784c; sf read 0x22000000 0x7c000 0x3636a8; bootz 0x22000000 - 0x21000000
bootdelay=1
ethact=gmac0
ethaddr=fc:c2:3d:02:f4:e9
stderr=serial
stdin=serial
stdout=serial

Environment size: 309/8188 bytes

sf read请注意,我只更新了第一个命令中的大小bootcmd。它用来读取sf read 0x21000000 0x70000 0x77c8,它对应于我从原始文件中获取的 DTB 的大小at91-sama5d2_xplained.dts

这是我得到的错误:

SF: Detected AT25DF321 with page size 256 Bytes, erase size 4 KiB, total 4 MiB
device 0 offset 0x70000, size 0x784c
SF: 30796 bytes @ 0x70000 Read: OK
device 0 offset 0x7c000, size 0x3636a8
SF: 3552936 bytes @ 0x7c000 Read: OK
Kernel image @ 0x22000000 [ 0x000000 - 0x3636a8 ]
ERROR: Did not find a cmdline Flattened Device Tree
Could not find a valid device tree

当然,我的问题是:我做错了什么?

我有一些假设,我尝试过:

  1. 我的大小错误:我尝试在 中使用 0x7900 bootcmd(对应于 SAM-BA 报告的 30976 字节),但这没有帮助。
  2. 我闪现到了错误的地址:我不完全确定中的地址0x21000000是什么,但从 SAM-BA 提供的示例文件中我推断 0x70000 是正确的。更改为没有帮助。将 SAM-BA 写入命令更改为写入 at会导致错误,无法写入超过内存末尾。sf readbootcmd0x210000000x00x21070000
  3. 我的 DTB 是错误的。我不认为我在 DTS 文件中做了特别奇怪的事情,并且由于它已编译,我认为它至少采用了应该可读的格式。

任何帮助/建议/指示/等。非常感谢,因为我现在有一个无法启动的设备...我还担心如果我闪到了错误的地址,我会破坏各种我不知道的东西。


细节

DTS文件:

/dts-v1/;
#include "at91-sama5d2_xplained_common.dtsi"

/ {
    model = "Atmel SAMA5D2 Xplained";
    compatible = "atmel,sama5d2-xplained", "atmel,sama5d2", "atmel,sama5";

    ahb {
        sdmmc1: sdio-host@b0000000 {        
            status = "disabled"; /* conflict with spi1 */
        };

        apb {
            can0: can@f8054000 {
                status = "okay";
            };

            can1: can@fc050000 {
                status = "okay";
            };

            spi1: spi@fc000000 {
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_spi1_default>;
                status = "okay";
            };

            pinctrl@fc038000 {
                pinctrl_spi1_default: spi1_default {
                    pinmux = <PIN_PA22__SPI1_SPCK>,
                         <PIN_PA23__SPI1_MOSI>,
                         <PIN_PA24__SPI1_MISO>,
                         <PIN_PA25__SPI1_NPCS0>;
                    bias-disable;
                };
            };           
        };
    };
};

DTB 的编译:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- dtbs
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: 'include/generated/mach-types.h' is up to date.
  CHK     include/generated/bounds.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  DTC     arch/arm/boot/dts/at91-sama5d2_xplained_custom.dtb

验证DTB文件大小:

$ file arch/arm/boot/dts/at91-sama5d2_xplained_custom.dtb
arch/arm/boot/dts/at91-sama5d2_xplained_custom.dtb: Device Tree Blob version 17, size=30796, boot CPU=0, string block size=1692, DT structure block size=29048

SAM-BA 闪存命令输出:

# sam-ba -p serial:ttyACM0:115200 -b sama5d2-xplained -a serialflash -c write:at91-sama5d2_xplained_custom.dtb:0x70000
Opening serial port 'ttyACM0'
Connection opened.
Detected memory size is 4194304 bytes.
Executing command 'write:at91-sama5d2_xplained_custom.dtb:0x70000'
Added 180 bytes of padding to align to page size
Wrote 30976 bytes at address 0x00070000 (100.00%)
Connection closed.

SAM-BA 尝试写入超出内存末尾的内容:

# sam-ba -p serial:ttyACM0:115200 -b sama5d2-xplained -a serialflash -c write:at91-sama5d2_xplained_custom.dtb:0x21070000
Opening serial port 'ttyACM0'
Connection opened.
Detected memory size is 4194304 bytes.
Executing command 'write:at91-sama5d2_xplained_custom.dtb:0x21070000'
Added 180 bytes of padding to align to page size
Error: Command 'write:at91-sama5d2_xplained_custom.dtb:0x21070000': Cannot write past end of memory, only -549912576 bytes remaining at offset 0x21070000 (requested 30976 bytes)
Connection closed.

答案1

用户错误。

我发现SAM-BA还有验证方法:

# sam-ba -p serial:ttyACM0:115200 -b sama5d2-xplained -a serialflash -c verify:at91-sama5d2_xplained_custom.dtb:0x70000
Opening serial port 'ttyACM0'
Connection opened.
Detected memory size is 4194304 bytes.
Executing command 'verify:at91-sama5d2_xplained_custom.dtb:0x70000'
Added 180 bytes of padding to align to page size
Error: Command 'verify:at91-sama5d2_xplained_custom.dtb:0x70000': Failed verification. First error at file offset 0x00000000
Connection closed.

不好。事实证明,第 5 步遗漏了一个非常重要的步骤:首先,您需要在写入之前擦除闪存(我不知道;显然我一直使用为我处理此问题的工具):

# sam-ba -p serial:ttyACM0:115200 -b sama5d2-xplained -a serialflash -c erase:0x70000:0x8000
Opening serial port 'ttyACM0'
Connection opened.
Detected memory size is 4194304 bytes.
Executing command 'erase:0x70000:0x8000'
Erased 32768 bytes at address 0x00070000 (100.00%)
Connection closed.

# sam-ba -p serial:ttyACM0:115200 -b sama5d2-xplained -a serialflash -c write:at91-sama5d2_xplained_custom.dtb:0x70000
Opening serial port 'ttyACM0'
Connection opened.
Detected memory size is 4194304 bytes.
Executing command 'write:at91-sama5d2_xplained_custom.dtb:0x70000'
Added 180 bytes of padding to align to page size
Wrote 30976 bytes at address 0x00070000 (100.00%)
Connection closed.

# sam-ba -p serial:ttyACM0:115200 -b sama5d2-xplained -a serialflash -c verify:at91-sama5d2_xplained_custom.dtb:0x70000
Opening serial port 'ttyACM0'
Connection opened.
Detected memory size is 4194304 bytes.
Executing command 'verify:at91-sama5d2_xplained_custom.dtb:0x70000'
Added 180 bytes of padding to align to page size
Verified 30976 bytes at address 0x00070000 (100.00%)
Connection closed.

相关内容