[flashrom] Sector unprotect at AT25DF081A

Stefan Tauner stefan.tauner at alumni.tuwien.ac.at
Sat May 3 22:43:02 CEST 2014


On Sat, 12 Apr 2014 19:19:20 +0200
Márton Miklós <martonmiklosqdev at gmail.com> wrote:

> Hello flashrom developers!
> 
> I am currently hacking flashrom support for a National Instrments 
> USB-8451 USB-SPI converter. I have found an AT25DF081A in the drawer to 
> be used as a medical rabbit for my experiments.
> Probing, reading works fine, but the chip is sector protected. The 
> flashrom tries to disable the protection with clearing the 7th bit 
> (SPRL) in the status register, but as the datasheet states:

Actually flashrom (in its current version) tries to do a global
unprotect as specified by section 9.5... but reading that again I think
we are doing it wrong. We should first disable SPRL and then do another
status register write to do the global unprotect. Currently we just do
one write and that will fail to do the unprotect if SPRL is enabled,
AFAICS.

> /As a safeguard against accidental or erroneous locking or unlocking of 
> sectors, the Sector Protection Registers can themselves be locked from 
> updates by using the SPRL (Sector Protection Registers Locked) bit of 
> the Status Register (refer to "Status Register Commands" on page 16 for 
> more details). If the Sector Protection Registers are locked, then any 
> attempts to issue the Unprotect Sector command will be ignored, and the 
> device will reset the WEL bit in the Status////Register back to a 
> logical "0" and return to the idle state once the CS pin has been 
> deasserted.//
> /
> So to unlock my flash I would have to walk through the sectors and issue 
> an Unprotect sector command with the sector's address.
> My problem is that the erase blocks addresses and the sector addresses 
> are different things. In my case it has 64Kbyte block feature and the 
> sectors are 64Kbyte, but it also has 4KByte block feature too.
> 
> What would you recommend how to implement the sector unlocking mode?
> My proposal is the following:
> - Add a sector describing structure to the flashchip structure. It would 
> contain the sector count and sector size.
> - Create a new unlock method: 
> spi_disable_blockprotect_at2x_sector_unprotect for e.g. which clears the 
> SPRL, then (if SWP is not 0) loops through the sectors and unlock them.
> - If we want to be nice after the write we can reprotect the device.

If I am correct above we don't need to loop... if we would have to,
then I would propose to hardcode the needed step sizes/addresses into a
function until we get a better feeling if a more generic solution is
needed and how it should look like. For the chip in question the only
needed information to loop over all protection blocks is their block
size of 64 kB, so something like
spi_disable_blockprotect_at2x_sector_unprotect(struct flashctx *flash, unsigned int block_size);
would be feasible... if we need the sector size at all and it differs
among the chips of the at2x family...

-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner




More information about the flashrom mailing list