相关软件下载地址:http://pan.baidu.com/s/16yo8Y
适用于fsc100开发板
交叉编译器arm-cortex_a8-linux-gnueabi-gcc
u-boot-2010.03
一、建立自己的平台
1、 下载源码
我们可以在下面这个网站上下载最新的和以前任一版本的uboot
2、 解压uboot源码并进入目录
$ tar xvf u-boot-2010.03.tar.gz
$ cd u-boot-2010.03
3、 添加fsc100平台信息
我们关心的板级相关文件或目录
u-boot-2010.03/Makefile
u-boot- 2010.03/include/configs/smdkc100.h
u-boot- 2010.03 /cpu/arm_cortexa8/start.S
u-boot- 2010.03 /board/samsung/smdkc100
u-boot- 2010.03 /lib_arm
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顶层目录下的Makefile中添加fsc100配置信息
$ vim Makefile
在
smdkc100_config: unconfig
@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 smdkc100 samsung s5pc1xx
下添加:
fsc100_config: unconfig
@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 fsc100 samsung s5pc1xx
1、 编译u-boot-2010.03
$ make distclean
$ make fsc100_config
$ make
编译完成后生成的u-boot.bin就是可执行的镜像文件。但是该文件只能在smdkc100平台上运行,我们需要对u-boot源代码进行相应的修改。
二、针对我们的fsc100平台进行相应的移植
1、 修改include/configs/fsc100.h
修改内存基址
#define CONFIG_SYS_SDRAM_BASE 0x30000000
为
#define CONFIG_SYS_SDRAM_BASE 0x20000000
把
#undef CONFIG_CMD_NAND
改成
#define CONFIG_CMD_NAND
把
#undef CONFIG_CMD_NET
改成
#define CONFIG_CMD_NET
在
#define CONFIG_CMD_NAND
后添加
#define CONFIG_SYS_ICACHE_OFF 1
注释以下内容
#define CONFIG_CMD_ONENAND
注释以下内容
#define MTDIDS_DEFAULT “onenand…”
……
#define CONFIG_UPDATEB “updateb=……”
注释以下内容
#define CONFIG_EXTRA_ENV_SETTINGS
……
“ubi=enabled”
修改提示符
#define CONFIG_SYS_PROMPT “SMDKC100 # ”
为
#define CONFIG_SYS_PROMPT “FSC100 # ”
修改
#define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_SDRAM_BASE+0x5e00000)
为
#define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_SDRAM_BASE+0x10000000)
修改内核加载地址
#define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_SDRAM_BASE
为
#define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE+0x8000)
修改内存容量
#define PHYS_SDRAM_1_SIZE (128 << 20)
为
#define PHYS_SDRAM_1_SIZE (256 << 20)
修改环境变量存放位置
#define CONFIG_ENV_IS_IN_ONENAND 1
为
#define CONFIG_ENV_IS_IN_NAND 1
注释以下内容
从
#define CONFIG_USE_ONENAND_BOARD_INIT
到
#define CONFIG_SYS_ONENAND_BASE 0xE7100000
在
#define CONFIG_DOS_PARTITION 1
下面添加如下信息
添加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)
添加网卡信息
#ifdef CONFIG_CMD_NET
#define CONFIG_NET_MULTI
#define CONFIG_CMD_PING 1
#define CONFIG_DRIVER_DM9000 1
#define CONFIG_DM9000_BASE 0x88000000
#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 CONFIG_GATEWAYIP 192.168.1.1
#define CONFIG_NETMASK 255.255.255.0
#endif
1、 复制lowlevel_init.S mem_setup.S到board/samsung/fsc100
上述代码专门针对fsc100使用的内存进行初始化,可参考相关芯片手册
2、 复制fsc100.c到board/smsung/fsc100 覆盖原来的fsc100.c
fsc100.c 包含的是板级初始化函数
3、 在board/samsung/fsc100/目录下添加nand_cp.c
#include <common.h>
#ifdef CONFIG_S5PC1XX
#include <asm/io.h>
#include <linux/mtd/nand.h>
#define _REG__(x) (*(volatile unsigned long *)(x))
#define _REGb__(x) (*(volatile unsigned char *)(x))
#define NFCONT_REG _REG__(0xE7200004)
#define NFCMD_REG _REG__(0xE7200008)
#define NFADDR_REG _REG__(0xE720000C)
#define NFDATA8_REG _REGb__(0xE7200010)
#define NFSTAT_REG _REG__(0xE7200028)
#define NAND_CONTROL_ENABLE() (NFCONT_REG |= (1 << 0))
static int nandll_read_page (uchar *buf, ulong addr, int large_block)
{
int i;
int page_size = 512;
if (large_block) page_size = 2048;
NAND_ENABLE_CE();
NFCMD_REG = NAND_CMD_READ0;
/* Write Address */
NFADDR_REG = 0;
if (large_block) NFADDR_REG = 0;
NFADDR_REG = (addr) & 0xff;
NFADDR_REG = (addr >> 8) & 0xff;
NFADDR_REG = (addr >> 16) & 0xff;
if (large_block) NFCMD_REG = NAND_CMD_READSTART;
NF_TRANSRnB();
for (i=0; i<page_size; i++) {
*buf++ = NFDATA8_REG;
}
NAND_DISABLE_CE();
return 0;
}
static int nandll_read_blocks (ulong dst_addr, ulong size, int large_block)
{
uchar *buf = (uchar *)dst_addr;
int i, pages;
uint page_shift = 9;
if (large_block) page_shift = 11;
pages = size >> page_shift;
for (i=0; i<pages; i++) {
nandll_read_page(buf, i, large_block);
buf += (1 << page_shift);
}
return 0;
}
int copy_uboot_to_ram (void)
{
int i, large_block = 0;
vu_char id;
NAND_CONTROL_ENABLE();
NAND_ENABLE_CE();
NFCMD_REG = NAND_CMD_READID;
NFADDR_REG = 0x0;
/* wait for a while */
for (i=0; i<200; i++);
id = NFDATA8_REG;
id = NFDATA8_REG;
if (id > 0x80) large_block = 1;
return nandll_read_blocks(0x2ff80000, 0x40000, large_block);
}
#endif
1、 修改board/samsung/fsc100/Makefile
把
SOBJS := lowlevel_init.o
改成
SOBJS := lowlevel_init.o mem_setup.o
把
COBJS-y := fsc100.o
改成
COBJS-y := fsc100.o nand_cp.o
2、 修改board/samsun/fsc100/config.mk
把
TEXT_BASE = 0x34800000
改成
TEXT_BASE = 0x2FF80000
3、 修改cpu/arm_cortexa8/start.S
在
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
bl cpu_init_crit
#endif
之后添加如下代码
/* 判断uboot是否在内存中运行 */
ldr r0, =_TEXT_BASE
adr r1, _TEXT_BASE
cmp r0, r1
beq stack_setup
ldr sp, =(0x22000000)
bl copy_uboot_to_ram
b stack_setup
4、 链接文件的修改
修改cpu/arm_cortexa8/u-boot.lds为:
……
.text :
{
cpu/arm_cortexa8/start.o (.text)
board/samsung/fsc100/lowlevel_init.o
board/samsung/fsc100/mem_setup.o
board/samsung/fsc100/nand_cp.o
*(.text)
}
……
5、 复制s5pc100.h s5pc1x0.h hardware.h 到 include/asm-arm/arch-s5pc1xx/
6、 复制s5p_nand.c到drivers/mtd/nand/
7、 修改drivers/mtd/nand/Makefile
在
COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o
后面添加
COBJS-$(CONFIG_NAND_S5PC100) += s5p_nand.o
8、 修改include/linux/mtd/mtd-abi.h
struct nand_ecclayout {
……
struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
uint32_t useecc;
uint32_t reserved;
};
9、 在lib_arm/board.c中添加网卡初始化代码
在
eth_initialize(gd->bd);
后面添加
eth_init(gd->bd);
10、 修改网卡驱动drivers/net/dm9xxx.c
在函数dm9000_init中,
DM9000_iow(DM9000_IMR, IMR_PAR);
之后的内容都注释掉,直到该函数结束(return 0之前)
11、 修改include/net.h
static inline int is_multicast_ether_addr(const u8 *addr)
{
return (0x01 == addr[0]);
}
12、 修改net/net.c
在 int NetArpWaitTry; 后添加如下代码
ulong timer_clk;
void ArpTimeoutCheck(void)
{
……
把
t = get_timer(0);
改成
t = get_timer(0) / (timer_clk / CONFIG_SYS_HZ);
}
extern unsigned long (*get_pclk)(void);
int NetLoop(proto_t protocol)
{
bd_t *bd = gd->bd;
添加如下代码:
timer_clk = get_pclk() / (16 * 2);
……
注释以下代码
eth_halt();
eth_set_current();
if (eth_init(bd) < 0) {
eth_halt();
return -1;
}
把
if (timeHandler && ( … > timeDelta) {
改成
ulong t;
t = get_timer(0) / (timer_clk / CONFIG_SYS_HZ);
if (timeHandler && (t - timeStart) > timeDelta) {
……
}
void NetSetTimeout(ulong iv, thand_f *f)
{
把
timeStart = get_timer(0);
改成
timeStart = get_timer(0) / (timer_clk / CONFIG_SYS_HZ);
}
int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len)
{
……
把
NetArpWaitTimerStart = get_timer(0);
改成
NetArpWaitTimerStart = get_timer(0) / (timer_clk / CONFIG_SYS_HZ);
……
}
int PingSend(void)
{
……
把
NetArpWaitTimerStart = get_timer(0);
改成
NetArpWaitTimerStart = get_timer(0) / (timer_clk / CONFIG_SYS_HZ);
……
}
注释该文件中所有的eth_halt()
1、 go命令的优化
修改该common/cmd_boot.c
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 linux parameters at 0x20000100 ");
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 line is: "%s" ",cmdline);
/***************************************************************/
addr = simple_strtoul(argv[1], NULL, 16);
printf ("## Starting application at 0x%08lX ... ", addr);
/******************* added by farsight 2011-12-18 ******************/
__asm__(
"ldr r1, =1826 "
"mov ip, #0 "
"mcr p15, 0, ip, c8, c7, 0 "
"mcr p15, 0, ip, c7, c5, 0 "
"mcr p15, 0, ip, c7, c5, 6 "
"mcr p15, 0, ip, c7, c10, 4 "
"mcr p15, 0, ip, c7, c5, 4 "
"mrc p15, 0, ip, c1, c0, 0 "
"bic ip, ip, #0x00002000 "
"bic ip, ip, #0x00000007 "
"orr ip, ip, #0x00000002 "
"orr ip, ip, #0x00000800 "
"bic ip, ip, #0x00001000 "
"mcr p15, 0, ip, c1, c0, 0 "
"mov pc, %0 "
"nop "
:
:"r"(addr)
);
/***************************************************************/
rc = do_go_exec ((void *)addr, argc - 1, argv + 1);
if (rc != 0) rcode = 1;
printf ("## Application terminated, rc = 0x%lX ", rc);
return rcode;
}
三、重新编译
$ make distclean
$ make fsc100_config
$ make
这样我们就得到能够在fsc100平台上使用的u-boot.bin