如何从u-boot启动Linux内核?

时间:2022-12-17 03:08:57

My Linux kernel image uImage is in my U-disk. And I want to boot it from U-Boot. Also the device tree file am335x-evm.dtb is in my U-disk. What I did is below:

我的Linux内核映像uImage在u盘里。我想从U-Boot启动。另外,设备树文件am335x-evm。dtb在我的u盘里。我所做的如下:

U-Boot# usb start
(Re)start USB...
USB0:   scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
U-Boot# fatls usb 0:1
  3821960   uimage
            kit3/
  4065280   modules.tar
            my_modules/
            extra/
            system volume information/
      375   uenv.txt
    40474   am335x-evm.dtb

4 file(s), 4 dir(s)

U-Boot# fatload usb 0:1 0xC0700000 uImage
reading uImage
3821960 bytes read in 2375 ms (1.5 MiB/s)
U-Boot# fatload usb 0:1 0xC0e00000 am335x-evm.dtb
reading am335x-evm.dtb
40474 bytes read in 48 ms (823.2 KiB/s)
U-Boot# bootm 0xC0700000 - 0xC0e00000
## Booting kernel from Legacy Image at c0700000 ...
   Image Name:   Linux-3.12.10-ge35dc10-dirty
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3821896 Bytes = 3.6 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at c0e00000
   Booting using the fdt blob at 0xc0e00000
   Loading Kernel Image ... OK
OK
   Using Device Tree in place at c0e00000, end c0e0ce19

Starting kernel ...

And it stops here. How to do? Thanks!

止于此。怎么办?谢谢!

Result: Thanks for everyone who answered in this post! Now I can boot the system by using the image in U-disk. What I do is:

结果:感谢所有在这篇文章中回答的人!现在我可以使用u盘中的图像引导系统。我所做的是:

setenv bootargs "console=ttyO0,115200n8 root=/dev/mmcblk0p2 rw rootfstype=ext4 mem=512M coherent_pool=8M loglevel=0 lpj=3317760 rootwait"
usb start; fatls usb 0:1; fatload usb 0:1 0x82000000 uImage-orig-onUSB;fatload usb 0:1 0x80F80000 am335x-evm.dtb;bootm 0x82000000 - 0x80F80000

Without the first sentence, the system can also boot and start the GUI program which will show in a display. But the debug serial port has no reaction any more!

如果没有第一个句子,系统也可以启动并启动将显示在显示中的GUI程序。但是调试串行端口没有任何反应!

As for the second sentence, if I use the ram address of 0xC0700000 and 0xC0e00000, like this below, then it will stop to load the kernel. The reason should be what sawdust mentioned in his answer. @sawdust

对于第二个句子,如果我使用0xC0700000和0xC0e00000的ram地址,像下面这样,那么它将停止加载内核。原因应该是他的回答中提到的sawdust。@sawdust

setenv bootargs "console=ttyO0,115200n8 root=/dev/mmcblk0p2 rw rootfstype=ext4 mem=512M coherent_pool=8M loglevel=0 lpj=3317760 rootwait"
usb start; fatls usb 0:1; fatload usb 0:1 0xC0700000 uImage-orig-onUSB;fatload usb 0:1 0xC0e00000 am335x-evm.dtb;bootm 0xC0700000 - 0xC0e00000

2 个解决方案

#1


2  

Despite the message "Starting kernel ...", the kernel has not actually started executing (because the image has to be first relocated and also uncompressed), and consequently enabling earlyprintk will have no effect yet.
What does look suspect are the RAM addresses.

尽管消息“启动内核…”,内核实际上并没有开始执行(因为映像必须首先被重新定位,而且也必须是未压缩的),因此启用earlyprintk将没有任何效果。看起来可疑的是RAM地址。

The typical "am33xx-evm" board only has 512MB of RAM starting at 0x80000000.
Yet you are trying to use RAM addresses from 0xC0700000 to 0xC0E0CE19 where physical memory should not exist.
Obviously the kernel and the device tree are not loaded properly.

典型的“am33xx-evm”板只有512MB的RAM,从0x80000000开始。但是,您尝试使用从0xC0700000到0xC0E0CE19的RAM地址,其中物理内存不应该存在。显然,内核和设备树都没有正确加载。

Instead of

而不是

fatload usb 0:1 0xC0700000 uImage
fatload usb 0:1 0xC0e00000 am335x-evm.dtb
bootm 0xC0700000 - 0xC0e00000

try using

试着用

fatload usb 0:1 0x80200000 uImage 
fatload usb 0:1 0x80e00000 am335x-evm.dtb
bootm 0x80200000 - 0x80e00000 

#2


1  

The booting sequence looks fine. The kernel and the device tree are loaded properly. The problem seems to be in the kernel itself. Probably it is just not built with the right settings. Specifically the console device and early printk facility should be enabled. Also check your bootargs.

引导序列看起来很好。内核和设备树被正确加载。问题似乎在于内核本身。可能它不是用正确的设置构建的。应该启用控制台设备和早期的printk工具。也检查你的bootargs。

#1


2  

Despite the message "Starting kernel ...", the kernel has not actually started executing (because the image has to be first relocated and also uncompressed), and consequently enabling earlyprintk will have no effect yet.
What does look suspect are the RAM addresses.

尽管消息“启动内核…”,内核实际上并没有开始执行(因为映像必须首先被重新定位,而且也必须是未压缩的),因此启用earlyprintk将没有任何效果。看起来可疑的是RAM地址。

The typical "am33xx-evm" board only has 512MB of RAM starting at 0x80000000.
Yet you are trying to use RAM addresses from 0xC0700000 to 0xC0E0CE19 where physical memory should not exist.
Obviously the kernel and the device tree are not loaded properly.

典型的“am33xx-evm”板只有512MB的RAM,从0x80000000开始。但是,您尝试使用从0xC0700000到0xC0E0CE19的RAM地址,其中物理内存不应该存在。显然,内核和设备树都没有正确加载。

Instead of

而不是

fatload usb 0:1 0xC0700000 uImage
fatload usb 0:1 0xC0e00000 am335x-evm.dtb
bootm 0xC0700000 - 0xC0e00000

try using

试着用

fatload usb 0:1 0x80200000 uImage 
fatload usb 0:1 0x80e00000 am335x-evm.dtb
bootm 0x80200000 - 0x80e00000 

#2


1  

The booting sequence looks fine. The kernel and the device tree are loaded properly. The problem seems to be in the kernel itself. Probably it is just not built with the right settings. Specifically the console device and early printk facility should be enabled. Also check your bootargs.

引导序列看起来很好。内核和设备树被正确加载。问题似乎在于内核本身。可能它不是用正确的设置构建的。应该启用控制台设备和早期的printk工具。也检查你的bootargs。