SAMA5D28 custom board: nandflash issue in uboot

Discussions about all user software around SAM Series.

Moderator: nferre

ganesha.ld
Posts: 34
Joined: Mon Dec 19, 2011 7:01 pm

SAMA5D28 custom board: nandflash issue in uboot

Thu Oct 19, 2017 1:17 pm

Hi,
I am trying to bring up a Custom board with SAMA5D28 (MRL C) processor. This board design is based on SAMA5D2 xplained (XULT) rev 2 board. We have also added nandflash additionally to our custom board.

I'm using sam-ba_3.2.0 for programming the nandflash.

I'm facing some issue with nandflash in u-boot. Here are the details of nandflash I'm using

Model: Micron MT29F8G08ABABAWP (1 Giga Bytes, 8 bit)
Organization
– Page size x8: 4320 bytes (4096 + 224 bytes)
– Block size: 128 pages (512K +28 K bytes)
– Plane size: 2 planes x 1024 blocks per plane
– Device size: 8Gb: 2048 blocks
- Minimum required ECC: 4-bit ECC

I have used "0xc2a02e07" as pmecc header value while programming the nandflash.
usePmecc = 1, (0x1)
nbSectorPerPage = 3, (0x3) - 8 sectors per page
spareSize = 224, (0xe0)
eccBitReq = 1, (0x1) - 4 bits ECC
sectorSize = 0, (0x0) - 512 bytes per secor consideration
eccOffset = 168, (0xa8) - 7 bytes/sector, so 224-(7*8) = 168.
I have been able to get the at91bootstrap up and it copies uboot code into appropriate RAM location.
Even uboot comes up and detects the nandflash correctly (that its 1024 MiB nand). Now, uboot throws an error saying that NO valid environment area found in nandflash. Also, reports that a bad block in offset 0x100000 while trying to save an environment variable using saveenv command.

Here is the log:
RomBOOT
AT91Bootstrap 3.8.9-dirty (Wed Oct 11 19:11:44 IST 2017) SemaConnect

All interrupts redirected to AIC
Auto-Config the TWI Bus by the board
NAND: ONFI flash detected
NAND: Manufacturer ID: 0x2c Chip ID: 0x38
NAND: Page Bytes: 4096, Spare Bytes: 224
NAND: ECC Correctability Bits: 4, ECC Sector Bytes: 512
NAND: Disable On-Die ECC
PMECC: version is: 0x0
PMECC: page_size: 4096, oob_size: 224, pmecc_cap: 4, sector_size: 512
NAND: Initialize PMECC params, cap: 4, sector: 512
NAND: Image: Copy 0xa0000 bytes from 0x40000 to 0x26f00000
NAND: Done to load image

U-Boot 2017.03-linux4sam_5.7-dirty (Oct 17 2017 - 16:01:17 +0530)

CPU: SAMA5D28-CU
Crystal frequency: 12 MHz
CPU clock : 498 MHz
Master clock : 166 MHz
DRAM: 256 MiB
NAND: 1024 MiB
MMC: sdio-host@a0000000: 0, sdio-host@b0000000: 1
*** Error - No Valid Environment Area found
*** Warning - bad CRC, using default environment

In: serial
Out: serial
Err: serial
Failed to read ethernet address from EEPROM
Net:
Warning: ethernet@f8008000 (eth0) using random MAC address - aa:1a:25:4c:28:89
eth0: ethernet@f8008000
Hit any key to stop autoboot: 0
=>
=>
=> setenv ethaddr aa:1a:25:4c:28:89
=> save
Saving Environment to NAND...
Erasing redundant NAND...
Attempt to erase non block-aligned data
Erasing NAND...
Skipping bad block at 0x00100000
Writing to NAND... FAILED!
=>
Please refer to attached schematics for nandflash connections
Please help in resolving the issue.
Thanks!!
blue_z
Location: USA
Posts: 1549
Joined: Thu Apr 19, 2007 10:15 pm

Re: SAMA5D28 custom board: nandflash issue in uboot

Fri Oct 20, 2017 1:00 am

ganesha.ld wrote:I'm facing some issue with nandflash in u-boot.
...
Even uboot comes up and detects the nandflash correctly (that its [sic] 1024 MiB nand). Now, uboot throws an error saying that NO valid environment area found in nandflash. Also, reports that a bad block in offset 0x100000 while trying to save an environment variable using saveenv command.
That is not an adequate evaluation of NAND functionality while testing a custom board.
The " Error - No Valid Environment Area found" message can be explained away as expected for a new install, i.e. you intentionally erased the flash prior to writing the new U-Boot image.
In general you should verify read functionality before trying any write operation, otherwise you have no way to confirm the writes.
IOW there are several other U-Boot commands (e.g. `nand info`, `nand device`, `nand read`, `nand read.raw`) to try before posting. Study the U-Boot documentation for NAND.

U-Boot is a standalone program, and assumes little in terms of what hardware has been initialized. Consequently U-Boot will not inherit any NAND configuration from AT91Bootstrap, and U-Boot has to be properly configured for your board and NAND chip(s).
Study the various CONFIG_SYS_NAND_* parameters in the README and doc/README.nand files in the U-Boot source tree.

Typically boards use CONFIG_SYS_NAND_ONFI_DETECTION and the default/minimum PMECC configuration is employed. For alternate configurations, study doc/README.atmel_pmecc.

If necessary enable debug output in U-Boot, e.g. try

Code: Select all

#define CONFIG_MTD_DEBUG
#define CONFIG_MTD_DEBUG_VERBOSE        7

ganesha.ld wrote:Please refer to attached schematics for nandflash connections
There is no such attachment to your post.
Regardless, the last time I reviewed a schematic, I was paid for my time.

Regards
ganesha.ld
Posts: 34
Joined: Mon Dec 19, 2011 7:01 pm

Re: SAMA5D28 custom board: nandflash issue in uboot

Tue Oct 24, 2017 3:21 pm

Hi,
blue_z wrote: necessary enable debug output in U-Boot, e.g. try

#define CONFIG_MTD_DEBUG
#define CONFIG_MTD_DEBUG_VERBOSE 7

I have enabled these debug flags, here is the bootup log:
RomBOOT

AT91Bootstrap 3.8.9-dirty (Wed Oct 11 19:11:44 IST 2017) SemaConnect

All interrupts redirected to AIC
Auto-Config the TWI Bus by the board
NAND: ONFI flash detected
NAND: Manufacturer ID: 0x2c Chip ID: 0x38
NAND: Page Bytes: 4096, Spare Bytes: 224
NAND: ECC Correctability Bits: 4, ECC Sector Bytes: 512
NAND: Disable On-Die ECC
PMECC: version is: 0x0
PMECC: page_size: 4096, oob_size: 224, pmecc_cap: 4, sector_size: 512
NAND: Initialize PMECC params, cap: 4, sector: 512
NAND: Image: Copy 0xa0000 bytes from 0x40000 to 0x26f00000
NAND: Done to load image

U-Boot 2017.03-linux4sam_5.7-dirty (Oct 24 2017 - 12:48:49 +0530)

CPU: SAMA5D28-CU
Crystal frequency: 12 MHz
CPU clock : 498 MHz
Master clock : 166 MHz
DRAM: 256 MiB
NAND: device found, Manufacturer ID: 0x2c, Chip ID: 0x38
Micron MT29F8G08ABABAWP
1024 MiB, SLC, erase size: 512 KiB, page size: 4096, OOB size: 224
ONFI params, minimum required ECC: 4 bits in 512 bytes
Initialize PMECC params, cap: 4, sector: 512
WARNING: MT29F8G08ABABAWP: the ECC used on your system is too weak compared to the one required by the NAND chip
mtd: Giving out device 0 to nand0
1024 MiB
MMC: sdio-host@a0000000: 0, sdio-host@b0000000: 1
Scanning device for bad blocks
nand_do_read_oob: from = 0x00000000, len = 224
Bad eraseblock 0 at 0x000000000000
nand_do_read_oob: from = 0x00080000, len = 224
Bad eraseblock 1 at 0x000000080000
nand_do_read_oob: from = 0x00100000, len = 224
Bad eraseblock 2 at 0x000000100000
nand_do_read_oob: from = 0x00180000, len = 224
Bad eraseblock 3 at 0x000000180000
nand_do_read_oob: from = 0x00200000, len = 224
....................
....................
Bad eraseblock 2046 at 0x00003ff00000
nand_do_read_oob: from = 0x3ff80000, len = 224
Bad eraseblock 2047 at 0x00003ff80000
nand_isbad_bbt(): bbt info for offs 0x00100000: (block 2) 0x03
nand_isbad_bbt(): bbt info for offs 0x00140000: (block 2) 0x03
*** Error - No Valid Environment Area found
*** Warning - bad CRC, using default environment

In: serial
Out: serial
Err: serial
Failed to read ethernet address from EEPROM
Net:
Warning: ethernet@f8008000 (eth0) using random MAC address - 26:38:45:54:36:3b
eth0: ethernet@f8008000
Hit any key to stop autoboot: 0
=>
And here are the outputs of "nand device", "nand info", "nand write.raw" and "nand read.raw" commands:
=> nand info
Device 0: nand0, sector size 512 KiB
Page size 4096 b
OOB size 224 b
Erase size 524288 b
subpagesize 4096 b
options 0x40000200
bbt options 0x 0
=> nand device
Device 0: nand0, sector size 512 KiB
Page size 4096 b
OOB size 224 b
Erase size 524288 b
subpagesize 4096 b
options 0x40000200
bbt options 0x 0
=>
=> mw.l 0x22000000 0xA5A5A5A5A5 0x20
=> md 0x22000000 0x20
22000000: a5a5a5a5 a5a5a5a5 a5a5a5a5 a5a5a5a5 ................
22000010: a5a5a5a5 a5a5a5a5 a5a5a5a5 a5a5a5a5 ................
=>
=> nand write.raw 0x22000000 0x600000 0x100
NAND write: raw_access: error at offset 600000, ret -5
1105920 bytes written: ERROR
=>
=> nand read.raw 0x22600000 0x600000 0x20
NAND read: 1105920 bytes read: OK
=> md 0x22600000 0x20
22600000: 00000000 00000000 00000000 00000000 ................
22600010: 00000000 00000000 00000000 00000000 ................
=>
Even the "raw" write is gives an error..

I have added these nandflash related defines in "include/configs/sama5d2_xplained.h":
#ifdef CONFIG_CMD_NAND
#define CONFIG_NAND_ATMEL
#define CONFIG_ATMEL_NAND_HWECC
#define CONFIG_ATMEL_NAND_HW_PMECC
#define CONFIG_CMD_NAND_TRIMFFS
#define CONFIG_CMD_MTDPARTS
#define CONFIG_MTD_DEVICE
#define CONFIG_MTD_PARTITIONS
#endif

#ifdef CONFIG_SYS_USE_NANDFLASH
#undef CONFIG_ENV_OFFSET
#undef CONFIG_ENV_OFFSET_REDUND
#define CONFIG_ENV_IS_IN_NAND
#define CONFIG_ENV_OFFSET 0x100000
#define CONFIG_ENV_OFFSET_REDUND 0x140000
#define CONFIG_SYS_MAX_NAND_DEVICE 1
#define CONFIG_SYS_NAND_BASE ATMEL_BASE_CS3
#define CONFIG_SYS_NAND_MASK_ALE (1 << 21)
#define CONFIG_SYS_NAND_MASK_CLE (1 << 22)
#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x40000
#define CONFIG_SYS_NAND_5_ADDR_CYCLE
#define CONFIG_SYS_NAND_PAGE_SIZE 0x1000
#define CONFIG_SYS_NAND_PAGE_COUNT 64
#define CONFIG_SYS_NAND_OOBSIZE 224
#define CONFIG_SYS_NAND_BLOCK_SIZE 0x40000
#define CONFIG_SYS_NAND_BAD_BLOCK_POS 0x0
#define CONFIG_MTD_DEBUG
#define CONFIG_MTD_DEBUG_VERBOSE 7
#define CONFIG_SYS_NAND_ONFI_DETECTION
#endif
Am I missing something here (in these definitions)?
blue_z
Location: USA
Posts: 1549
Joined: Thu Apr 19, 2007 10:15 pm

Re: SAMA5D28 custom board: nandflash issue in uboot

Thu Oct 26, 2017 12:34 am

ganesha.ld wrote:And here are the outputs of "nand device", "nand info", "nand write.raw" and "nand read.raw" commands:
...
Even the "raw" write is gives an error..
Recap: You report NAND write fails.
I tell you there are other commands to test, and you need to verify read functionality before trying any write operation.
But you persist in trying a (blind) write (using an inappropriate command and w/o an erase no less!), and then trying a read.

Why are you wasting my time?
Try reading what has already been written and read successfully, i.e. the beginning of NAND where AT91Bootstrap is stored.
ganesha.ld
Posts: 34
Joined: Mon Dec 19, 2011 7:01 pm

Re: SAMA5D28 custom board: nandflash issue in uboot

Thu Oct 26, 2017 12:47 pm

blue_z wrote:
Thu Oct 26, 2017 12:34 am
..............
Why are you wasting my time?
Try reading what has already been written and read successfully, i.e. the beginning of NAND where AT91Bootstrap is stored.
I apologize for not providing sufficient information. I don't intend to waste your time.

I had already tried reading raw nandflash at offset 0 (AT91Bootstrap area) using "nand read.raw" and also dumping the raw nandflash values at offset 0 using "nand dump". Both the command give out "0"s.

Code: Select all

=> nand dump 0x00
Page 00000000 dump:
	00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
	00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
	.............
	00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
OOB:
	00 00 00 00 00 00 00 00
	00 00 00 00 00 00 00 00
	............
	00 00 00 00 00 00 00 00
=>
=> nand read.raw 0x22000000 0x00 0x100
NAND read:  1105920 bytes read: OK
=> md 0x22000000
22000000: 00000000 00000000 00000000 00000000    ................
22000010: 00000000 00000000 00000000 00000000    ................
.............
Recap: You report NAND write fails.
I tell you there are other commands to test, and you need to verify read functionality before trying any write operation.
But you persist in trying a (blind) write (using an inappropriate command and w/o an erase no less!), and then trying a read.
I had already erased whole nandflash chip using sam-ba, before programming bootstrap and uboot.
So, I assume that the nandflash was ready for write again in the area I tried.
I just used "nand write.raw" to avoid any ECC process and bad-block skip.
I had also tried "nand erase" command, which reported a "bad block"

Code: Select all

=> nand erase 0x600000 0x100000  
NAND erase: device 0 offset 0x600000, size 0x100000
nand_isbad_bbt(): bbt info for offs 0x00600000: (block 12) 0x03
Skipping bad block at  0x00600000                                          
nand_isbad_bbt(): bbt info for offs 0x00680000: (block 13) 0x03
Skipping bad block at  0x00680000                                          
OK
Also, "nand bad" command reports ALL the blocks in the nandflash chip as BAD. :(

Code: Select all

=> nand bad
Device 0 bad blocks:
nand_isbad_bbt(): bbt info for offs 0x00000000: (block 0) 0x03   00000000
...........
nand_isbad_bbt(): bbt info for offs 0x3ff80000: (block 2047) 0x03  3ff80000
What I'm confused is, if uboot is able to read the nandflash's ONFI parameter page, why its not able to read/write data area.

Thanks,
blue_z
Location: USA
Posts: 1549
Joined: Thu Apr 19, 2007 10:15 pm

Re: SAMA5D28 custom board: nandflash issue in uboot

Thu Oct 26, 2017 9:23 pm

ganesha.ld wrote:I had already tried reading raw nandflash at offset 0 (AT91Bootstrap area) using "nand read.raw" and also dumping the raw nandflash values at offset 0 using "nand dump". Both the command give out "0"s.
Your description reads as if you performed this test, and then choose to reject the results as not meaningful and not worth reporting.
Turns out that this basic test is salient, and all your other tests trying to write (and then read) are not meaningful (i.e. a waste of time).

ganesha.ld wrote:What I'm confused is, if uboot is able to read the nandflash's ONFI parameter page, why its not able to read/write data area.
NAND flash devices can have two data interfaces: an asynchronous interface for legacy NAND applications, and a synchronous interface for high-performance I/O operations.

https://www.flashmemorysummit.com/Engli ... braham.pdf

Your configuration for NAND in U-Boot is suspect.


Regards

Return to “Software”

Who is online

Users browsing this forum: No registered users and 1 guest