u-boot version:2011.09-rc1
/home/lucas/u-boot-2011.09-rc1
OS:debian 7.1
cross-compilation chain:arm-linux-4.3.2
致谢:部分内容参考http://my.csdn.net/crazyman2010的博文,感谢分享。
第一步:u-boot初步编译
【目的】验证开发平台可以正确编译u-boot,初步建立文件目录。
1.建立目标板相关文件
(1)建立板级文件夹
在board/samsung下建立fl440目录,并将相似的板级文件夹smdk2410下全部文件拷贝过去。重命名fl2440下的smdk2410.c为fl2440.c;修改Makefile中的目标COBJS中的smdk2410.o为fl2440.o。
(2)建立芯片级文件夹
直接使用cpu/arm920t的芯片文件夹即可,无需修改。
2.初步编译u-boot生成.bin文件
(1)建立配置文件
拷贝includ/configs/smdk2410.h,重命名为fl2440.h。
(2)建立编译规则
在根目录的Makefile中找到ARM架构smdk2410编译规则
smdk2410_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t
smdk2410 samsung s3c24x0
仿写fl2440编译规则
fl2440+config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t
fl2440 samsung s3c24x0
另外需要指定交叉编译:
CROSS_COMPILE ?= arm-linux-
(3)编译u-boot
make clean
make fl2440_config
make
【注】根目录下生成u-boot.bin和u-boot(即u-boot.axf,添加axf缀即可)。若编译工具为3.3.2等不支持软浮点型,需要把arm920t/config.mk中的#-msoft-float注释掉。
【特别说明】DNW下载的程序是从指定位置运行,而u-boot默认地址为0。FL2440的DRAM地址空间是0x30000000-0x34000000,共64M。所以需要修改
(1)修改DNW配置,设置下载地址为0x32000000;
(2)修改include/configs/fl2440.h:#define CONFIG_SYS_TEXT_BASE 0x32000000
第二步:修改相关配置,在SDRAM中调试
【注】因为实在SDRAM中调试,需要跳过cpu的初始化,所以应在include/configs/fl2440.h中添加#define CONFIG_SKIP_LOWLEVEL_INIT 1
1.修改include/configs/fl2440.h
删除:
#define CONFIG_S3C2410 /*specifically a SAMSUNG S3C2410 SoC */
#define CONFIG_SMDK2410 /* on
aSAMSUNG SMDK2410 Board */
添加:
#define CONFIG_S3C2440
【注】将NAND配置先注释起来,不然会有很多错误:/*#define CONFIG_CMD_NAND*/
更改内存范围:
#defineCONFIG_SYS_MEMTEST_END
0x33F00000
修改为:
#defineCONFIG_SYS_MEMTEST_END
0x34000000
2.修改时钟
(1)修改arch/arm/cpu/arm920t/start.S
在line163处增加屏蔽中断代码:
# if defined(CONFIG_S3C2440)
ldr r1,=0x7fff /*S3C2440使用15位,所以是111 1111 1111 1111*/
ldr
r0,=INTSUBMSK
str r1, [r0]
# endif
删除:
ldr r0, =CLKDIVN
mov
r1, #3
str r1, [r0]
添加:
# if defined(CONFIG_S3C2440)
ldr r0,=CLKDIVN
mov r1,
#5
str
r1, [r0]
#endif
(2)修改board/samsung/fl2440/fl2440.c
删除:
#define FCLK_SPEED 1
#ifFCLK_SPEED==0
/* Fout = 203MHz, Fin = 12MHz for Audio */
#define M_MDIV 0xC3
#define M_PDIV 0x4
#define M_SDIV 0x1
#elifFCLK_SPEED==1
/* Fout = 202.8MHz */
#define M_MDIV 0xA1
#define
M_PDIV 0x3
#define M_SDIV 0x1
#endif
#define
USB_CLOCK 1
#if USB_CLOCK==0
#define
U_M_MDIV 0xA1
#define
U_M_PDIV 0x3
#define
U_M_SDIV 0x1
#elif USB_CLOCK==1
#define U_M_MDIV 0x48
#define U_M_PDIV 0x3
#define U_M_SDIV 0x2
#endif
添加:(晶振12M,CPU405M,USB48M)
#define M_MDIV 0x7f
#define M_PDIV 0x2
#define M_SDIV 0x1
#define U_M_MDIV 0x38
#define U_M_PDIV 0x2
#define U_M_SDIV
0x2
修改 board_init 函数中:
gd->bd->bi_arch_number =
MACH_TYPE_SMDK2410;
改为:
gd->bd->bi_arch_number =
MACH_TYPE_S3C2440;
3.再次编译u-boot,串口有输出
第三步:配置Nand Flash(K9F1G08U0A 128MB 8BIT)
1.删除对Nor Flash支持
(1)修改include/configs/fl2440.h:
删除:
#define CONFIG_SYS_FLASH_CFI
#define CONFIG_FLASH_CFI_DRIVER
#define CONFIG_FLASH_CFI_LEGACY
#define
CONFIG_SYS_FLASH_LEGACY_512Kx16
#define
CONFIG_FLASH_SHOW_PROGRESS 45
#define
CONFIG_SYS_MAX_FLASH_BANKS 1
#define
CONFIG_SYS_FLASH_BANKS_LIST { CONFIG_SYS_FLASH_BASE }
#define CONFIG_SYS_MAX_FLASH_SECT (19)
#define
CONFIG_ENV_ADDR
(CONFIG_SYS_FLASH_BASE + 0x070000)
#define CONFIG_ENV_IS_IN_FLASH
添加:
#define CONFIG_SYS_NO_FLASH 1
#define CONFIG_ENV_IS_NOWHERE
1
(2)修改include/config_cmd_default.h:
删除:
#define CONFIG_CMD_IMI
#define CONFIG_CMD_IMLS
(3)修改 board/samsung/fl2440/fl2440.c:
修改board_flash_get_legacy函数附近代码:
#if !defined(CONFIG_SYS_NO_FLASH)
ulong board_flash_get_legacy(ulong
base, int banknum, flash_info_t *info)
{
info->portwidth =
FLASH_CFI_16BIT;
info->chipwidth = FLASH_CFI_BY16;
info->interface =
FLASH_CFI_X16;
return 1;
}
#endif
2.添加Nand Flash支持
(1)修改include/configs/fl2440.h
取消CONFIG_CMD_NAND的注释。
(2)添加Nand驱动文件
拷贝drivers/mtd/nand/s3c2410_nand.c,并更名s3c2440_nand.c,并修改:
删除:
#define
S3C2410_NFCONF_EN
(1<<15)
#define S3C2410_NFCONF_512BYTE
(1<<14)
#define
S3C2410_NFCONF_4STEP (1<<13)
#define S3C2410_NFCONF_INITECC (1<<12)
#define S3C2410_NFCONF_nFCE
(1<<11)
#define S3C2410_NFCONF_TACLS(x)
((x)<<8)
#define S3C2410_NFCONF_TWRPH0(x)
((x)<<4)
#define S3C2410_NFCONF_TWRPH1(x)
((x)<<0)
#define S3C2410_ADDR_NALE 4
#define
S3C2410_ADDR_NCLE 8
添加:
#define S3C2440_ADDR_NALE 0xc
#define S3C2440_ADDR_NCLE 0x8
替换所有的2410为2440::g/2410/s//2440/g
修改boart_nand_init函数:
删除:
#else
tacls = 4;
twrph0 = 8;
twrph1 = 8;
#endif
cfg = S3C2440_NFCONF_EN;
cfg |=
S3C2440_NFCONF_TACLS(tacls - 1);
cfg |=
S3C2440_NFCONF_TWRPH0(twrph0 - 1);
cfg |=
S3C2440_NFCONF_TWRPH1(twrph1 - 1);
writel(cfg,
&nand_reg->nfconf);
添加:
#else
/*
HCLK is 100MHZ
FL2440‘NAND FLASH IS K9F1G08U0A
time_acls=tacls*HCLK=10ns
time_we=HCLK*(twrph0+1)=15ns
time_wh=HCLK*(twrph1+1)=10ns
*/
tacls = 1;//10ns
twrph0 = 1;//20ns
twrph1 = 0;
#endif
u_int32_t cnt;
cfg =tacls<<12 |
twrph0<<8 | twrph1<<4;//for nfconf
cfg &= ~(1<<0);//bus
width:8bit
writel(cfg,
&nand_reg->nfconf);
cnt
= 1<<6|1<<5|1<<0;//for nfcont
writel(cnt,&nand_reg->nfcont);
修改s3c2440_hwcontrol函数:
struct nand_chip *chip = mtd->priv;
struct s3c2440_nand *nand =
s3c2440_get_base_nand();
debugX(1, "hwcontrol(): 0x%02x
0x%02x\n", cmd, ctrl);
//if (ctrl &
NAND_CTRL_CHANGE) {
ulong
IO_ADDR_W = (ulong)nand;
if (ctrl & NAND_CLE)
IO_ADDR_W |= S3C2440_ADDR_NCLE;
if (ctrl & NAND_ALE)
IO_ADDR_W |= S3C2440_ADDR_NALE;
//chip->IO_ADDR_W=(void*)IO_ADDR_W;
if(ctrl & NAND_NCE){
writel(readl(&nand->nfcont) &
~(1<<1),&nand->nfcont);
}else{
writel(readl(&nand->nfcont) |
(1<<1),&nand->nfcont);
}
//}
if (cmd !=
NAND_CMD_NONE)
writeb(cmd,(void*)IO_ADDR_W);
3.重新编译u-boot,有Nand信息输出
第三步:添加网卡支持(DM9000)
1.删除原网卡CS8900支持
修改include/configs/fl2440.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_DRIVER_DM9000 1
#define CONFIG_DM9000_BASE
0x20000300
#define DM9000_IO CONFIG_DM9000_BASE
#define DM9000_DATA (CONFIG_DM9000_BASE+4) /* the cmd pin is
addr2*/
#define CONFIG_ETHADDR a8:00:3E:26:0A:5B
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_IPADDR
192.168.1.11
#define CONFIG_SERVERIP 192.168.1.234
#define CONFIG_NET_MULTI
/*
#define
CONFIG_NETMASK
255.255.255.0
#define
CONFIG_IPADDR
10.0.0.110
#define
CONFIG_SERVERIP 10.0.0.1
*/
【注】DM9000接到NGCS4,基址为0x20000000,网卡基址0x20000300。
2.添加DM9000支持
(1)修改board/samsung/fl2440/fl2440.c中的board_eth_init函数
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t
*bis)
{
return
dm9000_initialize(bis);
}
#endif
(2)修改drivers/net/dm9000x.c
删除:
i = 0;
while (!(dm9000_phy_read(1) & 0x20)) { /*
autonegation complete bit */
udelay(1000);
i++;
if (i == 10000) {
printf("could not establish link\n");
return 0;
}
}
/* see what we‘ve got */
lnk
= dm9000_phy_read(17) >> 12;
printf("operating at
");
switch (lnk) {
case 1:
printf("10M half duplex
");
break;
case 2:
printf("10M full duplex
");
break;
case 4:
printf("100M half duplex
");
break;
case 8:
printf("100M full duplex
");
break;
default:
printf("unknown: %d ",
lnk);
break;
}
printf("mode\n");
删除函数 dm9000_halt 中的内容:
static void dm9000_halt(struct eth_device *netdev)
{
#if 0
DM9000_DBG("%s\n",
__func__);
/* RESET
devie */
dm9000_phy_write(0, 0x8000); /* PHY RESET */
DM9000_iow(DM9000_GPR,
0x01); /* Power-Down PHY */
DM9000_iow(DM9000_IMR,
0x80); /* Disable all interrupt */
DM9000_iow(DM9000_RCR,
0x00); /* Disable RX */
#endif
}
3.重新编译u-boot,可以启动网卡了
FL2440移植u-boot2011.09,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/lucas-hsueh/p/3709063.html