From: William J Beksi <wjbeksi@setabox.com>
To: Kuefmann Andreas ICM CP RD SD 1 <andreas.kuefmann@siemens.com>
Cc: "'linux-mtd@lists.infradead.org'" <linux-mtd@lists.infradead.org>
Subject: Re: how to change size of MTD partitions at runtime
Date: Wed, 01 Sep 2004 23:34:32 +0800 [thread overview]
Message-ID: <4135EC08.7010304@setabox.com> (raw)
In-Reply-To: <7F3FE9B2FBF6194691BC493C6699C0B1568B8D@mchh9esa.mchh.siemens.de>
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/
>
>
>
next prev parent reply other threads:[~2004-09-01 15:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4135EC08.7010304@setabox.com \
--to=wjbeksi@setabox.com \
--cc=andreas.kuefmann@siemens.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox