Arm
U-boot 找不到有效的設備樹
我有一個問題:嘗試刷新新設備樹後,我的設備( Atmel SAMA5D27 Xplained板)無法啟動。
這是我所做的(詳細資訊在此消息的末尾):
- 我從 Github (tag linux4sam_5.3)下載了Linux4SAM 原始碼樹。我使用了這個標籤,因為這是我拿到設備時安裝的標籤。
- 我對文件進行了更改以
arch/arm/boot/dts/at91-sama5d2_xplained.dts
啟用 SPI1 設備(並禁用 SDMMC1 設備,因為它與 SPI1 引腳衝突)。我將文件保存在與 Makefile 相同的目錄中,at91-sama5d2_xplained_custom.dts
並相應地修改了 Makefile。- 我使用以下命令編譯(從原始碼樹的根目錄)
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- dtbs
:. 生成了一個新的 DTB。- 我使用命令驗證了 DTB 文件的大小,該
file
命令被告知 DTB 為 30796 字節。- 我使用SAM-BA 實用程序將 DTB 刷入設備,這很成功,但報告刷入了 30976 個字節。
- 我重新啟動了設備,它卡在了 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
,它對應於我從原始at91-sama5d2_xplained.dts
文件中獲得的 DTB 的大小。這是我得到的錯誤:
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
當然,我的問題是:我做錯了什麼?
我有一些假設,我嘗試過:
- 我弄錯了大小:我嘗試在
bootcmd
(對應於 SAM-BA 報告的 30976 字節)中使用 0x7900,但這沒有幫助。- 我閃到了錯誤的地址:我不完全確定地址
0x21000000
在sf read
中是什麼bootcmd
,但從 SAM-BA 提供的範例文件中我推斷 0x70000 是正確的。更改0x21000000
為0x0
沒有幫助。將 SAM-BA 寫入命令更改為 write at0x21070000
會導致錯誤,它無法寫入超過記憶體末尾。- 我的 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.
使用者錯誤。
我發現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.