• AVR Freaks

Hot!Enable NAND flash on-die ECC with sam-ba

Author
jharden
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2021/02/03 00:15:35
  • Location: 0
  • Status: offline
2021/03/01 05:13:55 (permalink)
0

Enable NAND flash on-die ECC with sam-ba

Hi,
 
I am writing a BSP and application software for a board based on the SAMA5D27-D1G SiP and we are using a 512 MiB NAND Flash from Micron (MT29F4G08ABAFAWP). This flash memory has on-die support for calculating ECC with 8 bit correction capability. It is fairly easy to add or enable support for this in at91bootstrap, U-Boot and the Linux kernel, but my problem is that the SAM-BA NAND flash applet for the SAMA5D2 does not seem to have this option, so when writing to the flash with sam-ba, the ECC bits in the OOB area are never written. Thus, I cannot enable this feature when booting because then the ECC calculation becomes wrong compared to the (not) stored bits.
 
Is there any other version of the NAND flash applet that has support enabling on-die ECC? How else can I solve the problem?
 
Best regards,
Jonas
#1

2 Replies Related Threads

    blue_z
    Moderator
    • Total Posts : 18
    • Reward points : 0
    • Status: offline
    Re: Enable NAND flash on-die ECC with sam-ba 2021/03/01 18:34:15 (permalink)
    4 (1)
    jharden
    Is there any other version of the NAND flash applet that has support enabling on-die ECC?
    You neglect to mention which version of SAM-BA you're using, but presumably it's some 3.x rather than 2.x. 
     
    The NAND flash applet of SAM-BA 3.x is from the Atmel Software Package
    A quick look at samba_applets/nandflash/main.c has in handle_cmd_initialize() :
        /* try reading ONFI data */
        if (nand_onfi_device_detect(&nand) && nand_onfi_check_compatibility(&nand)) {
            nand_onfi_disable_internal_ecc(&nand);
       ...

    Interestingly there's a complementary (and apparently unused) routine nand_onfi_enable_internal_ecc() in the driver module drivers/nvm/nand/nand_flash_onfi.c, but it has some restrictions that would need revising for the chip you're using. 
    So instead of unconditionally disabling any internal ECC, hack the init routine to first try enabling the internal ECC. 
    You could then try rebuilding the NAND flash applet for SAM-BA with a hacked NAND driver.
     
    jharden
    How else can I solve the problem?
    You could try loading U-Boot somehow, and use its capabilities.
     
     
    Regards
    #2
    jharden
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2021/02/03 00:15:35
    • Location: 0
    • Status: offline
    Re: Enable NAND flash on-die ECC with sam-ba 2021/03/03 00:05:20 (permalink)
    0
    blue_z
    You neglect to mention which version of SAM-BA you're using, but presumably it's some 3.x rather than 2.x.

    Yes, you're assumption is correct. I am using version 3.2.3, but I can upgrade to the latest 3.x if needed.
     
    blue_z
    The NAND flash applet of SAM-BA 3.x is from the Atmel Software Package

    Thanks for pointing me there! I didn't see any reference to it in the SAM-BA source code or documentation, but I might have just missed it. I will try to build the NAND flash applet and modify it for using the internal ECC, as you suggest.
     
    Best regards,
    Jonas
    #3
    Jump to:
    © 2021 APG vNext Commercial Version 4.5