【实验步骤】
一、建立自己的平台
下载源码
我们可以在下面这个网站上下载最新的和以前任一版本的uboot
ftp://ftp.denx.de/pub/u-boot/
解压uboot源码并进入目录
$ tar xvf u-boot-2013.01.tar.bz2
$ cd u-boot-2013.01
指定交叉编译工具链
$ vim Makefile
把
ifeq ($(HOSTARCH),$(ARCH))
CROSS_COMPILE ?=
endif
下添加
ifeq (arm,$(ARCH))
CROSS_COMPILE ?= arm-linux-gnueabi-
endif
指定产品BOARD
找一个最类似的board配置修改, 我们参考的是board/samsung/origen/
$ cp -rf board/samsung/origen/ board/samsung/x4412
$ mv board/samsung/x4412/origen.c board/samsung/x4412/x4412.c
$ vim board/samsung/x4412/Makefile
修改 origen.o 为 x4412.o
$ cp include/configs/origen.h include/configs/x4412.h
$ vim include/configs/x4412.h
修改
#define CONFIG_SYS_PROMPT "ORIGEN #"
为
#define CONFIG_SYS_PROMPT "x4412 #"
修改
#define CONFIG_IDENT_STRING for ORIGEN
为
#define CONFIG_IDENT_STRING for x4412
#vim boards.cfg
参考
origen arm armv7 origen samsung exynos
并在后面新增
x4412 arm armv7 x4412 samsung exynos
实现串口输出
修改lowlevel_init.S文件
$vim board/samsung/x4412/lowlevel_init.S
添加临时栈
在
lowlevel_init:
后添加
ldr sp,=0x02060000 @use iRom stack in bl2
添加关闭看门狗代码
在
beq wakeup_reset
后添加
#if 1 /*for close watchdog */
/* PS-Hold high */
ldr r0, =0x1002330c
ldr r1, [r0]
orr r1, r1, #0x300
str r1, [r0]
ldr r0, =0x11000c08
ldr r1, =0x0
str r1, [r0]
/* Clear MASK_WDT_RESET_REQUEST */
ldr r0, =0x1002040c
ldr r1, =0x00
str r1, [r0]
#endif
添加串口初始化代码
在uart_asm_init: 的
str r1, [r0, #EXYNOS4_GPIO_A1_CON_OFFSET]
后添加
ldr r0, =0x10030000
ldr r1, =0x666666
ldr r2, =CLK_SRC_PERIL0_OFFSET
str r1, [r0, r2]
ldr r1, =0x777777
ldr r2, =CLK_DIV_PERIL0_OFFSET
str r1, [r0, r2]
注释掉trustzone初始化
注释掉
bl uart_asm_init
下的
bl tzpc_init
网卡移植
添加网络初始化代码
$ vim board/samsung/x4412/x4412.c
在struct exynos4_gpio_part2 *gpio2; 后添加
#ifdef CONFIG_DRIVER_DM9000
#define EXYNOS4412_SROMC_BASE 0X12570000
#define DM9000_Tacs (0x1)
#define DM9000_Tcos (0x1)
#define DM9000_Tacc (0x5)
#define DM9000_Tcoh (0x1)
#define DM9000_Tah (0xC)
#define DM9000_Tacp (0x9)
#define DM9000_PMC (0x1)
struct exynos_sromc {
unsigned int bw;
unsigned int bc[6];
};
/*
* s5p_config_sromc() - select the proper SROMC Bank and configure the
* band width control and bank control registers
* srom_bank - SROM
* srom_bw_conf - SMC Band witdh reg configuration value
* srom_bc_conf - SMC Bank Control reg configuration value
*/
void exynos_config_sromc(u32 srom_bank, u32 srom_bw_conf, u32 srom_bc_conf)
{
unsigned int tmp;
struct exynos_sromc *srom = (struct exynos_sromc *)(EXYNOS4412_SROMC_BASE);
/* Configure SMC_BW register to handle proper SROMC bank */
tmp = srom->bw;
tmp &= ~(0xF << (srom_bank * 4));
tmp |= srom_bw_conf;
srom->bw = tmp;
/* Configure SMC_BC register */
srom->bc[srom_bank] = srom_bc_conf;
}
static void dm9000aep_pre_init(void)
{
unsigned int tmp;
unsigned char smc_bank_num = 1;
unsigned int smc_bw_conf=0;
unsigned int smc_bc_conf=0;
/* gpio configuration */
writel(0x00220020, 0x11000000 + 0x120);
writel(0x00002222, 0x11000000 + 0x140);
/* 16 Bit bus width */
writel(0x22222222, 0x11000000 + 0x180);
writel(0x0000FFFF, 0x11000000 + 0x188);
writel(0x22222222, 0x11000000 + 0x1C0);
writel(0x0000FFFF, 0x11000000 + 0x1C8);
writel(0x22222222, 0x11000000 + 0x1E0);
writel(0x0000FFFF, 0x11000000 + 0x1E8);
smc_bw_conf &= ~(0xf<<4);
smc_bw_conf |= (1<<7) | (1<<6) | (1<<5) | (1<<4);
smc_bc_conf = ((DM9000_Tacs << 28)
| (DM9000_Tcos << 24)
| (DM9000_Tacc << 16)
| (DM9000_Tcoh << 12)
| (DM9000_Tah << 8)
| (DM9000_Tacp << 4)
| (DM9000_PMC));
exynos_config_sromc(smc_bank_num,smc_bw_conf,smc_bc_conf);
}
#endif
在gd->bd->bi_boot_params = (PHYS_SDRAM_1 + 0x100UL); 后添加
#ifdef CONFIG_DRIVER_DM9000
dm9000aep_pre_init();
#endif
在文件末尾添加
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_DRIVER_DM9000
rc = dm9000_initialize(bis);
#endif
return rc;
}
#endif
修改配置文件添加网络相关配置
$ vim include/configs/x4412.h
修改
#undef CONFIG_CMD_PING
为
#def ine CONFIG_CMD_PING
修改
#undef CONFIG_CMD_NET
为
#def ine CONFIG_CMD_NET
在文件末尾
#endif /* __CONFIG_H */
前面添加
#ifdef CONFIG_CMD_NET
#define CONFIG_NET_MULTI
#define CONFIG_DRIVER_DM9000 1
#define CONFIG_DM9000_BASE 0x07000000
#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.0.66
#define CONFIG_SERVERIP 192.168.0.100
#define CONFIG_GATEWAYIP 192.168.0.1
#define CONFIG_NETMASK 255.255.255.0
#endif
三、编译u-boot
$ make distclean
$ make x4412_config
$ make
编译完成后生成的u-boot.bin就是可执行的镜像文件。
但是该文件还不能在我们板子上运行,我们需要对u-boot源代码进行相应的修改。
添加三星加密方式. (也可以直接使用x4412源码提供的编译脚本进行修改)
exynos 需要三星提供的初始引导加密后,我们的u-boot,才能被引导运行
$cp sdfuse_q u-boot-2013.01 -rf
$ chmod 777 u-boot-2013.01/sdfuse_q -R
注:sdfuse_q 三星提供的加密处理
$cp CodeSign4SecureBoot u-boot-2013.01 -rf
注:CodeSign4SecureBoot 三星提供的安全启动方式
修改Makefile
$vim Makefile
修改实现sdfuse_q的编译
在
$(obj)u-boot.bin: $(obj)u-boot
$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(BOARD_SIZE_CHECK)
下添加
@#./mkuboot
@split -b 14336 u-boot.bin bl2
@make -C sdfuse_q/
@#cp u-boot.bin u-boot-4212.bin
@#cp u-boot.bin u-boot-4412.bin
@#./sdfuse_q/add_sign
@./sdfuse_q/chksum
@./sdfuse_q/add_padding
@rm bl2a*
@echo
拷贝编译脚本
$ cp build.sh u-boot-2013.01
$ chmod 777 u-boot-2013.01/ build.sh
$ ./buildsh
注:build.sh 脚本方式完成自动添加加密方式,
编译生成所需文件u-boot_x4412.bin