给fs4412板子配置uboot
uboot激活流程
(arch/arm/cpu/armv7/start.S)
reset
1.设置CPU模式为SVC
//在这里加点灯的代码。看程序的代码有没有执行//
ldr r0,=0x11000C40
ldr r1,[r0]
bic r1,r1,#0xf0000000
orr r1,r1,#0x10000000
str r1,[r0]
ldr r0,=0x11000C44
ldr r1,[r0]
orr r1,r1,#0x80
str r1,[r0]
/* set power refuse to accept signal of resetting */
ldr r0,=0x11000C00
ldr r1,[r0]
bic r1,r1,#0xf00
orr r1,r1,#0x100
str r1,[r0]
ldr r0,=0x11000C04
ldr r1,[r0]
orr r1,r1,#0x4
str r1,[r0]
2.设置异常向量表
3.cpu_init_cp15 : 设置cp15协处理器
内存映射 关闭
4.cpu_init_crit
--> lowlevel_init//(board/samsung/fs4412/lowlevel_init.S):
if(uboot != ram)
{
-->system_clock_init
-->mem_ctrl_asm_init
}
uart_asm_init
tzpc_init
5._main(arch/arm/lib/crt0.S)
C运行环境的初始化和调用C函数
board_init_r(arch/arm/lib/board.c)
设备相关初始化init
for(;;) //进入命令行,等待命令,执行命令
main_loop();
编译的顺序:
make distclean(先清空以前的uboot.bin文件)
cp board/samsung/origen board/samsung/fs4412
cp include/configs/origen.h include/configs/fs4412.h
make fs4412_config---------xxx.mk
make -j8
需要bl1 和 bl2
./build.sh
现象:板子灯亮了,闪烁,并且没有显示
思考:闪烁—>板子在不断重启
板子重启 <-- 电源模块收到复位信号 <-- 产生复位信号 <-- ???(程序异常)
在/* for UART */前有问题,发出了复位信号,让灯闪烁
解决办法:
找到电源模块,让电源模块不去接受复位信号
电源模块:S5M8767
找到function
GPX0_2 输出高电平
现象:板子的灯一直亮,但没有显示
思考:复位问题解决,交互问题没有解决
超级终端无显示:串口有问题
检测之后是系统的波特率有问题不一定是分配了100MHZ
解决办法:
串口初始化:lowlevel_init.s中找
ldr r0, =EXYNOS4_CLOCK_BASE
/* UART[0:4] */
ldr r1, =CLK_SRC_PERIL0_VAL
ldr r2, =CLK_SRC_PERIL0_OFFSET
str r1, [r0, r2]
/* CLK_DIV_PERIL0: UART Clock Divisors */
ldr r1, =CLK_DIV_PERIL0_VAL
ldr r2, =CLK_DIV_PERIL0_OFFSET
str r1, [r0, r2]
复制粘贴在 bl uart_asm_init之后
并且@bl tzpc_init
现象:有显示,可以交互了,但是ping、tftp 网络命令都没有
思考:uboot网络命令丰富–> common–>cmd_net.c—> ping 有---->有 CONFIG_CMD_PING宏控制–>借鉴别人(板子的头文件中打开)
解决办法:
1、增加命令:
fs4412.h中修改
#define CONFIG_CMD_PING
#define CONFIG_CMD_NET
现象:可以ping命令,但是卡死,终端上net报错
net initialization skipped
思考:网络初始化错误
解决:
2、增加网络初始化
origen.c中增加
{
#ifdef CONFIG_DRIVER_DM9000
int board_eth_init(bd_t *bis)
{
return dm9000_initialize(bis);
}
#endif
}
fs4412.h中增加
{
#ifdef CONFIG_CMD_NET
#define CONFIG_DRIVER_DM9000 1
#define CONFIG_DM9000_BASE 0x05000000
#define DM9000_IO CONFIG_DM9000_BASE
#define DM9000_DATA (CONFIG_DM9000_BASE + 4)
#define CONFIG_ETHADDR 11:22:33:44:55:66
#define CONFIG_IPADDR 192.168.12.251
#define CONFIG_SERVERIP 192.168.12.147
#define CONFIG_GATEWAYIP 192.168.12.1
#define CONFIG_NETMASK 255.255.255.0
#endif
}
3、增加SROM设置
在fs4412/origen.c 增加:
在board_init中增加:
{
#ifdef CONFIG_DRIVER_DM9000
dm9000aep_pre_init();
#endif
}
在fs4412/origen.c 增加:
{
#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
}
在include/configs/中 vi fs4412.h
设置开机自启动文件
#define CONFIG_BOOTARGS "root=/dev/ram rw console=ttySAC2,115200 clk_ignore_unused init=/linuxr"
#define CONFIG_BOOTCOMMAND "tftp 41000000 uImage;tftp 42000000 exynos4412-fs4412.dtb;tftp 43000000 ramdisk.img;bootm 41000000 43000000 42000000"