This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] AM62A7: Bad Block Implementation for NAND Flash Parts

Part Number: AM62A7
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

From release 10.00.00.14 onwards, BBM has been implemented in TI Drivers for NAND Flash Parts. 

AM62A MCU SDK: https://www.ti.com/tool/download/MCU-PLUS-SDK-AM62A/10.00.00.14

Few commonly asked questions are:

  1. Where is the Bad Block implementation?
  2. How to enable bad block checking for my application?
  3. While writing or reading to the flash part, what happens if a block is bad? Please explain the procedure.

Let's address each one of these questions.

  • Where is the Bad Block implementation?

    The current Bad block implementation in the TI drivers can be found under the following directory:

    "C:\ti\mcu_plus_sdk_am62ax_10_00_00_14\source\board\flash\ospi\flash_nand_ospi.c"

  • How to enable bad block checking for my application?

    For your custom application, you can go ahead and look out for a file named example.syscfg. You can go ahead and open this in the SysConfig tool which TI provides. Now, from this point onwards you would need to enable the Bad Block Checking as shown in the screenshot below.

    The dropdown option Yes should be selected if you want to enable bad block checking and no either way.

    Now you have enabled bad block checking for your application, but how does this works? Let's see in the responses below.

  • While writing or reading to the flash part, what happens if a block is bad? Please explain the procedure.

    So the current SDK code which does the BBM does the following for both write and read operations to the flash.

    For an instance, consider the NAND flash part on the AM62A TI EVM. 

    So there are about 512 blocks and each block has 64 pages.

    Now the write operation for an instance is done to specific page which the user/application provides.

    Now here is the thing, so lets say we have few blocks at the very starting namely 1st, 2nd, 3rd block,..... and so on.

    Now lets assume 1st and 3rd blocks are good and 2nd block is bad.

    Given each block has 64 pages, so currently we are in the following scenario.

    1st block(good: has 64 pages), 2nd block(bad: has 64 pages), 3rd block(good: has 64 pages)

    Now a write operation of some data D1 on page 10 would be successful as this page 10 falls under 1st block(good).

    Now if the user does a write operation on page 70, then the drivers for BBM are written in such a way that it will write to the next available good block.

    So, now the value D2 to be written to page 70 falls under 2nd block(bad) so we add the value 64 to this number and get the new page number = 70 + 64 = 134. Now the value D2 will be written to 134(3rd block(good)). NOTE: If any value apart from 0xFF is encountered in the spare area of the first page itself, then we do not skip a page, but a block itself. So essentially we are skipping a block or 64 pages, as 64 pages makes up one block(considering NAND flash part on AM62A TI EVM)

    Please Note:

    It might be possible that prior to the value D2 being written to page 134, page 134 might be already having some value Dx.

    Now since the new value D2 is written to page 134, the value Dx will be overwritten and this is not taken care in the TI drivers as of now.

    Please also note:

    The way a bad block is checked as of now is as follows. So for the current block, we check the first page. Now in the first page we check the spare area(spare area size: 128 bytes) and compare the value. If it is 0xFF then it is fine, but if it is any other value apart from 0xFF then its bad block.