U-boot(七):U-boot移植
????????本文主要探讨基于210官方U-boot源码移植。
移植基础
tar -jxvf android_uboot_smdkv210.tar.bz2
cd u-boot-samsung-dev
rm -rf onenand_ipl onenand_bl1 lib_avr32 lib_blackfin lib_i386 lib_m68k lib_mips lib_microblaze lib_nios lib_nios2 lib_ppc lib_sh lib_sparc
cd board
ls|grep -v 'samsung'|xargs -I {} rm -rf {}
cd samsung
ls|grep smdk|grep -v '110'|xargs -I {} rm -rf {}
cd u-boot-samsung-dev/cpu
ls |grep -v 's5pc11x'|xargs -I {} rm -rf {}
cd ../include
rm -rf asm-avr32、asm-blackfin、asm-i386、asm-m68k、asm-sh、asm-microblaze、asm-mips、asm-nios、asm-nios2、asm-ppc、asm-sparc
cd asm-arm
ls|grep 'arch-'|grep -v 's5pc11x'|xargs -I {} rm -rf {}
cd include/configs
ls |grep -v 'smdkv210'|xargs -I {} rm -rf {}
cd u-boot-samsung-dev
vim mk
#!/bin/sh
make distclean
make smdkv210single_config
make -j4
chmod +x mk
vim Makfile
CROSS_COMPILE = /root/arm-2009q3/bin/arm-none-linux-gnueabi-
make smdkv210single_config ==> include/configs/smdkv210single.h
./mk
????????uboot移植异常,供电锁存正常,串口异常,分析low_level_init.S得到210的uboot无使用PMIC,注释PMIC初始化,编译移植
/* init PMIC chip */
//not use PMIC in 210 uboot
//bl PMIC_InitIp
编译移植结果:
修改行提示符(smdkv210single.h)
//#define CFG_PROMPT ? ? ? ? ? ? ?"SMDKV210 # " ? /* Monitor Command Prompt ? ? ? */
#define CFG_PROMPT ? ? ? ? ? ? ?"root # " ? /* Monitor Command Prompt ? ? ? */
修改uboot串口(默认串口2,无需修改,smdkv210single.h)
#define CONFIG_SERIAL3 ? ? ? ? ?1 ? ? ? /* we use UART2 on SMDKC110 */
????????s5pv110.h依据smdkv210single.h中的串口宏开关,定义出串口2配置寄存器基地址,再依据偏移地址定义初始化串口配置
#if defined(CONFIG_SERIAL1)
#define ELFIN_UART_CONSOLE_BASE (ELFIN_UART_BASE + ELFIN_UART0_OFFSET)
#elif defined(CONFIG_SERIAL2)
#define ELFIN_UART_CONSOLE_BASE (ELFIN_UART_BASE + ELFIN_UART1_OFFSET)
#elif defined(CONFIG_SERIAL3)
#define ELFIN_UART_CONSOLE_BASE (ELFIN_UART_BASE + ELFIN_UART2_OFFSET)
#elif defined(CONFIG_SERIAL4)
#define ELFIN_UART_CONSOLE_BASE (ELFIN_UART_BASE + ELFIN_UART3_OFFSET)
#else
#define ELFIN_UART_CONSOLE_BASE (ELFIN_UART_BASE + ELFIN_UART0_OFFSET)
#endif
?修改默认网络配置(smdkv210single.h)
/*#define CONFIG_BOOTARGS ? ? ? "root=ramfs devfs=mount console=ttySA0,9600" */
#define CONFIG_ETHADDR ? ? ? ? ?00:40:5c:26:0a:5b
#define CONFIG_NETMASK ? ? ? ? ?255.255.255.0
#define CONFIG_IPADDR ? ? ? ? ? 192.168.100.27
#define CONFIG_SERVERIP ? ? ? ? 192.168.100.100
#define CONFIG_GATEWAYIP ? ? ? ?192.168.100.1
????????iNand已有环境变量则需清除,重启后才会首先使用代码中的环境变量
????????
uboot:
mmc write 0 30000000 11# 32
????????将DDR的0x30000000开头一段内存内容写入iNand的17扇区开始的32个扇区内(写入长度16KB)
DDR移植
????????DDR时钟
????????????????lowlevel_init.S中system_clock_init函数依据smdkv210single.h的宏开关对所有时钟做初始化(包含DDR,DDR时钟宏开关)
smdkv210single.h
/*-----------------------------------------------------------------------
?* Stack sizes
?*
?* The stack sizes are set up in start.S using the settings below
?*/
#define CONFIG_STACKSIZE?? ?0x40000?? ??? ?/* regular stack 256KB */
#ifdef CONFIG_USE_IRQ
#define CONFIG_STACKSIZE_IRQ?? ?(4*1024)?? ?/* IRQ stack */
#define CONFIG_STACKSIZE_FIQ?? ?(4*1024)?? ?/* FIQ stack */
#endif
//#define CONFIG_CLK_667_166_166_133
//#define CONFIG_CLK_533_133_100_100
//#define CONFIG_CLK_800_200_166_133
//#define CONFIG_CLK_800_100_166_133
#define CONFIG_CLK_1000_200_166_133
//#define CONFIG_CLK_400_200_166_133
//#define CONFIG_CLK_400_100_166_133
????????DDR配置
DRAM: ? ? 1 GB
DRAM bank ? = 0x00000000
-> start ? ?= 0x20000000
-> size ? ? = 0x20000000
DRAM bank ? = 0x00000001
-> start ? ?= 0x40000000
-> size ? ? = 0x20000000
DRAM大小和DRAM bank 0/1 的起始地址和大小有误,修改显示为:
DRAM: ? ? 512MB
DRAM bank ? = 0x00000000
-> start ? ?= 0x30000000
-> size ? ? = 0x10000000
DRAM bank ? = 0x00000001
-> start ? ?= 0x40000000
-> size ? ? = 0x10000000
????????????????修改DMC起始地址和大小(smdkv210single.h)
#define MEMORY_BASE_ADDRESS ? ? 0x30000000
#define CONFIG_NR_DRAM_BANKS ? ?2 ? ? ? ? ?/* we have 2 bank of DRAM */
//#define SDRAM_BANK_SIZE ? ? ? 0x20000000 ? ?/* 512 MB */
#define SDRAM_BANK_SIZE ? ? ? ? 0x10000000 ? ?/* 256 MB */
#define PHYS_SDRAM_1 ? ? ? ? ? ?MEMORY_BASE_ADDRESS /* SDRAM Bank #1 */
#define PHYS_SDRAM_1_SIZE ? ? ? SDRAM_BANK_SIZE
//#define PHYS_SDRAM_2 ? ? ? ? ?(MEMORY_BASE_ADDRESS + SDRAM_BANK_SIZE) /* SDRAM Bank #2 */
#define PHYS_SDRAM_2 ? ? ? ? ? ?0x40000000 /* SDRAM Bank #2 */
#define PHYS_SDRAM_2_SIZE ? ? ? SDRAM_BANK_SIZE
????????????????????????DMC0的起始地址修改需修改寄存器配置
#if defined(CONFIG_MCP_SINGLE)
//#define DMC0_MEMCONFIG_0 ? ? ?0x20E01323 ? ? ?// MemConfig0 ? 256MB config, 8 banks,Mapping Method[12:15]0:linear, 1:linterleaved, 2:Mixed
#define DMC0_MEMCONFIG_0 ? ? ? ?0x30F01323 ? ? ?// MemConfig0 ? 256MB config, 8 banks,Mapping Method[12:15]0:linear, 1:linterleaved, 2:Mixed
#define DMC0_MEMCONFIG_1 ? ? ? ?0x40F01323 ? ? ?// MemConfig1
#define DMC0_TIMINGA_REF ? ? ? ?0x00000618 ? ? ?// TimingAref ? 7.8us*133MHz=1038(0x40E), 100MHz=780(0x30C), 20MHz=156(0x9C), 10MHz=78(0x4E)
#define DMC0_TIMING_ROW ? ? ? ? 0x28233287 ? ? ?// TimingRow ? ?for @200MHz
#define DMC0_TIMING_DATA ? ? ? ?0x23240304 ? ? ?// TimingData ? CL=3
#define DMC0_TIMING_PWR ? ? ? ? 0x09C80232 ? ? ?// TimingPower
#define DMC1_MEMCONTROL ? ? ? ? 0x00202400 ? ? ?// MemControl ? BL=4, 2 chip, DDR2 type, dynamic self refresh, force precharge, dynamic power down off
#define DMC1_MEMCONFIG_0 ? ? ? ?0x40C01323 ? ? ?// MemConfig0 ? 512MB config, 8 banks,Mapping Method[12:15]0:linear, 1:linterleaved, 2:Mixed
#define DMC1_MEMCONFIG_1 ? ? ? ?0x00E01323 ? ? ?// MemConfig1
#define DMC1_TIMINGA_REF ? ? ? ?0x00000618 ? ? ?// TimingAref ? 7.8us*133MHz=1038(0x40E), 100MHz=780(0x30C), 20MHz=156(0x9C), 10MHz=78(0x4
#define DMC1_TIMING_ROW ? ? ? ? 0x28233289 ? ? ?// TimingRow ? ?for @200MHz
#define DMC1_TIMING_DATA ? ? ? ?0x23240304 ? ? ?// TimingData ? CL=3
#define DMC1_TIMING_PWR ? ? ? ? 0x08280232 ? ? ?// TimingPower
????????修改MMU内存映射
? ? ? ? ? ? ? ? 210的uboot做了MMU映射,故修改完DMC0的起始地址需要修改它对应的地址映射
修改(start.S):
? ? //.set __base,0x200
? ? ? ? .set __base,0x300
? ? ? ? // 256MB for SDRAM with cacheable
依据(start.S):
/* Set the TTB register */
?? ?ldr?? ?r0, _mmu_table_base
?? ?ldr?? ?r1, =CFG_PHY_UBOOT_BASE
?? ?ldr?? ?r2, =0xfff00000
?? ?bic?? ?r0, r0, r2
?? ?orr?? ?r1, r0, r1
?? ?mcr?? ?p15, 0, r1, c2, c0, 0
修改(smdkc110.c):
#ifdef CONFIG_MCP_SINGLE
ulong virt_to_phy_smdkc110(ulong addr)
{
? ? ? ? if ((0xc0000000 <= addr) && (addr < 0xd0000000))
? ? ? ? ? ? ? ? //return (addr - 0xc0000000 + 0x20000000);
? ? ? ? ? ? ? ? return (addr - 0xc0000000 + 0x30000000);
? ? ? ? else
? ? ? ? ? ? ? ? printf("The input address don't need "\
? ? ? ? ? ? ? ? ? ? ? ? "a virtual-to-physical translation : %08lx\n", addr);
? ? ? ? return addr;
}
#else
ulong virt_to_phy_smdkc110(ulong addr)
{
? ? ? ? if ((0xc0000000 <= addr) && (addr < 0xd0000000))
? ? ? ? ? ? ? ? return (addr - 0xc0000000 + 0x30000000);
? ? ? ? else if ((0x30000000 <= addr) && (addr < 0x50000000))
? ? ? ? ? ? ? ? return addr;
? ? ? ? else
? ? ? ? ? ? ? ? printf("The input address don't need "\
? ? ? ? ? ? ? ? ? ? ? ? "a virtual-to-physical translation : %08lx\n", addr);
? ? ? ? return addr;
}
#endif
依据(smdkv210single.h):
?? ?#define CONFIG_ENABLE_MMU
?? ?#ifdef CONFIG_ENABLE_MMU
?? ?#define virt_to_phys(x)?? ?virt_to_phy_smdkc110(x)
?? ?#else
?? ?#define virt_to_phys(x)?? ?(x)
?? ?#endif
? ? ? ? 其他异常
SD/MMC: ?unrecognised EXT_CSD structure version 7
unrecognised EXT_CSD structure version 7
Card init fail!
修改SD/MMC的大小,显示为
SD/MMC: ?3776MB
? ? ? ? ? ? ? ? 该异常是由于mmc驱动代码不支持该版本号的inand,修改mmc.c中对SD/mmc版本号的判别(inand为高版本sd卡)
? ext_csd_struct = ext_csd[EXT_CSD_REV];
? ? ? ? //if (ext_csd_struct > 5) {
? ? ? ? if (ext_csd_struct > 8) {
? ? ? ? ? ? ? ? printf("unrecognised EXT_CSD structure "
? ? ? ? ? ? ? ? ? ? ? ? "version %d\n", ext_csd_struct);
? ? ? ? ? ? ? ? err = -1;
? ? ? ? ? ? ? ? goto out;
? ? ? ? }
网卡驱动移植
????????DM9000基础
????????SoC的SROM bank和网卡芯片的CS引脚连接,主机SoC访问SROM bank地址来访问网卡芯片内部寄存器
????????网卡芯片内部寄存器使用相对地址访问,从00开始网卡芯片寄存器地址:SROM bank起始地址+网卡芯片内部寄存器相对地址
????????主机SoC访问网卡芯片是总线式访问(IO与内存统一编址),无内置网卡控制器而Nand/SD接口需要时序来访问
????????210的SROM控制器是8/16bit接口,实际使用16位接口,网线有8根,4根都是GND,发送2根(Tx-,Tx+),接收2根(Rx+,Rx-)
????????网卡芯片CS引脚(片选信号),210每个SROM bank对应选信号CSn(n=0-5),210的DM9000接在CSn1(SROM bank1),DM9000总线地址基地址是0x88000000
????????DM9000的CMD引脚接210的ADDR2引脚,数据线和地址线复用,CMD为高电平传输DATA,低电平传输INDEX(偏移地址)
????????socket接口和网络mingling(ping,tftp...)是对网卡驱动的封装实现的
?????????DM9000移植(/drivers/net/dm9000x.c,dm9000x.h)
? ? ? ? 网卡硬件配置
? ? ? ? 网卡基地址:SROMC_BANK1(0x88000000) + 0x300(网卡芯片内部偏移(自带))
? ? ? ? 网卡命令地址(CMD,DM9000_DATA):? 网卡基地址 + 4,由于使用ADDR2(0b100)
/*
* Hardware drivers
*/
#define DM9000_16BIT_DATA
#define CONFIG_DRIVER_DM9000 1
#ifdef CONFIG_DRIVER_DM9000
#define CONFIG_DM9000_BASE (0x88000300)
#define DM9000_IO (CONFIG_DM9000_BASE)
#if defined(DM9000_16BIT_DATA)
#define DM9000_DATA (CONFIG_DM9000_BASE+4)
#else
#define DM9000_DATA (CONFIG_DM9000_BASE+1)
#endif
#endif
????????????????网卡初始化在uboot二阶段init_sequences中进行网卡芯片初始化(board_init->dm9000_pre_init,软件初始化)
? ? ? ? ? ? ? ? 设置CSn1(16位数据线,DATA线和SD线号对应:1)
? ? ? ? ? ? ? ? 设置SROM_BC1?
? ? ? ? ? ? ? ? 设置GPIO?
?
/*
* Miscellaneous platform dependent initialisations
*/
static void dm9000_pre_init(void)
{
unsigned int tmp;
#if defined(DM9000_16BIT_DATA)
//SROM_BW_REG &= ~(0xf << 20);
//SROM_BW_REG |= (0<<23) | (0<<22) | (0<<21) | (1<<20);
SROM_BW_REG &= ~(0xf << 4);
SROM_BW_REG |= (1<<7) | (1<<6) | (1<<5) | (1<<4);
#else
SROM_BW_REG &= ~(0xf << 20);
SROM_BW_REG |= (0<<19) | (0<<18) | (0<<16);
#endif
//SROM_BC5_REG = ((0<<28)|(1<<24)|(5<<16)|(1<<12)|(4<<8)|(6<<4)|(0<<0));
SROM_BC1_REG = ((0<<28)|(1<<24)|(5<<16)|(1<<12)|(4<<8)|(6<<4)|(0<<0));
tmp = MP01CON_REG;
tmp &=~(0xf<<20);
tmp |=(2<<20);
MP01CON_REG = tmp;
}
s5pv110.h
#define ELFIN_SROM_BASE 0xE8000000
#define SROM_BW_REG __REG(ELFIN_SROM_BASE+0x0)
#define SROM_BC1_REG __REG(ELFIN_SROM_BASE+0x8)
#define ELFIN_GPIO_BASE 0xE0200000
#define MP01CON_OFFSET 0x2E0
#define MP01CON_REG __REG(ELFIN_GPIO_BASE + MP01CON_OFFSET)
重新编译,移植uboot,启动内核
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!