基于u-boot for tiny210 ver1.0(by liukun321咕唧咕唧):
smart210移植u-boot记录第一版:
<一>从SD卡启动,基本功能实现
从原理图上看出,smart210的DDR2全部挂载在DRAM0区域,而且是由四块K4T1G084QF组成,共512M,在memorycontrol的配置上,对210 的内存配在/include/configs/smart210.h 中实现。
/* Smart210 has 4 bank of DRAM */
#define CONFIG_NR_DRAM_BANKS 1 /*DRAM only 1*/
#define SDRAM_BANK_SIZE 0x20000000 /* 512 MB */
#define PHYS_SDRAM_1 MEMORY_BASE_ADDRESS
#define PHYS_SDRAM_1_SIZE SDRAM_BANK_SIZE
从datasheet上来看,DRAM0的BASE_ADDRESS为0x2000_0000,大小为0x2000_0000
所以有
#define CONFIG_SYS_SDRAM_BASE 0x20000000
#define CONFIG_SYS_TEXT_BASE 0x23E00000
#define MEMORY_BASE_ADDRESS CONFIG_SYS_SDRAM_BASE
由于smart210的DRAM是由四片DDR2组成1 chip ,查看datasheet中DRAM控制器部分可知
#define DMC0_MEMCONTROL 0x00202400 // 根据datasheet配置MemControl寄存器//MemControl BL=4, 1Chip, DDR2 Type, dynamic self refresh, force precharge, dynamic power down off
#define DMC0_MEMCONFIG_0 0x20E00323 //根据datasheet配置MemConfig0寄存器
// MemConfig0 256MB config, 8 banks,Mapping Method[12:15]0:linear, 1:linterleaved, 2:Mixed
其中chip_mask = 0xF8对应的偏移地址为0x0000_0000---0x07FF_FFFF的原理是:0xF8==1111.1000 各位取反可得
0x07==0000.0111 而DMC0的基地址为0x2000_0000偏移地址为:0x0000_0000---0x1FFF_FFFF所以这里chip_mask的值为0xE0
#define DMC0_MEMCONFIG_1 0x00E00323 // MemConfig1
另外启动在初始化RAM时会读取ram的大小,函数在/board/samsug/smart210/smart210.c 实现,需要作如下修改:
+187:#if defined(PHYS_SDRAM_2)
188 :gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
189 : gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2, \
190: PHYS_SDRAM_2_SIZE);
+191:#endif
添加smart210目标板:
1、修改uboot源码根目录 boards.cfg 文件,183行添加:
smart210 arm armv7 smart210 samsung s5pc1xx
2、cp board/samsung/mini210 board/samsung/smart210
3、将board/samsung/tiny210 下的tiny210 替换为 smart210,并将此目录下的Makefile的29行修改为
COBJS := smart210.o ; 再将此目录下 lowlevel_init.S 第35行修改为#include &quot; smart210_val.h&quot;。
4、cp include/configs/tiny210.h include/configs/ smart210.h
5、vim include/configs/smart210.h
修改:
#define CONFIG_TINY210 ----> #define CONFIG_Smart210
#define MACH_TYPE_ TINY210 -----> #define MACH_TYPE_Smart210
#define CONFIG_MACH_TYPE MACH_TYPE_TINY210 -----> #define CONFIG_MACH_TYPE MACH_TYPE_Smart210
#define MACH_TYPE_TINY210 2456 -----> #define MACH_TYPE_SMART210 2456
<二>添加网络功能
smart210的网卡芯片是DM9000,DM9000一般u-boot都一起移植好了驱动,只需手动添加进去就好,根据原来图来看
1.在include/configs/smart210.h 添加下述宏
/* DM9000 网卡配置*/
#define DM9000_16BIT_DATA //从原理图上看,DM9000的数据宽度为16
#define CONFIG_CMD_NET
#define CONFIG_DRIVER_DM9000 1
#define CONFIG_NET_MULTI 1
#define CONFIG_NET_RETRY_COUNT 1
#define CONFIG_DM9000_NO_SROM 1
#ifdef CONFIG_DRIVER_DM9000
#define CONFIG_DM9000_BASE (0x88001000) //DM9000的片选引脚选择的是Xm0CSn1,而Xm0CSn1是SROMC_BANK1的片选线,查datasheet可知,SROMC_BANK1的基地址为0x88001000
#define DM9000_IO (CONFIG_DM9000_BASE)
#if defined(DM9000_16BIT_DATA)
#define DM9000_DATA (CONFIG_DM9000_BASE+0x300C)
#else
#define DM9000_DATA (CONFIG_DM9000_BASE+1)
#endif
#endif
#define CFG_PHY_UBOOT_BASE MEMORY_BASE_ADDRESS+Ox3E00000
#define CFG_PHY_KERNEL_BASE MEMORY_BASE_ADDRESS+0x8000
#define CONFIG_ETHADDR 00:40:5c:26:0a:5b
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_IPADDR 10.0.0.10
#define CONFIG_SERVERIP 10.0.0.19
#define CONFIG_GATEWAYIP 10.0.0.1
#define CONFIG_CMD_DATE
#define CONFIG_ENV_OVERWRITE
#define CONFIG_OVERWRITE_ETHADDR_ONCE
/* auto complete command 命令TAB键自动补齐*/
#define CONFIG_CMDLINE_EDITING
#define CONFIG_AUTO_COMPLETE
#define CONFIG_SYS_HUSH_PARSER
123行:
#if 0
#undef CONFIG_CMD_NET
#undef CONFIG_CMD_NFS
#endif
2.修改common/cmd_date.c
+32: #if !defined(CONFIG_S5PC100) && !defined(CONFIG_S5PC110) && !defined(CONFIG_S5P6442)
+229:#endif
3.修改 board/samsung/smart210/smart210.c
(1)添加#include <netdev.h>//有int board_eth_init(bd_t *bis)的函数声明
(2)屏蔽掉下面smc9115_pre_init(); 函数的调用
158:
int board_init(void)
{
/* Set Initial global variables */
s5pc110_gpio = (struct s5pc110_gpio *)S5PC110_GPIO_BASE;
// smc9115_pre_init();
pwm_pre_init();
#ifdef CONFIG_DRIVER_DM9000
dm9000_pre_init();
#endif
gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
gd->bd->bi_boot_params = (PHYS_SDRAM_1+0x100);
return 0;
}
(3)243:添加int board_eth_init(bd_t *bis)函数
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_DRIVER_DM9000
rc = dm9000_initialize(bis);
#endif
return rc;
}
(4)修改 115: static void dm9000_pre_init(void) 函数,参考linux内核及datasheet,
可作如下修改.
static void dm9000_pre_init(void)
{
unsigned int tmp;
#if defined(DM9000_16BIT_DATA)
SROM_BW_REG &= ~(0xf << 4);
SROM_BW_REG |= (0x1 << 4);
#else
SROM_BW_REG &= ~(0xf << 20);
SROM_BW_REG |= (0<<19) | (0<<18) | (0<<16);
#endif
SROM_BC1_REG = ((0<<28)|(0<<24)|(5<<16)|(0<<12)|(0<<8)|(0<<4)|(0<<0));
tmp = MP01CON_REG;
tmp &=~(0xf<<4);
tmp |=(2<<4);
MP01CON_REG = tmp;
}
4.修改driver/net/dm9000x.c551:
static void dm9000_get_enetaddr(struct eth_device *dev)
{
#if !defined(CONFIG_DM9000_NO_SROM)
int i;
for (i = 0; i < 3; i++)
dm9000_read_srom_word(i, dev->enetaddr + (2 * i));
#else
if (!eth_getenv_enetaddr(&quot;ethaddr&quot;, dev->enetaddr)) {
printf(&quot;Please set ethaddr!\n&quot;);
}
#endif
}
/****************************************************修 改 完 成***********************************************************************/
编译u-boot
$export PATH=/opt/FriendlyARM/toolschain/4.5.1/bin:$PATH //加入编译工具链接
$make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- smart210_config
$make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- all spl
将u-boot镜像写入SD卡
将SD卡通过读卡器接上电脑(或直接插入笔记本卡槽),通过&quot;cat /proc/partitions&quot;找出SD卡对应的设备,我的设备节点是/dev/sdb.
执行下面的命令
$sudo dd iflag=dsync oflag=dsync if=spl/tiny210-spl.bin of=/dev/sdb seek=1
$sudo dd iflag=dsync oflag=dsync if=u-boot.bin of=/dev/sdb seek=49
将SD卡插入开发板启动,打开超级终端:
启动: |