RT5350配置uboot 支持8M的Flash

来源:互联网 发布:淘宝店的信誉等级 编辑:程序博客网 时间:2024/06/06 09:41

 RT5350配置uboot 支持8M的Flash

Uboot 采用U-Boot 1.1.3

 

一、在uboot 目录下配置支持8M flash

cd  /home/RT5350/Uboot/

make menuconfig


二、重新编译

1make

2、生成uboot.img

三、烧录镜像板子出现如下信息


四、定位打印信息

 

可以看到uboot启动之后,通过spi方式读取到的 flash信息在配置表当中查询不到

uboot搜索这条打印信息可以查询到如下位置

“Warning: un-recognized chip ID, please update bootloader!”

 

grep -r -n “Warning: un-recognized chip ID, please update bootloader!”

 

./drivers/spi_flash.c 838 位置出现

 

struct chip_info *chip_prob(void)

{

        struct chip_info *info, *match;

        u8 buf[5];

        u32 jedec, weight;

        int i;

 

        raspi_read_devid(buf, 5);

        jedec = (u32)((u32)(buf[1] << 24) | ((u32)buf[2] << 16) | ((u32)buf[3] <<8) | (u32)buf[4]);

 

        printf("spi device id: %x %x %x %x %x (%x)\n", buf[0], buf[1], buf[2], buf[3], buf[4], jedec);

 

        // FIXME, assign default as AT25D

        weight = 0xffffffff;

        match = &chips_data[0];

        for (i = 0; i < sizeof(chips_data)/sizeof(chips_data[0]); i++) {

                info = &chips_data[i];

                if (info->id == buf[0]) {

                        if (info->jedec_id == jedec) {

                                printf("find flash: %s\n", info->name);

                                return info;

                        }

 

                        if (weight > (info->jedec_id ^ jedec)) {

                                weight = info->jedec_id ^ jedec;

                                match = info;

                        }

                }

        }

        printf("Warning: un-recognized chip ID, please update bootloader!\n");

 

        return match;

}

 

unsigned long raspi_init(void)

{

        spic_init();

        spi_chip_info = chip_prob();

        

        return spi_chip_info->sector_size * spi_chip_info->n_sectors;

}

 

 

以上函数功能主要是:

raspi_init 初始化spi ,读取spi信息,返回spi flash的大小。

chip_prob() 函数是探测flashID信息,从flash当中raspi_read_devid函数读取到的ID信息和chips_data表当中的数据进行匹配,得出flash大小。

从打印信息可以看到info->id= 0xc8 ,flash序列号jedec  = 0x4017c840

 

在配置表chips_data 当中没有这个id ,所以才才打印出如下信息

printf("Warning: un-recognized chip ID, please update bootloader!\n");

找不到flash,在raspi_init打印flash大小,还是默认用4M

printf("raspi_init  =%d\n",spi_chip_info->sector_size * spi_chip_info->n_sectors);

 

五、配置表如下



六、添加自己的flash 

我们需要添加自己的flash信息进去,uboot才能正确识别大小

在最后添加一行

{ "W25Q64_1",           0xc8, 0x4017c840, 64 * 1024, 128, 0 },

 

添加的参数描述:


W25Q64_1 :表示名字 ,可以自定义。

id:0xc8 是当前取出来的ID值(上面的打印函数可以看出raspi_read_devid

jedec_id: 序列号,读取出来的值0x4017c840

sector_size flash片区大小 (64 * 1024

n_sectors: 总共有多少片(128

64*1024*128/1024/1024 =8M 计算出8M

 

addr4b :读写保护 0表示可以读写  1:表示只能读取flash

 

七、重新编译下载

出现如下打印信息


 

就可以正确读取flash,下载超过4M的内核就可以正常通过



0 0
原创粉丝点击