<div class="gmail_quote">On Fri, Jan 28, 2011 at 3:00 PM, David Hendricks <span dir="ltr"><<a href="mailto:dhendrix@google.com">dhendrix@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="gmail_quote"><div class="im">On Fri, Jan 28, 2011 at 1:03 AM, Mathias Krause <span dir="ltr"><<a href="mailto:mathias.krause@secunet.com" target="_blank">mathias.krause@secunet.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



Hi,<br>
<br>
flashrom currently tries to unlock the chip before each read/write/erase<br>
command. To prevent further modifications of the chip content, e.g. for<br>
security reasons, it would be helpful if flashrom would also be capable<br>
of the opposite operation. I talked with Carl-Daniel a little about it<br>
and he mentioned problems like having to implement features like partial<br>
locks, chips that cannot be unlocked after being locked, etc. To support<br>
those features and handle the problematic chips something more than this<br>
little patch can do must be implemented. But for now it would be nice to<br>
have *something*. See it as a starting point to solve the much bigger<br>
problem.<br></blockquote><div><br></div></div><div>Yep, it certainly gets hairy.</div><div><br></div><div>On Fri, Jan 28, 2011 at 1:03 AM, Mathias Krause <span dir="ltr"><<a href="mailto:mathias.krause@secunet.com" target="_blank">mathias.krause@secunet.com</a>></span> wrote: </div>

<div class="im">



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This patch adds a function pointer to struct flashchip and a command<br>
line option to trigger this function to enable full flash chip write<br>
protection. It's currently only implemented for the Atmel AT26DF081A<br>
since this is the chip I'm currently working with and which I can test<br>
easily.<br></blockquote></div></div><br><div>For what it's worth, we've been doing something similar in the Chromium OS branch (<a href="http://git.chromium.org/gitweb/?p=flashrom.git;a=tree" target="_blank">http://git.chromium.org/gitweb/?p=flashrom.git;a=tree</a>). Apologies if it seems a bit sloppy at the moment, we've had to wedge in a lot stuff to solve immediate concerns.</div>





<div><br></div><div>We also added a member to the flashchip structure (.wp), but in our case it is a pointer to a "writeprotect" structure which contains a bunch of function pointers. We felt this was necessary since write protection varies greatly between chips and we want fine-grained control.</div>





<div><br></div><div>In our model, the user specifies the byte range (offset and length) and enables write protection in two steps. For example: "flashrom --wp-range 0x200000 0x200000 --wp-enable".</div><div><br>





</div><div>Most of the ugly stuff in our code is contained within writeprotect.c. So if you want to give it a try it should integrate into your tree pretty easily.</div>
<div><br></div><font color="#888888"><div>-- <br>David Hendricks (dhendrix)<br>Systems Software Engineer, Google Inc.<br>
</div>
</font></blockquote></div><br><div>It seems we keep missing each other on IRC, so let's just continue the discussion here.</div><div><br></div><div><minipli> dhendrix: I looked at the google flashrom write protect code and it actually does a different thing then my patch</div>

<div><minipli> dhendrix: it has the possibility to write protect (and after that, unprotect again) subranges of the flash memory</div><div><minipli> dhendrix: my patch just enables write protect for the whole chip and locks the register afterwards</div>

<div><minipli> dhendrix: the lock, though, is only as effective, as the WP pin indicates (either hardware locked or software locked)</div><div><br></div><div>The Chromium OS code does it in two parts. First, the user specifies a range (--wp-range). Second, the user enables write protection (--wp-enable).</div>

<div><br></div><div>As I understand, for write protection to take effect the WP pin must be active. Until that happens, the status register which holds the block protection status and WP enable bit can be modified by software.</div>

<div><br></div><div>In any case, I believe the ends which you are trying to achieve can be accomplished using the Chromium OS approach. However, there are many machines in the field which require partial firmware updates, and thus cannot be compatible with the coarse-grained approach.</div>

<br>-- <br>David Hendricks (dhendrix)<br>Systems Software Engineer, Google Inc.<br>