* how to change size of MTD partitions at runtime
@ 2004-09-01 11:41 Kuefmann Andreas ICM CP RD SD 1
2004-09-01 15:34 ` William J Beksi
2004-09-02 13:19 ` Stephan Linke
0 siblings, 2 replies; 4+ messages in thread
From: Kuefmann Andreas ICM CP RD SD 1 @ 2004-09-01 11:41 UTC (permalink / raw)
To: 'linux-mtd@lists.infradead.org'
Hi all,
I'm searching for a solution to dynamically change the size of
MTD partitions at runtime.
This functionality is required for a flash update of kernel and/or
rootfs in the special case that the new kernel/rootfs is larger
than the old one. (in an embedded environment)
1.)
there is no problem in erasing the flash, e.g eraseall /dev/mtd?,
(acting from a chrooted environment)
2.)
However, reprogramming the flash with a larger image (now
exceeding the limits of the previous partition) isn't as
easy as a cp newimage.img /dev/mtd?.
The MTD layer will still rely on the (old) partition sizes
that were valid during system startup. (taken over from a
U-BOOT environment)
My plans are as follows:
- erase the flash partitions
- adapt the u-boot environment to reflect the new mtd partition sizes
- force the MTD subsystem to "re-read" the partition table in u-boot's
environment.
- cp the new images to /dev/mtd? (which now reflect the changed
partition sizes)
My question now is:
- How can I manage to force a re-read of the partition table?
Or can you think of another solution to change MTD partitions at
runtime?
Thank you,
regards,
- Andy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: how to change size of MTD partitions at runtime
2004-09-01 11:41 how to change size of MTD partitions at runtime Kuefmann Andreas ICM CP RD SD 1
@ 2004-09-01 15:34 ` William J Beksi
2004-09-02 13:19 ` Stephan Linke
1 sibling, 0 replies; 4+ messages in thread
From: William J Beksi @ 2004-09-01 15:34 UTC (permalink / raw)
To: Kuefmann Andreas ICM CP RD SD 1; +Cc: 'linux-mtd@lists.infradead.org'
Hi,
Kuefmann Andreas ICM CP RD SD 1 wrote:
>Hi all,
>
>I'm searching for a solution to dynamically change the size of
>MTD partitions at runtime.
>
>This functionality is required for a flash update of kernel and/or
>rootfs in the special case that the new kernel/rootfs is larger
>than the old one. (in an embedded environment)
>
>1.)
>there is no problem in erasing the flash, e.g eraseall /dev/mtd?,
>(acting from a chrooted environment)
>
>2.)
>However, reprogramming the flash with a larger image (now
>exceeding the limits of the previous partition) isn't as
>easy as a cp newimage.img /dev/mtd?.
>
>The MTD layer will still rely on the (old) partition sizes
>that were valid during system startup. (taken over from a
>U-BOOT environment)
>
>
I'm using the proc filesytem to dynamically change the mtd partition
sizes on my flash at runtime. I added a function to mtdcore.c that looks
like this:
static int mtd_write_proc (struct file *filp, const char *buf, unsigned
long count, void *data)
{
int value;
struct mtd_info *this;
unsigned long pos = (unsigned long)(filp->f_pos);
down(&mtd_table_mutex);
while (pos < count) {
/* Get the partition number. */
if (pos == 0) {
value = antoi(buf, pos, count);
this = mtd_table[value];
}
/* Change size of the partition (in Mb). */
if (pos == 2) {
value = antoi(buf, pos, count);
this->size = value*1024*1024;
}
pos++;
}
up(&mtd_table_mutex);
return count;
}
The partition table values can be changed by writing the partition
number and size (in megabytes) to /proc/mtd: echo 1 3 > /proc/mtd ||
||I'm not sure if this is the best way to dynamically change the
partition sizes at runtime, nor is it very safe.
>My question now is:
>- How can I manage to force a re-read of the partition table?
>
>
>
>
Where do you keep your partition table? I'm using a cramfs filesystem
and LinuxBIOS on nand flash. I reserve the first block of the flash to
store a partition table, bad block list, and other information. I have a
set of user space utilites for reading and writing the partition table.
--
William J Beksi
>______________________________________________________
>Linux MTD discussion mailing list
>http://lists.infradead.org/mailman/listinfo/linux-mtd/
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: how to change size of MTD partitions at runtime
2004-09-01 11:41 how to change size of MTD partitions at runtime Kuefmann Andreas ICM CP RD SD 1
2004-09-01 15:34 ` William J Beksi
@ 2004-09-02 13:19 ` Stephan Linke
1 sibling, 0 replies; 4+ messages in thread
From: Stephan Linke @ 2004-09-02 13:19 UTC (permalink / raw)
To: Kuefmann Andreas ICM CP RD SD 1, linux-mtd
Hi Andreas,
for the same purpose I am using an additional partition that covers the range of kernel and rootfs to update both of them at the
same time. Ofcourse in this case after writing the images the device has to be rebooted.
How do you handle remounting the rootfs and synchronization with current systems configuration so you don't have to reboot?
Regards, Stephan
> -----Original Message-----
> From: linux-mtd-bounces@lists.infradead.org
> [mailto:linux-mtd-bounces@lists.infradead.org]On Behalf Of Kuefmann
> Andreas ICM CP RD SD 1
> Sent: Mittwoch, 1. September 2004 13:42
> To: 'linux-mtd@lists.infradead.org'
> Subject: how to change size of MTD partitions at runtime
>
>
> Hi all,
>
> I'm searching for a solution to dynamically change the size of
> MTD partitions at runtime.
>
> This functionality is required for a flash update of kernel and/or
> rootfs in the special case that the new kernel/rootfs is larger
> than the old one. (in an embedded environment)
>
> 1.)
> there is no problem in erasing the flash, e.g eraseall /dev/mtd?,
> (acting from a chrooted environment)
>
> 2.)
> However, reprogramming the flash with a larger image (now
> exceeding the limits of the previous partition) isn't as
> easy as a cp newimage.img /dev/mtd?.
>
> The MTD layer will still rely on the (old) partition sizes
> that were valid during system startup. (taken over from a
> U-BOOT environment)
>
> My plans are as follows:
> - erase the flash partitions
> - adapt the u-boot environment to reflect the new mtd partition sizes
> - force the MTD subsystem to "re-read" the partition table in u-boot's
> environment.
> - cp the new images to /dev/mtd? (which now reflect the changed
> partition sizes)
>
> My question now is:
> - How can I manage to force a re-read of the partition table?
>
> Or can you think of another solution to change MTD partitions at
> runtime?
>
> Thank you,
> regards,
> - Andy
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* AW: how to change size of MTD partitions at runtime
@ 2004-09-02 14:48 Kuefmann Andreas ICM CP RD SD 1
2004-09-02 15:39 ` Stephan Linke
0 siblings, 1 reply; 4+ messages in thread
From: Kuefmann Andreas ICM CP RD SD 1 @ 2004-09-02 14:48 UTC (permalink / raw)
To: 'Stephan Linke', Kuefmann Andreas ICM CP RD SD 1,
linux-mtd
Hi Stephan,
thanks for your proposal. Unfortunately we have a very limited flash, so we
can't afford an additional partition for sw update purpose as you suggested.
If it should happen that future kernel/rootfs images would exceed the current
mtd partition sizes we'd have to shrink another mtd partition (user data)
accordingly in order to regain the missing space.
I don't think I'd have to re-mount/re-sync after the update, since it's OK
to reboot the machine after the update has completed.
regards,
- Andy
-----Ursprüngliche Nachricht-----
Von: Stephan Linke [mailto:Stephan.Linke@epygi.de]
Gesendet: Donnerstag, 2. September 2004 15:20
An: Kuefmann Andreas ICM CP RD SD 1; linux-mtd@lists.infradead.org
Betreff: RE: how to change size of MTD partitions at runtime
Hi Andreas,
for the same purpose I am using an additional partition that covers the range of kernel and rootfs to update both of them at the same time. Ofcourse in this case after writing the images the device has to be rebooted. How do you handle remounting the rootfs and synchronization with current systems configuration so you don't have to reboot?
Regards, Stephan
> -----Original Message-----
> From: linux-mtd-bounces@lists.infradead.org
> [mailto:linux-mtd-bounces@lists.infradead.org]On Behalf Of Kuefmann
> Andreas ICM CP RD SD 1
> Sent: Mittwoch, 1. September 2004 13:42
> To: 'linux-mtd@lists.infradead.org'
> Subject: how to change size of MTD partitions at runtime
>
>
> Hi all,
>
> I'm searching for a solution to dynamically change the size of MTD
> partitions at runtime.
>
> This functionality is required for a flash update of kernel and/or
> rootfs in the special case that the new kernel/rootfs is larger than
> the old one. (in an embedded environment)
>
> 1.)
> there is no problem in erasing the flash, e.g eraseall /dev/mtd?,
> (acting from a chrooted environment)
>
> 2.)
> However, reprogramming the flash with a larger image (now exceeding
> the limits of the previous partition) isn't as easy as a cp
> newimage.img /dev/mtd?.
>
> The MTD layer will still rely on the (old) partition sizes that were
> valid during system startup. (taken over from a U-BOOT environment)
>
> My plans are as follows:
> - erase the flash partitions
> - adapt the u-boot environment to reflect the new mtd partition sizes
> - force the MTD subsystem to "re-read" the partition table in u-boot's
> environment.
> - cp the new images to /dev/mtd? (which now reflect the changed
> partition sizes)
>
> My question now is:
> - How can I manage to force a re-read of the partition table?
>
> Or can you think of another solution to change MTD partitions at
> runtime?
>
> Thank you,
> regards,
> - Andy
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: how to change size of MTD partitions at runtime
2004-09-02 14:48 AW: " Kuefmann Andreas ICM CP RD SD 1
@ 2004-09-02 15:39 ` Stephan Linke
0 siblings, 0 replies; 4+ messages in thread
From: Stephan Linke @ 2004-09-02 15:39 UTC (permalink / raw)
To: Kuefmann Andreas ICM CP RD SD 1, linux-mtd
Hi Andreas,
by saying "additional partion" a partition that mappes to the same area inside the flash as the kernel/rootfs/other area . That you
whant to replace. You don't need more space to do so. Just tell this additional partition that it should be lokated at the same
position as your old partitions. For instance you use this additional partition to map the entire flash. Then you can access the raw
flash for writing the binaries to it.
Maybe changing the partitioning works too...
I always recalculate the flash areas for kernel, rootfs and a second fs during kernel startup based on the data in the flash. During
system update I simply erase the entire area and then write the data to it.
In any case you should watch out for open filehandles to your filesystems while replacing them. "Open file handle problems" appeare
more often when the layout of the flash and rootfs changes dramaticaly during the update process.
Stephan
> -----Original Message-----
> From: Kuefmann Andreas ICM CP RD SD 1
> [mailto:andreas.kuefmann@siemens.com]
> Sent: Donnerstag, 2. September 2004 16:48
> To: 'Stephan Linke'; Kuefmann Andreas ICM CP RD SD 1;
> linux-mtd@lists.infradead.org
> Subject: AW: how to change size of MTD partitions at runtime
>
>
> Hi Stephan,
>
> thanks for your proposal. Unfortunately we have a very limited flash, so we
> can't afford an additional partition for sw update purpose as you suggested.
>
> If it should happen that future kernel/rootfs images would exceed the current
> mtd partition sizes we'd have to shrink another mtd partition (user data)
> accordingly in order to regain the missing space.
>
> I don't think I'd have to re-mount/re-sync after the update, since it's OK
> to reboot the machine after the update has completed.
>
> regards,
> - Andy
>
> -----Ursprüngliche Nachricht-----
> Von: Stephan Linke [mailto:Stephan.Linke@epygi.de]
> Gesendet: Donnerstag, 2. September 2004 15:20
> An: Kuefmann Andreas ICM CP RD SD 1; linux-mtd@lists.infradead.org
> Betreff: RE: how to change size of MTD partitions at runtime
>
>
> Hi Andreas,
>
> for the same purpose I am using an additional partition that covers the range of kernel and rootfs to update both of them
> at the same time. Ofcourse in this case after writing the images the device has to be rebooted. How do you handle
> remounting the rootfs and synchronization with current systems configuration so you don't have to reboot?
>
> Regards, Stephan
>
> > -----Original Message-----
> > From: linux-mtd-bounces@lists.infradead.org
> > [mailto:linux-mtd-bounces@lists.infradead.org]On Behalf Of Kuefmann
> > Andreas ICM CP RD SD 1
> > Sent: Mittwoch, 1. September 2004 13:42
> > To: 'linux-mtd@lists.infradead.org'
> > Subject: how to change size of MTD partitions at runtime
> >
> >
> > Hi all,
> >
> > I'm searching for a solution to dynamically change the size of MTD
> > partitions at runtime.
> >
> > This functionality is required for a flash update of kernel and/or
> > rootfs in the special case that the new kernel/rootfs is larger than
> > the old one. (in an embedded environment)
> >
> > 1.)
> > there is no problem in erasing the flash, e.g eraseall /dev/mtd?,
> > (acting from a chrooted environment)
> >
> > 2.)
> > However, reprogramming the flash with a larger image (now exceeding
> > the limits of the previous partition) isn't as easy as a cp
> > newimage.img /dev/mtd?.
> >
> > The MTD layer will still rely on the (old) partition sizes that were
> > valid during system startup. (taken over from a U-BOOT environment)
> >
> > My plans are as follows:
> > - erase the flash partitions
> > - adapt the u-boot environment to reflect the new mtd partition sizes
> > - force the MTD subsystem to "re-read" the partition table in u-boot's
> > environment.
> > - cp the new images to /dev/mtd? (which now reflect the changed
> > partition sizes)
> >
> > My question now is:
> > - How can I manage to force a re-read of the partition table?
> >
> > Or can you think of another solution to change MTD partitions at
> > runtime?
> >
> > Thank you,
> > regards,
> > - Andy
> >
> > ______________________________________________________
> > Linux MTD discussion mailing list
> > http://lists.infradead.org/mailman/listinfo/linux-mtd/
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-09-02 15:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-01 11:41 how to change size of MTD partitions at runtime Kuefmann Andreas ICM CP RD SD 1
2004-09-01 15:34 ` William J Beksi
2004-09-02 13:19 ` Stephan Linke
-- strict thread matches above, loose matches on Subject: below --
2004-09-02 14:48 AW: " Kuefmann Andreas ICM CP RD SD 1
2004-09-02 15:39 ` Stephan Linke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox