硬汉嵌入式论坛

 找回密码
 立即注册
查看: 6881|回复: 4
收起左侧

[有问必答] 跪求大神解决,把nand flash 改为2G的,移植后出现电脑无法格式化。

[复制链接]

10

主题

12

回帖

42

积分

新手上路

积分
42
发表于 2014-4-25 17:10:05 | 显示全部楼层 |阅读模式
这两天在研究把nand flash 改为2G的,
用的型号为  H27UAG8T2B。
用的例程是  F4-006b_USB Mass Storage例程(NAND Flash模拟U盘)
修改文件  bsp_nand_flash.c中的
               uint32_t NAND_ReadID(void);//读NAND Flash的ID。ID存储到形参指定的结构体变量中。
               static uint8_t FSMC_NAND_WritePage(uint8_t *_pBuffer, uint32_t _ulPageNo, uint16_t _usAddrInPage, uint16_t _usByteCount)               //写页
               static uint8_t FSMC_NAND_ReadPage(uint8_t *_pBuffer, uint32_t _ulPageNo, uint16_t _usAddrInPage, uint16_t _usByteCount)                //读页
               static uint8_t FSMC_NAND_EraseBlock(uint32_t _ulBlockNo);                            //擦快
               static uint8_t FSMC_NAND_PageCopyBackEx(uint32_t _ulSrcPageNo, uint32_t _ulTarPageNo, uint8_t *_pBuf, uint16_t _usOffset, uint16_t _usSize)  //将一页数据复制到另外一个页,并更新目标页中的部分数据。源页和目标页必须同为偶数页或同为奇数页。
               static uint8_t FSMC_NAND_PageCopyBack(uint32_t _ulSrcPageNo, uint32_t _ulTarPageNo)             将一页数据复制到另外一个页
修改文件  bsp_nand_flash.中的
                      #define NAND_PAGE_SIZE             ((uint16_t)0x2000) /* 8192 bytes per page w/o Spare Area */
               #define NAND_BLOCK_SIZE            ((uint16_t)0x0100) /* 256 pages per block */
               #define NAND_ZONE_SIZE             ((uint16_t)0x0400) /* 1024 Block per zone */
               #define NAND_SPARE_AREA_SIZE       ((uint16_t)0x01c0) /* last 64 bytes as spare area */
               #define NAND_MAX_ZONE              ((uint16_t)0x0001) /* 1 zones of 1024 block */

      上述函数都修改正确
然后查看usbd_storage_msd.c中对接函数

int8_t STORAGE_Read (uint8_t lun,                                          
                 uint8_t *buf,
                 uint32_t blk_addr,
                 uint16_t blk_len)

int8_t STORAGE_Write (uint8_t lun,                  
                  uint8_t *buf,
                  uint32_t blk_addr,
                  uint16_t blk_len)
int8_t STORAGE_Init (uint8_t lun)
int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_size)
这四个函数,对接函数正确,但是出现问题。

出现U盘模式
360截图20140425170635615.jpg
可以识别大小
360截图20140425170654210.jpg

格式化失败
360截图20140425170711167.jpg

求大神解决。
回复

使用道具 举报

10

主题

12

回帖

42

积分

新手上路

积分
42
 楼主| 发表于 2014-4-28 17:29:33 | 显示全部楼层
[s:149]
回复

使用道具 举报

10

主题

12

回帖

42

积分

新手上路

积分
42
 楼主| 发表于 2014-4-28 17:29:55 | 显示全部楼层
有人做过类似的东西吗
回复

使用道具 举报

9

主题

12

回帖

39

积分

新手上路

积分
39
发表于 2014-8-21 19:31:01 | 显示全部楼层
#define NAND_ZONE_SIZE             ((uint16_t)0x0400) /* 1024 Block per zone */
回复

使用道具 举报

9

主题

12

回帖

39

积分

新手上路

积分
39
发表于 2014-8-21 19:31:36 | 显示全部楼层
#define NAND_ZONE_SIZE             ((uint16_t)0x0800)                       --------  /* 2048 Block per zone */
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-6-13 21:29 , Processed in 0.221138 second(s), 27 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表