Nand Flash Driver Adding Guide
Nand Flash Driver Adding Guide
Doc Edition K
WWW.HJTAG.COM
NAND FLASH DRIVER ADDING GUIDE
This document introduces how to add a new NAND flash driver into H-Flasher. User can use this guide as a
reference to add a new driver or modify existing ones.
1. BASIC INTRODUCTION
The access of NAND flash and NOR flash are quite different. NOR flash can be accessed directly through the
address bus and data bus. It means that a general flash driver can be made for a specific NOR flash device, which
can be used for different MCUs. For NAND flash, the access needs to be done through NAND flash controller.
For different MCUs, the NAND flash controllers are totally different. It means that no general flash driver can be
made for a specific NAND flash. Hence, the driver for NAND flash can only be written based on a specific
NAND flash and MCU combination.
To add a new NAND flash driver into H- Flasher, both a flash device descriptor and the corresponding flash
driver need to be provided. The flash device descriptor contains all the basic information about the NAND flash
device, like the size, the organization, FLASH ID, driver, etc. The flash driver is a small piece of binary code,
which can be used to operate on the flash device, like read, write and erase. H-Flasher communicates with the
driver to achieve the basic flash operations. For more details about the flash descriptor and flash driver, please
refer to the following sections.
The NAND flash device descriptor is a TXT file, which can be open and edited with any TXT editors. The
descriptor contains all the basic information about the flash device. H-Flasher can obtain all the details by parsing
the descriptor. Following is an illustrative descriptor based on K9F1G08 from Samsung.
FLASH_TYPE=3
FLASH_SIZE=128M
FLASH_ID=0x00A100EC
FLASH_ADDRESS=0x0
FLASH_NAND_DEVICE=(2048+64)x64PAGESx1024BLOCKS
FLASH_WIDTH=8/0/0
FLASH_DRIVER=1003/0/0
FLASH_SIZE=128M
Used to specify the size of the flash device, the unit is BYTE. In this example, the size is 128M Bytes.
FLASH_ID=0x00A100EC
Used to specify the flash ID. In this example, the device ID is 0xA1and the manufacturer ID is 0xEC.
FLASH_ADDRESS=0x0
Used to specify the starting address. For NAND flash, this should always be 0x0.
FLASH_NAND_DEVICE=(2048+64)x64PAGESx1024BLOCKS
Used to specify the organization of the NAND flash. In this example, the flash device contains 1024 blocks,
each block contains 64 pages and the size of each page is (2048+64) Bytes. The size of the main area is 2048
Bytes and the size of the spare area is 64 Bytes.
FLASH_WIDTH=8/0/0
Used to specify the bus width. In this example, the width is 8-BIT. For a 16-BIT flash device, the
corresponding width should be specified as FLASH_WIDTH=0/16/0. For a 32-BIT flash device, the
corresponding width should be specified as FLASH_WIDTH=0/0/32.
FLASH_DRIVER=1003/0/0
Used to specify the driver. In this example, the flash width is 8-BIT and its corresponding driver is 1003. For
a 8-BIT flash device, the driver should be specified as FLASH_DRIVER=DRIVER/0/0.For a 16-BIT flash
device, the driver should be specified as FLASH_DRIVER=0/DRIVER/0. For a 32-BIT flash device, the
driver should be specified as FLASH_DRIVER=0/0/DRIVER. Please note that the driver can only be named
by digits, otherwise, H-Flasher can’t recognize it.
To add a new NAND flash into H-Flasher, create a new flash device descriptor and fill in all the details. Then
copy it to H-JTAG\FDEVICE\NAND-FLASH\. After restarting H-Flasher, the new device will be shown in the
flash list under the NAND-FLASH folder. The name of the device is the file name of the descriptor.
NAND flash driver is a piece of binary code, which implements all the basic flash operations. H-Flasher
achieves all the operations by talking to the driver. Besides the descriptor, the corresponding driver also needs to
be provided.
In the source codes, all the flash operations are defined and implemented in Flash.H and Flash.C. To modify
an existing driver to fit your own hardware platform, only these two files need to be changed. Flash.H contains all
the definitions about the flash and MCU. Flash.C contains all the implementation of the basic flash operations. All
the functions implemented in Flash.C are listed below.
void nand_init(void)
This is the function used for initialization. User can put any initialization code in this function.
U32 nand_read_id(void)
This is the function used for the read of flash ID. This function should read the flash ID and return it.
U32 nand_info_table(void)
This is the function used to receive the bad block table and relocation table. This function will only be used
when RELOCATION mode is enabled in H-Flasher. Under RELOCATION mode, H-Flasher will send the
bad block table and relocation table to the driver after the programming is done. This function is used to
receive the tables. User can use this function to build the bad block table and relocation table inside the flash
based on the received information.
If you need any further information or help, please feel free to contact us through email or telephone. We will
always try to provide as much help as possible. Our contacts can be found on our website www.hjtag.com.