📄 nand_flash.h
字号:
/*****************************************************************************
** nand_flash.h
**
** Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
**
** This file contains copyrighted material. Use of this file is
** restricted by the provisions of a Freescale Software License
** Agreement, which has either been electronically accepted by
** you or has been expressly executed between the parties.
**
** Description: Explanation for the usage of this file.
**
** Revision History:
** -----------------
*****************************************************************************/
#ifndef __NAND_FLASH_H__
#define __NAND_FLASH_H__
#include "type.h"
#include "stdlib.h"
#include "string.h"
#define NAND_CMD_READ (0x00)
#define NAND_CMD_READ1 (0x01)
#define NAND_CMD_READ2 (0x50)
#define NAND_CMD_READ_CONFIRM (0x30)
#define NAND_CMD_PAGE_PROG (0x80)
#define NAND_CMD_PAGE_PROG_CONFIRM (0x10)
#define NAND_CMD_ERASE (0x60)
#define NAND_CMD_ERASE_CONFIRM (0xD0)
#define NAND_CMD_READID (0x90)
#define NAND_CMD_RESET (0xFF)
#define NAND_CMD_READ_STATUS (0x70)
#define NAND_STATUS_READY (0x40)
#define NAND_STATUS_NOT_PROTECT (0x80)
#define NAND_STATUS_PROG_ERROR (0x01)
typedef struct {
u8 man_id;
u8 dev_id;
u8 bus_width;
u32 page_size;
u16 oob_size;
u8 bbm_offset;
u16 bbi_page_offset;
u8 scan_pg_num;
u8 row_addr_cycle;
u32 blk_count;
u32 ppb;
u8 model[128];
u8* bbt;
} nand_t;
/*!
* nand flash function declarations
*/
/*initialize nand flash */
extern s16 nand_init(void);
/*read flash content */
extern s16 nand_read (u32 FlashAddress, u32 TargetAddress, u32 ByteSize,dump_callback callback);
/*write data to flash*/
extern s16 nand_write(u32 FlashAddress, u32 SourceAddress, u32 ByteSize,u8 file_format,response_callback callback);
/* Compare memory content*/
extern s16 nand_compare(u32 FlashAddress, u32 TargetAddress, u32 ByteSize,response_callback callback);
/* Erase content in specific range*/
extern s16 nand_erase_conditional(u32 StartAddress, u32 EndAddress,response_callback callback);
extern void copy_spare(nand_t *nd,char *pbuf,char *pspare,int len,u8 bfrom);
extern s16 mark_bad_block(nand_t *nd,u32 nrblk);
extern u8 is_good_block(nand_t* nd, u32 nrblk,int allowbbt);
extern int nand_scan_bbt(nand_t *nd);
extern u8 nand_isbad_bbt(nand_t *nd, u32 nrblk, int allowbbt);
extern int nand_bbt_markbad(nand_t *nd, u32 nrblk);
#endif /* __NAND_FLASH_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -