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.

how to enable am335x nand bbt in kernel and u-boot?

In am335x sdk, the file driver/mtd/nand/omap2.c:
info->nand.options  = pdata->devsize;  //1. why using devsize
info->nand.options  |= NAND_SKIP_BBTSCAN; //2. relationship with u-boot BBT
I change like this:

#if 0
    info->nand.options  = pdata->devsize;
    info->nand.options  |= NAND_SKIP_BBTSCAN;
#else
    info->nand.bbt_options |= NAND_BBT_USE_FLASH;
#endif

At the same time in u-boot:

//am335x_evm.h

#define CONFIG_SYS_NAND_USE_FLASH_BBT

//omap_gpmc.c

    nand->options = NAND_NO_PADDING | NAND_CACHEPRG | NAND_NO_AUTOINCR;
#ifdef CONFIG_SYS_NAND_USE_FLASH_BBT
    nand->options     |= NAND_USE_FLASH_BBT;
#endif

Is there any some question to enable BBT in NAND (not in ram)?

  • Hi,

    I will forward this to the SW team.

  • Hi,

    As I understand you are using SDK 6.0. To enable BBT the right place is board file <>/ti-sdk-am335x-evm-06.00.00.00/board-support/linux-3.2.0-psp04.06.00.11/arch/arm/mach-omap2/board-am335xevm.c in evm_nand_init(...) procedure. For example:
    pdata->ecc_opt =OMAP_ECC_BCH8_CODE_HW;
    pdata->bbt_options = NAND_BBT_USE_FLASH;
    pdata->elm_used = true;

    bbt-options is not defined. You have to declare it in <>/ti-sdk-am335x-evm-06.00.00.00/board-support/linux-3.2.0-psp04.06.00.11/arch/arm/plat-omap/include/plat/nand.h file in a structure omap_nand_platform_data. For example:
    enum omap_ecc ecc_opt;
    unsigned bbt_options;
    bool elm_used;

    BR
    Ivan
  • 1. question about kernel:
    Is it necessary to set "info->nand.bbt_options |= NAND_BBT_USE_FLASH;" in driver/mtd/nand/omap2.c?
    Can you explain the aim of this c code:
    info->nand.options = pdata->devsize;
    info->nand.options |= NAND_SKIP_BBTSCAN;
    2. question about u-boot:
    In u-boot:
    //am335x_evm.h
    #define CONFIG_SYS_NAND_USE_FLASH_BBT
    //omap_gpmc.c
    nand->options = NAND_NO_PADDING | NAND_CACHEPRG | NAND_NO_AUTOINCR;
    #ifdef CONFIG_SYS_NAND_USE_FLASH_BBT
    nand->options |= NAND_USE_FLASH_BBT;
    #endif
    But I find BBT will be reinitialized once board is reset. when I execute cmd "nand markbad offset", cmd "nand bad" can not reflect the markbad block once board is reset.

    Could you answer my two question?
    Thanks a lot.
  • Hi,

    For the question 1:
    - no - you haven't set "info->nand.bbt_options |= NAND_BBT_USE_FLASH;" in driver/mtd/nand/omap2.c. This initialization is needed for nand_bbt.c.
    - info->nand.options = pdata->devsize;
    - info->nand.options |= NAND_SKIP_BBTSCAN;
    - this is bit initialization word. You can see that nand.options always used with and(&) xxx.
    To be sure that this BBT check will execute you can check in all places the result from "info->bbt_options & NAND_BBT_USE_FLASH". If this result is true will execute checking.
    For the question 2:
    - I think that is not needed to make this changes there, but you see from question 1 what is needed and you can make this your self.

    BR
    Ivan
  • What you said:
    ---board-am335xevm.c in evm_nand_init(...) procedure. For example:
    ---pdata->ecc_opt =OMAP_ECC_BCH8_CODE_HW;
    ---pdata->bbt_options = NAND_BBT_USE_FLASH;
    structure omap_nand_platform_data * pdata;

    Could you tell me the relationship between " info->nand.bbt_options |= NAND_BBT_USE_FLASH;" and "info->nand.bbt_options |= NAND_BBT_USE_FLASH;" ?

    About question 2:
    Why? "But I find BBT will be reinitialized once board is reset. when I execute cmd "nand markbad offset", cmd "nand bad" can not reflect the markbad block once board is reset." when I set "nand->options |= NAND_USE_FLASH_BBT;" in u-boot?


    Thanks a lot.
  • Hi,

    I told that because it's good to make this initialization in a board file. But if you prefer you can make this initialization anywhere. It's important this initialization to be done at the latest in a driver initialization.
    The logic for u-boot is the same. You can make this initialization in a board include file or other places. I saw that in a driver nand_default_bbt(...) is set if (this->options & NAND_IS_AND) is true, but if you want can set outside this if.

    BR
    Ivan
  • 1.Thers is something wrong in u-boot when I enable "#define CONFIG_SYS_NAND_USE_FLASH_BBT". when excuting ""nand markbad offset",

    bad block infomation is written to oob, when you reset boart, "nand bad" cmd can read the bad block.

    But when you disable "#define CONFIG_SYS_NAND_USE_FLASH_BBT", after excuting ""nand markbad offset",
    bad block infomation is written to bbt(not int oob of that block), when you reset boart, "nand bad" cmd can not read the bad block.

    Could you tell me why?

    Thanks a lot.

  • 1. There is something with the description above.
    Thers is something wrong in u-boot when I enable "#define CONFIG_SYS_NAND_USE_FLASH_BBT". After excuting command "nand markbad offset", bad block infomation is written to bbt(not in oob), and when you reset board, command "nand bad" can not read the bad block.

    But when you disable "#define CONFIG_SYS_NAND_USE_FLASH_BBT", after excuting command "nand markbad offset",
    bad block information is only written to oob, when you reset board, command "nand bad" can read the bad block.

    Could you tell me why?

    Thanks a lot.
  • Hi ,

    Please see more detailed the available options for BBT defined in include/linux/mtd/nand.h for kernel and include/linux/mtd/nand.h for u-boot and see the comments for declaration and estimate which definitions are needed.

    BR
    Ivan