• 启动修改TQ2440 uboot2012.10移植一串口正常输出


    最近应用开辟的过程中涌现了一个小问题,顺便记录一下原因和方法--启动修改

        难得五一没排安,闲着无聊,植移u-boot-2012.10到TQ2440,与大家分享。往往植移u-boot或做裸板开辟,有诸多不便,电脑没有并口也没有openjtag,大多数人都望而止步,也不忍心坏破新买板子的系统。我想到一种方法,电脑没有并口,没有openjtag还是能做裸板开辟,也能植移u-boot。一般新买的s3c2440开辟板,出厂前NOR Flash已烧好u-boot,并且支撑NAND、NOR Flash、DM9000等外设。可以这样做,NOR Falsh启动将出厂u-boot也烧到NAND,确保擦除一个还有一个u-boot。裸板开辟时,NOR Flash启动,烧写裸板序程到NAND,再NAND启动试调自己的裸板序程;植移u-boot 时,NOR Flash启动,烧写植移的u-boot到NAND试调,最后试调OK后,再用NOR Flash启动u-boot烧到NOR Flash。言归正传,开始植移u-boot-2012.10

        
    开辟环境:
    系统:ubuntu 10.04.4
    单板:tq2440
    NAND FLASH:K9F1216U0A 256MB
    NOR Flash:AM29LV160A 2MB
    SDRAM:HY57V561620 x2 64MB
    NET:DM9000AEP
    编译器:arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
    搭建开辟环境详见ubuntu 10.04.4开辟环境配置。

        目标:
    1.支撑NOR Flash启动,串口常正输出
    2.支撑NAND启动
    3.支撑DM9000网卡
    4.加添u-boot菜单
    5.u-boot裁剪及制造丁补

     一、取获源代码

        ftp://ftp.denx.de/pub/u-boot/  载下u-boot-2012.10.tar.bz2,解压到工作目录可即。

        取获交叉编译链 http://code.google.com/p/smp-on-qemu/downloads/list  择选arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2并载下。然后在ubuntu下直接解压可即,还要配置环境变量

        sudo gedit  /etc/environment// 修改PATH,在最后再加“:/.../arm-2009q3/bin”,其中“...”是面上arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2解压的径路。接着Log Out ubuntu系统,以可就直接应用交叉编译链。

        二、建新单板

        change@change:~$ cd Si/TQ2440/u-boot-2012.10/
    change@change:~/Si/TQ2440/u-boot-2012.10$ cp board/samsung/smdk2410 board/samsung/TQ2440 -rf
    change@change:~/Si/TQ2440/u-boot-2012.10$ cp include/configs/smdk2410.h include/configs/TQ2440.h
    change@change:~/Si/TQ2440/u-boot-2012.10$ vim boards.cfg

        72:增长如下内容

        TQ2440     arm     arm920t     -      samsung     s3c24x0

        三、配置·、编译

        change@change:~/Si/TQ2440/u-boot-2012.10$ make TQ2440 CROSS_COMPILE=arm-none-linux-gnueabi-

        arm-none-linux-gnueabi-objcopy -O srec u-boot u-boot.srec
    arm-none-linux-gnueabi-objcopy --gap-fill=0xff -O binary u-boot u-boot.bin

        终究生成u-boot.bin文件,但是当初还不能用,须要修改源码支撑单板TQ2440

        四、修改代码,支撑串口常正输出

        1.修改时钟配置

     arch/arm/cpu/arm920t/start.S:170,去掉之前的时钟配置,参考update序程改成自己的代码

     /* FCLK:HCLK:PCLK = 1:2:4 */
     /* default FCLK is 120 MHz ! */
    // ldr r0, =CLKDIVN
    // mov r1, #3
    // str r1, [r0]

        增长如下代码175:

    #define S3C2440_MPLL_400MHZ     ((0x5c<<12)|(0x01<<4)|(0x01))
    /* 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的线总模蔦u0153覾u0160\u017e肻u017d印癴ast bus mode”变成“asynchronous bus mode” */
    	mrc	p15, 0, r1, c1, c0, 0		/* 读出制控\u0152腬u017d嫫?*/ 
    	orr	r1, r1, #0xc0000000			/* 置设为“asynchronous bus mode” */
    	mcr	p15, 0, r1, c1, c0, 0		/* 衆u017d入制控\u0152腬u017d嫫?*/
    
    	/* 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

        2.修改SDRAM置设代码

        样同参考update序程,改成自己的SDRAM初始化序程board/samsung/TQ2440/lowlevel_init.S:154的SMRDATA替换成如下代码:

        每日一道理
    微笑,是春天里的一丝新绿,是秋日里的一缕阳光,是骄阳下的一片浓荫,是冬雪中的一株梅红……微笑着去面对吧,你会感到人生是那样的温馨与甜蜜!
    SMRDATA:
    	.long 0x22011110	 //BWSCON
    	.long 0x00000700	 //BANKCON0
    	.long 0x00000700	 //BANKCON1
    	.long 0x00000700	 //BANKCON2
    	.long 0x00000700	 //BANKCON3  
    	//.long 0x00000700	 //BANKCON4
    	.long 0x00000740	 //BANKCON4
    	.long 0x00000700	 //BANKCON5
    	.long 0x00018005	 //BANKCON6
    	.long 0x00018005	 //BANKCON7
    	.long 0x008C04F4	 // REFRESH
    	.long 0x000000B1	 //BANKSIZE
    	.long 0x00000030	 //MRSRB6
    	.long 0x00000030	 //MRSRB7

        3.修改串口波特率置设

        arch/arm/cpu/arm920t/s3c24x0/speed.c 发明82:get_HCLK(void)里没有定义CONFIG_S3C2440,决解方法如下:

        include/configs/TQ2440.h:38

        //#define CONFIG_S3C2410  /* specifically a SAMSUNG S3C2410 SoC */
    #define CONFIG_S3C2440  /* specifically a SAMSUNG S3C2410 SoC */

        再配置编译看看,有问题也可以时及修改

        change@change:~/Si/TQ2440/u-boot-2012.10$ make TQ2440 CROSS_COMPILE=arm-none-linux-gnueabi-

        s3c2410_nand.c: In function 's3c2410_hwcontrol':
    s3c2410_nand.c:57: warning: implicit declaration of function 's3c2410_get_base_nand'
    s3c2410_nand.c:57: warning: initialization makes pointer from integer without a cast
    s3c2410_nand.c:72: error: dereferencing pointer to incomplete type
    s3c2410_nand.c:72: error: dereferencing pointer to incomplete type
    s3c2410_nand.c:75: error: dereferencing pointer to incomplete type
    s3c2410_nand.c:75: error: dereferencing pointer to incomplete type
    s3c2410_nand.c: In function 's3c2410_dev_ready':
    s3c2410_nand.c:85: warning: initialization makes pointer from integer without a cast
    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
    make[2]: *** [s3c2410_nand.o] Error 1

        果然涌现错误,这样先决解串口问题,把NAND分部蔽屏掉再说drivers/mtd/nand/Makefile:

        COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o      //不定义宏CONFIG_NAND_S3C2410可即

        接着找到include/configs/TQ2440.h:193

        #ifdef CONFIG_CMD_NAND
    #define CONFIG_NAND_S3C2410
    #define CONFIG_SYS_S3C2410_NAND_HWECC
    #define CONFIG_SYS_MAX_NAND_DEVICE 1
    #define CONFIG_SYS_NAND_BASE  0x4E000000
    #endif

        蔽屏CONFIG_CMD_NAND可即,注意去掉2处宏定义,

        include/configs/TQ2440.h:100//#define CONFIG_CMD_NAND
    include/config_cmd_all.j62://#define CONFIG_CMD_NAND  /* NAND support   */

        我也是编译次几,发明nand还是编译进去了报错,修改完继承编译

        change@change:~/Si/TQ2440/u-boot-2012.10$ make TQ2440 CROSS_COMPILE=arm-none-linux-gnueabi-

        yaffs_uboot_glue.c: In function 'cmd_yaffs_devconfig':
    yaffs_uboot_glue.c:181: error: 'CONFIG_SYS_MAX_NAND_DEVICE' undeclared (first use in this function)
    yaffs_uboot_glue.c:181: error: (Each undeclared identifier is reported only once
    yaffs_uboot_glue.c:181: error: for each function it appears in.)
    make[2]: *** [yaffs_uboot_glue.o] Error 1

        直接蔽屏掉yaffs

        include/configs/TQ2440.h:210//#define CONFIG_YAFFS2

        记得编译之前要make distclean下,不然修改没生效,还是报错,就这个小问题,害我重编译好多次。

        change@change:~/Si/TQ2440/u-boot-2012.10$ make distclean

        change@change:~/Si/TQ2440/u-boot-2012.10$ make TQ2440 CROSS_COMPILE=arm-none-linux-gnueabi-

        arm-none-linux-gnueabi-objcopy -O srec u-boot u-boot.srec
    arm-none-linux-gnueabi-objcopy --gap-fill=0xff -O binary u-boot u-boot.bin

        终究编译通过,此时生成的u-boot.bin,烧进NOR Flash,串口输出常正。下一阶段植移u-boot支撑NAND启动。

    文章结束给大家分享下程序员的一些笑话语录: 古鸽是一种搜索隐禽,在中国快绝迹了…初步的研究表明,古鸽的离去,很可能导致另一种长着熊爪,酷似古鸽,却又习性不同的猛禽类——犤毒鸟

  • 相关阅读:
    urlencode 和 rawurlencode 的区别
    magic_quotes_gpc
    变量的值是多少
    git diff patch
    drupal前端开发的第一点
    git drupal eclipse
    spm总结
    features block
    alu features menu
    git reset 理解
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3053078.html
Copyright © 2020-2023  润新知