这里使用的是专门为三星平台编写的u-boot-samsung.tgz,目标板芯片为S5PC100(基于Cortex_a8)
1、下载源码
地址:ftp://ftp.denx.de/pub/u-boot/
2、解压源码
$ tar xvf u-boot-samsung.tgz
$ cd u-boot-samsung
3、添加fsc100平台信息
由于smdkc100是基于S5PC100芯片的参考板,因此在此基础上移植fsc100
$ cd board/samsung/
$ cp -a smdkc100 fsc100
$ cd fsc100
$ mv smdkc100.c fsc100.c
$ vim Makefile
修改:
COBJS-y:=smdkc100.o
为:
COBJS-y:=fsc100.o
$ cd include/configs
$ cp smdkc100.h fsc100.h
修改u-boot顶层目录下的Makefile,指定交叉工具链
$ vim Makefile
在:
ifeq ($(HOSTARCH,$(ARCH)))
CROSS_COMPILE ?=
endif
下行添加:
ifeq (arm,$(ARCH))
CROSS_COMPILE ?=arm-cortex_a8-linux-gnueabi-
endif
在u-boot顶层目录下的boards.cfg中添加fsc100配置信息
$ vim boards.cfg
在
smdkc100 arm armv7 smdkc100 samsung s5pc1xx
下行添加:
fsc100 arm armv7 smdkc100 samsung s5pc1xx
编译u-boot-samsung
$ make distclean
$ make fsc100_config
$ make
编译完成后生成的u-boot.bin就是可执行的boot镜像,但该文件只能用于smdkc100平台上运行,因此还需要做以下修改
4、针对fsc100平台进行相应的移植
1)修改include/configs/fsc100.h
a、在 #define CONFIG_S5PC100 1下行添加 #define CONFIG_S5PC1xx 1
b、#define CONFIG_SYS_SDRAM_BASE 0x30000000修改内存基址#define CONFIG_SYS_SDRAM_BASE 0x30000000
c、把#undef CONFIG_CMD_NAND改成#define CONFIG_CMD_NAND
d、在#define CONFIG_CMD_NAND后添加#define CONFIG_SYS_ICACHE_OFF 1
e、注释以下内容#define CONFIG_CMD_ONENAND-bottom:0cm;margin-left:58.5pt;margin-bottom:.0001pt;line-height:normal'>后添加#define CONFIG_SYS_ICACHE_OFF 1
f、注释以下内容:从#define CONFIG_BOOTCOMMAND “run ubifsbot”到#define CONFIG_UPDATEB “updateb=……”
g、注释以下内容#define CONFIG_EXTRA_ENV_SETTINGS \到“ubi=enabled”:yes'> CONFIG_UPDATEB “updateb=……”
h、修改提示符#define CONFIG_SYS_PROMPT “SMDKC100 # ”为#define CONFIG_SYS_PROMPT “FSC100 # ”
i、修改内核加载地址#define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_SDRAM_BASE为#define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE+0x8000)"
j、修改内存容量#define PHYS_SDRAM_1_SIZE (128 << 20)为#define PHYS_SDRAM_1_SIZE (256 << 20)
k、修改环境变量存放位置#define CONFIG_ENV_IS_IN_ONENAND 1为#define CONFIG_ENV_IS_IN_NAND 1
l、注释以下内容#define CONFIG_USE_ONENAND_BOARD_INIT到#define CONFIG_SYS_ONENAND_BASE 0xE7100000i-language:AR-SA'>#define CONFIG_ENV_IS_IN_NAND 1
m、设置临时栈地址,修改#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_LOAD_ADDR – 0x1000000)为#define CONFIG_SYS_INIT_SP_ADDR (0x22000)
n、注释以下内容#ifdef CONFIG_CMD_NET到#endif /* CONFIG_CMD_NET */e:ZH-CN;mso-bidi-language:AR-SA'>#define CONFIG_SYS_INIT_SP_ADDR (0x22000)
o、添加NAND信息
#define CONFIG_SYS_MAX_NAND_DEVICE 1
#define CONFIG_SYS_NAND_MAX_CHIPS 1
#define CONFIG_SYS_NAND_BASE 0xE7200000
#define CONFIG_NAND_S5PC100 1
#define CONFIG_NAND_BL1_8BIT_ECC 1
#define CFG_NAND_HWECC 1
#define NAND_ENABLE_CE() (NFCONT_REG &=~(1<<1))
#define NAND_DISABLE_CE() (NFCONT_REG|= (1<<1))
#define NF_TRANSRnB() do {while (! (NFSTAT_REG & (1<<0)) );} while(0)
p、添加网卡信息
#ifdef CONFIG_CMD_NET
#define CONFIG_CMD_PING 1
#define CONFIG_DRIVER_DM9000 1
#define CONFIG_DM9000_BASE 0x88000300
#define DM9000_IO CONFIG_DM9000_BASE
#define DM9000_DATA (CONFIG_DM9000_BASE + 4)
#define CONFIG_DM9000_USE_16BIT
#define CONFIG_DM9000_NO_SROM 1
#define CONFIG_ETHADDR 11:22:33:44:55:66
#define CONFIG_IPADDR 192.168.1.200
#define CONFIG_SERVERIP 192.168.1.100
#define CNNFIG_GATEWAYIP 192.168.1.1
#define CONFIG_NETMASK 255.255.255.0
#endif
2)添加lowlevel_init.S mem_setup.S到board/samsung/fsc100
3)添加fsc100.c到board/smsung/fsc100覆盖原来的fsc100.c
4)在board/samsung/fsc100/目录下添加nand_cp.c
5)修改board/samsung/fsc100/Makefile把SOBJS := lowlevel_init.o改成SOBJS := lowlevel_init.o mem_setup.o nand_cp.o
6)修改board/samsun/fsc100/config.mk把CONFIG_SYS_TEXT_BASE = 0x34800000改成CONFIG_SYS_TEXT_BASE = 0x27E00000n>nand_cp.o
7)修改arch/arm/cpu/armv7/start.S
在call_board_init_f: 之前添加如下代码
/* 如果uboot不在内存中,则从nand复制uboot到内存中 */
ldr r0, =0xff000fff
bic r1, pc, r0
ldr r2, _TEXT_BASE
bic r2, r2, r0
cmp r1, r2
beq call_board_init_f
ldr sp, =(0x22000000)
bl copy_uboot_to_ram
ldr pc, =call_board_init_f
8)链接文件的修改
修改arch/arm/cpu/armv7/u-boot.lds为:
……
.text :
{
arch/arm/cpu/armv7/start.o (.text)
board/samsung/fsc100/libfsc100.o
*(.text)
}
……
9)添加s5pc100.h s5pc1x0.h hardware.h 到arch/arm/include/asm/arch-s5pc1xx/
10)复制s5p_nand.c到drivers/mtd/nand/
11)修改drivers/mtd/nand/Makefile在COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o后面添加COBJS-$(CONFIG_NAND_S5PC100) += s5p_nand.o
12)修改include/linux/mtd/mtd-abi.h
struct nand_ecclayout {
……
struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
uint32_t useecc;
uint32_t reserved;
};13)修改net/net.c,注释以下内容
eth_halt();
eth_set_current();
if (eth_init(bd) < 0) {
eth_halt();
return -1;
}
注释该文件中其他所有的eth_halt()14)在arch/arm/lib/board.c中添加网卡初始化代码
在eth_initialize(gd->bd);后面添加eth_init(gd->bd);
15)修改网卡驱动drivers/net/dm9xxx.c
在函数dm9000_init中,
DM9000_iow(DM9000_IMR,IMR_PAR);
之后的内容都注释掉,直到该函数结束16)修改include/net.h
staticinline int is_multicast_ether_addr(const u8 *addr)
{
return (0x01 == addr[0]);
}
17)修改net/tftp.c把#define TIMEOUT 5000UL改成#define TIMEOUT 50000ULN18)go命令的优化,修改该common/cmd_boot.c
添加/**************** added by farsight 2011-12-18 *****************/与/***************************************************************/ /之间的代码,共两处
int do_go (cmd_tbl_t *cmdtp,int flag, int argc, char *argv[])
{
ulong addr,rc;
int rcode = 0;
if (argc < 2) {
return cmd_usage(cmdtp);
/**************** added by farsight 2011-12-18 *****************/
char *cmdline = getenv("bootargs");
struct param_struct *kernel_params=(struct param_struct*)0x20000100;
printf("setup linuxparameters at 0x20000100\n");
memset(kernel_params, 0, sizeof(struct param_struct));
kernel_params->u1.s.page_size=4096;
kernel_params->u1.s.nr_pages=0x10000000>>12;
memcpy(kernel_params->commandline, cmdline, strlen(cmdline)+1);
printf("linux command lineis: \"%s\"\n",cmdline);
/***************************************************************/
addr =simple_strtoul(argv[1], NULL, 16);
printf ("## Startingapplication at 0x%08lX ...\n", addr);
/******************* added by farsight 2011-12-18 ******************/
__asm__(
"ldr r1, =1826\n"
"mov ip,#0\n"
"mcr p15,0, ip, c8, c7, 0\n"
"mcr p15,0, ip, c7, c5,0\n"
"mcr p15,0, ip, c7, c5, 6\n"
"mcr p15,0, ip, c7, c10, 4\n"
"mcr p15,0, ip, c7, c5, 4\n"
"mrc p15,0, ip, c1, c0, 0\n"
"bic ip,ip, #0x00002000\n"
"bic ip,ip, #0x00000007\n"
"orr ip,ip, #0x00000002\n"
"orr ip,ip, #0x00000800\n"
"bic ip,ip, #0x00001000\n"
"mcr p15,0, ip, c1, c0, 0\n"
"mov pc, %0\n"
"nop\n"
:
:"r"(addr)
);
/***************************************************************/
rc = do_go_exec ((void *)addr,argc - 1, argv + 1);
if (rc != 0) rcode = 1;
printf ("## Applicationterminated, rc = 0x%lX\n", rc);
return rcode;
}19)编译u-boot-samsung
$ make distclean
$ make fsc100_config
$ make
注:以上提及几个需添加的文件,由于代码太长,不便粘贴,需要的可以联系jiez_liang@126.com,注明CSDN
5、U-boot的烧写
1)准备好硬件平台 S5PC100开发板一块,串口线一根,USB下载线一根,电源适配器一个
2)dnw-USB下载工具、USB驱动,超级终端
3)copy出编译好的u-boot.bin
4)串口电缆连接PC与开发板,超级终端上根据连接好串口后的串口号设置波特率为115200,流控制为无,其他默认
5)USB电缆连接PC与开发板,将SW1拔码调成‘0001’为USB下载方式
6)打开DNW下载工具,点击Configuration--->option选项,在USB Port下的Download Address填上0x27e00000,点击OK
7)点击USB Port菜单--->transmit--->transmit加载USB Installer_DDR2.bin
8)点击USB Port菜单--->transmit--->transmit加载u-boot.bin
9)此时超级终端上进入倒计时界面(按回车键出现提示符)
10)使用nandflash命令烧写u-boot到nandflash中,u-boot在nandflash中地址为0--------40000
10.1)nand erase 0 40000 擦除原先nand中0到40000地址的内容
10.2)nand write 0x27e00000 0 40000 将1)-8)USB下载至27e00000的新的U-boot烧写进nand 0-----40000中
11)将SW1拨码开关调至'0000',重启开发板(重新上电)