第一次移植uboot(1) .

第一次移植uboot,因此把移植步骤记录下来:

/*2010.11.17--2010.11.18*/
/*u-boot-1.1.4中smdk2410到fl2440(s3c2440)移植*/
交叉编绎工具:cross-3.3.2.tar.bz2
默认当前目录为:u-boot-1.1.4
要修改的文件:(1)examples/Makefile (2)Makefile (3)board/fl2440
(4)board/fl2440/fl2440.c (5)board/fl2440/Makefile
(6)include/configs/fl2440.h (7)cpu/arm920t/start.S
(8)include/configs/fl2440.h (8)include/s3c24x0.h
(9)include/s3c2440.h (10)cpu/arm920t/s3c24x0/interrupts.c
(11)cpu/arm920t/s3c24x0/speed.c (12)cpu/arm920t/s3c24x0/serial.c
(13)board/fl2440/fl2440.c (14)cpu/arm920t/s3c24x0/speed.c
(15)include/s3c24x0.h

 

1. 修改examples/Makefile
   126 %.srec:% -> %.srec:%.o
   129 %.bin:%  -> %.bin:%.o
   不修改的话smdk2410编绎不通过
2. Makefile下依照smdk2410_config添加:
   fl2440_config :
        @./mkconfig $(@:_config=) arm arm920t fl2440 NULL s3c24x0
3. cp -r board/smdk2410 board/fl2440
4. mv board/fl2440/smdk2410.c board/fl2440/fl2440.c
5. 修改board/fl2440/Makefile第28行:
   OBJS    := smdk2410.o flash.o -> OBJS    := fl2440.o flash.o
6. cp include/configs/smdk2410.h include/configs/fl2440.h

   到此fl2440可以编译通过

7. 修改cpu/arm920t/start.S
   <1>128行(# define CLKDIVN        0x4C000014)后加:

  1. /*129*/#elif defined(CONFIG_S3C2440)  
  2. # define pWTCON         0x53000000   
  3. # define INTMSK         0x4A000008   
  4. # define INTSUBMSK      0x4A00001C         
  5. # define CLKDIVN        0x4C000014         
  6. # define NFCONF         0x4E000000   
  7. # define NFCONT         0x4E000004   
  8. # define NFCMD          0x4E000008   
  9. # define NFADDR         0x4E00000C   
  10. # define NFDATA         0x4E000010   
  11. # define NFSTAT         0x4E000020   
  12. /*140*/# define NF_SECTOR_SIZE 2048  
 
   <2>修改143行为:
#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
   <3>158行(# endif)后加:

  1. /*159*/if defined(CONFIG_S3C2440)  
  2.  ldr     r1, =0x7ff  
  3.  ldr     r0, =INTSUBMSK  
  4.  str     r1, [r0]  
  5. /*163*/# endif  
 
   <4>169行(str     r1, [r0])后加:

  1. /*170*/if defined(CONFIG_S3C2440)  
  2.  ldr     r0, =CLKDIVN  
  3.  mov     r1, #5  
  4.  str     r1, [r0]  
  5. /*174*/#endif  
 
   <5>因为从NAND FLASH(k9f2g08u0a)起动uboot,所以197行到201行(即

copy_loop循环)改为:

  1. /*197*/#if defined(CONFIG_S3C2440)  
  2.  mov     r7, r0  
  3.  ldr     r3, =NFCONF  
  4.  mov     r4, #0x300  
  5.  str     r4, [r3]                /*NFCONF =0x300 */  
  6.  ldr     r3, =NFCONT  
  7.  mov     r4, #0x11  
  8.  str     r4, [r3]                /*NFCONT = (1<<4)|(0<<1)|(1<<0)*/  
  9.  ldr     r3, =NFCMD  
  10.  mov     r4, #0xff  
  11.  str     r4, [r3]                /*reset nand flash:NFCMD = 0xff*/  
  12. wait1:  
  13.  ldr     r5, =NFSTAT  
  14.  ldr     r4, [r5]  
  15.  tst     r4, #1  
  16.  beq     wait1  
  17. copy_loop:  
  18.   /*read nand flash*/  
  19.  ldr     r3, =NFCMD  
  20.  mov     r4, #0x00  
  21.  str     r4, [r3]                /*write_cmd(0x00)*/  
  22.    
  23.  ldr     r5, =NFADDR             /*write addr r0*/  
  24.  and     r4, r0, #0xff  
  25.  str     r4, [r5]  
  26.  mov     r4, r0, lsr#8  
  27.  and     r4, r4, #0x0f  
  28.  str     r4, [r5]  
  29.  mov     r4, r0, lsr#12  
  30.  and     r4, r4, #0xff  
  31.  str     r4, [r5]  
  32.  mov     r4, r0, lsr#20  
  33.  and     r4, r4, #0xff  
  34.  str     r4, [r5]  
  35.  mov     r4, r0, lsr#28  
  36.  and     r4, r4, #0x01  
  37.  str     r4, [r5]  
  38.   
  39.  mov     r4, #0x30  
  40.  str     r4, [r3]                /*write_cmd(0x30)*/  
  41.    
  42.  ldr     r3, =NFSTAT             /*wait_idle()*/  
  43. wait0:  
  44.  ldr     r4, [r3]  
  45.  tst     r4, #1  
  46.  beq     wait0  
  47.    
  48.  /*start read data*/  
  49.  ldr     r3, =NF_SECTOR_SIZE  
  50.  mov     r4, #0  
  51.  ldr     r5, =NFDATA  
  52. copy1sector:  
  53.  ldr     r6, [r5]  
  54.  str     r6, [r1]  
  55.  add     r0, r0, #4  
  56.  add     r1, r1, #4  
  57.  add     r4, r4, #4  
  58.  add     r7, r7, #4  
  59.  cmp     r4, r3  
  60.  bcc     copy1sector  
  61.  add     r0, r0, #2048  
  62.  cmp     r7, r2  
  63.  ble     copy_loop  
  64.  ldr     r0, =NFCONT  
  65.  ldr     r1, [r0]  
  66.  orr     r1, r1, #0x2  
  67.  str     r1, [r0]  
  68. #elif defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)   
  69. copy_loop:  
  70.         ldmia   r0!, {r3-r10}           /* copy from source address [r0]    */  
  71.         stmia   r1!, {r3-r10}           /* copy to   target address [r1]    */  
  72.         cmp     r0, r2                  /* until source end addreee [r2]    */  
  73.         ble     copy_loop  
  74. /*270*/#endif/*CONFIG_S3C2440*/  
 
   start.S修改完

8. 修改include/configs/fl2440.h
   <1>37行#define CONFIG_S3C2410          1
      改为:#define CONFIG_S3C2440          1

   此时编译fl2440,报错board_init函数中S3C24X0_GPIO未定义

9. 修改include/s3c24x0.h
   453行(#endif)后加:

  1. #ifdef CONFIG_S3C2440   
  2.  S3C24X0_REG32 GPACON;  
  3.  S3C24X0_REG32 GPADAT;  
  4.  S3C24X0_REG32 res1[2];  
  5.  S3C24X0_REG32 GPBCON;  
  6.  S3C24X0_REG32 GPBDAT;  
  7.  S3C24X0_REG32 GPBUP;  
  8.  S3C24X0_REG32 res2;  
  9.  S3C24X0_REG32 GPCCON;  
  10.  S3C24X0_REG32 GPCDAT;  
  11.  S3C24X0_REG32 GPCUP;  
  12.  S3C24X0_REG32 res3;  
  13.  S3C24X0_REG32 GPDCON;  
  14.  S3C24X0_REG32 GPDDA1T;  
  15.  S3C24X0_REG32 GPDUP;  
  16.  S3C24X0_REG32 res4;  
  17.  S3C24X0_REG32 GPECON;  
  18.  S3C24X0_REG32 GPEDAT;  
  19.  S3C24X0_REG32 GPEUP;  
  20.  S3C24X0_REG32 res5;  
  21.  S3C24X0_REG32 GPFCON;  
  22.  S3C24X0_REG32 GPFDAT;  
  23.  S3C24X0_REG32 GPFUP;  
  24.  S3C24X0_REG32 res6;  
  25.  S3C24X0_REG32 GPGCON;  
  26.  S3C24X0_REG32 GPGDAT;  
  27.  S3C24X0_REG32 GPGUP;  
  28.  S3C24X0_REG32 res7;  
  29.  S3C24X0_REG32 GPHCON;  
  30.  S3C24X0_REG32 GPHDAT;  
  31.  S3C24X0_REG32 GPHUP;  
  32.  S3C24X0_REG32 res8;  
  33.   
  34.  S3C24X0_REG32 MISCCR;  
  35.  S3C24X0_REG32 DCLKCON;  
  36.  S3C24X0_REG32 EXTINT0;  
  37.  S3C24X0_REG32 EXTINT1;  
  38.  S3C24X0_REG32 EXTINT2;  
  39.  S3C24X0_REG32 EINTFLT0;  
  40.  S3C24X0_REG32 EINTFLT1;  
  41.  S3C24X0_REG32 EINTFLT2;  
  42.  S3C24X0_REG32 EINTFLT3;  
  43.  S3C24X0_REG32 EINTMASK;  
  44.  S3C24X0_REG32 EINTPEND;  
  45.  S3C24X0_REG32 GSTATUS0;  
  46.  S3C24X0_REG32 GSTATUS1;  
  47.  S3C24X0_REG32 GSTATUS2;  
  48.  S3C24X0_REG32 GSTATUS3;  
  49.  S3C24X0_REG32 GSTATUS4;  
  50.   
  51.  S3C24X0_REG32 res9[3];  
  52.  S3C24X0_REG32 MSLCON;  
  53.  S3C24X0_REG32 GPJCON;  
  54.  S3C24X0_REG32 GPJDAT;  
  55.  S3C24X0_REG32 GPJUP;  
  56. #endif  
 
   此时编译fl2440,报错s3c24x0_rtc.c中SetRTC_Access函数中S3C24X0_RTC未定

9. cp include/s3c2410.h include/s3c2440.h
   <1>修改include/s3c2440.h
      31行:#ifndef __S3C2410_H__
      改为:#ifndef __S3C2440_H__
      32行:#define __S3C2410_H__
      改为:#define __S3C2440_H__
   <2>修改rtc/s3c24x0_rtc.c
      36行(#include <s3c2410.h>)后加:
#elif defined(CONFIG_S3C2440)
#include <s3c2440.h>

   此时编译fl2440,报错:u-boot-1.1.4/cpu/arm920t/interrupts.c:80: undefined reference to `reset_cpu'

10. 修改cpu/arm920t/s3c24x0/interrupts.c
   <1>33行(#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB))
      改为:#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB) || defined(CONFIG_S3C2440)
   <2>39行(#include <s3c2410.h>)后加:
#elif defined(CONFIG_S3C2440)
#include <s3c2440.h>

    此时编译fl2440,报错:u-boot-1.1.4/cpu/arm920t/s3c24x0/interrupts.c:71: undefined reference to

`get_PCLK'

11. 修改cpu/arm920t/s3c24x0/speed.c
    <1>33行(#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB))
      改为:#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB) || defined(CONFIG_S3C2440)
    <2>38行(#include <s3c2410.h>)后加:
#elif defined(CONFIG_S3C2440)
#include <s3c2440.h>

    此时编译fl2440,报错:u-boot-1.1.4/lib_arm/board.c:79: undefined reference to `serial_init'

12. 修改cpu/arm920t/s3c24x0/serial.c
    <1>22行(#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB))
      改为:#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB) || defined(CONFIG_S3C2440)
    <2>27行(#include <s3c2410.h>)后加:
#elif defined(CONFIG_S3C2440)
#include <s3c2440.h>

    此时编译fl2440成功!
    此时用H-FLASHER把u-boot.bin烧入NAND FLASH程序可运行,但因时钟问题串

口输出乱码!
  
13. 修改board/fl2440/fl2440.c
    <1>33行(#define FCLK_SPEED 1)改为:
#define FCLK_SPEED 2
    <2>42行(#define M_SDIV  0x1)后加:
#elif FCLK_SPEED==2             /* Fout = 400MHz */
#define M_MDIV  0x5c
#define M_PDIV  0x1
#define M_SDIV  0x1
    <3>49行(#define USB_CLOCK 1)改为:
#define USB_CLOCK 2
    <4>58行(#define U_M_SDIV        0x2)后加:
#elif USB_CLOCK==2
#define U_M_MDIV        0x38
#define U_M_PDIV        0x2
#define U_M_SDIV        0x2

14. 修改cpu/arm920t/s3c24x0/speed.c
   <1>72行(return((CONFIG_SYS_CLK_FREQ * m) / (p << s));)改为:

  1. #if defined(CONFIG_S3C2440)   
  2.     return((CONFIG_SYS_CLK_FREQ * m * 2) / (p << s));  
  3. #elif defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)   
  4.     return((CONFIG_SYS_CLK_FREQ * m) / (p << s));  
  5. #endif  
 
   <2>90行(return((clk_power->CLKDIVN & 0x2) ? get_FCLK()/2 : get_FCLK

());)改为:

  1. #if defined(CONFIG_S3C2440)   
  2. #define S3C2440_CLKDIVN_HDIVN_MASK      (3<<1)   
  3. #define S3C2440_CLKDIVN_HDIVN_1         (0<<1)   
  4. #define S3C2440_CLKDIVN_HDIVN_2         (1<<1)   
  5. #define S3C2440_CLKDIVN_HDIVN_4_8       (2<<1)   
  6. #define S3C2440_CLKDIVN_HDIVN_3_6       (3<<1)   
  7. #define S3C2440_CAMDIVN_HCLK4_HALF      (1<<9)   
  8. #define S3C2440_CAMDIVN_HCLK3_HALF      (1<<8)   
  9.   
  10. unsigned long clkdiv;  
  11. unsigned long camdiv;  
  12. int hdiv = 1;  
  13.   
  14. clkdiv = clk_power->CLKDIVN;  
  15. camdiv = clk_power->CAMDIVN;  
  16.   
  17. switch(clkdiv & S3C2440_CLKDIVN_HDIVN_MASK)  
  18. {  
  19.     case S3C2440_CLKDIVN_HDIVN_1:  
  20.        hdiv = 1;  
  21.        break;  
  22.     case S3C2440_CLKDIVN_HDIVN_2:  
  23.        hdiv = 2;  
  24.        break;  
  25.     case S3C2440_CLKDIVN_HDIVN_4_8:  
  26.        hdiv = (camdiv & S3C2440_CAMDIVN_HCLK4_HALF) ? 8 : 4;  
  27.        break;  
  28.     case S3C2440_CLKDIVN_HDIVN_3_6:  
  29.        hdiv = (camdiv & S3C2440_CAMDIVN_HCLK3_HALF) ? 6 : 3;  
  30.        break;  
  31.     default:  
  32.        break;  
  33. }  
  34.     return get_FCLK() / hdiv;  
  35. #elif defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)   
  36.     return((clk_power->CLKDIVN & 0x2) ? get_FCLK()/2 : get_FCLK());  
  37. #endif  

15. 修改include/s3c24x0.h中S3C24X0_CLOCK_POWER结构体为:
   typedef struct {
        S3C24X0_REG32   LOCKTIME;
        S3C24X0_REG32   MPLLCON;
        S3C24X0_REG32   UPLLCON;
        S3C24X0_REG32   CLKCON;
        S3C24X0_REG32   CLKSLOW;
        S3C24X0_REG32   CLKDIVN;
#ifdef CONFIG_S3C2440
        S3C24X0_REG32   CAMDIVN;
#endif
} /*__attribute__((__packed__))*/ S3C24X0_CLOCK_POWER;

   此时编译运行uboot,串口即可正常输出并显示!
   (修改include/configs/fl2440.h中宏#define CFG_PROMPT "SMDK2410 # "为

#define CFG_PROMPT "FL2440 # ")

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值