S3C2440之uboot移植

虚拟机环境:Oracle VM VirtualBox
Linux系统:ubuntu_14.04.6
交叉编译工具:[100ask分享的所有文件](https://eyun.baidu.com/s/3b1UtLc)
100ask分享的所有文件 > 002_JZ2440资料光盘_20180516(免费) > 资料光盘 > A盘 > tools.zip > arm-linux-gcc-4.3.2.tar.bz2
gcc-3.4.5-glibc-2.3.6/bin
make distclean && make smdk2410_config && make
make distclean && make jz2440_config && make

移植u-boot到JZ2440_V3开发板
1.获取并解压u-boot:
tar -jxvf u-boot-1.1.6.tar.bz2 -C S3C2440

2.在顶层Makefile中增加交叉编译工具路径
grep arm-linux -r ./

/CROSS_COMPILE

ARM_LINUX_XXX=/home/xlbtlmy/Desktop/ARM_Linux/gcc-3.4.5-glibc-2.3.6/bin

CROSS_COMPILE = arm-linux-

CROSS_COMPILE = $(ARM_LINUX_XXX)/arm-linux-

此时可以编译smdk2410
make smdk2410_config
make
make clean
make distclean

3.在顶层Makefile中增加如下两行:
/smdk2410_config
jz2440_config   :   unconfig                                  
	@$(MKCONFIG) $(@:_config=) arm arm920t jz2440 NULL s3c24x0

4.在include/config增加jz2440.h头文件
cd include/configs/
cp smdk2410.h jz2440.h

5.在board增加jz2440文件夹
board/
cp -r smdk2410/ jz2440

此时直接可以编译jz2440
make jz2440_config
make
make clean
make distclean

6.在board/jz2440/中修改:
mv smdk2410.c jz2440.c

7.在board/jz2440/Makefile中修改:
OBJS   := smdk2410.o flash.o -> OBJS   := jz2440.o flash.o

8.在include文件夹下增加:
cp s3c2410.h s3c2440.h

9.修改include/s3c2440.h:
#ifndef __S3C2410_H__
#define __S3C2410_H__

#ifndef __S3C2440_H__
#define __S3C2440_H__

10.修改board/jz2440/jz2440.c:
#include <s3c2410.h>

#include <s3c2440.h>

/* --- */
grep CONFIG_SMDK2410 -r ./
./README:		CONFIG_SMDK2400,	CONFIG_SMDK2410,	CONFIG_TRAB,
./include/configs/jz2440.h:#define CONFIG_SMDK2410		1	/* on a SAMSUNG SMDK2410 Board  */
./include/configs/smdk2410.h:#define CONFIG_SMDK2410		1	/* on a SAMSUNG SMDK2410 Board  */
./cpu/arm920t/s3c24x0/interrupts.c:      defined(CONFIG_SMDK2410) || \

grep CONFIG_S3C2410 -r ./
./include/configs/VCMA9.h:#define	CONFIG_S3C2410		1	/* in a SAMSUNG S3C2410 SoC     */
./include/configs/jz2440.h:#define	CONFIG_S3C2410		1	/* in a SAMSUNG S3C2410 SoC     */
./include/configs/smdk2410.h:#define	CONFIG_S3C2410		1	/* in a SAMSUNG S3C2410 SoC     */
./include/configs/sbc2410x.h:#define	CONFIG_S3C2410		1	/* in a SAMSUNG S3C2410 SoC     */
./include/common.h:#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_LH7A40X)
./include/s3c24x0.h:#ifdef CONFIG_S3C2410
./include/s3c24x0.h:#ifdef CONFIG_S3C2410
./include/s3c24x0.h:#ifdef CONFIG_S3C2410
./include/s3c24x0.h:#ifdef CONFIG_S3C2410
./include/s3c24x0.h:#ifdef CONFIG_S3C2410
./include/s3c24x0.h:#ifdef CONFIG_S3C2410
./cpu/arm920t/s3c24x0/speed.c:#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB)
./cpu/arm920t/s3c24x0/speed.c:#elif defined(CONFIG_S3C2410)
./cpu/arm920t/s3c24x0/speed.c:#endif /* defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB) */
./cpu/arm920t/s3c24x0/i2c.c:#elif defined(CONFIG_S3C2410)
./cpu/arm920t/s3c24x0/i2c.c:#ifdef CONFIG_S3C2410
./cpu/arm920t/s3c24x0/i2c.c:#ifdef CONFIG_S3C2410
./cpu/arm920t/s3c24x0/i2c.c:#ifdef CONFIG_S3C2410
./cpu/arm920t/s3c24x0/i2c.c:#ifdef CONFIG_S3C2410
./cpu/arm920t/s3c24x0/i2c.c:#ifdef CONFIG_S3C2410
./cpu/arm920t/s3c24x0/usb_ohci.c:#elif defined(CONFIG_S3C2410)
./cpu/arm920t/s3c24x0/interrupts.c:#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB)
./cpu/arm920t/s3c24x0/interrupts.c:#elif defined(CONFIG_S3C2410)
./cpu/arm920t/s3c24x0/interrupts.c:#endif /* defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB) */
./cpu/arm920t/s3c24x0/serial.c:#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB)
./cpu/arm920t/s3c24x0/serial.c:#elif defined(CONFIG_S3C2410)
./cpu/arm920t/s3c24x0/serial.c:#endif /* defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB) */
./cpu/arm920t/start.S:#elif defined(CONFIG_S3C2410)
./cpu/arm920t/start.S:#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)
./cpu/arm920t/start.S:# if defined(CONFIG_S3C2410)
./cpu/arm920t/start.S:#endif	/* CONFIG_S3C2400 || CONFIG_S3C2410 */
./rtc/s3c24x0_rtc.c:#elif defined(CONFIG_S3C2410)

11.在include/s3c24x0.h修改:
#ifdef CONFIG_S3C2410

#if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)

12.在include/common.h中修改:
#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_LH7A40X)

#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440) || defined(CONFIG_LH7A40X)

13.在cpu/arm920t/s3c24x0/文件夹下修改:
|| defined (CONFIG_S3C2440)
#elif defined(CONFIG_S3C2440)
#include <s3c2440.h>
speed.c:
i2c.c:
usb_ohci.c
interrupts.c
serial.c

14.在cpu/arm920t/start.S中修改:

15.在rtc/s3c24x0_rtc.c中修改:

16.在interrupt.c中增加:
defined(CONFIG_SMDK2410) || \
defined(CONFIG_JZ2440)   || \

17.在include/configs/jz2440.h中修改:
#define CONFIG_ARM920T      1   /* This is an ARM920T Core  */
#define CONFIG_S3C2410      1   /* in a SAMSUNG S3C2410 SoC     */                                                                                        
#define CONFIG_SMDK2410     1   /* on a SAMSUNG SMDK2410 Board  */

#define CONFIG_ARM920T      1   /* This is an ARM920T Core  */
#define CONFIG_S3C2440      1   /* in a SAMSUNG S3C2440 SoC     */                                                                                        
#define CONFIG_JZ2440       1   /* on a SAMSUNG JZ2440 Board  */
1.修改board/jz2440/lowlevel_init.S:
#define REFCNT          1113    /* period=15.6us, HCLK=60Mhz, (2048+1-15.6*60) */

#define REFCNT          0x4f4    /* period=7.8125us, HCLK=100Mhz, (2048+1-7.8125*100) */

2.修改include/asm-arm/mach-types.h:
grep MACH_TYPE_SMDK2410 -r ./

#define MACH_TYPE_SMDK2410             193

#define MACH_TYPE_JZ2440               1939

3.修改board/jz2440/jz2440.c中的board_init函数:
#define S3C2440_MPLL_400MHZ ((0x5c<<12)|(0x01<<4)|(0x01))
#define S3C2440_UPLL_48MHZ  ((0x38<<12)|(0x02<<4)|(0x02))
#define S3C2440_CLKDIV      0x05

#define S3C2410_MPLL_200MHZ ((0x5c<<12)|(0x04<<4)|(0x00))
#define S3C2410_UPLL_48MHZ  ((0x28<<12)|(0x01<<4)|(0x02))
#define S3C2410_CLKDIV      0x03

int board_init (void)
{
	S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
	S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
	
	/* set up the I/O ports */
	gpio->GPACON=0x007FFFFF;
	gpio->GPBCON=0x00044555;
	gpio->GPBUP =0x000007FF;
	gpio->GPCCON=0xAAAAAAAA;
	gpio->GPCUP =0x0000FFFF;
	gpio->GPDCON=0XAAAAAAAA;
	gpio->GPDUP =0x0000FFFF;
	gpio->GPECON=0xAAAAAAAA;
	gpio->GPEUP =0X0000FFFF;
	gpio->GPFCON=0x000055AA;
	gpio->GPFUP =0x000000FF;
	gpio->GPGCON=0xFF95FFBA;
	gpio->GPGUP =0x0000FFFF;
	gpio->GPHCON=0x002AFAAA;
	gpio->GPHUP =0x000007FF;
	
	if((gpio->GSTATUS1 == 0x32410000) || (gpio->GSTATUS1 == 0x32410002)) {
		clk_power->CLKDIVN = S3C2410_CLKDIV;
		
		__asm__(
			"mrc p15, 0, r1, c1, c0, 0\n"
			"orr r1, r1, #0xc0000000\n"
			"mcr p15, 0, r1, c1, c0, 0\n"
			:::"r1"
			);
		
		/* to reduce PLL lock time, adjust the LOCKTIME register */
		clk_power->LOCKTIME = 0xFFFFFF;
		
		/* configure MPLL */
		clk_power->MPLLCON = S3C2410_MPLL_200MHZ;
		
		/* some delay between MPLL and UPLL */
		delay(4000);
		
		/* configure UPLL */
		clk_power->UPLLCON = S3C2410_UPLL_48MHZ;
		
		/* some delay between MPLL and UPLL */
		delay(8000);
		
		/* arch number of SMDK2410-Board */
		gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
	} else {
		clk_power->CLKDIVN = S3C2440_CLKDIV;
		
		__asm__(
			"mrc p15, 0, r1, c1, c0, 0\n"
			"orr r1, r1, #0xc0000000\n"
			"mcr p15, 0, r1, c1, c0, 0\n"
			:::"r1"
			);
		
		/* to reduce PLL lock time, adjust the LOCKTIME register */
		clk_power->LOCKTIME = 0xFFFFFF;
		
		/* configure MPLL */
		clk_power->MPLLCON = S3C2440_MPLL_400MHZ;
		
		/* some delay between MPLL and UPLL */
		delay(4000);
		
		/* configure UPLL */
		clk_power->UPLLCON = S3C2440_UPLL_48MHZ;
		
		/* some delay between MPLL and UPLL */
		delay(8000);
		
		/* arch number of JZ2440-Board */
		gd->bd->bi_arch_number = MACH_TYPE_JZ2440;
	}
	
	/* adress of boot parameters */
	gd->bd->bi_boot_params = 0x30000100;
	
	icache_enable();
	dcache_enable();

	return 0;
}

4.修改cpu/arm920t/s3c24x0/speed.c:
DECLARE_GLOBAL_DATA_PTR;

static ulong get_PLLCLK(int pllreg)                      
{                                                        
    S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
    ulong r, m, p, s;                                    
                                                         
    if (pllreg == MPLL)                                  
    r = clk_power->MPLLCON;                              
    else if (pllreg == UPLL)                             
    r = clk_power->UPLLCON;                              
    else                                                 
    hang();                                              
                                                         
    m = ((r & 0xFF000) >> 12) + 8;                       
    p = ((r & 0x003F0) >> 4) + 2;                        
    s = r & 0x3;                                         
                                                         
    if (gd->bd->bi_arch_number == MACH_TYPE_SMDK2410)    
        return((CONFIG_SYS_CLK_FREQ * m) / (p << s));    
    else                                                 
        return((CONFIG_SYS_CLK_FREQ * m * 2) / (p << s));                    
} 

/*for s3c2440*/
#define S3C2440_CLKDIVN_PDIVN       (1<<0)
#define S3C2440_CLKDIVN_HDIVN_MASK  (3<<1)
#define S3C2440_CLKDIVN_HDIVN_1     (0<<1)
#define S3C2440_CLKDIVN_HDIVN_2     (1<<1)
#define S3C2440_CLKDIVN_HDIVN_4_8   (2<<1)
#define S3C2440_CLKDIVN_HDIVN_3_6   (3<<1)
#define S3C2440_CLKDIVN_UCLK        (1<<3)

#define S3C2440_CAMDIVN_CAMCLK_MASK (0xf<<0)
#define S3C2440_CAMDIVN_CAMCLK_SEL  (1<<4)
#define S3C2440_CAMDIVN_HCLK3_HALF  (1<<8)
#define S3C2440_CAMDIVN_HCLK4_HALF  (1<<9)
#define S3C2440_CAMDIVN_DVSEN       (1<<12)

ulong get_HCLK(void)      
{                         
    S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
    unsigned long clkdiv; 
    unsigned long camdiv; 
    int hdiv = 1;         
                          
    if (gd->bd->bi_arch_number == MACH_TYPE_SMDK2410)            
        return((clk_power->CLKDIVN & 0x2) ? get_FCLK()/2 : get_FCLK());
    else                  
    {                     
        clkdiv = clk_power->CLKDIVN;                             
        camdiv = clk_power->CAMDIVN;                             
                          
        switch (clkdiv & S3C2440_CLKDIVN_HDIVN_MASK) {           
        case S3C2440_CLKDIVN_HDIVN_1:                            
            hdiv = 1;     
            break;        
                          
        case S3C2440_CLKDIVN_HDIVN_2:                            
            hdiv = 2;     
            break;        
                          
        case S3C2440_CLKDIVN_HDIVN_4_8:                          
            hdiv = (camdiv & S3C2440_CAMDIVN_HCLK4_HALF) ? 8 : 4;
            break;        
                          
        case S3C2440_CLKDIVN_HDIVN_3_6:                          
            hdiv = (camdiv & S3C2440_CAMDIVN_HCLK3_HALF) ? 6 : 3;
            break;        
        }                 
       
        return get_FCLK() / hdiv;
    }                     
}

/* return PCLK frequency */
ulong get_PCLK(void)
{
    S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
    unsigned long clkdiv;
    unsigned long camdiv;
    int hdiv = 1;
   
    if (gd->bd->bi_arch_number == MACH_TYPE_SMDK2410)
        return((clk_power->CLKDIVN & 0x1) ? get_HCLK()/2 : get_HCLK());
    else
    {
        clkdiv = clk_power->CLKDIVN;
        camdiv = clk_power->CAMDIVN;
   
        switch (clkdiv & S3C2440_CLKDIVN_HDIVN_MASK) {
        case S3C2440_CLKDIVN_HDIVN_1:
            hdiv = 1;
            break;
   
        case S3C2440_CLKDIVN_HDIVN_2:
            hdiv = 2;
            break;
   
        case S3C2440_CLKDIVN_HDIVN_4_8:
            hdiv = (camdiv & S3C2440_CAMDIVN_HCLK4_HALF) ? 8 : 4;
            break;
   
        case S3C2440_CLKDIVN_HDIVN_3_6:
            hdiv = (camdiv & S3C2440_CAMDIVN_HCLK3_HALF) ? 6 : 3;
            break;
        }
       
        return get_FCLK() / hdiv / ((clkdiv & S3C2440_CLKDIVN_PDIVN) ? 2:1);
    }
}

speed.c:113: error: structure has no member named `CAMDIVN'
在include下的s3c24x0.h上的clock&power结构中添加相应名为CAMDIVN的结构变量

5.修改include/s3c24x0.h:
S3C24X0_CLOCK_POWER

#if defined(CONFIG_S3C2440) 
    S3C24X0_REG32   CAMDIVN;                                                                                                                              
#endif

对比100ask24x0

patch -p1 < ../../u-boot-1.1.6_100ask24x0.patch

patching file board/100ask24x0/100ask24x0.c
patching file board/100ask24x0/config.mk
patching file board/100ask24x0/flash.c
patching file board/100ask24x0/lowlevel_init.S
patching file board/100ask24x0/Makefile
patching file board/100ask24x0/u-boot.lds
patching file common/cmd_load.c
patching file common/cmd_nand.c
patching file cpu/arm920t/s3c24x0/Makefile
patching file cpu/arm920t/s3c24x0/nand_flash.c
patching file cpu/arm920t/s3c24x0/speed.c
patching file drivers/nand/nand_base.c
patching file drivers/nand/nand_util.c
patching file include/configs/100ask24x0.h
patching file include/nand.h
patching file include/s3c2410.h
patching file include/s3c24x0.h
patching file Makefile

6.修改include/configs/jz2440.h
6.修改include/configs/jz2440.h
#if 0                            
#define CONFIG_AMD_LV400    1   /* uncomment this if you have a LV400 flash */
#define CONFIG_AMD_LV800    1   /* uncomment this if you have a LV800 flash */
#endif                           
                                 
#define CONFIG_MX29LV160D   1    
                                 
#define CFG_MAX_FLASH_BANKS 1   /* max number of memory banks */
#ifdef CONFIG_AMD_LV800          
#define PHYS_FLASH_SIZE     0x00100000 /* 1MB */
#define CFG_MAX_FLASH_SECT  (19)    /* max number of sectors on one chip */
#define CFG_ENV_ADDR        (CFG_FLASH_BASE + 0x0F0000) /* addr of environment */
#endif                           
#ifdef CONFIG_AMD_LV400          
#define PHYS_FLASH_SIZE     0x00080000 /* 512KB */
#define CFG_MAX_FLASH_SECT  (11)    /* max number of sectors on one chip */
#define CFG_ENV_ADDR        (CFG_FLASH_BASE + 0x070000) /* addr of environment */
#endif                           

#define CFG_FLASH_CFI           1
#define CFG_MONITOR_BASE        0
#define CFG_FLASH_CFI_DRIVER    1
                                 
#if defined CONFIG_MX29LV160D    
#define PHYS_FLASH_SIZE     0x00200000 /* 2MB */ 
#define CFG_MAX_FLASH_SECT  (35)    /* max number of sectors on one chip */ 
#define CFG_ENV_ADDR        (CFG_FLASH_BASE + 0x1F0000) /* addr of environment */ 
#endif

7.修改board/jz2440/Makefile:
COBJS := jz2440.o flash.o

COBJS := jz2440.o

至此,uboot从nor flash启动移植成功

虚拟机下USB设备端口还是kermit会有些问题,折腾了两天,参考了好多博客和资料,终于能初步移植u-boot了

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值