主题 : nand_write: Attempt to write not page aligned data 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 7800
精华: 0
发帖: 49
金钱: 490 两
威望: 257 点
贡献值: 0 点
综合积分: 98 分
注册时间: 2009-07-29
最后登录: 2017-09-13
10楼  发表于: 2009-10-23 15:41
明白了,那我nand write.yaffs 30008000 offset filesize 这个filesize大小就按照我下载的大小写就行了?因为用mkyaffs2制作的必定是2112对齐的?
级别: 新手上路
UID: 7800
精华: 0
发帖: 49
金钱: 490 两
威望: 257 点
贡献值: 0 点
综合积分: 98 分
注册时间: 2009-07-29
最后登录: 2017-09-13
11楼  发表于: 2009-10-23 15:50
换了版主提供的mkyaffs2image 制作出来大小还是1599312,怎么回事?
但是1159312是2048的整数倍哦!
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
贡献值: 71 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
12楼  发表于: 2009-10-23 15:54
引用第10楼linuxway于2009-10-23 15:41发表的  :
明白了,那我nand write.yaffs 30008000 offset filesize 这个filesize大小就按照我下载的大小写就行了?因为用mkyaffs2制作的必定是2112对齐的?

是的
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
贡献值: 71 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
13楼  发表于: 2009-10-23 16:02
引用第11楼linuxway于2009-10-23 15:50发表的  :
换了版主提供的mkyaffs2image 制作出来大小还是1599312,怎么回事?
但是1159312是2048的整数倍哦!

那我就不知道了,我用root_qtopia.tgz制作出来的yaffs2 image是38130048,2112字节的整数倍
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 7800
精华: 0
发帖: 49
金钱: 490 两
威望: 257 点
贡献值: 0 点
综合积分: 98 分
注册时间: 2009-07-29
最后登录: 2017-09-13
14楼  发表于: 2009-10-23 16:03
等等 制作文件系统之前先要压缩文件成tgz的吗?
级别: 新手上路
UID: 7800
精华: 0
发帖: 49
金钱: 490 两
威望: 257 点
贡献值: 0 点
综合积分: 98 分
注册时间: 2009-07-29
最后登录: 2017-09-13
15楼  发表于: 2009-10-23 16:04
我的命令是 mkyaffs2image  fs  fs.image
fs是根文件系统顶层目录
级别: 新手上路
UID: 7800
精华: 0
发帖: 49
金钱: 490 两
威望: 257 点
贡献值: 0 点
综合积分: 98 分
注册时间: 2009-07-29
最后登录: 2017-09-13
16楼  发表于: 2009-10-23 16:18
您好,我换了100ask 上的mkyaffs2image 制作出来正好是2112的整数倍,烧写后却出现开始给的data abort 可能是什么造成的呢?以下是我的nand_util.c文件修改了的后面的部分:
复制代码
  1. int nand_write_skip_bad(nand_info_t *nand, size_t offset, size_t *length,
  2.             u_char *buffer)
  3. {
  4.     int rval;
  5.     size_t left_to_write = *length;
  6.     size_t len_incl_bad;
  7.     u_char *p_buffer = buffer;
  8.     
  9.     [u]if(nand->writeoob==1)
  10.     {
  11.         size_t oobsize = nand->oobsize;
  12.         size_t datasize = nand->writesize;
  13.         
  14.         int datapages = 0;
  15.         
  16.         if(((*length)%(nand->oobsize + nand->writesize)) != 0)
  17.         {
  18.             printf("*length=%d,pagesize=%d\n",*length,nand->oobsize+nand->writesize);
  19.             printf("Attempt to write error length data!\n");
  20.             return -EINVAL;
  21.         }
  22.         
  23.         datapages = *length/(datasize + oobsize);
  24.         printf("datasize+oobsize=%d,datapages=%d\n",datasize+oobsize,datapages);
  25.         *length = datapages * datasize;
  26.         left_to_write = *length;
  27.         nand->skipfirstblock=1;
  28.     }
  29.     /* Reject writes, which are not page aligned */
  30. /*    if ((offset & (nand->writesize - 1)) != 0 ||
  31.         (*length & (nand->writesize - 1)) != 0) {
  32.         printf ("Attempt to write non page aligned data\n");
  33.         return -EINVAL;
  34.     }
  35. */[/u]    len_incl_bad = get_len_incl_bad (nand, offset, *length);
  36.     if ((offset + len_incl_bad) >= nand->size) {
  37.         printf ("Attempt to write outside the flash area\n");
  38.         return -EINVAL;
  39.     }
  40.     if (len_incl_bad == *length) {
  41.         rval = nand_write (nand, offset, length, buffer);
  42.         if (rval != 0) {
  43.             printf ("NAND write to offset %x failed %d\n",
  44.                 offset, rval);
  45.             return rval;
  46.         }
  47.     }
  48.     while (left_to_write > 0) {
  49.         size_t block_offset = offset & (nand->erasesize - 1);
  50.         size_t write_size;
  51.         if (nand_block_isbad (nand, offset & ~(nand->erasesize - 1))) {
  52.             printf ("Skip bad block 0x%08x\n",
  53.                 offset & ~(nand->erasesize - 1));
  54.             offset += nand->erasesize - block_offset;
  55.             continue;
  56.         }
  57.         /*added */
  58.         [u]if(nand->skipfirstblock==1)
  59.         {
  60.             nand->skipfirstblock=0;
  61.             printf("skip the first blcok!\n");
  62.             offset+=nand->erasesize - block_offset;
  63.             continue;
  64.         }[/u]        /*end add*/
  65.         if (left_to_write < (nand->erasesize - block_offset))
  66.             write_size = left_to_write;
  67.         else
  68.             write_size = nand->erasesize - block_offset;
  69.         rval = nand_write (nand, offset, &write_size, p_buffer);
  70.         if (rval != 0) {
  71.             printf ("NAND write to offset %x failed %d\n",
  72.                 offset, rval);
  73.             *length -= left_to_write;
  74.             return rval;
  75.         }
  76.         left_to_write -= write_size;
  77.         offset        += write_size;
  78. [u]//        p_buffer      += write_size;
  79.         if(nand->writeoob==1)
  80.     p_buffer += write_size + (write_size/nand->writesize*nand->oobsize);
  81.         else
  82.             p_buffer += write_size;[/u]
  83.     }
  84.     return 0;
  85. }
  86. /**
  87. * nand_read_skip_bad:
  88. *
  89. * Read image from NAND flash.
  90. * Blocks that are marked bad are skipped and the next block is readen
  91. * instead as long as the image is short enough to fit even after skipping the
  92. * bad blocks.
  93. *
  94. * @param nand NAND device
  95. * @param offset offset in flash
  96. * @param length buffer length, on return holds remaining bytes to read
  97. * @param buffer buffer to write to
  98. * @return 0 in case of success
  99. */
  100. int nand_read_skip_bad(nand_info_t *nand, size_t offset, size_t *length,
  101.                u_char *buffer)
  102. {
  103.     int rval;
  104.     size_t left_to_read = *length;
  105.     size_t len_incl_bad;
  106.     u_char *p_buffer = buffer;
  107.     len_incl_bad = get_len_incl_bad (nand, offset, *length);
  108.     if ((offset + len_incl_bad) >= nand->size) {
  109.         printf ("Attempt to read outside the flash area\n");
  110.         return -EINVAL;
  111.     }
  112.     if (len_incl_bad == *length) {
  113.         rval = nand_read (nand, offset, length, buffer);
  114.         if (rval != 0) {
  115.             printf ("NAND read from offset %x failed %d\n",
  116.                 offset, rval);
  117.             return rval;
  118.         }
  119.     }
  120.     while (left_to_read > 0) {
  121.         size_t block_offset = offset & (nand->erasesize - 1);
  122.         size_t read_length;
  123.         if (nand_block_isbad (nand, offset & ~(nand->erasesize - 1))) {
  124.             printf ("Skipping bad block 0x%08x\n",
  125.                 offset & ~(nand->erasesize - 1));
  126.             offset += nand->erasesize - block_offset;
  127.             continue;
  128.         }
  129.         if (left_to_read < (nand->erasesize - block_offset))
  130.             read_length = left_to_read;
  131.         else
  132.             read_length = nand->erasesize - block_offset;
  133.         rval = nand_read (nand, offset, &read_length, p_buffer);
  134.         if (rval != 0) {
  135.             printf ("NAND read from offset %x failed %d\n",
  136.                 offset, rval);
  137.             *length -= left_to_read;
  138.             return rval;
  139.         }
  140.         left_to_read -= read_length;
  141.         offset       += read_length;
  142.         p_buffer     += read_length;
  143.     }
  144.     return 0;
  145. }
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
贡献值: 71 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
17楼  发表于: 2009-10-23 16:21

 回 14楼(linuxway) 的帖子

不需要,你可以试试用http://www.arm123.com.cn/linux/root_qtopia.tgz,解压开来之后再用mkyaffs2image做成镜像。注意解压和制作镜像需要root权限,否则文件系统里的一些特殊文件比如设备节点可能会损坏。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 7800
精华: 0
发帖: 49
金钱: 490 两
威望: 257 点
贡献值: 0 点
综合积分: 98 分
注册时间: 2009-07-29
最后登录: 2017-09-13
18楼  发表于: 2009-10-23 16:38
这个弄出来有58M 太大了吧? 全部直接下到内存行吗?
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
贡献值: 71 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
19楼  发表于: 2009-10-23 17:16

 回 18楼(linuxway) 的帖子

你换台电脑吧,我做出来的镜像是38M
至于为什么crash, 我没有你的源代码,不清楚具体crash在什么地方,只能靠你自己查了
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."