U-boot移植 (v2012.04.1 S3C2440平台) (五) DM9000驱动支持,yaffs文件系统下载支持

时间:2021-03-05 17:13:10

9  DM9000 网卡驱动支持

u-boot-v2012.04对DM9000网上的支持已经比较完善的,只需要在配置里加上DM9000的编译选项,并在启动时加上DM9000的初始化就行了。

include/configs/micro2440.h:

#define CONFIG_DRIVER_DM9000            1

#define CONFIG_DM9000_BASE            0x20000000

#define DM9000_IO                CONFIG_DM9000_BASE

#define DM9000_DATA                (CONFIG_DM9000_BASE + 4)

#define CONFIG_DM9000_USE_16BIT            1

board/samsung/micro2440/micro2440.c:

#ifdef CONFIG_CMD_NET

int board_eth_init(bd_t *bis)

{

    int rc = 0;

#ifdef CONFIG_CS8900

    rc = cs8900_initialize(0, CONFIG_CS8900_BASE);

#endif

#ifdef CONFIG_DRIVER_DM9000

    rc = dm9000_initialize(bis);

#endif

    return rc;

}

#endif



10  YAFFS 文件系统烧写支持

新版的u-boot对yaffs文件系统的支持已经很完善了,不过要支持烧写yaffs文件系统,还是要进行一些修改。

修改include/configs/micro2440.h:

/*

* File system

*/

#define CONFIG_CMD_FAT

#define CONFIG_CMD_EXT2

#define CONFIG_CMD_UBI

#define CONFIG_CMD_UBIFS

#define CONFIG_CMD_MTDPARTS

#define CONFIG_CMD_NAND_YAFFS

#define CONFIG_MTD_DEVICE


修改common/cmd_nand.c:

#ifdef CONFIG_CMD_NAND_TRIMFFS

        } else if (!strcmp(s, ".trimffs")) {

            if (read) {

                printf("Unknown nand command suffix '%s'\n", s);

                return 1;

            }

            ret = nand_write_skip_bad(nand, off, &rwsize,

                        (u_char *)addr,

                        WITH_DROP_FFS);

#endif

#ifdef CONFIG_CMD_NAND_YAFFS

        } else if (!strcmp(s, ".yaffs")) {

            if (read) {

                printf("Unknown nand command suffix '%s'.\n", s);

                return 1;

            }

            ret = nand_write_skip_bad(nand, off, &rwsize,

                        (u_char *)addr,

                       WITH_YAFFS_OOB);

#endif


修改driver/mtd/nand/nand_util.c:

need_skip = check_skip_len(nand, offset, *length);

    if (need_skip < 0) {

        printf ("Attempt to write outside the flash area\n");

        *length = 0;

        return -EINVAL;

    }


#ifndef CONFIG_CMD_NAND_YAFFS

    if (!need_skip && !(flags & WITH_DROP_FFS)) {

        rval = nand_write (nand, offset, length, buffer);

        if (rval == 0)

            return 0;


        *length = 0;

        printf ("NAND write to offset %llx failed %d\n",

            offset, rval);

        return rval;

    }

#endif

#ifdef CONFIG_CMD_NAND_YAFFS

        if (flags & WITH_YAFFS_OOB) {

            int page, pages;

            size_t pagesize = nand->writesize;

            size_t pagesize_oob = pagesize + nand->oobsize;

            struct mtd_oob_ops ops;


            ops.len = pagesize;

            ops.ooblen = nand->oobsize;

           ops.mode = MTD_OOB_RAW;

            ops.ooboffs = 0;


            pages = write_size / pagesize_oob;

            for (page = 0; page < pages; page++) {

                WATCHDOG_RESET();