public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* erase.c
@ 2001-03-12 21:43 Kári Davíðsson
  2001-03-12 22:53 ` erase.c Alice Hennessy
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kári Davíðsson @ 2001-03-12 21:43 UTC (permalink / raw)
  To: mtd

Hi,

In the intel chip that we are using here all sectors seem to be locked
by default.
So in the erase utility I propose the following patch.

Maybe it is ambigous to do force unlocking of sectors like this.
Should we maybe have a separate utility to lock/unlock sectors?

K.D.

--- ../mtd/util/erase.c Thu Sep 21 22:00:07 2000
+++ util/erase.c        Mon Mar 12 14:58:58 2001
@@ -51,6 +51,12 @@
                 erase.length, erase.start);
          fflush(stdout);
 
+         if(ioctl(Fd, MEMUNLOCK, &erase) != 0)
+         {
+                 perror("\nMTD Unlock failure");
+                 close(Fd);
+                 return 8;
+                }
          if (ioctl(Fd,MEMERASE,&erase) != 0)
              {      
                  perror("\nMTD Erase failure");


To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: erase.c
  2001-03-12 21:43 erase.c Kári Davíðsson
@ 2001-03-12 22:53 ` Alice Hennessy
  2001-03-12 23:10 ` erase.c Alice Hennessy
  2001-03-13  8:03 ` erase.c David Woodhouse
  2 siblings, 0 replies; 6+ messages in thread
From: Alice Hennessy @ 2001-03-12 22:53 UTC (permalink / raw)
  To: Kári Davíðsson; +Cc: mtd, ahennessy

Kári Davíðsson wrote:

> Hi,
>
> In the intel chip that we are using here all sectors seem to be locked
> by default.
> So in the erase utility I propose the following patch.
>
> Maybe it is ambigous to do force unlocking of sectors like this.
> Should we maybe have a separate utility to lock/unlock sectors?
>
> K.D.
>
> --- ../mtd/util/erase.c Thu Sep 21 22:00:07 2000
> +++ util/erase.c        Mon Mar 12 14:58:58 2001
> @@ -51,6 +51,12 @@
>                  erase.length, erase.start);
>           fflush(stdout);
>
> +         if(ioctl(Fd, MEMUNLOCK, &erase) != 0)
> +         {
> +                 perror("\nMTD Unlock failure");
> +                 close(Fd);
> +                 return 8;

>
> +                }
>           if (ioctl(Fd,MEMERASE,&erase) != 0)
>               {
>                   perror("\nMTD Erase failure");
>
> To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org

I have tests for both lock and unlock that can easily become the
utilities if desired.


lock.c: locks num sectors at ofs or all sectors
USAGE: %s <mtd device> <ofs> <num of sectors or -1 for all sectors>

unlock.c: unlocks all sectors since that's what Intel chips do
USAGE: %s <mtd device>

Alice



To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: erase.c
  2001-03-12 21:43 erase.c Kári Davíðsson
  2001-03-12 22:53 ` erase.c Alice Hennessy
@ 2001-03-12 23:10 ` Alice Hennessy
  2001-03-13  8:03 ` erase.c David Woodhouse
  2 siblings, 0 replies; 6+ messages in thread
From: Alice Hennessy @ 2001-03-12 23:10 UTC (permalink / raw)
  To: Kári Davíðsson; +Cc: mtd, ahennessy

Kári Davíðsson wrote:

> Hi,
>
> In the intel chip that we are using here all sectors seem to be locked
> by default.
> So in the erase utility I propose the following patch.
>
> Maybe it is ambigous to do force unlocking of sectors like this.
> Should we maybe have a separate utility to lock/unlock sectors?
>
> K.D.
>
> --- ../mtd/util/erase.c Thu Sep 21 22:00:07 2000
> +++ util/erase.c        Mon Mar 12 14:58:58 2001
> @@ -51,6 +51,12 @@
>                  erase.length, erase.start);
>           fflush(stdout);
>
> +         if(ioctl(Fd, MEMUNLOCK, &erase) != 0)
> +         {
> +                 perror("\nMTD Unlock failure");
> +                 close(Fd);
> +                 return 8;
> +                }
>           if (ioctl(Fd,MEMERASE,&erase) != 0)
>               {
>                   perror("\nMTD Erase failure");
>
> To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org

The unlock ioctl unlocks all of the flash sectors at once (because the
Intel flash's command unlocks
all of the sectors at once).  I put in a check for this in mtdpart.c
against the entire flash size but it looks like it was changed -
I also need to add a check in cfi_cmdset_0001.c for those that don't use
partitions.

FYI,  the request that is trying to erase or write to a locked sector
will return
an EROFS error.

Alice



To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: erase.c
  2001-03-12 21:43 erase.c Kári Davíðsson
  2001-03-12 22:53 ` erase.c Alice Hennessy
  2001-03-12 23:10 ` erase.c Alice Hennessy
@ 2001-03-13  8:03 ` David Woodhouse
  2001-03-13 18:44   ` erase.c Alice Hennessy
  2 siblings, 1 reply; 6+ messages in thread
From: David Woodhouse @ 2001-03-13  8:03 UTC (permalink / raw)
  To: Kári Davíðsson; +Cc: mtd

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=UTF8, Size: 418 bytes --]

On Mon, 12 Mar 2001, [iso-8859-1] Kári Davíðsson wrote:

> Maybe it is ambigous to do force unlocking of sectors like this.
> Should we maybe have a separate utility to lock/unlock sectors?

Use a separate utility. Locking isn't very useful if the code
automatically unlocks the chip for you if you try to overwrite it :)

-- 
dwmw2




To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: erase.c
  2001-03-13  8:03 ` erase.c David Woodhouse
@ 2001-03-13 18:44   ` Alice Hennessy
  2001-03-14  2:55     ` erase.c Alice Hennessy
  0 siblings, 1 reply; 6+ messages in thread
From: Alice Hennessy @ 2001-03-13 18:44 UTC (permalink / raw)
  To: David Woodhouse; +Cc: Kári Davíðsson, mtd, ahennessy

David Woodhouse wrote:

> On Mon, 12 Mar 2001, [iso-8859-1] Kári Davíðsson wrote:
>
> > Maybe it is ambigous to do force unlocking of sectors like this.
> > Should we maybe have a separate utility to lock/unlock sectors?
>
> Use a separate utility. Locking isn't very useful if the code
> automatically unlocks the chip for you if you try to overwrite it :)
>
> --
> dwmw2
>
> To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org

I've checked in utility files unlock.c and lock.c  and a new Makefile to
include them.

I still need to fix the parameter checking in mtdpart.c and
cfi_cmdset_0001.c to insure
that the unlock is for the entire flash.

Alice



To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: erase.c
  2001-03-13 18:44   ` erase.c Alice Hennessy
@ 2001-03-14  2:55     ` Alice Hennessy
  0 siblings, 0 replies; 6+ messages in thread
From: Alice Hennessy @ 2001-03-14  2:55 UTC (permalink / raw)
  To: mtd, ahennessy

>
>
> I still need to fix the parameter checking in mtdpart.c and
> cfi_cmdset_0001.c to insure
> that the unlock is for the entire flash.
>

Nevermind,

This would require the user to know the size of the entire flash  - it's
just simpler
to document that unlocking the flash means unlocking the whole thing - to
help that
I'll document better in cfi_cmdset_0001.c and
rename the function do_unlock_oneblock() to simply   do_unlock().

Alice



To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2001-03-14  2:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-03-12 21:43 erase.c Kári Davíðsson
2001-03-12 22:53 ` erase.c Alice Hennessy
2001-03-12 23:10 ` erase.c Alice Hennessy
2001-03-13  8:03 ` erase.c David Woodhouse
2001-03-13 18:44   ` erase.c Alice Hennessy
2001-03-14  2:55     ` erase.c Alice Hennessy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox