Subject: Re: MTD Partitions Permissions at Run Time.

From: [email-masked]
Date: Wed, 26 Mar 2008 21:53:16 +0100 (CET)

Hi.

> Ours is a embedded product with pre-defined flash partitions say "Boot"
> , "Kernel" , "Rootfs" & "ProductData".
> The kernel which is in the box (linux 2.6.14)has Boot partition as "RO"
> (Read Only). We have a requirement in the field that the boot code
> should be upgraded also.
> Is there any possibility of changing the partition permissions at
> run-time? If so how ?
> Our solution was to create a Kernel image Boot as RW, upgrade the kernel
> & reboot. Later change the Boot code.

It is. For the MeshCube, for each mtd partition we have added a proc entry
called /proc/sys/mtd/<mtdnum>/rw, with a value of 0 meanung read only and a
value of 1 meaning read-write. We used it to be able to disable the write
protection of the bootloader partition before an update of the bootloader.

I have attached the patch as an indication, of how it could be done. This patch
will not work with a 2.6 kernel anymore. It has been for the 2.4.27 kernel, that
has been used for the MeshCube.

It must be adopted to the 2.6 kernel and the /proc/sys stuff could be done in a
better way than we did it using the sysctl support.
You may take a look at some drivers like drivers/parport/procfs.c how it is done
for the parallel port.
The function register_sysctl_table is the key to it.

Regards,
Michael