Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: AT91SAM9G45 Bad Block Table Format in U-Boot and Kernel
PostPosted: Wed Dec 08, 2010 2:58 pm 
Offline

Joined: Sat Sep 11, 2010 1:32 am
Posts: 23
Since I have re-written a version of SAM-Ba to program my serial flash and nand flash via my re-written bootstrap, I need to support NAND EEC and Bad Block Tables. The EEC code (software version) was provided my Atmel in its Sample Code (hamming.c). However, the Bad Block Table Support was not. I want my Bootstrap Bad Block Table to be understood by U-Boot and Linux so I need to get the format correctly. However, there looks to be a few different formats used by u-boot and linux.

I think I should use the following:
1) Last 4 Blocks can hold primary and mirror BBT (bad blcok tables)
2) OOB section of page 1 should hold the signatures
static unsigned char bbt_pattern[] = {'B', 'b', 't', '0' };
static unsigned char mirror_pattern[] = {'1', 't', 'b', 'B' };
3) Signature Offset is 8 Bytes into OOB (?????????)
4) Version is 1 byte after the signature in OOB (???????????)
5) 2 bits per block bit mask in data area of page
11 - good block
10 - reserved - most software should interpret as "don't use this block"
01 - block went bad during use
00 - block was marked bad by the factory

Does anyone Agree? Also, How can I test a block that I write in my Bootstrap with a block read from U-Boot to check EEC and BBT?

Thanks, Gary


Top
 Profile  
 
 Post subject: Re: AT91SAM9G45 Bad Block Table Format in U-Boot and Kernel
PostPosted: Wed Dec 08, 2010 5:19 pm 
Offline

Joined: Sat Sep 11, 2010 1:32 am
Posts: 23
OK, Lots of Good stuff in u-boot/drivers/mtd/nand/nand_base.c

(Note: Add your devices and Manufacturers if need to nand_ids.c)

Default for Large Block Devices (on AT91SAM9G45EKES)
oobblock = 2048 bytes
oobsize = 64
erasesize = 128K
Bad Block Position = Byte 0
Bad Block Function = nand_default_bbt in u-boot/drivers/mtd/nand/nand_bbt.c

HOWEVER:
The NAND Flash Option 'NAND_USE_FLASH_BBT' is not set on any Flash IC by default.

So, I think you need to add the following lines to u-boot/board/atmel/at91sam9g45ekes.c
function: board_nand_init()
#ifdef CFG_NAND_USE_BBT
nand->options |= NAND_USE_FLASH_BBT;
#endif

Plus of course, add CFG-NAND_USE_BBT to your board config file

I will add to this thread as I test...


Top
 Profile  
 
 Post subject: Re: AT91SAM9G45 Bad Block Table Format in U-Boot and Kernel
PostPosted: Wed Dec 08, 2010 6:04 pm 
Offline

Joined: Sat Sep 11, 2010 1:32 am
Posts: 23
OK, so after you enable BBT support in U-Boot and reboot the device, it takes about 2 minutes to come up the next time while it creates the bad block table.

The Primary Table was created in block 2047 (last one provided it wasn't bad from the factory)
Page = 131008
Addr = 0xFFE0000 (really page * 2048 bytes per page)

U-Boot>nand dump ffe0000
OOB:
ff ff ff ff ff ff ff ff
42 62 74 30 01 ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff f3 ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
Signature = 42 62 74 30 = "Bbt0"
Version = 1

Note: The mirror was also created at block 2046 just as expected.
Note: Any non-FF's in the data section of the block means a bad block

Enjoy


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: