|
解决u-boot-1.2.0中go命令的bug
[复制链接]
u-boot-1.2.0现在可以使用tftp,支持nand读写。但是在使用go命令时,遇到了问题。现象如下:
U-boot # tftp 0x31000000 zImage
TFTP from server 192.168.1.216; our IP address is 192.168.1.110
Filename 'zImage'.
Load address: 0x31000000
Loading: #################################################################
################################################################
done
Bytes transferred = 658908 (a0ddc hex)
U-boot # go 0x31000000
## Starting application at 0x31000000 ...
Uncompressing Linux................................................ done, booting the kernel.
Error: a
可见,跳转地址0x31000000传递成功,zImage头部的解压缩程序也成功了,解压完成之后真正进入内核执行阶段出现问题。这说明参数传递有问题,标志就是出现Error:a。读过vivi的汇编代码知道,我们还需要传递两个参数,保证R0为0,R1为mach type。另外呢,需要设定Linux启动的命令行参数。所以,需要查看uboot的源代码,在【common/cmd_boot.c】中。
#if defined(CONFIG_I386)
DECLARE_GLOBAL_DATA_PTR;
#endif
int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
ulong addr, rc;
int rcode = 0;
if (argc 2) {
printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
addr = simple_strtoul(argv[1], NULL, 16);
printf ("## Starting application at 0x%08lX ...\n", addr);
/*
* pass address parameter as argv[0] (aka command name),
* and all remaining args
*/
#if defined(CONFIG_I386)
/*
* x86 does not use a dedicated register to pass the pointer
* to the global_data
*/
argv[0] = (char *)gd;
#endif
#if !defined(CONFIG_NIOS)
rc = ((ulong (*)(int, char *[]))addr) (--argc, &argv[1]);
#else
/*
* Nios function pointers are address >> 1
*/
rc = ((ulong (*)(int, char *[]))(addr>>1)) (--argc, &argv[1]);
#endif
if (rc != 0) rcode = 1;
printf ("## Application terminated, rc = 0x%lX\n", rc);
return rcode;
}
可以看出,这里没有开放宏DECLARE_GLOBAL_DATA_PTR,这样gd就无法使用。以前看过gd部分,相关的环境变量等都与此数据结构有关。读源代码发现,这个go并没有适合s3c2410的代码。所以应该根据情况添加自己的部分。传递参数采用tag方式,前面vivi中的代码稍作修改就可以拿过来用了,关键的语句:
rc = ((ulong (*)(int, char *[]))addr)(0, gd->bd->bi_arch_number);
这句比较难理解。其实就是执行函数的指针,带有两个参数,然后调转到函数地址执行。等价于vivi中的call(0, mach_type, addr)。patch内容如下,参考修改: 完成后测试成功,如下:
U-Boot 1.2.0 (Sep 20 2007 - 15:57:54)
U-Boot code: 33F80000 -> 33F97A90 BSS: -> 33F9C340
RAM Configuration:
Bank #0: 30000000 64 MB
NAND: 32 MB
In: serial
Out: serial
Err: serial
U-boot # tftp 0x30008000 zImage
TFTP from server 192.168.1.216; our IP address is 192.168.1.110
Filename 'zImage'.
Load address: 0x30008000
Loading: #################################################################
################################################################
done
Bytes transferred = 658908 (a0ddc hex)
U-boot # go 0x30008000
## Starting application at 0x30008000 ...
Setup linux parameters at 0x30000100
linux command line is: "noinitrd root=/dev/mtdblock3 console=ttyS0"
Uncompressing Linux................................................ done, booting the kernel.
Linux version 2.4.18-rmk7-pxa1 (armlinux@lqm) (gcc version 2.95.3 20010315 (release)) #10 Thu Sep 20 10:09:50 CST 2007
CPU: ARM/CIRRUS Arm920Tsid(wb) revision 0
Machine: Embest EduKit III (S3C2410)
On node 0 totalpages: 16384
zone(0): 16384 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: noinitrd root=/dev/mtdblock3 console=ttyS0
DEBUG: timer count 15626
Console: colour dummy device 80x30
Calibrating delay loop... 49.86 BogoMIPS
Memory: 64MB = 64MB total
Memory: 62860KB available (1251K code, 294K data, 60K init)
Dentry-cache hash table entries: 8192 (order: 4, 65536 bytes)
Inode-cache hash table entries: 4096 (order: 3, 32768 bytes)
Mount-cache hash table entries: 1024 (order: 1, 8192 bytes)
Buffer-cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
CPU clock = 200.000 Mhz, HCLK = 100.000 Mhz, PCLK = 50.000 Mhz
Starting kswapd
devfs: v1.10 (20020120) Richard Gooch (rgooch@atnf.csiro.au)
devfs: devfs_debug: 0x0
devfs: boot_options: 0x1
ttyS%d0 at I/O 0x50000000 (irq = 52) is a S3C2410
ttyS%d1 at I/O 0x50004000 (irq = 55) is a S3C2410
ttyS%d2 at I/O 0x50008000 (irq = 58) is a S3C2410
Console: switching to colour frame buffer device 30x40
Installed S3C2410 frame buffer
pty: 256 Unix98 ptys configured
s3c2410-ts initialized
S3C2410 Real Time Clock Driver v0.1
block: 128 slots per queue, batch=32
eth0: cs8900 rev K(3.3 Volts) found at 0xd0000300
cs89x0 media RJ-45, IRQ 37
NAND device: Manufacture ID: 0xec, Chip ID: 0x75 (Samsung KM29U256T)
Creating 4 MTD partitions on "Samsung KM29U256T":
0x00000000-0x00020000 : "bootloader"
0x00020000-0x00030000 : "param"
0x00030000-0x00300000 : "kernel"
0x00300000-0x02000000 : "root"
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP, IGMP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 4096)
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
NetWinder Floating Point Emulator V0.95 (c) 1998-1999 Rebel.com
VFS: Mounted root (cramfs filesystem).
Mounted devfs on /dev
Freeing init memory: 60K
init started: BusyBox v1.00 (2005.06.09-02:02+0000) multi-call binary
Starting pid 11, console /dev/console: '/etc/init.d/rcS'
Bummer, could not run '/etc/init.d/rcS': No such file or directory
Bummer, could not run '/etc/init.d/rcS': No such file or directory
Please press Enter to activate this console.
Starting pid 12, console /dev/console: '/bin/sh'
/ #
|
|