newtelcom 发表于 2010-02-15 10:22

u-boot-2009.08移植到micro2440(128MB)笔记(3)


6.       include
\asm-arm\arch-s3c24x0\mmc.h    --- 添加
       S3C2410 MMC register definitions

\asm-arm\arch-s3c24x0\regs-sdi.h--- 添加
S3C2410 SDIO register definitions

\configs\mini2440.h             --- 添加
       这个配置文件非常重要,需要详细了解,和开发板相关的全部配置几乎都在这里了。

\linux\mtd\mtd.h
      
struct mtd_info {
   u_char type;
   u_int32_t flags;
   uint64_t size;          /* Total size of the MTD */

   /* "Major" erase size for the device. Naïve users may take this
      * to be the only erase size available, or may use the more detailed
      * information below if they desire
      */
   u_int32_t erasesize;
   /* Minimal writable flash unit size. In case of NOR flash it is 1 (even
      * though individual bits can be cleared), in case of NAND flash it is
      * one NAND page (or half, or one-fourths of it), in case of ECC-ed NOR
      * it is of ECC block size, etc. It is illegal to have writesize = 0.
      * Any driver registering a struct mtd_info must ensure a writesize of
      * 1 or larger.
      */
   u_int32_t writesize;

#if defined(ENABLE_CMD_NAND_YAFFS)
            /*Thanks for hugerat's code*/
   u_char rw_oob;
   u_char skipfirstblk;
#endif
                …
}

common.h
         #if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || \
         defined(CONFIG_LH7A40X) || defined(CONFIG_S3C6400) || defined(CONFIG_S3C2440)

mmc.h
       这个文件中的mmc_cid,mmc_csd的定义不使用了,
新的定义在include\asm-arm\arch-s3c24x0\mmc.h文件中。

#if 0
struct mmc_cid {
         unsigned long psn;
         unsigned short oid;
         unsigned char mid;
         unsigned char prv;
         unsigned char mdt;
         char pnm;
};

struct mmc_csd
{
         u8      csd_structure:2,
                  spec_vers:4,
                   rsvd1:2;
         u8      taac;
         u8      nsac;
         u8      tran_speed;
         u16    ccc:12,
                   read_bl_len:4;
         u64    read_bl_partial:1,
                   write_blk_misalign:1,
                   read_blk_misalign:1,
                   dsr_imp:1,
                   rsvd2:2,
                   c_size:12,
                   vdd_r_curr_min:3,
                   vdd_r_curr_max:3,
                   vdd_w_curr_min:3,
                   vdd_w_curr_max:3,
                   c_size_mult:3,
                   sector_size:5,
                   erase_grp_size:5,
                   wp_grp_size:5,
                   wp_grp_enable:1,
                   default_ecc:2,
                   r2w_factor:3,
                   write_bl_len:4,
                   write_bl_partial:1,
                   rsvd3:5;
         u8      file_format_grp:1,
                   copy:1,
                   perm_write_protect:1,
                   tmp_write_protect:1,
                   file_format:2,
                   ecc:2;
         u8      crc:7;
         u8      one:1;
};
#endif

       //int mmc_init(struct mmc *mmc);
//int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size);
int mmc_init(int verbose);
int mmc_read(ulong src, uchar *dst, int size);

part.h
       #define IF_TYPE_SDHC            9

s3c24x0.h
       主要是s3c2440的nand寄存器控制和s3c2410不同,usb寄存器也不一样,然后s3c2440多了一个GPIO口。
         typedef struct {
         S3C24X0_REG32   LOCKTIME;
         S3C24X0_REG32   MPLLCON;
         S3C24X0_REG32   UPLLCON;
         S3C24X0_REG32   CLKCON;
         S3C24X0_REG32   CLKSLOW;
         S3C24X0_REG32   CLKDIVN;
#if defined (CONFIG_S3C2440)
         S3C24X0_REG32 CAMDIVN;
#endif
}


#if defined(CONFIG_S3C2410)
/* NAND FLASH (see S3C2410 manual chapter 6) */
typedef struct {
         S3C24X0_REG32   NFCONF;
         S3C24X0_REG32   NFCMD;
         S3C24X0_REG32   NFADDR;
         S3C24X0_REG32   NFDATA;
         S3C24X0_REG32   NFSTAT;
         S3C24X0_REG32   NFECC;
} /*__attribute__((__packed__))*/ S3C2410_NAND;
#endif
#if defined (CONFIG_S3C2440)
/* NAND FLASH (see S3C2440 manual chapter 6) */
typedef struct {
         S3C24X0_REG32 NFCONF;
         S3C24X0_REG32 NFCONT;
         S3C24X0_REG32 NFCMD;
         S3C24X0_REG32 NFADDR;
         S3C24X0_REG32 NFDATA;
         S3C24X0_REG32   NFMECCD0;
         S3C24X0_REG32   NFMECCD1;
         S3C24X0_REG32   NFSECCD;
         S3C24X0_REG32   NFSTAT;
         S3C24X0_REG32   NFESTAT0;
         S3C24X0_REG32   NFESTAT1;
         S3C24X0_REG32   NFMECC0;
         S3C24X0_REG32   NFMECC1;
         S3C24X0_REG32   NFSECC;
         S3C24X0_REG32   NFSBLK;
         S3C24X0_REG32   NFEBLK;
} /*__attribute__((__packed__))*/ S3C2410_NAND;
#endif

typedef struct {
#ifdef __BIG_ENDIAN
         S3C24X0_REG8   res1;
         S3C24X0_REG8   FUNC_ADDR_REG;
         S3C24X0_REG8   res2;
         S3C24X0_REG8   PWR_REG;
         S3C24X0_REG8   res3;
         S3C24X0_REG8   EP_INT_REG;
         S3C24X0_REG8   res4;
         S3C24X0_REG8   USB_INT_REG;
         S3C24X0_REG8   res5;
         S3C24X0_REG8   EP_INT_EN_REG;
         S3C24X0_REG8   res6;
         S3C24X0_REG8   USB_INT_EN_REG;
         S3C24X0_REG8   res7;
         S3C24X0_REG8   FRAME_NUM1_REG;
         S3C24X0_REG8   res8;
         S3C24X0_REG8   FRAME_NUM2_REG;
         S3C24X0_REG8   res9;
         S3C24X0_REG8   INDEX_REG;
         S3C24X0_REG8   res10;
         S3C24X0_REG8   MAXP_REG;
         S3C24X0_REG8   res11;
         S3C24X0_REG8   EP0_CSR_IN_CSR1_REG;
         S3C24X0_REG8   res12;
         S3C24X0_REG8   IN_CSR2_REG;
         S3C24X0_REG8   res13;
         S3C24X0_REG8   OUT_CSR1_REG;
         S3C24X0_REG8   res14;
         S3C24X0_REG8   OUT_CSR2_REG;
         S3C24X0_REG8   res15;
         S3C24X0_REG8   OUT_FIFO_CNT1_REG;
         S3C24X0_REG8   res16;
         S3C24X0_REG8   OUT_FIFO_CNT2_REG;
#else /*little endian */
         S3C24X0_REG8   FUNC_ADDR_REG;
         S3C24X0_REG8   res1;
         S3C24X0_REG8   PWR_REG;
         S3C24X0_REG8   res2;
         S3C24X0_REG8   EP_INT_REG;
         S3C24X0_REG8   res3;
         S3C24X0_REG8   USB_INT_REG;
         S3C24X0_REG8   res4;
         S3C24X0_REG8   EP_INT_EN_REG;
         S3C24X0_REG8   res5;
         S3C24X0_REG8   USB_INT_EN_REG;
         S3C24X0_REG8   res6;
         S3C24X0_REG8   FRAME_NUM1_REG;
         S3C24X0_REG8   res7;
         S3C24X0_REG8   FRAME_NUM2_REG;
         S3C24X0_REG8   res8;
         S3C24X0_REG8   INDEX_REG;
         S3C24X0_REG8   res9;
         S3C24X0_REG8   MAXP_REG;
         S3C24X0_REG8   res10;
         S3C24X0_REG8   EP0_CSR_IN_CSR1_REG;
         S3C24X0_REG8   res11;
         S3C24X0_REG8   IN_CSR2_REG;
         S3C24X0_REG8   res12;
         S3C24X0_REG8   OUT_CSR1_REG;
         S3C24X0_REG8   res13;
         S3C24X0_REG8   OUT_CSR2_REG;
         S3C24X0_REG8   res14;
         S3C24X0_REG8   OUT_FIFO_CNT1_REG;
         S3C24X0_REG8   res15;
         S3C24X0_REG8   OUT_FIFO_CNT2_REG;
         S3C24X0_REG8   res16;
#endif /*__BIG_ENDIAN */
//       S3C24X0_USB_DEV_FIFOS      fifo;
//       S3C24X0_USB_DEV_DMAS   dma;
         S3C24X0_REG32   res17;
         S3C24X0_USB_DEV_FIFOS   fifo;
         S3C24X0_REG32   res18;
         S3C24X0_USB_DEV_DMAS    ep1;
         S3C24X0_USB_DEV_DMAS    ep2;
         S3C24X0_REG8    res19;
         S3C24X0_USB_DEV_DMAS    ep3;
         S3C24X0_USB_DEV_DMAS    ep4;
} /*__attribute__((__packed__))*/ S3C24X0_USB_DEVICE;


       ….
#if defined (CONFIG_S3C2440)
         S3C24X0_REG32   res9;
         S3C24X0_REG32   MSLCON;
         S3C24X0_REG32   GPJCON;
         S3C24X0_REG32   GPJDAT;
         S3C24X0_REG32   GPJUP;

#endif
#endif
} /*__attribute__((__packed__))*/ S3C24X0_GPIO;



#if defined(CONFIG_S3C2410)
#if 0
#ifdef __BIG_ENDIAN
         S3C24X0_REG8   res;
         S3C24X0_REG8   SDIDAT;
#else
         S3C24X0_REG8   SDIDAT;
         S3C24X0_REG8   res;
#endif
#endif
         S3C24X0_REG32   SDIDAT;
         S3C24X0_REG32   SDIIMSK;
#elif defined(CONFIG_S3C2440)
         S3C24X0_REG32   SDIIMSK;
         S3C24X0_REG32   SDIDAT;
#endif

s3c2410.h
       s3c2440和s3c2410几乎相同,但是s3c2440多了CAM和AC97接口,所以配置是通用的。
#define BIT_CAM                     (0x1
#define BIT_BAT_FLT               (0x1
#define BIT_TICK                     (0x1
#define BIT_WDT                     (0x1
#define BIT_WDT_AC97         (0x1

serial.h
         #if defined(CONFIG_S3C2410) ||defined(CONFIG_S3C2440)


7.       lib_arm
board.c
         #include 3c2410.h>    //tekkamanninja


static int display_banner (void)
{
#if defined(CONFIG_MINI2440_LED)   
                   S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
                   gpio->GPBDAT = 0x101; //tekkamanninja
#endif

         printf ("\n\n%s\n\n", version_string);      
         printf (" modified by tekkamanninja (tekkamanninja@163.com)\n");
         printf (" Love Linux forever!!\n\n");
         debug ("U-Boot code: %08lX -> %08lXBSS: -> %08lX\n",
                _armboot_start, _bss_start, _bss_end);
#ifdef CONFIG_MODEM_SUPPORT
         debug ("Modem Support enabled\n");
#endif
#ifdef CONFIG_USE_IRQ
         debug ("IRQ Stack: %08lx\n", IRQ_STACK_START);
         debug ("FIQ Stack: %08lx\n", FIQ_STACK_START);
#endif

         return (0);
}



void start_armboot (void)
{
   init_fnc_t **init_fnc_ptr;
   char *s;
#if defined(CONFIG_VFD) || defined(CONFIG_LCD)
   unsigned long addr;
#endif
#if defined(CONFIG_MINI2440_LED)      
            S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
#endif


#if defined(CONFIG_MINI2440_LED)      
            gpio->GPBDAT = 0x0; //tekkamanninja
   #endif

#if defined(CONFIG_CFB_CONSOLE)      
   printf ("%s\n", version_string);
   printf ("modified by tekkamanninja\n(tekkamanninja@163.com)\n");
   printf ("Love Linux forever!!\n");
#endif

   /* main_loop() can return to retry autoboot, if so just run it again. */
   for (;;) {
            main_loop ();
   }

   /* NOTREACHED - no way out of command loop except booting */
}

8.       net
bootp.c
         //#define TIMEOUT                   5000UL
         #define TIMEOUT            (5000UL*CONFIG_SYS_HZ/1000)
         /* Milliseconds before trying BOOTP again */
其实应该是CONFIG_SYS_HZ刚好配置为1000,
         //bp->bp_secs = htons(get_timer(0) / 1000);
         bp->bp_secs = htons(get_timer(0) / CONFIG_SYS_HZ);
还有一处:
       //bp->bp_secs = htons(get_timer(0) / 1000);
         bp->bp_secs = htons(get_timer(0) / CONFIG_SYS_HZ);

      
bootp.h
         // #define SELECT_TIMEOUT 3000UL /* Milliseconds to wait for offers */
          #define SELECT_TIMEOUT (CONFIG_SYS_HZ/1000*3000UL)/* Milliseconds to wait for offers */

net.c
         # define ARP_TIMEOUT            (CONFIG_SYS_HZ/1000*5000UL)       /* Milliseconds before trying ARP again */
       多处:
       NetSetTimeout (10000UL*CONFIG_SYS_HZ/1000, startAgainTimeout);

nfs.c

#define NFS_TIMEOUT (CONFIG_SYS_HZ/1000*2000UL)

static int
nfs_umountall_reply (uchar *pkt, unsigned len)
{
         struct rpc_t rpc_pkt;

         debug("%s\n", __func__);

         memcpy ((unsigned char *)&rpc_pkt, pkt, len);

         if ((ntohl(rpc_pkt.u.reply.id)+1) != rpc_id)
                   return -1;

         if (rpc_pkt.u.reply.rstatus||
             rpc_pkt.u.reply.verifier ||
             rpc_pkt.u.reply.astatus) {
                   return -1;
         }

         fs_mounted = 0;
         memset (dirfh, 0, sizeof(dirfh));

         return 0;
}

rarp.c
#define TIMEOUT            (5000UL*CONFIG_SYS_HZ/1000)

sntp.c
       #define SNTP_TIMEOUT (10000UL*CONFIG_SYS_HZ/1000)
tftp.c
         //#define TIMEOUT                   5000UL               /* Millisecs to timeout for lost pkt */
         #define TIMEOUT            (60000UL)

9.       Makefile
设置交叉编译工具,CROSS_COMPILE,tekkamanninja用的是arm-9tdmi-linux-gnu-,我用的是arm-linux-gcc-4.3.2

CROSS_COMPILE =arm-9tdmi-linux-gnu-

__LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD))修改为
__LIBS := $(subst $(obj),,$(LIBBOARD)) $(subst $(obj),,$(LIBS)),
似乎没有什么区别。

10.   最终修改Makefile中的CROSS_COMPILE =arm-linux-
总结一下,实际需要修改的文件,蓝色表示只需要添加|| defined(CONFIG_S3C2440)的文件:
目录
状态
涉及的文件
board
添加
添加 \tekkamanninja
添加 \tekkamanninja\mini2440
common
修改
cmd_load.c
cmd_mem.c
cmd_mmc.c
cmd_nand.c
serial.c
cpu
修改|添加
\arm920t\s3c24x0\interrupts.c
\arm920t\s3c24x0\Makefile
\arm920t\s3c24x0\mmc.c--- 添加
\arm920t\s3c24x0\speed.c
\arm920t\s3c24x0\timer.c
\arm920t\s3c24x0\usb.c
\arm920t\s3c24x0\usb_ohci.c
\arm920t\config.mk
\arm920t\start.S
drivers
修改|添加
\i2c\s3c24x0_i2c.c
\mtd\nand\nand_base.c
\mtd\nand\nand_util.c
\mtd\nand\s3c2410_nand.c
\net\dm9000x.c
\rtc\s3c24x0_rtc.c
\serial\serial_s3c24x0.c
\usb\host\ohci-hcd.c
\vedio\cfb_console.c
\vedio\Makefile
\vedio\s3c2410_fb.c--- 添加
\vedio\videomodes.c
\vedio\videomodes.h
include
修改|添加
\asm-arm\arch-s3c24x0\mmc.h    --- 添加
\asm-arm\arch-s3c24x0\regs-sdi.h--- 添加
\configs\mini2440.h             --- 添加
\linux\mtd\mtd.h
common.h
mmc.h
part.h
s3c24x0.h
s3c2410.h
serial.h
lib_arm
修改
board.c
net
修改
nfs.c
根目录
修改
Makefile

移植过程中重要的宏定义
总结一下,最重要的几个宏定义,这些配置都在mini2440.h中设置。
CONFIG_S3C2440
非常重要
CONFIG_MINI2440
主要是针对mini2440开发板,配置LED
ENABLE_CMD_NAND_YAFFS
增加对Yaffs文件系统的支持,
ENABLE_CMD_NAND_YAFFS_SKIPFB
ENABLE_CMD_LOADB_X
增加的U-boot命令
CONFIG_CMD_MMC
给SD卡使用的
CONFIG_MINI2440_LED
调试用,非必须的
CONFIG_SYS_HZ
方便调整频率,非必须的,实际上原始代码按照1000来配置的,但是这里为了精确,tekkamanninja采用了下面的方法来计算。
/* the PWM TImer 4 uses a counter of 15625 for 10 ms, so we need */
/* it to wrap 100 times (total 1562500) to get 1 sec. */
#defineCONFIG_SYS_HZ 1562500

总结一下:CONFIG_S3C2410 和CONFIG_S3C2440,只要在CONFIG_S3C2410出现的地方,几乎都有CONFIG_S3C2440,搜索整个路径,得到:


http://blogimg.chinaunix.net/blog/upfile2/100215101523.jpg

排除include\configs目录下的文件,剩下:
http://blogimg.chinaunix.net/blog/upfile2/100215101553.jpg


其中的有些文件只需要简单的在出现CONFIG_S3C2410后面加上CONFIG_S3C2440即可。



本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/111832/showart_2181984.html
页: [1]
查看完整版本: u-boot-2009.08移植到micro2440(128MB)笔记(3)