全部博文(685)
分类: LINUX
2014-08-02 18:08:47
接上篇文章,现在开始启动U盘中的kernel,又碰到了很多问题!
用 fatload usb 0 0x80000000 uImage.lzm ; bootm 0x80000000
总是碰到下面的错误:
MT7620 # bootm 0x80000000
## Booting image at 80000000 ...
Image Name: PandoraBox Linux-3.3.8
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 1058737 Bytes = 1 MB
Load Address: 80000000
Entry Point: 80000000
Verifying Checksum ... OK
Uncompressing Kernel Image ... LZMA ERROR 1 - must RESET board to recover
暂时没有找到问题所在,决定试试usbboot
usbboot usb 0
在U盘存在分区的情况下,输出如下:
MT7620 # usbboot usb 0
Loading from USB device 0, partition 1: Name: usbda1
Type: U-Boot
First Block: 63, # of blocks: 2056257, Block Size: 512
** Bad Magic Number **
若没有分区,则输出如下:
MT7620 # usbboot usb 0
error reading partinfo...try to boot raw
Loading from USB device 0, partition 1: Name: Raw Type: U-Boot
First Block: 0, # of blocks: 2880, Block Size: 512
** Bad Magic Number **
注意First Block!于是准备用RAW方式启动kernel
先把uImage写入U盘
sudo dd if=./uImage-mw305r.lzma of=/dev/sdc bs=512
然后再试图usbboot,但是,可悲的失败了!控制台输出:
MT7620 # usbboot usb 0
error reading partinfo...try to boot raw
Loading from USB device 0, partition 1: Name: Raw Type: U-Boot
First Block: 0, # of blocks: 2880, Block Size: 512
Image Name: PandoraBox Linux-3.3.8
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 1058737 Bytes = 1 MB
Load Address: 80000000
Entry Point: 80000000
..............................................................................................................................................................................................................
MT7620 #
原来,在cmd_usb.c中的do_usbboot函数中,有如下判断:
/* Check if we should attempt an auto-start */
if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
char *local_args[2];
extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
local_args[0] = argv[0];
local_args[1] = NULL;
printf ("Automatic boot of image at addr 0x%08lX ...\n", addr);
rcode=do_bootm (cmdtp, 0, 1, local_args);
return rcode;
}
OK,环境变量中设置:
setenv autostart yes
然后再次尝试,可耻的再次失败!故障和fatload一样!
MT7620 # usbboot usb 0
error reading partinfo...try to boot raw
Loading from USB device 0, partition 1: Name: Raw Type: U-Boot
First Block: 0, # of blocks: 2880, Block Size: 512
Image Name: PandoraBox Linux-3.3.8
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 1058737 Bytes = 1 MB
Load Address: 80000000
Entry Point: 80000000
..............................................................................................................................................................................................................
Automatic boot of image at addr 0x00000000 ...
## Booting image at 00000000 ...
Image Name: PandoraBox Linux-3.3.8
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 1058737 Bytes = 1 MB
Load Address: 80000000
Entry Point: 80000000
Verifying Checksum ... OK
Uncompressing Kernel Image ... LZMA ERROR 1 - must RESET board to recover
浏览代码之后,发现usbboot命令居然输入错了!
正确的格式是
usbboot loadaddress dev[:part]
故,应该这样输入:
usbboot 0x80000000 0
但结果还是一样的失败!再次失败!
在do_bootm的代码中,加入诊断代码,对比spi上的kernel和U盘上的kernel,观察控制台输出:
// manfeel , debug
printf("\nhdr->ih_load = 0x%08X\n",hdr->ih_load);
printf("data pointer = 0x%p\n",data);
printf("first 8 bytes data = %08X,%08X\n",((unsigned int*)data)[0],((unsigned int*)data)[1]);
printf("data length = %d\n", len);
i = lzmaBuffToBuffDecompress ((char*)ntohl(hdr->ih_load),
&destLen, (char *)data, len);
if (i != LZMA_RESULT_OK) {
printf ("LZMA ERROR %d - must RESET board to recover\n", i);
SHOW_BOOT_PROGRESS (-6);
udelay(100000);
do_reset (cmdtp, flag, argc, argv);
}
# SPI上的kernel(正常启动)
hdr->ih_load = 00000080
data pointer = 80c00000
first 8 bytes data = 8000006D,313F4800
data length = 001027B1
# U盘上的kernel
hdr->ih_load = 0x00000080
data pointer = 0x80001040
first 8 bytes data = 8000006D,313F4800
data length = 1058737
LZMA ERROR 1 - must RESET board to recover
发现除了data的地址不一样以外,其他的都一模一样!试着修改了一下载入地址:
usbboot 0x80c00000 0
哈哈,kernel启动了!但最终会panic,正常,因为rootfs没有设定好。
在rt2880.h中似乎发现了一些load address的定义代码:
#if defined(RT6855A_FPGA_BOARD) || defined(RT6855A_ASIC_BOARD) || defined(MT7620_FPGA_BOARD) || defined(MT7620_ASIC_BOARD)
#define CFG_SPINAND_LOAD_ADDR 0x80c00000
接下来需要研究bootargs的问题了。