如何在解压缩失败时找到ARM Linux入口点?

Ati*_*liz 6 boot arm linux-kernel embedded-linux u-boot

我试图通过U-boot在i.MX6的自定义板上启动Linux(CPU内核是ARM Cortex A9)

我们似乎成功移植了Das U-Boot(2009.08).但是在最后的U-Boot消息中启动Linux失败:"启动内核......"

这是我的相关环境:

bootargs=console=ttymxc1,115200 vmalloc=400M root=/dev/mmcblk0p1 rootwait consoleblank=0 earlyprintk video=mxcfb0:dev=lcd,LCD-ORTUS,if=RGB24 video=mxcfb1:dev=hdmi,1280x720M@60,if=RGB24 calibration tsdev=tsc2004 fbmem=10M,28M
bootcmd=ext2load mmc 0:1 10800000 /boot/uImage ; bootm 10800000
Run Code Online (Sandbox Code Playgroud)

启动输出是

Loading file "/boot/uImage" from mmc device 0:1 (xxa1)  
4043552 bytes read  
## Booting kernel from Legacy Image at 10800000 ...  
   Image Name:   Linux-3.0.35  
   Image Type:   ARM Linux Kernel Image (uncompressed)  
   Data Size:    4043488 Bytes =  3.9 MB  
   Load Address: 10008000  
   Entry Point:  10008000  
   Verifying Checksum ... OK  
   Loading Kernel Image ... OK  
OK  

Starting kernel ...  
Run Code Online (Sandbox Code Playgroud)

当我objdump内核时,在地址80008000处,我看到了arch/arm/kernel/head.S的入口点,而不是arch/arm/boot/compressed/head.S.

我看到的是,内核甚至没有解压缩.我尝试添加一些寄存器操作代码来发送压缩/ head.S中的GPIO信号,但没有响应.

我的问题是,我怎样才能确保U-Boot正在调用正确的入口点?

完全相同的内核二进制文件使用相同的U-Boot命令在飞思卡尔的参考板上成功启动.

编辑:我在U-Boot中添加了一些痕迹.在调用内核之前,指针theKernel是10008000而不是10800000.这是否意味着U-boot在错误的位置跳转?

saw*_*ust 7

我们似乎成功移植了Das U-Boot.

有证据表明这是一个错误的假设.

在调用内核之前,指针theKernel是10008000而不是10800000.

您使用的是哪个版本的U-Boot?
在2012.10和2013.04版本的U-Boot中,该变量theKernel仅由AVR32和MIPS等拱门的代码声明和使用.
没有应该使用的ARM代码theKernel.

u-boot-2012.10$ find . -print | xargs grep theKernel
./arch/avr32/lib/bootm.c:   void    (*theKernel)(int magic, void *tagtable);
./arch/avr32/lib/bootm.c:   theKernel = (void *)images->ep;
./arch/avr32/lib/bootm.c:          theKernel, params_start);
./arch/avr32/lib/bootm.c:   theKernel(ATAG_MAGIC, params_start);
./arch/microblaze/lib/bootm.c:  void    (*theKernel) (char *, ulong, ulong);
./arch/microblaze/lib/bootm.c:  theKernel = (void (*)(char *, ulong,    ulong))images->ep;
./arch/microblaze/lib/bootm.c:      (ulong) theKernel, rd_data_start, (ulong) of_flat_tree);
./arch/microblaze/lib/bootm.c:  theKernel (commandline, rd_data_start, (ulong) of_flat_tree);
./arch/mips/lib/bootm.c:    void (*theKernel) (int, char **, char **, int *);
./arch/mips/lib/bootm.c:    theKernel = (void (*)(int, char **, char **, int *))images->ep;
./arch/mips/lib/bootm.c:        (ulong) theKernel);
./arch/mips/lib/bootm.c:    theKernel(linux_argc, linux_argv, linux_env, 0);
./arch/mips/lib/bootm_qemu_mips.c:  void (*theKernel) (int, char **, char **, int *);
./arch/mips/lib/bootm_qemu_mips.c:  theKernel = (void (*)(int, char **, char **, int *))images->ep;
./arch/mips/lib/bootm_qemu_mips.c:      (ulong) theKernel);
./arch/mips/lib/bootm_qemu_mips.c:  theKernel(0, NULL, NULL, 0);
./arch/nds32/lib/bootm.c:   void    (*theKernel)(int zero, int arch, uint params);
./arch/nds32/lib/bootm.c:   theKernel = (void (*)(int, int, uint))images->ep;
./arch/nds32/lib/bootm.c:          (ulong)theKernel);
./arch/nds32/lib/bootm.c:   theKernel(0, machid, bd->bi_boot_params);
u-boot-2012.10$
Run Code Online (Sandbox Code Playgroud)


请解释如何跟踪不应在ARM处理器上定义或分配的变量.

U-Boot打印"Starting kernel ..."后的下一个输出应该是"Uncompressing Linux ...".
对于飞思卡尔拱门,此文本输出取决于machine type number(arch_id通过)U-Boot到内核的正确传递.
您需要验证是否machine type number在U-Boot中正确定义了这一点.

U-Boot的配置文件是什么样的?

我尝试添加一些寄存器操作代码来发送压缩/ head.S中的GPIO信号,但没有响应.

您是否理智检查此代码以确保其按预期工作?
您是否从U-Boot命令行尝试了GPIO操作?

我的问题是,我怎样才能确保U-Boot正在调用正确的入口点?

对于ARM arch,它是跳转到bootm命令中指定的地址.
由于uImage加载地址和bootm指定相同的0x10800000地址,因此应该是好的(假设U-Boot已正确配置并为ARM构建).

在调用内核之前,指针theKernel是10008000而不是10800000.这是否意味着U-boot在错误的位置跳转?

是.
如果检查源代码(对于AVR32或MIPS),您会发现它theKernel是从映像头分配的,特别是入口点值.然后U-Boot会跳转到这个位置.
但真正的问题是你的ARM Cortex A9不应该使用这个代码或这个变量.

似乎没有为正确的拱门配置U-Boot和/或可能无法正确定义机器类型.

更正:

正如OP指出的那样,旧版本的U-Boot确实使用了变量,theKernel即使对于ARM拱形也是如此.

U-Boot输出行:

   Loading Kernel Image ... OK  
Run Code Online (Sandbox Code Playgroud)

表示U-Boot已经(成功)将内核映像(没有映像信息头)从bootm0x10800000 的地址(加上报头长度的偏移量0x40 )复制到加载地址0x10008000.此存储器移动操作由程序执行bootm_load_os()公共/ cmd_bootm.c.

因此,您报告的0x10008000的值是正确的theKernel.
没有迹象表明U-Boot跳到了错误的位置.

如前所述,您应该验证是否正确定义了机器类型.该值将__arch_decomp_setup()arch/arm/plat-mxc/include/mach/uncompress.h中使用, 以便在内核引导之前的解压缩期间输出文本.