Raspberry Pi 4 在启动时卡在“Starting Kernel”处。

huangapple go评论79阅读模式
英文:

Raspberry Pi 4 U-Boot on booting hanging in Starting Kernel

问题

我正在进行一个项目,在这个项目中,我想要创建自己的嵌入式Linux系统,使用U-Boot。因此,我正在使用Buildroot,这是我最近开始学习的工具。在成功创建自己的raspberrypi4_defconfig之后,我目前正在努力解决U-Boot无法正确工作的问题。

我正在使用的版本:

  1. 树莓派 4
  2. buildroot-2019.11
  3. U-Boot(因此我每天拉取新的更改)

工作的当前状态:

我在Ubuntu(32位)上构建。我使用raspberrypi4_defconfig配置Buildroot,并在没有更改的情况下进行编译。然后,我为rpi_4_32b_defconfig创建了一个U-Boot defconfig,并使用以下命令创建了u-boot.bin:make CROSS_COMPILE=arm-linux-gnueabihf- u-boot.bin
现在,我的下一步是配置config.txt,并用以下内容替换其内容:

enable_uart=1
kernel=u-boot.bin

另外,我将我的u-boot.bin复制到SD卡中。

我实际执行的最后一步是使用以下内容构建我的自定义boot.scr.uimg:

mmc dev 0
fatload mmc 0:1 ${fdt_addr_r} bcm2711-rpi-4-b.dtb
fatload mmc 0:1 ${kernel_addr_r} zImage
setenv bootargs console=ttyS0,115200 \
root=/dev/mmcblk0p2 rootfstype=ext4 rootwait rw
bootz ${kernel_addr_r} - ${fdt_addr_r}

问题:
到目前为止,我已经成功进入了U-Boot菜单,但在启动时卡在“Starting Kernel”处。我认为可能是我的boot.scr.uimg不正确,但我不确定。

环境:

arch=arm
baudrate=115200
board=rpi
board_name=4 Model B
board_rev=0x11
board_rev_scheme=1
board_revision=0xC03111
...
(此处省略部分内容)
...

启动日志:

U-Boot 2020.01-rc4-00066-g7e5ee346fc (Dec 05 2019 - 16:55:27 +0100)

DRAM:  948 MiB
RPI 4 Model B (0xc03111)
MMC:   emmc2@7e340000: 0, mmcnr@7e300000: 1
Loading Environment from FAT... *** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   Net Initialization Skipped
No ethernet found.
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr.uimg
297 bytes read in 18 ms (15.6 KiB/s)
## Executing script at 02400000
switch to partitions #0, OK
mmc0 is current device
40559 bytes read in 29 ms (1.3 MiB/s)
5601344 bytes read in 1084 ms (4.9 MiB/s)
Kernel image @ 0x080000 [ 0x000000 - 0x557840 ]
## Flattened Device Tree blob at 02600000
   Booting using the fdt blob at 0x2600000
   Using Device Tree in place at 02600000, end 0260ce6e

Starting kernel ...

希望这可以帮助你解决问题。

英文:

I am working on a project where I want to create my own embedded linux with U-Boot. Therefore I am working with buildroot, which i recently start learning. After successfully creating my own rasberrypi4_defconfig i am currently struggling at the problem to get u-boot work correctly.

What versions I am working with:

  1. Rpi 4
  2. buildroot-2019.11
  3. u-boot (therefore i pull everyday the new changes)

Current State of the work:

I build on a Ubuntu(32bit). I configure buildroot with the raspberrypi4_defconfig and make it without changes. Then i make a u-boot defconfig for rpi_4_32b_defconfig and create the u-boot.bin with make CROSS_COMPILE=arm-linux-gnueabihf- u-boot.bin
Now my next step was to configure the config.txt and exchange the content with following:

enable_uart=1
kernel=u-boot.bin

In addition i copyied my u-boot.bin into my sd-card.

The last step that i actually did is to build my own boot.scr.uimg with following content

mmc dev 0
fatload mmc O:1 ${fdt_addr_r} bcm2711-rpi-4-b.dtb
fatload mmc 0:1 ${kernel_addr_r} zImage
setenv bootargs console=ttyS0,115200 \
root=/dev/mmcblk0p2 rootfstype=ext4 rootwait rw
bootz ${kernel_addr_r} - ${fdt_addr_r}

Problem
So far i am archieving to reach the U-boot menu but on booting i get stucked in Starting Kernel
I actually thing that my boot.scr.uimg is maybe not correct but dont get it.

Environment

arch=arm
baudrate=115200
board=rpi
board_name=4 Model B
board_rev=0x11
board_rev_scheme=1
board_revision=0xC03111
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr ${fdtcontroladdr};fi;load ${devty
pe} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootarm.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${f
dt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc0 mmc1 pxe dhcp
bootargs=console=ttyS0,115200 \
root=/dev/mmcblk0p2 rootfstype=ext4 rootwait rw
bootcmd=run distro_bootcmd
bootcmd_dhcp=if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;setenv efi_fdtfile ${fdtfile}; if test -z "${f
dtfile}" -a -n "${soc}"; then setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; fi; setenv efi_old_vci ${bootp_vci};setenv efi_old_
arch ${bootp_arch};setenv bootp_vci PXEClient:Arch:00010:UNDI:003000;setenv bootp_arch 0xa;if dhcp ${kernel_addr_r}; then tftpboot $
{fdt_addr_r} dtb/${efi_fdtfile};if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r}; else bootefi ${kernel_addr_r
} ${fdtcontroladdr};fi;fi;setenv bootp_vci ${efi_old_vci};setenv bootp_arch ${efi_old_arch};setenv efi_fdtfile;setenv efi_old_arch;s
etenv efi_old_vci;
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_mmc1=devnum=1; run mmc_boot
bootcmd_pxe=dhcp; if pxe get; then pxe boot; fi
bootdelay=2
bootfstype=fat
cpu=armv7
dhcpuboot=usb start; dhcp u-boot.uimg; bootm
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
ethaddr=dc:a6:32:45:1f:d1
fdt_addr=2eff5d00
fdt_addr_r=0x02600000
fdt_high=ffffffff
fdtcontroladdr=3af6ac98
fdtfile=bcm2711-rpi-4-b.dtb
fileaddr=2600000
filesize=9e6f
initrd_high=ffffffff
kernel_addr_r=0x00080000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0x00200000
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
pxefile_addr_r=0x02500000
ramdisk_addr_r=0x02700000
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done; setenv devplist
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; if test -z "${fdtfile}" -a -n "${soc}"; then setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; fi; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootarm.efi; then echo Found EFI removable media binary efi/boot/bootarm.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi; setenv efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scriptaddr=0x02400000
serial#=10000000f58b842c
soc=bcm283x
stderr=serial,vidconsole
stdin=serial,usbkbd
stdout=serial,vidconsole
usbethaddr=dc:a6:32:45:1f:d1
vendor=raspberrypi

Environment size: 3996/16380 bytes

Boot Log

U-Boot 2020.01-rc4-00066-g7e5ee346fc (Dec 05 2019 - 16:55:27 +0100)

DRAM:  948 MiB
RPI 4 Model B (0xc03111)
MMC:   emmc2@7e340000: 0, mmcnr@7e300000: 1
Loading Environment from FAT... *** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   Net Initialization Skipped
No ethernet found.
Hit any key to stop autoboot:  0 
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr.uimg
297 bytes read in 18 ms (15.6 KiB/s)
## Executing script at 02400000
switch to partitions #0, OK
mmc0 is current device
40559 bytes read in 29 ms (1.3 MiB/s)
5601344 bytes read in 1084 ms (4.9 MiB/s)
Kernel image @ 0x080000 [ 0x000000 - 0x557840 ]
## Flattened Device Tree blob at 02600000
   Booting using the fdt blob at 0x2600000
   Using Device Tree in place at 02600000, end 0260ce6e

Starting kernel ...

答案1

得分: 2

  1. 确保在第一个分区的config.txt中有"enable_uart=1"。

  2. 树莓派4支持32位和64位模式。固件config.txt、u-boot和内核应该使用相同的配置。

以下是我的64位系统config.txt示例:

[pi4]
kernel=u-boot.bin
max_framebuffers=2

[all]
arm_64bit=1
enable_uart=1
dtparam=i2c=on
dtparam=spi=on
dtparam=act_led_trigger=heartbeat
dtparam=pwr_led_trigger=mmc0
dtparam=audio=on
device_tree_address=0x02000000
dtoverlay=vc4-fkms-v3d,cma-128

对于32位系统,只需删除"arm_64bit=1",然后使用32位u-boot、内核和设备树二进制文件(dtb)。

请确保为每个系统使用正确的工具链。

以下是我的u-boot、内核和buildroot工具链示例:

  • 64位:gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu
  • 32位:gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf
  1. 在u-boot的bootargs中添加"8250.nr_uarts=1"。然后你将获得完整的内核引导日志,有助于找出卡在哪里。

以下是我的用于在第二个分区加载rootfs的bootargs示例:

setenv bootargs 8250.nr_uarts=1 console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait rw
  1. 加载内核和设备树,然后启动内核。

对于64位系统:

fatload mmc 0:1 ${kernel_addr_r} Image
fatload mmc 0:1 ${fdt_addr} bcm2711-rpi-4-b.dtb
booti ${kernel_addr_r} - ${fdt_addr}

对于32位系统:

fatload mmc 0:1 ${kernel_addr_r} zImage
fatload mmc 0:1 ${fdt_addr} bcm2711-rpi-4-b.dtb
bootz ${kernel_addr_r} - ${fdt_addr}

请注意,我们需要使用fdt_addr而不是fdt_addr_r,尽管fdt_addr_t也对我有效。请参考https://elinux.org/RPi_U-Boot了解fdt_addr与fdt_addr_t的区别。

英文:

I had the same confusing problem on raspberry pi 4 and finally I found out solution.

  1. Make sure "enable_uart=1" is in config.txt in first partition.

  2. Raspberry pi 4 supports both 32-bit and 64-bit mode. The firmware config.txt, u-boot and kernel should be same configuration.

Here is my config.txt for 64-bit system.

[pi4]
kernel=u-boot.bin
max_framebuffers=2

[all]
arm_64bit=1
enable_uart=1
dtparam=i2c=on
dtparam=spi=on
dtparam=act_led_trigger=heartbeat
dtparam=pwr_led_trigger=mmc0
dtparam=audio=on
device_tree_address=0x02000000
dtoverlay=vc4-fkms-v3d,cma-128

Just remove "arm_64bit=1" for 32-bit system, working with 32-bit u-boot and kernel and device tree binary (dtb).

Please make sure you're using correct toolchain for each system.

Here is my toolchain for u-boot, kernel and buildroot:

64-bit: gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu
32-bit: gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf
  1. Add "8250.nr_uarts=1" in u-boot bootargs. Then you'll get full kernel boot log, and it will help you to find out where it is stuck.

Here is my bootargs to load rootfs on second partition.

setenv bootargs 8250.nr_uarts=1 console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait rw
  1. Load kernel and device tree, and start kernel

For 64-bit system

fatload mmc 0:1 ${kernel_addr_r} Image
fatload mmc 0:1 ${fdt_addr} bcm2711-rpi-4-b.dtb
booti ${kernel_addr_r} - ${fdt_addr}

For 32-bit system

fatload mmc 0:1 ${kernel_addr_r} zImage
fatload mmc 0:1 ${fdt_addr} bcm2711-rpi-4-b.dtb
bootz ${kernel_addr_r} - ${fdt_addr}

Note that we need use fdt_addr instead of fdt_addr_r, although fdt_addr_t also works for me. See https://elinux.org/RPi_U-Boot for fdt_addr vs fdt_addr_t.

答案2

得分: 1

  1. 尝试去掉任何行继续符号 () 以确保不会让 U-Boot 混淆。
  2. 这可能是与 initrd 内容有关的问题(是否包含了所有正确的驱动程序?是否正确构建?是否加载到内存中?)。
  3. 请参考https://stackoverflow.com/a/58832898/7158800中有关你的 .dts/.dtb 文件中 chosen 行的注意事项。一旦你决定要指定的控制台设备,请确保 .dtb 与 U-Boot bootargs 匹配。
  4. 如果你有 JTAG 调试器,请确保你是否真的进入了 Linux 中的 start_kernel()。在使用 grub 包装器时,我曾经卡住过,所以你可能认为你正在将控制权转移到 Linux,但实际上你可能跳入了深空,或者至少是一些尚未准备好的代码。如果你看不到任何早期的输出语句(例如 Booting Linux on physical CPU 0x0),请 确保 你是否真的进入了 Linux。
英文:
  1. Try the bootargs without any line continuation () to make sure you're not confusing U-Boot.
  2. This could be an issue with the initrd contents (got all the right drivers included? built correctly? loaded into memory?).
  3. See note in https://stackoverflow.com/a/58832898/7158800 re the chosen line in your .dts/.dtb file. Once you decide on the console device you want to specify, make sure the .dtb matches the U-Boot bootargs.
  4. If you have a JTAG debugger, make sure you're even getting to start_kernel() in Linux. I've gotten hung up before when using grub wrappers, so you think you're transferring control to Linux but you're actually jumping into deep space or at least code that's not ready for prime time. Ensure that you're hitting Linux at all if you are seeing none of the early statements printed (i.e. Booting Linux on physical CPU 0x0).

huangapple
  • 本文由 发表于 2020年1月3日 23:05:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/59580877.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定