This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Intel FLASH


> From: Jani Monoses [mailto:jani@iv.ro] 
> 
> I defined BOOTBLOCK_FLASH so I didn't query and changed that lookup
> table you see in strata.c. This way I didn't let CFI detect the blocks
> since as you saw it does not assume multiple erase sizes:the parts
> before W30 (J,K) were stratas but had no bootblocks like the B and C
> models and the driver was originally written for those.
> so if you define that yours is a bootblock it should detect the 640's
> size. Hopefully.I did it so in my platform flash .inl file:
> (2 variants of board)
> 
I started off defining BOOTBLOCK_FLASH, and that didn't work -- my device
returns 0x65 for the device code, hence my digression into CFI.  I now have
code that merges the two partitions into a single partition, but no
expectation that locking/unlocking and/or erasing blocks in the parameter
partition (formerly known as the boot block) will work.

Along the way, I have observed a few things in the code that I want to run
by you folks and then clean up.  First of all, here is my interpretation of
what the CYGOPT_FLASH_IS_BOOTBLOCK, CYGOPT_FLASH_IS_NOT_ADVANCED, and
CYGOPT_FLASH_IS_SYNCHRONOUS compile flags do:

// Secret decoder ring:
// CYGOPT_FLASH_IS_BOOTBLOCK
//      flash_erase_block.c
//      flash_unlock_block.c
//              use this to erase or unlock the smaller blocks at the
//              bottom of flash.  In the case of 'flash_unlock_block()',
//              this only happens if 'CYGOPT_FLASH_IS_SYNCHRONOUS' is
//              also defined.
//      flash_query.c
//              Issues a 'FLASH_Read_ID' command to read the device ID
//              rather than the 'FLASH_Read_Query' command to read the
device
//              information.
//      strata.c
//              Identifes the size of the flash based on the ID returned
//              by 'flash_query()'.
//      strata.h
//              Defines 'FLASH_Program' to be 0x40 instead of 0x10, controls
//              whether or not 'FLASH_Write_Buffer' is defined.
//
// CYGOPT_FLASH_IS_NOT_ADVANCED
//      strata.h
//              Defines 'FLASH_Write_Buffer' only if this, and
//              'CYGOPT_FLASH_IS_BOOTBLOCK' are not defined.  If
//              'FLASH_Write_Buffer' is defined, then
//              'flash_program_buf()' writes blocks at a time (as
//              determined by the 'buffer_size' parameter associated
//              with the device).
//
// CYGOPT_FLASH_IS_SYNCHRONOUS
//      flash_unlock_block.c
//              If this is defined, then we unlock individual blocks,
//              otherwise, we scan the device to determine which blocks
//              are currently locked, unlock the ones that need to be
//              unlocked, and then relock the ones we wanted to be locked.
//              BTW, this is incompatible with bootblock devices.
//              This doesn't make much sense to me (perhaps it is residue
//              from an older version of the code for another device) since
//              the K3 device supports individual block locking/unlocking.
//              Oh well

Also, a few other observations...
1) The few datasheets I have looked at for the B3, K3, etc... devices all
say that either 0x40 or 0x10 can be used to program a single word into the
device.  So, conditioning 'FLASH_Program' to be 0x40 vs 0x10 based on
'CYGOPT_FLASH_IS_BOOTBLOCK' is a little confusing.

2) 'flash_program_buf()' writes the 'FLASH_Program' word to 'BA[0]' rather
than '*addr', which is what the datasheets I've seen so far all say to do.

3) "flash_query.c" has the following (personally annoying) code:
#define CNT 20*1000*10  // Aprox 20ms
...
for (cnt = CNT: cnt > 0; cnt--)

4) If you were bored enough to read through all of the comments above for my
secret decoder ring, you see that 'CYGOPT_FLASH_IS_SYNCHRONOUS' is, at a
minimum, misnamed, and, more likely, not terribly useful.

I am going to take a stab at cleaning this stuff up, folding in Jani's patch
in the process, and making a first cut at supporting different partition
sizes for the first or last partition (following the lead of the 28Fxxxx
code).  All questions, comments, and words of encouragement are welcome at
this point.

--wpd


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]