2010-09-14 06:38:49     BF537 Nand flash problem

Document created by Aaronwu Employee on Sep 25, 2013
Version 1Show Document
  • View in full screen mode

2010-09-14 06:38:49     BF537 Nand flash problem


Message: 93415   


Hello All,


I have browsed the forums and find similar posts to mine but nothing solves my problem.  I decided to start a new posts rather than hi-jacking an old one:


We have developed a board using the BF537 chip.  We tied AMS2 to the nand chip select and could see the nand device getting detected.  However we cannot erase, write, read, etc to the device.


I downloaded the latest U-boot from blackfin.uclinux and uncommented the nand_define to get u-boot with nand support on the BF537


U-Boot 2008.10 (ADI-2009R1.1-rc1) (Sep 13 2010 - 16:49:32)


CPU:   ADSP bf537-0.3 (Detected Rev: 0.3) (bypass boot)

Board: ADI BF537 stamp board

       Support: http://blackfin.uclinux.org/

Clock: VCO: 500 MHz, Core: 500 MHz, System: 125 MHz

RAM:   64 MB

Flash:  4 MB

NAND:  128 MiB

In:    serial

Out:   serial

Err:   serial

Net:   Warning: Generating 'random' MAC address

Blackfin EMAC

MAC:   52:7E:57:13:0E:78

Hit any key to stop autoboot:  0

bfin> nand info

Device 0: AND 128MiB 3,3V 8-bit, sector size 16 KiB


bfin> nand erase clean

NAND erase: device 0 whole chip

Bad block table not found for chip 0

Bad block table not found for chip 0

No space left to write bad block table

Skipping bad block at  0x00000000

Skipping bad block at  0x00004000




Skipping bad block at  0x07ffc000



If i try and write i get the same, skips all bad blocks (entire flash) and fails the write, same with read.


Skip bad block 0x07ff8000

Skip bad block 0x07ffc000

NAND write to offset 8000000 failed -22

0 bytes written: ERROR


Skipping bad block 0x07ff8000

Skipping bad block 0x07ffc000

NAND read from offset 8000000 failed -22

0 bytes read: ERROR


I have also tried to nand scrub:


bfin> nand scrub

NAND scrub: device 0 whole chip

Warning: scrub option will erase all factory set bad blocks!

         There is no reliable way to recover them.

         Use this command only for testing purposes if you

         are sure of what you are doing!

Really scrub this NAND flash? <y/N>

Erasing at 0x7ffc000 -- 100% complete.

Bad block table not found for chip 0

Bad block table not found for chip 0

No space left to write bad block table



Any advice or help will be appreciated,






2010-09-14 06:57:40     Re: BF537 Nand flash problem

Aaron Wu (CHINA)

Message: 93416   


What's your Nand chip? Could you check if the current ADI platform Nand operation command  and operation cycle is fully compatible with that of your own Nand?




2010-09-14 07:08:31     Re: BF537 Nand flash problem


Message: 93417   


Sorry I was busy checking for the second board we have to read the nand chip:


The NAND device we are using is:


MT29F2G08AADWP.  Need to meet with a client now will be back on and do some more research in a bit.










2010-09-14 07:28:17     Re: BF537 Nand flash problem

Aaron Wu (CHINA)

Message: 93418   


Yes from your description it looks like only the ID of the Nand is correctly read out, may need to do more dubug to find out where it fails. There is a probability that the currently cycle does not match your specific Nand perfectly.




2010-09-14 07:52:00     Re: BF537 Nand flash problem


Message: 93420   


Newer Micron NAND Flash devices like the MT29F2G08AADWP require a Reset command before the Read ID command, or that part replies with values of 0x2C, 0x01, 0x02, 0x03, 0x04 to indicate it has not been reset, which results in U-Boot detecting it as the 128M AND part that it reported.


I found that fixing it required adding line


    chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);

directly before line


    chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1);

in U-Boot nand_base.c function nand_get_flash_type().


You also should check that you have set U-Boot to give slow enough bus timing for the NAND device.




Andrew Rook




2010-09-14 09:25:12     Re: BF537 Nand flash problem


Message: 93424   


Hey all,


Thanks for the quick reply's.  Yes I was actually playing around in the nand_base.c function and saw it was not selecting the correct nand device.  I did the reset before the READID command is sent and it now detects the correct NAND device 0xDA from the list. 


We are however still having some issues - It could be related to the bus timing.  The command nand scrub now returns a success however: read, write and erase do not.  We have a feeling it must be something to do either with the bus timing or the busy read output from the nand device. 


I see in u-boot that BFIN_NAND_READY is set to PF3 - on our board we tied that to PG1.  Is there any problems this will give us?  I have changed BFIN_NAND_READY to PG3 but still gives the same output: Skiiping bad block (for the entire device).  I cannot find anywhere to set the port to an input, how do I do this? 


On the bus timing where can I check this from u-boot, we have the oscilliscope out and will measure it just now.


Thank you for all the help,






2010-09-14 09:50:50     Re: BF537 Nand flash problem

Mike Frysinger (UNITED STATES)

Message: 93425   


the BFIN_NAND_READY setting is completely board specific which means it is up to the board porter (i.e. you) to make sure it actually matches the hardware.


along those lines, i see your output says "bf537 stamp" when it isnt that at all.  you should be creating your own board port instead of modifying an existing one.




2010-09-14 09:57:14     Re: BF537 Nand flash problem

Mike Frysinger (UNITED STATES)

Message: 93426   


the reset in question is already in trunk and will be in the next release (2010R1)






2010-09-14 10:19:32     Re: BF537 Nand flash problem


Message: 93427   


Yes I accept that,


That said to begin this process I will need to set BFIN_NAND_READY as PG1, is there anything I need to do on the port setup to have this as on input instead of an output?  I have searched through the u-boot code and cannot find anywhere where they set a port as output or input.








2010-09-14 10:30:40     Re: BF537 Nand flash problem

Mike Frysinger (UNITED STATES)

Message: 93428   


did you look in the board-specific nand driver ?  grepping for "BFIN_NAND_READY" shows an obvious hit in boards/<board>/nand.c ...




2010-09-14 11:49:43     Re: BF537 Nand flash problem


Message: 93435   


Hey All,


Following mike's instructions led me to the board specific nand.c file where I noticed the CONFIG_NAND_GPIO_PORT was still set to F changing this to G got system going.  We are now able to read, write and erase the flash.  Thank you all for you help.




Now it is on to the uClinux part of the project and getting that to see the flash as well.