转:http://dev.firnow.com/course/6_system/linux/Linuxxl/20100521/203214.html
弄了三天的TQ2440 NOR Flash今天尘埃落定.
兼职是简直是煎熬啊.找了很多的 问题.最后到一一解决.
移植Flash 驱动关键是 驱动函数的理解. 虽然移植成功了.但是还是向我的站长要的驱动函数.
NOR Flash的版本是EON29LV160AB 2M
现在总结一下经验:
1:修改root@localhost olduboot]# cd include/configs/my2440.h
这个配置文件.
这个文件里.我们可以修改如下参数./* /**************************************************************************/
#ifndef __CONFIG_H #define __CONFIG_H
/* * High Level Configuration Options * (easy to change) */ #define CONFIG_ARM920T 1 /* This is an ARM920T Core */ #define CONFIG_S3C2410 1 /* in a SAMSUNG S3C2410 SoC */ #define CONFIG_SMDK2410 1 /* on a SAMSUNG SMDK2410 Board */
#define CONFIG_S3C2440 1 /*on my 2440 TQ board*/ /* input clock of PLL */ #define CONFIG_SYS_CLK_FREQ 12000000/* the SMDK2410 has 12MHz input clock */
#define USE_920T_MMU 1 #undef CONFIG_USE_IRQ /* we don't need IRQ/FIQ stuff */
/* * Size of malloc() pool */ #define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 128*1024) #define CONFIG_SYS_GBL_DATA_SIZE 128 /* size in bytes reserved for initial data */
/* * Hardware drivers这里是网卡的配置参数 */ #define CONFIG_DRIVER_CS8900 1 /* we have a CS8900 on-board */ #define CS8900_BASE 0x19000300 #define CS8900_BUS16 1 /* the Linux driver does accesses as shorts */
/* * select serial console configuration 串口1 */ #define CONFIG_S3C24X0_SERIAL #define CONFIG_SERIAL1 1 /* we use SERIAL 1 on SMDK2410 */
/************************************************************ * RTC 时钟配置 ************************************************************/ #define CONFIG_RTC_S3C24X0 1
/* allow to overwrite serial and ethaddr */ #define CONFIG_ENV_OVERWRITE
#define CONFIG_BAUDRATE 115200
/* * BOOTP options */ #define CONFIG_BOOTP_BOOTFILESIZE #define CONFIG_BOOTP_BOOTPATH #define CONFIG_BOOTP_GATEWAY #define CONFIG_BOOTP_HOSTNAME
/* * Command line configuration. */ #include <config_cmd_default.h>
#define CONFIG_CMD_CACHE #define CONFIG_CMD_DATE #define CONFIG_CMD_ELF
//这里修改网卡的相关参数.也可以在Uboot控制台下修改. 这里修改下.顺手嘛
#define CONFIG_BOOTDELAY 3 /*#define CONFIG_BOOTARGS "root=ramfs devfs=mount console=ttySA0,9600" */ /*#define CONFIG_ETHADDR 08:00:3e:26:0a:5b */ #define CONFIG_NETMASK 255.255.255.0 #define CONFIG_IPADDR 192.168.1.123 #define CONFIG_SERVERIP 192.168.1.1 /*#define CONFIG_BOOTFILE "elinos-lart" */ /*#define CONFIG_BOOTCOMMAND "tftp; bootm" */
//下面是GDB调试用的.不理他
#if defined(CONFIG_CMD_KGDB) #define CONFIG_KGDB_BAUDRATE 115200/* speed to run kgdb serial port */ /* what's this ? it's not used anywhere */ #define CONFIG_KGDB_SER_INDEX 1 /* which serial port to use */ #endif
/* * Miscellaneous configurable options */ #define CONFIG_SYS_LONGHELP /* undef to save memory */ #define CONFIG_SYS_PROMPT "my2440 # " /* Monitor Command Prompt */
//这里修改的是Uboot控制台显示的那个参数
#define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */ #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16) /* Print Buffer Size */ #define CONFIG_SYS_MAXARGS 16 /* max number of command args */ #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE /* Boot Argument Buffer Size */
#define CONFIG_SYS_MEMTEST_START 0x30000000 /* memtest works on */ #define CONFIG_SYS_MEMTEST_END 0x33F00000 /* 63 MB in DRAM */
#define CONFIG_SYS_LOAD_ADDR 0x33000000 /* default load address */
//默认的下载地址.在 0x33000000 也就是BANK6 地址范围内
/* 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
/* valid baudrates 可用的波特率参数*/ #define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
/*----------------------------------------------------------------------- * Stack sizes * * The stack sizes are set up in start.S using the settings below */ #define CONFIG_STACKSIZE (128*1024) /* regular stack */ #ifdef CONFIG_USE_IRQ #define CONFIG_STACKSIZE_IRQ (4*1024) /* IRQ stack */ #define CONFIG_STACKSIZE_FIQ (4*1024) /* FIQ stack */ #endif
/*----------------------------------------------------------------------- * Physical Memory Map */ #define CONFIG_NR_DRAM_BANKS 1 /* we have 1 bank of DRAM */ #define PHYS_SDRAM_1 0x30000000 /* SDRAM Bank #1 */ #define PHYS_SDRAM_1_SIZE 0x04000000 /* 64 MB */
#define PHYS_FLASH_1 0x00000000 /* Flash Bank #1 */
#define CONFIG_SYS_FLASH_BASE PHYS_FLASH_1
/*----------------------------------------------------------------------- * FLASH and environment organization *这里开始就是要修改的FLASh参数,/ #if 0 //屏蔽不用的NOR Flash #define CONFIG_AMD_LV400 1 /* uncomment this if you have a LV400 flash */
#define CONFIG_AMD_LV800 1 /* uncomment this if you have a LV800 flash */ #endif
#define CONFIG_SYS_MAX_FLASH_BANKS 1 /* max number of memory banks */ #ifdef CONFIG_AMD_LV800 #define PHYS_FLASH_SIZE 0x00100000 /* 1MB */ #define CONFIG_SYS_MAX_FLASH_SECT (19) /* max number of sectors on one chip */ #define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x0F0000) /* addr of environment */ #endif #ifdef CONFIG_AMD_LV400 #define PHYS_FLASH_SIZE 0x00080000 /* 512KB */ #define CONFIG_SYS_MAX_FLASH_SECT (11) /* max number of sectors on one chip */ #define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x070000) /* addr of environment */ #endif /*使能我们的Flash型号.大小为2M.这个32是这么算的:Flash的操作方式有二种.我选择了扇区的操作方式.在Flash.c中会定义#define MAIN_SECT_SIZE 0x10000 /* 64 KB */ 所以我们的2M共有32个main_sect_size #define CONFIG_EON_29LV160AB 1 #define PHYS_FLASH_SIZE 0x200000 //2M #define CONFIG_SYS_MAX_FLASH_SECT (32) // 2M除以64K=32 #define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_SIZE)
//上面这个是NOR中环境变量的存放地址.
/* timeout values are in ticks */ #define CONFIG_SYS_FLASH_ERASE_TOUT (5*CONFIG_SYS_HZ) /* Timeout for Flash Erase */ #define CONFIG_SYS_FLASH_WRITE_TOUT (5*CONFIG_SYS_HZ) /* Timeout for Flash Write */
#define CONFIG_ENV_IS_IN_FLASH 1 #define CONFIG_ENV_SIZE 0x10000 /* Total Size of Environment Sector */
#endif /* __CONFIG_H */
以上是对头文件的 配置.
一下是我的Flash.c 文件 .就是支持Flash的初始化, 读写函数 以及检测型号的函数;
/
之后我用NAND里面的Uboot下载
[7] Download Program (uCOS-II or TQ2440_Test) to SDRAM and Run it
Enter your selection: 7
USB host is connected. Waiting a download.
再用DNW下载.到SDRAM里面运行.这个要屏蔽初始函数.
/*
* we do sys-critical inits only at reboot,
* not when booting from ram!
*/
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
//bl cpu_init_crit // we use test uboot so mask it!
#endif
还要修改个地方就是[root@localhost olduboot]# gedit include/flash.h
这个头文件.
主要有二个地方.一个是厂商的ID还有个是你的Flash ID.按照格式加上去. 其实我的是EON29LV160AB 修改如下. [没有才加上去的哈.有就免了] ID自己查
#define EON_MANUFACT 0x001c001c /* added by www.arm79.com EON manuf.ID*/
#define EON_ID_LV160AB 0x22492249 /* added by www.arm79.com 29LV160B ID (16 M, bottom boot sect) */
##### Boot for Nand Flash Main Menu #####
[1] Download u-boot or STEPLDR.nb1 or other bootloader to Nand Flash
[2] Download Eboot to Nand Flash
[3] Download Linux Kernel to Nand Flash
[5] Download CRAMFS image to Nand Flash
[6] Download YAFFS image to Nand Flash
[7] Download Program (uCOS-II or TQ2440_Test) to SDRAM and Run it
[8] Boot the system
[9] Format the Nand Flash
[0] Set the boot parameters
[a] Download User Program (eg: uCOS-II or TQ2440_Test)
[b] Download LOGO Picture (.bin) to Nand Flash
[l] Set LCD Parameters
[r] Reboot u-boot
[q] quit from menu
Enter your selection: 7
USB host is connected. Waiting a download.
Now, Downloading [ADDRESS:30000000h,TOTAL:98138]
RECEIVED FILE SIZE: 98138 (95KB/S, 1S)
## Starting application at 0x30000000 ...
U-Boot 2009.08 (Apr 29 2010 - 19:17:01)
DRAM: 64 MB
Flash: 2 MB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
my2440 #
至此我的TQ2440 NOR Flash的驱动就移植完了.其中遇到了很多难题.
下一步是移植nand 的驱动 , 也会总结一下经验出来.如果大家有什么不懂的,
我QQ :439353748
可以和我一起探讨.
但是我对驱动函数的理解还是不够,日后找个时间来研究一下.
2010年4月29日20:16:54
---Idiffer 在寝室奋战了几天. |