0% found this document useful (0 votes)
184 views5 pages

Nand Flash Driver Adding Guide

Manual H-JTAG SOC-FPGA 5000

Uploaded by

ddpout
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
184 views5 pages

Nand Flash Driver Adding Guide

Manual H-JTAG SOC-FPGA 5000

Uploaded by

ddpout
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

H-JTAG

NAND FLASH DRIVER


ADDING GUIDE

Doc Edition K

Release Date: 2012-02-15

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.

2. NAND FLASH DEVICE DESCRIPTOR

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

The detailed definitions are given below.

Copyright © 2012 WWW.HJTAG.COM All Rights Reserved 1


 FLASH_TYPE=3
Used to specify the flash type. Type 3 represents NAND flash.

 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.

3. NAND FLASH DRIVER

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.

Under the installation directory of H-JTAG ( H-JTAG\FDevice\NAND-FLASH\SourceCodes (ADS1.2) ), all


the source codes of our published drivers can be found. All these drivers are implemented based on the same
template. User can use them as reference to develop your own driver. Please note that the size of the generated
binary flash driver should be less than 16K Bytes.

Copyright © 2012 WWW.HJTAG.COM All Rights Reserved 2


First, the binary code needs to be compiled and generated. After that, rename the binary driver according to
the name specified in the descriptor and copy the driver to H-JTAG\FDEVICE\NAND-FLASH\DRIVERS. Then,
H-Flasher can find the driver according the obtained information from the descriptor.

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.

void nand_read_page(U32 blockidx, U32 pageidx)


This is the function used to read one page (main area only). The arguments include the block index and page
index to be read. This function should read one page of data from the main area of the specified page and
return them to H-Flasher by calling write_to_host(). The total length of the read data is the size of the main
area. Please note that each call of write_to_host() should return 4 Bytes of data to host.

void nand_dump_page(U32 blockidx, U32 pageidx)


This is the function used to read one page (main and spare areas). The arguments include the block index and
page index to be read. This function should read one page of data from the main area and spare area of the
specified page and return them to H-Flasher by calling write_to_host(). The total length of the read data is the
size of the main area and spare area. Please note that each call of write_to_host() should return 4 Bytes of
data to host.

U32 nand_program_page(U32 blockidx, U32 pageidx)


This is the function used to program one page. The arguments include the block index and page index to be
programmed. This function should receive one page of data (the length is the size of main area) from
H-Flasher by calling read_from_host() and then program them into the main area of the specified page. The
received data is only for main area. It is user’s decision on if the driver should program the spare area and
how. Please note that each call of read_from_host() receives 4 Bytes of data from host.

U32 nand_program_page_main_and_spare(U32 blockidx, U32 pageidx)


This is the function used to program one page. The arguments include the block index and page index to be
programmed. This function should receive one page of data (the length is the size of main area and spare area)
from H-Flasher by calling read_from_host() and then program them into the main area and spare area of the
specified page. Please note that each call of read_from_host() receives 4 Bytes of data from host.

U32 nand_erase_block(U32 blockidx)


This is the function used to erase a block. The argument includes the block index to be erased. This function
should erase the specified block and return the result.

Copyright © 2012 WWW.HJTAG.COM All Rights Reserved 3


U32 nand_check_blank(U32 blockidx)
This is the function used to check if a block is blank or not. The argument includes the block index to be
checked.

U32 nand_mark_badblock(U32 blockidx)


This is the function used to mark a bad block. The argument includes the block index to be marked.

U32 nand_is_badblock(U32 blockidx)


This is the function used to check if a block is bad or not. The argument includes the block index to be
checked.

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.

4. MORE INFORMATION AND HELP

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.

Copyright © 2012 WWW.HJTAG.COM All Rights Reserved 4

You might also like