[Yaffs-archive] Re: What's so special about device block 0?

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Charles Manning
Date:  
To: guxm, Jacob Dall, yaffs@toby-churchill.org
Subject: [Yaffs-archive] Re: What's so special about device block 0?
The history of this is that I needed a block number to signify "invalid
block". The value had to fit in with the use of 16 bits in the chunk grouping
mechanism etc. I could have used 0xFFFF/0xFFFFFFFFFF but that would have been
a bit messier in code and 0 was simpler.

Since block 0 is guaranteed to be good on NAND, it is sometimes used as a
special block to store information. Thus, I decided to use zero as "invalid
block" and "invalid chunk group".

You can potentially get around this by modifying the flash access code to map
start(-1) == physical block 0, and this **should** work - perhaps with minor
tweaks - but I have not tested this.

-- CHarles






On Thursday 17 June 2004 13:34, guxm wrote:
> Further,
> So I think such design is deliberate, strict, or to say correct. The
> dev->startBlock or endBlock is only a digital number. As for which physical
> block we map it to, we can just do it.
>
> Best regards
> GUXM
>
> Hi,
>
> I have the same question. I have tried to modify device.startBlock = 0, But
> I found that there is much code use 0 to check chunkId validation. So I
> have to map logical block n to physical block n-1. That is the
> dev->startBlock(=1) is mapped to physical block 0. It's OK now.
>
> For example:
> yaffs_PutChunkIntoFile()
> {
>     existingChunk = tn->level0[chunkInInode & YAFFS_TNODES_LEVEL0_MASK];

>
>     ... ...
>     if(existingChunk == 0)
>     {
>         in->nDataChunks++;
>     }

>
> }
>
> yaffs_DeleteChunk()
> {
>     if( chunkId <= 0 )
>         return;
> }

>
> yaffs_GetObjectName()
> {
>     else if(obj->chunkId <= 0)
>     {
>         char locName[20];
>         sprintf(locName,"%s%d",YAFFS_LOSTNFOUND_PREFIX,obj->objectId);
>         strncpy(name,locName,buffSize - 1);
>     }
> }

>
>
> Best regards
> guxm
>
>
> ======= 2004-06-15 21:39:00 ÄúÔÚÀ´ÐÅÖÐдµÀ£º=======
>
> >In lots of the source files, the following line of code is used
> >
> ><code>
> >    device.startBlock = 1;  // Don't use block 0
> ></code>

> >
> >Having searched through the docs and sources, I've found no clue why block
> >0 is different that the rest of the device blocks.
> >
> >Please, anyone, enlighten me.
> >
> >Thanks,
> >Jacob Dall
> >
> >
> >
> >--------------------------------------------------------------------------
> >------------- This mailing list is hosted by Toby Churchill open software
> > (www.toby-churchill.org). If mailing list membership is no longer wanted
> > you can remove yourself from the list by sending an email to
> > with the text "unsubscribe" (without the
> > quotes) as the subject.
>
> = = = = = = = = = = = = = = = = = = = =
>
>
>
>
> ---------------------------------------------------------------------------
>------------ This mailing list is hosted by Toby Churchill open software
> (www.toby-churchill.org). If mailing list membership is no longer wanted
> you can remove yourself from the list by sending an email to
> with the text "unsubscribe" (without the
> quotes) as the subject.


---------------------------------------------------------------------------------------
This mailing list is hosted by Toby Churchill open software (www.toby-churchill.org).
If mailing list membership is no longer wanted you can remove yourself from the list by
sending an email to with the text "unsubscribe"
(without the quotes) as the subject.