• mini2440移植最新u-boot-2012.04.01详细解说


    MINI2440开发板硬件环境

    nor flash型号:SST39VF1601

    nand flash型号:K9F1208

    网卡型号:DM9000E

    内核分区:4MB

    使用4.3.2的编译器
    cd /work/tools
    sudo tar xjf arm-linux-gcc-4.3.2.tar.bz2 -C /
    echo $PATH //查询当前环境变量
    export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/4.3.2/bin
    arm-linux-gcc -v
    并且设置开机环境变量参数
    sudo vi /etc/environment
    设置PATH,PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/4.3.2/bin
    arm-linux-gcc -v


    1、下载、建立source insight工程、编译、烧写、如果无运行分析原因
    tar xjf u-boot-2012.04.01.tar.bz2
    cd u-boot-2012.04.01
    make smdk2410_config
    make
    开发板设为NOR启动
    用eop工具烧写u-boot
    d:
    cd d:work
    oflash u-boot_2012.04.01_180306.bin

    oflash u-boot_180107.bin
    0.openjtag
    1.s4c2440
    1.nor flash
    0.烧录到0地址
    等待烧录完成

    2. 分析u-boot: 通过链接命令分析组成文件、阅读代码分析启动过程

    a. 初始化硬件:关看门狗、设置时钟、设置SDRAM、初始化NAND FLASH
    b. 如果bootloader比较大,要把它重定位到SDRAM
    c. 把内核从NAND FLASH读到SDRAM
    d. 设置"要传给内核的参数"
    e. 跳转执行内核

    2.1 set the cpu to SVC32 mode
    2.2 turn off the watchdog
    2.3 mask all IRQs by setting all bits in the INTMR
    2.4 设置时钟比例
    2.5 设置内存控制器
    2.6 设置栈,调用C函数board_init_f
    2.7 调用函数数组init_sequence里的各个函数
    2.7.1 board_early_init_f : 设置系统时钟、设置GPIO
    ......
    2.8 重定位代码:
    2.8.1 从NOR FLASH把代码复制到SDRAM
    2.8.2 程序的链接地址是0,访问全局变量、静态变量、调用函数时是使"基于0地址编译得到的地址"
    现在把程序复制到了SDRAM
    需要修改代码,把"基于0地址编译得到的地址"改为新地址
    2.8.3 程序里有些地址在链接时不能确定,要到运行前才能确定:fixabs
    2.9 clear_bss
    2.10 调用C函数board_init_r:第2阶段的代码


    可以修改配置定义CONFIG_S3C2440


    3. 修改U-BOOT代码
    make distclean
    3.1 建一个单板
    cd board/samsung/
    cp smdk2410 smdk2440 -rf
    cd ../../include/configs/
    cp smdk2410.h smdk2440.h

    cd ../..
    修改boards.cfg:
    vi boards.cfg
    :65 //跳到65行
    复制smdk2410 粘贴并修改为smdk2440
    仿照
    smdk2410 arm arm920t - samsung s3c24x0
    添加:
    smdk2440 arm arm920t - samsung s3c24x0

    make smdk2440_config
    make

    grep "smdk2410" * -nR


    3.2 烧写看结果
    3.3 调试:
    a. 阅读代码发现不足:UBOOT里先以60MHZ的时钟计算参数来设置内存控制器,但是MPLL还未设置
    处理措施: 把MPLL的设置放到start.S里,取消board_early_init_f里对MPLL的设置

    编译出来的uboot非常大,可以先烧写主光盘里的u-boot.bin到nor,然后用这个uboot来烧写新的uboot
    重启开发板,
    q //退出菜单
    mtd //查询分区表
    usb 1 30000000 //USB下载到30000000地址
    使用DNW下载u-boot.bin
    protect off all //关闭nor写保护
    erase 0 7FFFF //擦除0-7FFFF之间的数据
    cp.b 30000000 0 80000 //从30000000地址复制到0的地址中
    reset


    3.4 乱码,查看串口波特率的设置,发现在get_HCLK里没有定义CONFIG_S3C2440
    处理措施:include/configs/smdk2440.h: 去掉CONFIG_S3C2410

    #define CONFIG_S3C2440 //增加2440宏定义
    //#define CONFIG_CMD_NAND //暂时注释
    //#define CONFIG_YAFFS2 //暂时注释

    3.5 修改UBOOT支持NAND启动
    原来的代码在链接时加了"-pie"选项, 使得u-boot.bin里多了"*(.rel*)", "*(.dynsym)"
    使得程序非常大,不利于从NAND启动(重定位之前的启动代码应该少于4K)
    3.5.1 去掉 "-pie"选项
    grep "-pie" * -nR //搜索-pie
    vi arch/arm/config.mk +75
    改为#LDFLAGS_u-boot += -pie
    arch/arm/config.mk:75:LDFLAGS_u-boot += -pie 去掉这行

    3.5.2 参考"毕业班第1课"的start.S, init.c来修改代码
    把start.S放入archarmcpuarm920t目录
    把init.c放入board/samsung/smdk2440目录, 修改Makefile
    vi board/samsung/smdk2440/Makefile
    COBJS := smdk2410.o后面加上 init.o
    修改CONFIG_SYS_TEXT_BASE为0x33f80000
    修改start.S
    3.5.3 修改board_init_f, 把relocate_code去掉
    3.5.4 修改链接脚本: 把start.S, init.c, lowlevel.S等文件放在最前面
    rm u-boot.lds //删除链接脚本
    make
    find -name "u-boot.lds"
    vi ./arch/arm/cpu/u-boot.lds

    在CPUDIR/start.o (.text)下面插入 board/samsung/smdk2440/libsmdk2440.o (.text)
    make
    vi include/common.h +276
    void board_init_f (ulong) __attribute__ ((noreturn)); 改为unsigned int board_init_f (ulong) ;
    void board_init_r (gd_t *, ulong) __attribute__ ((noreturn)); 改为void board_init_r (gd_t *, ulong) ;
    board.c 文件中void board_init_f 改为 unsigned int board_init_f
    Init.c 文件66行中nand_read 改为 nand_read_ll
    make

    arm-linux-objdump -D u-boot > u-boot.dis //查看生成反汇编文件是否正确

    修改Board.c文件

    addr -= gd->mon_len; 
    addr &= ~(4096 - 1); 

    改为:

    //addr -= gd->mon_len;
    //addr &= ~(4096 - 1);
    addr = CONFIG_SYS_TEXT_BASE;/*addr = _TEXT_BASE*/

    vi include/configs/smdk2440.h //暂时修改CONFIG_SYS_TEXT_BASE为0x33f00000
    make
    开发板重新上电
    q //退出菜单
    mtd //查询分区表
    usb 1 30000000 //USB下载到30000000地址
    使用DNW下载u-boot.bin
    nand erase 0 80000 //擦除0-7FFFF之间的数据
    nand write 30000000 0 80000 //从30000000地址复制到0的地址中
    reset
    //拨码开关设为nand启动

    3.6 修改UBOOT支持NOR FLASH
    Cfi_flash.c文件中增加

    #define DEBUG
    #define _DEBUG 1



    然后make
    开发板上操作:
    q //退出菜单
    usb 1 30000000 //USB下载到30000000地址
    使用DNW下载u-boot.bin
    protect off all //关闭nor写保护
    erase 0 7FFFF //擦除0-7FFFF之间的数据
    cp.b 30000000 0 80000 //从30000000地址复制到0的地址中
    reset
    重启开发板,从nor启动

    U-Boot 2012.04.01 (Mar 22 2018 - 14:28:32)

    CPUID: 32440001
    FCLK: 400 MHz
    HCLK: 100 MHz
    PCLK: 50 MHz
    DRAM: 64 MiB
    WARNING: Caches not enabled
    Flash: fwc addr (null) cmd f0 00f0 16bit x 16 bit
    fwc addr 0000aaaa cmd aa 00aa 16bit x 16 bit
    fwc addr 00005554 cmd 55 0055 16bit x 16 bit
    fwc addr 0000aaaa cmd 90 0090 16bit x 16 bit
    fwc addr (null) cmd f0 00f0 16bit x 16 bit
    JEDEC PROBE: ID bf 234b 0
    fwc addr (null) cmd ff 00ff 16bit x 16 bit
    fwc addr (null) cmd 90 0090 16bit x 16 bit
    fwc addr (null) cmd ff 00ff 16bit x 16 bit
    JEDEC PROBE: ID 13 ea00 0
    *** failed ***
    ### ERROR ### Please RESET the board ###
    //以上为错误信息,nor flash型号为SST39VF1601,厂家ID为bf 设备ID为234b


    driversmtdjedec_flash.c 加上新的型号

    #ifdef CONFIG_SYS_FLASH_LEGACY_1024Kx16
    /*MINI2440使用SST39VF1601 JZ2440V2使用的是MT29LV160DB*/
    {
    .mfr_id    = (u16)SST_MANUFACT,/*厂家ID MINI2440=(u16)SST_MANUFACT JZ2440V2=(u16)MX_MANUFACT*/
    .dev_id    = SST39VF1601, /*设备ID MINI2440=0x234B JZ2440V2=0x2249*/
    .name    = "SST 39VF1601",/* 名称 MINI2440="SST SST39VF1601" JZ2440V2="MXIC MT29LV160DB"*/
    .uaddr    = { /*NOR flash看到的解锁地址*/ 
    [1] = MTD_UADDR_0x5555_0x2AAA /* x16 */ //[0] = MTD_UADDR_0x5555_0x2AAA, /* x8 */
    },
    .DevSize    = SIZE_2MiB,/* SIZE_2MiB */
    .CmdSet    = P_ID_AMD_STD,
    .NumEraseRegions    = 4, /*MINI2440=1 JZ2440V2=4 */
    .regions    = {
    ERASEINFO(0x1000,96),
    ERASEINFO(0x1000,160),
    ERASEINFO(0x1000,240),
    ERASEINFO(0x1000,16),
    
    //ERASEINFO(4*1024, 512), /*MINI2440 4K*512=2M*/
    
    //ERASEINFO(0x04000, 1),
    //ERASEINFO(0x02000, 2),
    //ERASEINFO(0x08000, 1),
    //ERASEINFO(0x10000, 7),
    }
    },
    #endif

    include/configs/Smdk2440.h中

    #define CONFIG_SYS_FLASH_LEGACY_512Kx16

    改为

    #define CONFIG_SYS_FLASH_LEGACY_1024Kx16
    #define CONFIG_SYS_MAX_FLASH_SECT    (19)

    改为

    #define CONFIG_SYS_MAX_FLASH_SECT    (512)
    #define CONFIG_ENV_ADDR    (CONFIG_SYS_FLASH_BASE + 0x070000)

    改为

    #define CONFIG_ENV_ADDR    (CONFIG_SYS_FLASH_BASE + 0x1f0000) 



    修复了重定位时留下来的BUG:SP要重新设置
    重新make
    开发板上操作:
    q //退出菜单
    usb 1 30000000 //USB下载到30000000地址
    使用DNW下载u-boot.bin
    protect off all //关闭nor写保护
    erase 0 7FFFF //擦除0-7FFFF之间的数据
    cp.b 30000000 0 80000 //从30000000地址复制到0的地址中
    reset
    //重启开发板,从nor启动





    //nor flash 读写测试
    protect off all //关闭nor写保护
    erase 80000 8FFFF //擦除0-7FFFF之间的数据
    cp.b 30000000 80000 10000 //从30000000地址复制到80000的地址中
    mw.b 30000000 78
    md.b 30000000 //读取30000000地址的数据 78
    cmp.b 30000000 80000 10000 //比较30000000地址 和80000地址的10000个数据,发现有不一致

    //换个地址重新测试
    erase 80000 8ffff
    cp.b 32000000 80000 10000
    cmp.b 32000000 80000 10000 //重新比较,结果一致


    //使用window下的超级终端
    loady 32000000
    传送->发送文件 选择协议ymodem 选择要发送的文件
    protect off all
    erase 0 7ffff
    cp.b 32000000 0 80000
    reset
    ctrl+c 可退出执行中的命令//测试用

    //超级终端测试nor flash 读写
    protect off all
    erase 80000 8ffff
    cp.b 30000000 80000 10000
    cmp.b 30000000 80000 10000 //比较结果一致


    3.7 修改UBOOT支持NAND FLASH
    include/configs/smdk2440.h文件中修改:

    //#define CONFIG_CMD_NAND 

    改为

    #define CONFIG_CMD_NAND //取消注释
    #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

    改为

    #ifdef CONFIG_CMD_NAND
    
    #ifdef CONFIG_S3C2410
    #define CONFIG_NAND_S3C2410
    #define CONFIG_SYS_S3C2410_NAND_HWECC
    #else
    #define CONFIG_NAND_S3C2440
    #define CONFIG_SYS_S3C2440_NAND_HWECC
    #endif
    
    #define CONFIG_SYS_MAX_NAND_DEVICE    1
    #define CONFIG_SYS_NAND_BASE    0x4E000000
    #endif


    把driversmtd ands3c2410_nand.c复制为s3c2440_nand.c
    修改vi drivers/mtd/nand/Makefile

    COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o

    改为

    COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o
    COBJS-$(CONFIG_NAND_S3C2440) += s3c2440_nand.o



    drivers/mtd/nand/S3c2440_nand.c文件中
    在int board_nand_init(struct nand_chip *nand)函数中

    cfg = S3C2410_NFCONF_EN;
    cfg |= S3C2410_NFCONF_TACLS(tacls - 1);
    cfg |= S3C2410_NFCONF_TWRPH0(twrph0 - 1);
    cfg |= S3C2410_NFCONF_TWRPH1(twrph1 - 1);
    writel(cfg, &nand_reg->nfconf);

    改为

    /*初始化时序*/
    cfg = ((tacls-1)<<12)|((twrph0-1)<<8)|((twrph1-1)<<4);
    writel(cfg, &nand_reg->nfconf);
    /* 使能NAND Flash控制器, 初始化ECC, 禁止片选 */
    writel((1<<4)|(1<<1)|(1<<0),&nand_reg->nfcont);



    在int board_nand_init(struct nand_chip *nand)函数中

    struct s3c2410_nand *nand_reg = s3c2410_get_base_nand();

    改为

    struct s3c2440_nand *nand_reg = s3c2440_get_base_nand(); 

    在static void s3c2440_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)函数中

    struct s3c2410_nand *nand = s3c2410_get_base_nand();

    改为

    struct s3c2440_nand *nand = s3c2440_get_base_nand();


    在static void s3c2440_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)函数中

    if (ctrl & NAND_NCE) /*使能选中*/
    writel(readl(&nand->nfconf) & ~S3C2410_NFCONF_nFCE,
    &nand->nfconf);
    else /*取消选中*/
    writel(readl(&nand->nfconf) | S3C2410_NFCONF_nFCE,
    &nand->nfconf);

    改为

    if (ctrl & NAND_NCE) /*使能选中*/
    writel(readl(&nand->nfcont) & ~(1<<1),
    &nand->nfcont);
    else /*取消选中*/
    writel(readl(&nand->nfcont) | (1<<1),
    &nand->nfcont);



    在static int s3c2440_dev_ready(struct mtd_info *mtd)函数中

    struct s3c2410_nand *nand = s3c2410_get_base_nand();

    改为

    struct s3c2440_nand *nand = s3c2440_get_base_nand();
    
    s3c2410_nand全部替换为s3c2440_nand
    s3c2410_hwcontrol全部替换为s3c2440_hwcontrol
    s3c2410_dev_ready全部替换为s3c2440_dev_ready


    在int board_nand_init(struct nand_chip *nand)函数中

    nand->select_chip = NULL;

    改为

    nand->select_chip = s3c2440_nand_select;



    在static void s3c2440_hwcontrol(struct mtd_info *mtd, int dat, unsigned int ctrl)函数中

    debug("hwcontrol(): 0x%02x 0x%02x
    ", cmd, ctrl);
    if (ctrl & NAND_CTRL_CHANGE) {
    ulong IO_ADDR_W = (ulong)nand;
    
    if (!(ctrl & NAND_CLE))
    IO_ADDR_W |= S3C2410_ADDR_NCLE;
    if (!(ctrl & NAND_ALE))
    IO_ADDR_W |= S3C2410_ADDR_NALE;
    
    chip->IO_ADDR_W = (void *)IO_ADDR_W;
    
    if (ctrl & NAND_NCE) //使能选中
    writel(readl(&nand->nfcont) & ~(1<<1),
    &nand->nfcont);
    else //取消选中
    writel(readl(&nand->nfcont) | (1<<1),
    &nand->nfcont);
    }
    if (cmd != NAND_CMD_NONE)
    writeb(cmd, chip->IO_ADDR_W);

    改为

    if(ctrl&NAND_CLE)
    {
    /*发命令*/
    writeb(dat,&nand->nfcmd);
    }
    else if(ctrl& NAND_ALE)
    {
    /*发地址*/
    writeb(dat,&nand->nfaddr);
    }



    在int board_nand_init(struct nand_chip *nand)函数上面增加:

    static void s3c2440_nand_select(struct mtd_info *mtd, int chipnr)
    {
    struct s3c2440_nand *nand = s3c2440_get_base_nand();
    
    switch (chipnr) {
    case -1:/*取消选中*/
    nand->nfcont|=(1<<1);
    break;
    case 0:/*选中*/
    nand->nfcont&=~(1<<1);
    break;
    
    default:
    BUG();
    }
    }



    //使用window下的超级终端烧录修改好的u-boot到nor flash
    loady 30000000
    传送->发送文件 选择协议ymodem 选择要发送的文件
    protect off all
    erase 0 7ffff
    cp.b 30000000 0 80000
    reset //开发板设为nor启动

    //使用window下的超级终端烧录修改好的u-boot到nand flash
    nand erase 0 80000
    nand write 0 0 80000
    nand read 30000000 0 80000
    cmp.b 0 30000000 80000 //比较读出数据和写入数据是否一致
    reset //开发板设为nand启动

    //nor启动可以操作NOR FLASH,也可以操作nand flash
    //nand启动不能识别nor flash,只能操作nand flash


    分析过程:
    nand_init
    nand_init_chip
    board_nand_init
    //设置nand_chip结构体, 提供底层的操作函数
    nand_scan
    nand_scan_ident
    nand_set_defaults
    chip->select_chip = nand_select_chip;
    chip->cmdfunc = nand_command;
    chip->read_byte = busw ? nand_read_byte16 : nand_read_byte;

    nand_get_flash_type
    chip->select_chip
    chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
    nand_command() // 即可以用来发命令,也可以用来发列地址(页内地址)、行地址(哪一页)
    chip->cmd_ctrl
    s3c2440_hwcontrol

    chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);
    *maf_id = chip->read_byte(mtd);
    *dev_id = chip->read_byte(mtd);


    3.8 修改UBOOT支持DM9000网卡
    在include/configs/Smdk2440.h文件中修改

    #define CONFIG_CS8900    /* we have a CS8900 on-board */
    #define CONFIG_CS8900_BASE    0x19000300
    #define CONFIG_CS8900_BUS16    /* the Linux driver does accesses as shorts */

    改为

    #if 0
    #define CONFIG_CS8900    /* we have a CS8900 on-board */
    #define CONFIG_CS8900_BASE    0x19000300
    #define CONFIG_CS8900_BUS16    /* the Linux driver does accesses as shorts */
    #else
    #define CONFIG_DRIVER_DM9000
    #define CONFIG_DM9000_BASE 0x20000000 //0x20000300
    #define DM9000_IO CONFIG_DM9000_BASE
    #define DM9000_DATA (CONFIG_DM9000_BASE+4)
    #endif



    在board/samsung/smdk2440/lowlevel_init.S文件中 SMRDATA段

    .long 0x00000700    //BANKCON4

    改为

    .long 0x00000740    //BANKCON4



    在board/samsung/smdk2440/S3c2410.c文件中

    int board_eth_init(bd_t *bis)
    {
    int rc = 0;
    #ifdef CONFIG_CS8900
    rc = cs8900_initialize(0, CONFIG_CS8900_BASE);
    #endif
    return rc;
    }

    改为

    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;
    }





    //使用window下的超级终端烧录修改好的u-boot到nor flash
    loady 30000000
    传送->发送文件 选择协议ymodem 选择要发送的文件
    protect off all
    erase 0 7ffff
    cp.b 30000000 0 80000
    reset //开发板设为nor启动


    eth_initialize
    board_eth_init
    cs8900_initialize

    *** ERROR: `ethaddr' not set
    set ipaddr 192.168.31.203
    set ethaddr 00:0c:29:4d:e4:f4 //set ethaddr 00:0c:29:d3:fe:1d //set ethaddr 08:08:11:18:12:27
    set serverip 192.168.31.201
    set gatewayip 192.168.31.1
    ping 192.168.31.71 //ping测试
    //设置后现在还不能save,会破坏分区

    //测试tftp下载uImage
    tftp 30000000 uImage
    bootm 30000000

    4. 易用性修裁剪及制作补丁
    //设置环境变量
    在include/configs/Smdk2440.h文件中修改

    #define CONFIG_NETMASK    255.255.255.0
    #define CONFIG_IPADDR    10.0.0.110
    #define CONFIG_SERVERIP    10.0.0.1

    改为

    #define CONFIG_NETMASK    255.255.255.0
    #define CONFIG_IPADDR    192.168.31.203
    #define CONFIG_SERVERIP    192.168.31.71    
    #define CONFIG_ETHADDR 00:0c:29:4d:e4:f4




    在#define CONFIG_LZMA下面增加

    #define CONFIG_CMD_NAND_YAFFS //后面下载yaffs文件系统需用到
    #define CONFIG_BOOTARGS "console=ttySAC0 root=/dev/mtdblock3"
    #define CONFIG_BOOTCOMMAND "nand read 30000000 kernel;bootm 30000000"

    //下面开始裁剪系统
    在include/configs/Smdk2440.h文件中修改,注释以下代码

    /************************************************************
    * USB support (currently only works with D-cache off)
    ************************************************************/
    //#define CONFIG_USB_OHCI 
    //#define CONFIG_USB_KEYBOARD
    //#define CONFIG_USB_STORAGE
    //#define CONFIG_DOS_PARTITION
    /************************************************************
    * RTC
    ************************************************************/
    //#define CONFIG_RTC_S3C24X0
    /*
    * BOOTP options
    */
    //#define CONFIG_BOOTP_BOOTFILESIZE
    //#define CONFIG_BOOTP_BOOTPATH
    //#define CONFIG_BOOTP_GATEWAY
    //#define CONFIG_BOOTP_HOSTNAME
    
    //#define CONFIG_CMD_DATE
    //#define CONFIG_CMD_DHCP
    //#define CONFIG_CMD_USB
    
    /*
    * 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



    在include/configs/Smdk2440.h文件中修改

    #define CONFIG_ENV_ADDR    (CONFIG_SYS_FLASH_BASE + 0x1f0000) //(CONFIG_SYS_FLASH_BASE + 0x070000)
    #define CONFIG_ENV_IS_IN_FLASH
    #define CONFIG_ENV_SIZE    0x10000
    /* allow to overwrite serial and ethaddr */
    #define CONFIG_ENV_OVERWRITE

    改为

    #if 0
    #define CONFIG_ENV_ADDR    (CONFIG_SYS_FLASH_BASE + 0x1f0000) //(CONFIG_SYS_FLASH_BASE + 0x070000)
    #define CONFIG_ENV_IS_IN_FLASH
    #define CONFIG_ENV_SIZE    0x10000
    /* allow to overwrite serial and ethaddr */
    #define CONFIG_ENV_OVERWRITE
    #endif
    #define CONFIG_ENV_IS_IN_NAND
    #define CONFIG_ENV_OFFSET 0x00040000
    #define CONFIG_ENV_SIZE 0x20000
    #define CONFIG_ENV_RANGE CONFIG_ENV_SIZE
    #define CONFIG_CMD_MTDPARTS
    #define CONFIG_MTD_DEVICE
    #define MTDIDS_DEFAULT    "nand0=mini2440-0" /*哪一个设备*/
    #define MTDPARTS_DEFAULT    "mtdparts=mini2440-0:256k(u-boot),"    
    "128k(params),"    
    "4m(kernel),"    
    "-(rootfs)"    




    在arch/arm/lib/Board.c文件中,在
    /* main_loop() can return to retry autoboot, if so just run it again. */
    上面增加

    run_command("mtdparts",0);
    //mtdparts_init(); 



    在drivers/mtd/nand/Nand_util.c文件中
    556行中

    ops.mode = MTD_OOB_AUTO; 

    改为

    ops.mode = MTD_OOB_RAW; /*MTD_OOB_AUTO改为MTD_OOB_RAW*/



    567行中

    if (!rval)

    改为

    if (rval)


    519行中

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

    改为

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


    //改好后,重新make
    q //退出菜单
    tftp 30000000 u-boot_2012_180323_CLIP.bin //tftp下载
    protect off all //关闭nor写保护
    erase 0 3ffff //擦除0-7FFFF之间的数据
    cp.b 30000000 0 40000 //从30000000地址复制到0-80000的地址中
    reset
    //重启开发板,从nor启动
    set bootcmd 'nand read 30000000 kernel;bootm 30000000'
    set mtdparts 'mtdparts=mini2440-0:256k(u-boot),128k(params),2m(kernel),-(rootfs)' //备用
    mtdparts default //恢复默认分区表(可选)
    mtdparts //查看分区表
    print //打印串口信息
    save //保存到flash
    reset //重启开发板

    //烧录内核uImage
    tftp 30000000 uImage //下载uImage
    nand erase.part kernel //擦除kernel
    nand write 30000000 kernel //写到kernel分区
    reset
    //已经可以启动内核了

    内核打印出来的分区信息
    0x00000000-0x00040000 : "bootloader"
    0x00040000-0x00060000 : "params"
    0x00060000-0x00260000 : "kernel"
    0x00260000-0x10000000 : "root"

    更新UBOOT(可选):
    tftp 30000000 u-boot_2012_180324_mini2440.bin; protect off all; erase 0 3ffff; cp.b 30000000 0 40000
    reset


    烧写JFFS2
    tftp 30000000 fs_mini_mdev.jffs2
    nand erase.part rootfs
    nand write.jffs2 30000000 0x00260000 5b89a8

    set bootargs console=ttySAC0 root=/dev/mtdblock3 rootfstype=jffs2
    boot


    烧写YAFFS
    reboot
    tftp 30000000 fs_mini_mdev.yaffs2
    nand erase.part rootfs
    nand write.yaffs 30000000 260000 889bc0 //$filesize
    boot
    nand dump 260000 //对比烧录到260000地址数据是否一致(测试用)

    制作mini2440补丁,方便以后安装调用:
    到修改好的u-boot-2012.04.01所在目录
    make distclean
    rm u-boot.dis //清除汇编文件
    cd ..
    mv u-boot-2012.04.01 u-boot-2012.04.01_mini2440 //更名为mini2440专用u-boot
    tar xjf u-boot-2012.04.01.tar.bz2 //解压原来的u-boot


    diff -urN u-boot-2012.04.01 u-boot-2012.04.01_mini2440 > u-boot-2012.04.01_mini2440.patch //生成补丁文件

    打补丁方法
    到u-boot-2012.04.01所在目录
    patch -p1 < ../u-boot-2012.04.01_mini2440.patch
    make smdk2440_config
    make

    //制作u-boot压缩包,以备日后调用
    tar cjvf u-boot-2012.04.01_mini2440.tar.bz2 u-boot-2012.04.01_mini2440 //压缩u-boot-2012.04.01_mini2440文件夹
    tar xjvf u-boot-2012.04.01_mini2440.tar.bz2 //解压到当前目录

    版权声明:本文为博主原创文章,转载请注明文章来源,有需要帮忙可加QQ:871263854
  • 相关阅读:
    Telnet远程测试
    数据库笔记
    gcc 链接不到 函数实现, undefined reference to xxx
    usb2ttl 引脚定义
    ip v4 地址中 局域网地址范围
    vdi 磁盘文件转换为 vmdk文件的命令
    tftp 命令使用
    无法通过vnc连接到局域网内的树莓派
    镜像服务网站
    C语言 scanf 输入浮点数的用法
  • 原文地址:https://www.cnblogs.com/Dream998/p/8640253.html
Copyright © 2020-2023  润新知