直接从nandflash和T卡启动linux的笔记_第1页
直接从nandflash和T卡启动linux的笔记_第2页
直接从nandflash和T卡启动linux的笔记_第3页
直接从nandflash和T卡启动linux的笔记_第4页
直接从nandflash和T卡启动linux的笔记_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、实现从nand flash和T卡启动功能所做的修改1、 让系统可以正确读取T卡中的文件需要修改uboot/include/movi.h文件中关于MOVI_BL2_POS的定义,具体如下:/#define MOVI_BL2_POS(MOVI_LAST_BLKPOS - MOVI_BL1_BLKCNT - MOVI_BL2_BLKCNT) - MOVI_ENV_BLKCNT)#define MOVI_BL2_POS(MOVI_LAST_BLKPOS - MOVI_BL1_BLKCNT - MOVI_BL2_BLKCNT)/ - MOVI_ENV_BLKCNT)2、 需要打开include/conf

2、igs/smdk6410.h中的下面几个配置,否则在读取nandflash时会有问题。CFG_NAND_HWECCCFG_NAND_FLASH_BBTCONFIG_NAND_BL1_8BIT_ECC3、 在uboot/cpu/s3c64xx/nand.c中添加对nand flash第一块进行读写的函数如下:void s3c_nand_write_page_8bit_for_irom(struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf)int i, eccsize = 512;int eccbytes = 13;int

3、 eccsteps = mtd->writesize / eccsize;uint8_t *ecc_calc = chip->buffers->ecccalc;uint8_t *p = (uint8_t *) buf;for (i = 0; eccsteps; eccsteps-, i += eccbytes, p += eccsize) s3c_nand_enable_hwecc_8bit(mtd, NAND_ECC_WRITE);chip->write_buf(mtd, p, eccsize);s3c_nand_calculate_ecc_8bit(mtd, p,

4、&ecc_calci);for (i = 0; i < eccbytes * (mtd->writesize / eccsize); i+)chip->oob_poii = ecc_calci;chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);int s3c_nand_read_page_8bit_for_irom(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf)int i, stat, eccsize = chip->ecc

5、.size;int eccbytes = chip->ecc.bytes;int eccsteps = chip->ecc.steps;int col = 0;uint8_t *p = buf;uint32_t *mecc_pos = chip->ecc.layout->eccpos;/* Step1: read whole oob */col = mtd->writesize;chip->cmdfunc(mtd, NAND_CMD_RNDOUT, col, -1);chip->read_buf(mtd, chip->oob_poi, mtd-&

6、gt;oobsize);col = 0;for (i = 0; eccsteps; eccsteps-, i += eccbytes, p += eccsize) chip->cmdfunc(mtd, NAND_CMD_RNDOUT, col, -1);chip->ecc.hwctl(mtd, NAND_ECC_READ);chip->read_buf(mtd, p, eccsize);chip->write_buf(mtd, chip->oob_poi + 0 + (chip->ecc.steps - eccsteps) * eccbytes), eccb

7、ytes);s3c_nand_calculate_ecc_8bit(mtd, 0, 0);stat = s3c_nand_correct_data_8bit(mtd, p, 0, 0);if (stat = -1)mtd->ecc_stats.failed+;col = eccsize * (chip->ecc.steps + 1 - eccsteps);return 0;4、 修改uboot/cpu/s3c64xx/nand_cp.c中的nand_bl2_copy()和and_bl2_copy_adv()两个函数如下:void nand_bl2_copy(void)int blo

8、ck, page;volatile uint *base = (uint *) 0x57e00000;/miaozh modify#if0for (block = 0; block < 16; block+) for (page = 0; page < 32; page+) NF8_ReadPage(block, page, (uchar *)base);base += (512 / (sizeof(uint);#elsefor (block = 0; block < 1; block+) for (page = 0; page <128 ; page+) NF8_Re

9、adPage_Adv(block, page, (uchar *)base);base += (4096 / (sizeof(uint);#endifvoid nand_bl2_copy_adv(void)int block, page;volatile uint *base = (uint *) 0x57e00000;/miaozh modify#if0for (block = 0; block < 2; block+) for (page = 0; page < 128; page+) NF8_ReadPage_Adv(block, page, (uchar *) base);

10、base += (2048 / (sizeof(uint);#elsefor (block = 0; block < 1; block+) for (page = 0; page < 128; page+) NF8_ReadPage_Adv(block, page, (uchar *) base);base += (4096 / (sizeof(uint);#endif5、 修改uboot/cpu/s3c64xx/nand_cp.c中的nandll_read_page ()和nandll_read_blocks ()两个函数如下:static int nandll_read_pag

11、e (uchar *buf, ulong addr, int large_block) int i;int page_size = 512;if (large_block)page_size = 2048;/miaozh addpage_size = 4096; NAND_ENABLE_CE(); NFCMD_REG = NAND_CMD_READ0; /* Write Address */ NFADDR_REG = 0;if (large_block) NFADDR_REG = 0;NFADDR_REG = (addr) & 0xff;NFADDR_REG = (addr >&

12、gt; 8) & 0xff;NFADDR_REG = (addr >> 16) & 0xff;if (large_block)NFCMD_REG = NAND_CMD_READSTART; NF_TRANSRnB();/* for compatibility(2460). u32 cannot be used. by scsuh */for(i=0; i < page_size; i+) *buf+ = NFDATA8_REG; NAND_DISABLE_CE(); return 0;/* * Read data from NAND. */static int

13、 nandll_read_blocks (ulong dst_addr, ulong size, int large_block) uchar *buf = (uchar *)dst_addr; int i;uint page_shift = 9;if (large_block)page_shift = 11;/miaozh addpage_shift = 12; /* Read pages */ for (i = 0; i < (0x3c000>>page_shift); i+, buf+=(1<<page_shift) nandll_read_page(buf

14、, i, large_block); return 0;6、 修改uboot/drivers/mtd/nand/nand_base.c中的nand_do_read_ops()函数如下:/miaozh modify#if0if (mtd->writesize = 512 && page < 512) | (mtd->writesize = 2048 && page < 128) s3c_nand_read_page_8bit(mtd, chip, bufpoi); #else if (mtd->writesize = 512 &

15、;& page < 512) | (mtd->writesize = 2048 && page < 128) |(mtd->writesize = 4096 && page < 128) s3c_nand_read_page_8bit_for_irom(mtd, chip, bufpoi);#endif7、 修改uboot/drivers/mtd/nand/nand_base.c中的nand_write_page ()函数如下:/miaozh modify#if0if (mtd->writesize = 512 &am

16、p;& page < 512) | (mtd->writesize = 2048 && page < 128) memset(chip->oob_poi, 0xff, mtd->oobsize);s3c_nand_write_page_8bit(mtd, chip, buf);#elseif (mtd->writesize = 512 && page < 512) | (mtd->writesize = 2048 && page < 128) | (mtd->writesize

17、= 4096 && page < 128) memset(chip->oob_poi, 0xff, mtd->oobsize);s3c_nand_write_page_8bit_for_irom(mtd, chip, buf);#endif8、 在drivers/mtd/nand/nand_util.c文件的nand_write_opts()函数中对应地方添加如下内容/* make sure device page sizes are valid */if (!(meminfo->oobsize = 16 && meminfo->w

18、ritesize = 512) && !(meminfo->oobsize = 8 && meminfo->writesize = 256) && !(meminfo->oobsize = 64 && meminfo->writesize = 2048) /*miaozh add*/ &&!(meminfo->oobsize = 218 && meminfo->writesize = 4096) ) printf("Unknown flash (not

19、normal NAND)n");return -1;9、 在drivers/mtd/nand/nand_util.c文件的nand_write_opts()函数中对应地方添加如下内容/* make sure device page sizes are valid */if (!(meminfo->oobsize = 16 && meminfo->writesize = 512) && !(meminfo->oobsize = 8 && meminfo->writesize = 256) && !(

20、meminfo->oobsize = 64 && meminfo->writesize = 2048)/*miaozh add*/ &&!(meminfo->oobsize = 218 && meminfo->writesize = 4096) ) printf("Unknown flash (not normal NAND)n");return -1;10、 在文件uboot/common/dlmalloc.c中添加下面的函数/miaozh addvoid init_sbrk_base(void)un

21、signed int *ptr;sbrk_base = (char*)(-1);top = initial_top;ptr = (unsigned int *)top;11、 修改uboot/lib_arm/board.c中的mem_malloc_init()函数staticvoid mem_malloc_init (ulong dest_addr)/printf("mem_malloc_init dest_addr=0x%08xn", dest_addr);mem_malloc_start = dest_addr;mem_malloc_end = dest_addr +

22、CFG_MALLOC_LEN;mem_malloc_brk = mem_malloc_start;memset (void *) mem_malloc_start, 0, mem_malloc_end - mem_malloc_start);/miaozh addinit_sbrk_base();12、 在uboot/lib_arm/board.c中添加set_gpk8()函数/miaozh add for dnwvoid set_gpk8(void)unsigned int tmp;tmp = readl(ELFIN_GPIO_BASE+GPKCON1_OFFSET);tmp = tmp &

23、amp;(0xf);tmp |= 1;writel(tmp, ELFIN_GPIO_BASE+GPKCON1_OFFSET);tmp = readl(ELFIN_GPIO_BASE+GPKPUD_OFFSET);tmp = tmp &(0x3<<16);writel(tmp, ELFIN_GPIO_BASE+GPKPUD_OFFSET);tmp = readl(ELFIN_GPIO_BASE+GPKDAT_OFFSET);tmp |= (0x1 << 8);writel(tmp, ELFIN_GPIO_BASE+GPKDAT_OFFSET);/end13、 在u

24、boot/common/cmd_nand.c中修改do_nand函数相应地方如下:/miaozh modify#if0if (read)ret = nand_read(nand, off, &size, (u_char *)addr);else ret = nand_write(nand, off, &size, (u_char *)addr);if (ret = 0) uint *magic = (uint*)(PHYS_SDRAM_1);if (0x24564236 = magic0) && (0x20764316 = magic1)magic0 = 0x27051956;#elseif (read) nand_read_options_t opts;memset(&opts, 0, sizeof(opts);opts.buffer= (u_char*) addr;opts.length= size;opts.offset= off;opts.quiet = quiet;ret = nand_read_opts(nand, &opts); else nand_write_options_t opts;memset(&opts, 0, sizeof(opts)

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论