如何從0編譯和移植uboot、增加串口?
c) 添加串口初始化代碼:在uart_asm_init: 的
351 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]
d) 注釋掉trustzone初始化注釋掉
104 bl uart_asm_init
下的代碼:
#if 0
bl tzpc_init
#endif
5. 網(wǎng)卡移植
因為各個廠家使用的網(wǎng)卡不盡相同,所以三星公司提供的驅(qū)動程序只預(yù)留了網(wǎng)卡初始化的函數(shù)入口,針對不同的板子,我們需要針對電路自己移植網(wǎng)卡的驅(qū)動。網(wǎng)卡的驅(qū)動詳解,我們會在后一章節(jié)詳細(xì)講解。
1、 添加網(wǎng)絡(luò)初始化代碼
$ vim board/samsung/origen/origen.c
在
31 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
2、 修改配置文件添加網(wǎng)絡(luò)相關(guān)配置$ vim include/configs/origen.h修改
85 #undef CONFIG_CMD_PING
為
#define CONFIG_CMD_PING
修改
90 #undef CONFIG_CMD_NET
為
#define CONFIG_CMD_NET
在文件末尾
#endif __CONFIG_H
前面添加
#ifdef CONFIG_CMD_NET
#define CONFIG_NET_M(jìn)ULTI
#define CONFIG_DRIVER_DM9000 1
#define CONFIG_DM9000_BASE 0x05000000 //內(nèi)存基地址
#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.6.187
#define CONFIG_SERVERIP 192.168.6.186
#define CONFIG_GATEWAYIP 192.168.1.1
#define CONFIG_NETMASK 255.255.255.0
#endif
其中CONFIG_DM9000_BASE 地址為何是0x05000000,后續(xù)章節(jié)會詳細(xì)分析。
6. FLASH移植 (EMMC)移植EMMC需要添加一些源文件:cmd_mmc.c
cmd_mmc_fdisk.c
cmd_movi.c
mmc.c
mmc.h
movi.c
movi.h
s5p_mshc.c
s5p_mshc.h
這些文件,由三星提供。
添加相關(guān)驅(qū)動
cp movi.c arch/arm/cpu/armv7/exynos/
修改文件arch/arm/cpu/armv7/exynos/Makefile在pinmux.o 后添加movi.o
修改板級文件 board/samsung/origen/origen.c,在
#include <asm/arch/mmc.h>
后面添加
#include <asm/arch/clk.h>
#include "origen_setup.h"
在
#ifdef CONFIG_GENERIC_M(jìn)MC
后面添加
u32 sclk_mmc4; clock source for emmc controller
#define __REGMY(x) (*((volatile u32 *)(x)))
#define CLK_SRC_FSYS __REGMY(EXYNOS4_CLOCK_BASE + CLK_SRC_FSYS_OFFSET)
#define CLK_DIV_FSYS3 __REGMY(EXYNOS4_CLOCK_BASE + CLK_DIV_FSYS3_OFFSET)
int emmc_init()
{
u32 tmp;
u32 clock;
u32 i;
setup_h(yuǎn)smmc_clock
MMC4 clock src = SCLKMPLL
tmp = CLK_SRC_FSYS & ~(0x000f0000);
CLK_SRC_FSYS = tmp | 0x00060000;
MMC4 clock div
tmp = CLK_DIV_FSYS3 & ~(0x0000ff0f);
clock = get_pll_clk(MPLL)/1000000;
for(i=0 ; i<=0xf; i++) {
sclk_mmc4=(clock/(i+1));
if(sclk_mmc4 <= 160) //200
{
CLK_DIV_FSYS3 = tmp | (i<<0);
break;
}
}
emmcdbg("[mjdbg] sclk_mmc4:%d MHZ; mmc_ratio: %d",sclk_mmc4,i);
sclk_mmc4 *= 1000000;
* MMC4 EMMC GPIO CONFIG
*
* GPK0[0] SD_4_CLK
* GPK0[1] SD_4_CMD
* GPK0[2] SD_4_CDn
* GPK0[3:6] SD_4_DATA[0:3]
writel(readl(0x11000048)&~(0xf),0x11000048); //SD_4_CLK/SD_4_CMD pull-down enable
writel(readl(0x11000040)&~(0xff),0x11000040);//cdn set to be output
writel(readl(0x11000048)&~(3<<4),0x11000048); //cdn pull-down disable
writel(readl(0x11000044)&~(1<<2),0x11000044); //cdn output 0 to shutdown the emmc power
writel(readl(0x11000040)&~(0xf<<8)|(1<<8),0x11000040);//cdn set to be output
udelay(100*1000);
writel(readl(0x11000044)|(1<<2),0x11000044); //cdn output 1
writel(0x03333133, 0x11000040);
writel(0x00003FF0, 0x11000048);
writel(0x00002AAA, 0x1100004C);
#ifdef CONFIG_EMMC_8Bit
writel(0x04444000, 0x11000060);
writel(0x00003FC0, 0x11000068);
writel(0x00002AAA, 0x1100006C);
#endif
#ifdef USE_M(jìn)MC4
smdk_s5p_mshc_init();
#endif
}
將 int board_mmc_init(bd_t *bis)函數(shù)內(nèi)容改寫為
int board_mmc_init(bd_t *bis)
{
int i, err;
#ifdef CONFIG_EMMC
err = emmc_init();
#endif
return err;
}
在末尾添加
#ifdef CONFIG_BOARD_LATE_INIT
#include <movi.h>
int chk_bootdev(void)//mj for boot device check
{
char run_cmd[100];
struct mmc *mmc;
int boot_dev = 0;
int cmp_off = 0x10;
ulong start_blk, blkcnt;
mmc = find_mmc_device(0);
if (mmc == NULL)
{
printf("There is no eMMC card, Booting device is SD card");
boot_dev = 1;
return boot_dev;
}
start_blk = (24*1024/MOVI_BLKSIZE);
blkcnt = 0x10;
sprintf(run_cmd,"emmc open 0");
run_command(run_cmd, 0);
sprintf(run_cmd,"mmc read 0 %lx %lx %lx",CFG_PHY_KERNEL_BASE,start_blk,blkcnt);
run_command(run_cmd, 0);
switch mmc to normal paritition
sprintf(run_cmd,"emmc close 0");
run_command(run_cmd, 0);
return 0;
}
int board_late_init (void)
{
int boot_dev =0 ;
char boot_cmd[100];
boot_dev = chk_bootdev();
if(!boot_dev)
{
printf("Checking Boot Mode ... EMMC4.41");
}
return 0;
}
#endif
添加相關(guān)命令
$ cp cmd_movi.c common/
$ cp cmd_mmc.c common/
$ cp cmd_mmc_fdisk.c common/
修改common/Makefile在
COBJS-$(CONFIG_CMD_M(jìn)MC) += cmd_mmc.o
后添加
COBJS-$(CONFIG_CMD_M(jìn)MC) += cmd_mmc_fdisk.o
COBJS-$(CONFIG_CMD_M(jìn)OVINAND) += cmd_movi.o
添加驅(qū)動
$ cp mmc.c drivers/mmc/
$ cp s5p_mshc.c drivers/mmc/
$ cp mmc.h include/
$ cp movi.h include/
$ cp s5p_mshc.h include/
修改Makefile
$vim drivers/mmc/Makefile
請輸入評論內(nèi)容...
請輸入評論/評論長度6~500個字
最新活動更多
-
11月20日火熱報名中>> 2024 智能家居出海論壇
-
11月28日立即報名>>> 2024工程師系列—工業(yè)電子技術(shù)在線會議
-
12月19日立即報名>> 【線下會議】OFweek 2024(第九屆)物聯(lián)網(wǎng)產(chǎn)業(yè)大會
-
即日-12.26火熱報名中>> OFweek2024中國智造CIO在線峰會
-
即日-2025.8.1立即下載>> 《2024智能制造產(chǎn)業(yè)高端化、智能化、綠色化發(fā)展藍(lán)皮書》
-
精彩回顧立即查看>> 【在線會議】多物理場仿真助跑新能源汽車
推薦專題
- 1 從“AI四小龍”看“六小虎”,大模型獨角獸難破盈利困局
- 2 腦機(jī)接口芯片,華為出了新專利!
- 3 大語言模型會不會成為即將破碎的AI泡沫?
- 4 格創(chuàng)東智入選IDC權(quán)威報告,AI創(chuàng)新成果多領(lǐng)域領(lǐng)先
- 5 高管輪崗機(jī)制,給百度帶來了什么?
- 6 今年諾獎對人工智能的重視,給我們的基礎(chǔ)教育提了個醒
- 7 銀行業(yè)AI大模型,從入局到求變
- 8 巨頭搶布局,VC狂撒錢,為了能讓「AI讀心」這些公司卷瘋了
- 9 阿斯麥ASML:“骨折級”洋相,又成AI第一殺手?
- 10 蘋果市值創(chuàng)新高,iPhone 16能否助力突破4萬億美元大關(guān)?
- 高級軟件工程師 廣東省/深圳市
- 自動化高級工程師 廣東省/深圳市
- 光器件研發(fā)工程師 福建省/福州市
- 銷售總監(jiān)(光器件) 北京市/海淀區(qū)
- 激光器高級銷售經(jīng)理 上海市/虹口區(qū)
- 光器件物理工程師 北京市/海淀區(qū)
- 激光研發(fā)工程師 北京市/昌平區(qū)
- 技術(shù)專家 廣東省/江門市
- 封裝工程師 北京市/海淀區(qū)
- 結(jié)構(gòu)工程師 廣東省/深圳市