uboot源码之时钟和串口修改

在uboot源码中添加单板

首先添加单板相关文件, board目录下将原来的2410复制成2440,在其基础上修改  cp  board/samsung/smdk2410     board/samsung/smdk2440     -rf

添加单板的配置文件,include目录下   复制    cp     include/configs/smdk2410.h         include/configs/smdk2440.h    

修改boards.cfg文件,将smdk2410的配置复制为smdk2440

配置:    make smdk2440_config

编译:    make

 

修改源代码支持启动

    修改时钟

        原来源码中是先设置时钟分频,再设置时钟大小的,这样在设置时钟大小之前有些程序运行就只能在外部12M晶振下运行,所以修改代码,将board_early_init_f函数中的时钟先屏蔽,

        然后修改时钟大小     

int board_early_init_f(void)
{
    struct s3c24x0_clock_power * const clk_power =
                    s3c24x0_get_base_clock_power();
    struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();


    /* to reduce PLL lock time, adjust the LOCKTIME register */
    //writel(0xFFFFFF, &clk_power->locktime);


    /* configure MPLL */
    //writel((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV,
    //      &clk_power->mpllcon);


    /* some delay between MPLL and UPLL */
    pll_delay(4000);


    /* configure UPLL */
    writel((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV,
           &clk_power->upllcon);


    /* some delay between MPLL and UPLL */
    pll_delay(8000);


    /* set up the I/O ports */
    writel(0x007FFFFF, &gpio->gpacon);
    writel(0x00044555, &gpio->gpbcon);
    writel(0x000007FF, &gpio->gpbup);
    writel(0xAAAAAAAA, &gpio->gpccon);
    writel(0x0000FFFF, &gpio->gpcup);
    writel(0xAAAAAAAA, &gpio->gpdcon);
    writel(0x0000FFFF, &gpio->gpdup);
    writel(0xAAAAAAAA, &gpio->gpecon);
    writel(0x0000FFFF, &gpio->gpeup);
    writel(0x000055AA, &gpio->gpfcon);
    writel(0x000000FF, &gpio->gpfup);
    writel(0xFF95FFBA, &gpio->gpgcon);
    writel(0x0000FFFF, &gpio->gpgup);
    writel(0x002AFAAA, &gpio->gphcon);
    writel(0x000007FF, &gpio->gphup);


    return 0;
}

start.s

  


	/*
	 * mask all IRQs by setting all bits in the INTMR - default
	 */
	mov	r1, #0xffffffff
	ldr	r0, =INTMSK
	str	r1, [r0]
# if defined(CONFIG_S3C2410)
	ldr	r1, =0x3ff
	ldr	r0, =INTSUBMSK
	str	r1, [r0]
# endif

#endif
/* 2. 设置时钟 */
	ldr r0, =0x4c000014
	//	mov r1, #0x03;			  // FCLK:HCLK:PCLK=1:2:4, HDIVN=1,PDIVN=1
	mov r1, #0x05;			  // FCLK:HCLK:PCLK=1:4:8
	str r1, [r0]

	/* 如果HDIVN非0,CPU的总线模式应该从“fast bus mode”变为“asynchronous bus mode” */
	mrc p15, 0, r1, c1, c0, 0		/* 读出控制寄存器 */ 
	orr r1, r1, #0xc0000000 		/* 设置为“asynchronous bus mode” */
	mcr p15, 0, r1, c1, c0, 0		/* 写入控制寄存器 */

	#define S3C2440_MPLL_400MHZ     ((0x5c<<12)|(0x01<<4)|(0x01))


	/* MPLLCON = S3C2440_MPLL_200MHZ */
	ldr r0, =0x4c000004
	ldr r1, =S3C2440_MPLL_400MHZ
	str r1, [r0]

	/* 启动ICACHE */
	mrc p15, 0, r0, c1, c0, 0	@ read control reg
	orr r0, r0, #(1<<12)
	mcr p15, 0, r0, c1, c0, 0	@ write it back

 

    修改内存

        smdk2440/lowlevel_init.S        lowlevel_init:

SMRDATA:
        .long 0x22011110     //BWSCON
        .long 0x00000700     //BANKCON0
        .long 0x00000700     //BANKCON1
        .long 0x00000700     //BANKCON2
        .long 0x00000700     //BANKCON3  
        .long 0x00000700     //BANKCON4
        .long 0x00000700     //BANKCON5
        .long 0x00018005     //BANKCON6
        .long 0x00018005     //BANKCON7
        .long 0x008C04F4     // REFRESH
        .long 0x000000B1     //BANKSIZE
        .long 0x00000030     //MRSRB6
        .long 0x00000030     //MRSRB7

 

    这个时候编译是通过的,但是在烧写到板子上会发现串口乱码,只是因为串口波特率的设置的原因

    修改串口波特率        

       arch/arm/cpu/arm920t/s3c24x0/speed.c       get_HCLK 函数中    没有定义CONFIG_S3C2440

       在configs/smdk2440.h中定义 #define  CONFIG_S3C2440

       这个时候编译会提示nand错误

        

s3c2410_nand.c:87: error: dereferencing pointer to incomplete type
s3c2410_nand.c: In function 'board_nand_init':
s3c2410_nand.c:129: warning: initialization makes pointer from integer without a cast
s3c2410_nand.c:150: error: dereferencing pointer to incomplete type
s3c2410_nand.c:153: error: dereferencing pointer to incomplete type
s3c2410_nand.c:154: error: dereferencing pointer to incomplete type

 

       为了先演示前面的修改情况,先屏蔽这一段,在configs/smdk2440.h中注释掉

#define CONFIG_CMD_BSP
#define CONFIG_CMD_CACHE
#define CONFIG_CMD_DATE
#define CONFIG_CMD_DHCP
#define CONFIG_CMD_ELF
//#define CONFIG_CMD_NAND
#define CONFIG_CMD_PING
#define CONFIG_CMD_REGINFO
#define CONFIG_CMD_USB

 

    然后重新make会出现  "nand_info" 错误

fs/yaffs2/libyaffs2.o: In function `yaffs_StartUp':
/home/book/Par_Uboot/mk_uboot/u-boot-2012.04.01/fs/yaffs2/yaffscfg.c:210: undefined reference to `nand_info'
Makefile:472: recipe for target 'u-boot' failed
make: *** [u-boot] Error 1

 

    这个时候再将#define CONFIG_YAFFS2注释掉,然后先make distclean 再重新上传配置和编译

/*
* File system
*/
#define CONFIG_CMD_FAT
#define CONFIG_CMD_EXT2
#define CONFIG_CMD_UBI
#define CONFIG_CMD_UBIFS
#define CONFIG_CMD_MTDPARTS
#define CONFIG_MTD_DEVICE
#define CONFIG_MTD_PARTITIONS
//#define CONFIG_YAFFS2
#define CONFIG_RBTREE

 

重新编译通过之后,通过uboot烧写板子上测试

    usb  1  30000000   打开dnw下载自己编译好的uboot.bin

    protect    off    all        去除写保护

    erase   0  7ffff        擦除512k的内容

    cp.b    30000000    0    80000        在30000000烧写512k的内容

   

   重新上电就可以看到正确的输出了

    

U-Boot 2012.04.01 (Sep 20 2019 - 15:32:58)


CPUID: 32440001
FCLK:  400 MHz
HCLK:  100 MHz
PCLK:   50 MHz
DRAM:  64 MiB
WARNING: Caches not enabled
Flash: *** failed ***
### ERROR ### Please RESET the board ###

 

你可能感兴趣的:(uboot)