u-boot-2010.03在LT2440上的移植详解 (五)
郑重声明,这系列文章改写自博客园 黄刚先生的《嵌入式Linux之我行——u-boot-2009.08在2440上的移植详解》
转载时请注明出处
文章出处:http://www.lt-net.cn
编译系统 |
Ubuntu10.04 |
交叉编译器 |
arm-linux-gcc 4.3.3 |
硬件设备 |
LT2440开发板 |
测试软件 |
u-boot-2010.03 |
依赖库 |
无 |
uboot下载地址:http://ftp.denx.de/pub/u-boot/u-boot-2010.03.tar.bz2
本次移植在u-boot-2010.03原有功能的基础上增加如下特性:
1.支持2KB page Nand Flash读写 2.支持Nand/Nor Flash启动自动识别 3.支持DM9000AEP 10M/100M自适应网卡 4.支持yaffs文件系统烧写 5.支持USB下载功能 6.支持一键式菜单 7.支持启动Logo 8.支持ubifs(待续)
上接:u-boot-2010.03在LT2440上的移植详解 (四)
支持u-boot通过网络下载linux内核,以及u-boot设置linux启动参数,并启动内核 上一节我们已经调试好了DM9000AEP网卡,接下来我们增加u-boot启动linux的所需参数 修改lt2440.h文件,增加相应宏定义即可
# gedit include/configs/lt2440.h
|
#define CONFIG_SETUP_MEMORY_TAGS 1 //内存标签设置
#define CONFIG_CMDLINE_TAG 1 // 命令行标签设置
|
重新编译u-boot,下载到NandFlash,主机使用Tftpd32.exe 传输文件,这个文件在/光盘资料/windows下工具软件及驱动/Tftpd32目录下,将linux内核文件拷贝到这个目录,打开开发板,使用printenv命令查看设置的开发板IP地址和主机IP地址是否得当。我如不对可以使用setenv命令设置环境变量,格式为: setenv serverip 192.168.1.10 接下来我们打开Tftpd32.exe 在超级终端输入 t uimage43 //uimage43为内核名字 然后就可以看到网络的数据在传输了,数据可以传输完,但是我们可以看到有丢包,还有速度比较慢 我们可以使用bootm命令启动SDRAM里面的linux内核 bootm 发现内核已经启动了。过程如下
LT2440 # t uimage43 dm9000 i/o: 0x18000300, id: 0x90000a46 DM9000: running in 16 bit mode MAC: 08:00:3e:26:0a:5b Using dm9000 device TFTP from server 192.168.1.10; our IP address is 192.168.1.66 Filename 'uimage43'. Load address: 0x33000000 Loading: T ################################################################################################################################## ###################### done Bytes transferred = 2223636 (21ee14 hex) LT2440 # bootm 33000000 ## Booting kernel from Legacy Image at 33000000 ... Image Name: Linux-2.6.33.6 Created: 2010-11-03 6:23:46 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2223572 Bytes = 2.1 MB Load Address: 30008000 Entry Point: 30008000 Verifying Checksum ... OK Loading Kernel Image ... OK OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel. Linux version 2.6.33.6 (pk@TFTech) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1- 203) ) #10 Wed Nov 3 14:23:19 CST 2010 CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=00007177 CPU: VIVT data cache, VIVT instruction cache Machine: SMDK2410 Memory policy: ECC disabled, Data cache writeback CPU S3C2440A (id 0x32440001) S3C24XX Clocks, Copyright 2004 Simtec Electronics S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
#define TIMEOUT 5000 /* Millisecs to timeout for lost pkt */ //14行
/*#ifdef CONFIG_TFTP_BLOCKSIZE //101行
#define TFTP_MTU_BLOCKSIZE CONFIG_TFTP_BLOCKSIZE
#else */
#define TFTP_MTU_BLOCKSIZE 1460
sprintf((char *)pkt, "%lu", TIMEOUT / 1000); //213行
//TftpTimeoutCountMax = TIMEOUT_COUNT; //415行 //NetSetTimeout (TftpTimeoutMSecs, TftpTimeout); NetSetTimeout (TIMEOUT * CONFIG_SYS_HZ, TftpTimeout);
NetSetTimeout (TIMEOUT * CONFIG_SYS_HZ, TftpTimeout); //519行
NetSetTimeout (TIMEOUT * CONFIG_SYS_HZ, TftpTimeout); //607行
|
# define ARP_TIMEOUT 5 /* Milliseconds before trying ARP again */ //102 行
if (NetArpWaitTry >= ARP_TIMEOUT_COUNT*CONFIG_SYS_HZ) { //266行
NetSetTimeout (10*CONFIG_SYS_HZ, startAgainTimeout); //587行
NetSetTimeout (10*CONFIG_SYS_HZ, startAgainTimeout); //598行
NetSetTimeout (10*CONFIG_SYS_HZ, PingTimeout); //768行
#define CDP_TIMEOUT CONFIG_SYS_HZ/4 /* one packet every 250ms */ //791行
|
修改系统HZ定义
# gedit include/configs/lt2440.h
|
#undef CONFIG_SYS_CLKS_IN_HZ /* everything, incl board info, in Hz */
/* the PWM TImer 4 uses a counter of 15625 for 10 ms, so we need *//* it to wrap 100 times (total 1562500) to get 1 sec. */
#define CONFIG_SYS_HZ 1562500 //#define CONFIG_SYS_HZ 1000
|
这样网络模块传输就正常了 从上面的内核启动过程中可以发现Machine: SMDK2410这个不是我们的机器,需要修改u-boot,修改启动参数使之适合我们机器 首先,确定u-boot中的MACH_TYPE。在u-boot的include/asm-arm/mach-types.h文件中针对不同的CPU定义了非常多的MACH_TYPE,可以找到下面这个定义:
// #define MACH_TYPE_SMDK2440 1008 //针对2440的MACH_TYPE码的值定义为1008,在1013行
// 我们修改为:
#define MACH_TYPE_LT2440 362
|
那么我们就修改u-boot的MACH_TYPE代码引用部分,确定u-boot的MACH_TYPE。如下:
#gedit board/samsung/lt2440/lt2440.c //修改board_init函数
|
/* arch number of SMDK2410-Board */ //gd->bd->bi_arch_number = MACH_TYPE_SMDK2410; 改为: gd->bd->bi_arch_number = MACH_TYPE_LT2440;
|
重新编译u-boot ,烧写后,再次启动内核:
Starting kernel ... Uncompressing Linux... done, booting the kernel. Linux version 2.6.33.6 (pk@TFTech) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1- 203) ) #10 Wed Nov 3 14:23:19 CST 2010 CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=00007177 CPU: VIVT data cache, VIVT instruction cache Machine: LT2440 Memory policy: ECC disabled, Data cache writeback CPU S3C2440A (id 0x32440001) S3C24XX Clocks, Copyright 2004 Simtec Electronics S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
发现板子ID已经修改正确
下接:u-boot-2010.03在LT2440上的移植详解 (六)
|