我修改的代码已经上传到github上,地址:https://github.com/qiaoyuguo/u-boot-2014.04-mini2440.git

参考文章: 《mini2440移植uboot 2011.03(上)

前几篇博文: 《mini2440移植uboot 2014.04(一)

mini2440移植uboot 2014.04(二)

mini2440移植uboot 2014.04(三)

后一篇博文: 《mini2440移植uboot 2014.04(五)

(六)添加dm9000网卡

host@debian:~/soft/mini2440/u-boot-2014.04$ vim include/configs/mini2440.h 
删除下面代码: #define CONFIG_CS8900 /* we have a CS8900 on-board */
#define CONFIG_CS8900_BASE 0x19000300
#define CONFIG_CS8900_BUS16 /* the Linux driver does accesses as shorts */
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_IPADDR 10.0.0.110
#define CONFIG_SERVERIP 10.0.0.1 添加新代码: #define CONFIG_CMD_NET
#define CONFIG_DRIVER_DM9000 1
#define CONFIG_DM9000_NO_SROM 1
#define CONFIG_DM9000_BASE 0x20000300
#define DM9000_IO CONFIG_DM9000_BASE
#define DM9000_DATA (CONFIG_DM9000_BASE + 4)
#define CONFIG_CMD_PING
#define CONFIG_ETHADDR 08:00:3e:26:0a:5b
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_IPADDR 192.168.211.25
#define CONFIG_SERVERIP 192.168.211.2 host@debian:~/soft/mini2440/u-boot-2011.03$ vim board/friendlyarm/mini2440/mini2440.c 在board_eth_init函数中返回语句前添加代码:
#ifdef CONFIG_DRIVER_DM9000
rc = dm9000_initialize(bis);
#endif 修改drivers/net/dm9000.c
#ifndef CONFIG_MINI2440
     i = 0;
     while (!(phy_read(1) & 0x20)) { /* autonegation complete bit */
         udelay(1000);
         i++;
         if (i == 10000) {
             printf("could not establish link\n");
             return 0;
         }
     }
#endif

重新编译加载到mini2440,执行ping命令,得到输出信息:

SMDK2410 # ping 192.168.211.2
Trying dm9000
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in bit mode
MAC: ::3e::0a:5b
operating at 100M full duplex mode
Using dm9000 device
host 192.168.211.2 is alive

但是,当执行tftp命令时会一直超时重发:

SMDK2410 # tftp  uImage
Trying dm9000
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in bit mode
MAC: ::3e::0a:5b
operating at 100M full duplex mode
TFTP blocksize = , timeout = ms
Using dm9000 device
TFTP from server 192.168.211.2; our IP address is 192.168.211.25
Filename 'uImage'.
Load address: 0x30008000
Loading: send option "timeout 5"
T send option "timeout 5"
T send option "timeout 5"
T send option "timeout 5"
T send option "timeout 5"
T send option "timeout 5"
T send option "timeout 5"
T send option "timeout 5"
T send option "timeout 5"
T send option "timeout 5"
T send option "timeout 5" Retry count exceeded; starting again
Trying dm9000
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in bit mode
MAC: ::3e::0a:5b
operating at 100M full duplex mode
。。。。。

用wireshark抓包,才知道是udp unreachable错误,猜测tftp服务没启动好,执行/etc/init.d/tftp-hpa restart后就好了。

(七)添加对内核启动的支持:

host@debian:~/soft/mini2440/u-boot-2014.04$ vim include/configs/mini2440.h 
添加一行代码:
#define CONFIG_BOOTARGS "noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0"

启动linux内核还需要有三行定义(这几行定义已经存在于include/configs/mini2440.h中,不需要重新定义):

#define CONFIG_SETUP_MEMORY_TAGS 
#define CONFIG_INITRD_TAG
#define CONFIG_CMDLINE_TAG

重新编译uboot,并按照上面的步骤加载到mini2440内存并启动。

然后执行命令,按照参考文章中的说明,执行下面命令:

SMDK2410 # tftp 30007fc0 uImage
Trying dm9000
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in bit mode
MAC: ::3e::0a:5b
operating at 100M full duplex mode
TFTP blocksize = , timeout = ms
Using dm9000 device
TFTP from server 192.168.211.2; our IP address is 192.168.211.25
Filename 'uImage'.
Load address: 0x30007fc0
Loading: send option "timeout 5"
T send option "timeout 5"
Got OACK: timeout
Blocksize ack: ,
#################################################################
#################################################################
#########################
378.9 KiB/s
done
Bytes transferred = (22b2c4 hex)
Initial value for argc=
Final value for argc=
Initial value for argc=
Final value for argc=
Initial value for argc=
Final value for argc=
Initial value for argc=
Final value for argc=
Initial value for argc=
Final value for argc=
SMDK2410 # bootm
## Current stack ends at 0x33b16d98 * kernel: default image load address = 0x30007fc0
## Booting kernel from Legacy Image at 30007fc0 ...
Image Name: Linux-2.6.32.2-FriendlyARM
Created: -- :: UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: Bytes = 2.2 MiB
Load Address:
Entry Point:
Verifying Checksum ... OK
kernel data at 0x30008000, len = 0x0022b284 ()
## No init Ramdisk
ramdisk start = 0x00000000, ramdisk end = 0x00000000
XIP Kernel Image ... OK
kernel loaded at 0x30008000, end = 0x30233284
using: ATAGS
## Transferring control to Linux (at address )... Starting kernel ... Uncompressing Linux................................................................................................................................................... .
Linux version 2.6.32.2-FriendlyARM (host@debian) (gcc version 4.4. (ctng-1.6.) ) # Wed Jun :: CST
CPU: ARM920T [] revision (ARMv4T), cr=c0007177
。。。。。。。
Failed to execute /linuxrc. Attempting defaults...
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
Backtrace:
[<c00341d0>] (dump_backtrace+0x0/0x10c) from [<c032bb98>] (dump_stack+0x18/0x1c)
r7: r6: r5:c001f5a4 r4:c0483e30
[<c032bb80>] (dump_stack+0x0/0x1c) from [<c032bbe8>] (panic+0x4c/0x11c)
[<c032bb9c>] (panic+0x0/0x11c) from [<c002f598>] (init_post+0xa8/0x10c)
r3: r2:c38fe000 r1:c38fe100 r0:c03dd7dc
[<c002f4f0>] (init_post+0x0/0x10c) from [<c0008634>] (kernel_init+0xe4/0x114)
r5:c001f5a4 r4:c04835c0
[<c0008550>] (kernel_init+0x0/0x114) from [<c004d914>] (do_exit+0x0/0x620)
r5: r4:
将uImage加载0x30007fc0是因为多了个0x40的文件头,代码实际入口仍然是0x30007fc0+0x40=0x30008000.
最后出现的错误是因为我的nand flash被全部擦除了,没有/linuxrc这个文件,导致内核崩溃,如果是原版的nand flash就会直接进入根文件系统
另外,nfs命令也是直接可用的,将内核文件拷贝到nfs系统文件夹下,启动nfs(nfs和tftp的配置可以参看我的博文《debian7配置》),
然后在uboot下用"nfs 30007fc0 /home/host/nfs/mini2440/uImage"命令可以下载uImage,使用bootm可以执行,执行效果和tftp一样。
(八)修改uboot系统提示符
当前uboot提示符仍然是"SMDK2410 #",需要将其改成"MINI2440 #",只需要修改include/configs/mini2440.h中的CONFIG_SYS_PROMPT宏定义,将SMDK2410替换成MINI2440。
然后重新编译加载uboot到mini2440,可以看到命令行已经被修改了:
MINI2440 # 
  
05-11 15:47