mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-27 17:15:00 +02:00
mtd - add partition offset parameter
The offset parameter can be used to write the data at the offset instead of writing it to the beginning of the partition. Signed-off-by: Marek Linder <lindner_marek@yahoo.de> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32600 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
08a9c557e0
commit
6a288531d7
@ -286,7 +286,7 @@ indicate_writing(const char *mtd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mtd_write(int imagefd, const char *mtd, char *fis_layout)
|
mtd_write(int imagefd, const char *mtd, char *fis_layout, size_t part_offset)
|
||||||
{
|
{
|
||||||
char *next = NULL;
|
char *next = NULL;
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
@ -370,6 +370,11 @@ resume:
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (part_offset > 0) {
|
||||||
|
fprintf(stderr, "Seeking on mtd device '%s' to: %u\n", mtd, part_offset);
|
||||||
|
lseek(fd, part_offset, SEEK_SET);
|
||||||
|
}
|
||||||
|
|
||||||
indicate_writing(mtd);
|
indicate_writing(mtd);
|
||||||
|
|
||||||
w = e = 0;
|
w = e = 0;
|
||||||
@ -509,7 +514,7 @@ static void usage(void)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" fixtrx fix the checksum in a trx header on first boot\n");
|
" fixtrx fix the checksum in a trx header on first boot\n");
|
||||||
}
|
}
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Following options are available:\n"
|
"Following options are available:\n"
|
||||||
" -q quiet mode (once: no [w] on writing,\n"
|
" -q quiet mode (once: no [w] on writing,\n"
|
||||||
" twice: no status messages)\n"
|
" twice: no status messages)\n"
|
||||||
@ -518,7 +523,8 @@ static void usage(void)
|
|||||||
" -f force write without trx checks\n"
|
" -f force write without trx checks\n"
|
||||||
" -e <device> erase <device> before executing the command\n"
|
" -e <device> erase <device> before executing the command\n"
|
||||||
" -d <name> directory for jffs2write, defaults to \"tmp\"\n"
|
" -d <name> directory for jffs2write, defaults to \"tmp\"\n"
|
||||||
" -j <name> integrate <file> into jffs2 data when writing an image\n");
|
" -j <name> integrate <file> into jffs2 data when writing an image\n"
|
||||||
|
" -p write beginning at partition offset\n");
|
||||||
if (mtd_fixtrx) {
|
if (mtd_fixtrx) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" -o offset offset of the image header in the partition(for fixtrx)\n");
|
" -o offset offset of the image header in the partition(for fixtrx)\n");
|
||||||
@ -554,7 +560,7 @@ int main (int argc, char **argv)
|
|||||||
int ch, i, boot, imagefd = 0, force, unlocked;
|
int ch, i, boot, imagefd = 0, force, unlocked;
|
||||||
char *erase[MAX_ARGS], *device = NULL;
|
char *erase[MAX_ARGS], *device = NULL;
|
||||||
char *fis_layout = NULL;
|
char *fis_layout = NULL;
|
||||||
size_t offset = 0;
|
size_t offset = 0, part_offset = 0;
|
||||||
enum {
|
enum {
|
||||||
CMD_ERASE,
|
CMD_ERASE,
|
||||||
CMD_WRITE,
|
CMD_WRITE,
|
||||||
@ -575,7 +581,7 @@ int main (int argc, char **argv)
|
|||||||
#ifdef FIS_SUPPORT
|
#ifdef FIS_SUPPORT
|
||||||
"F:"
|
"F:"
|
||||||
#endif
|
#endif
|
||||||
"frnqe:d:j:o:")) != -1)
|
"frnqe:d:j:p:o:")) != -1)
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'f':
|
case 'f':
|
||||||
force = 1;
|
force = 1;
|
||||||
@ -603,6 +609,14 @@ int main (int argc, char **argv)
|
|||||||
case 'd':
|
case 'd':
|
||||||
jffs2dir = optarg;
|
jffs2dir = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
errno = 0;
|
||||||
|
part_offset = strtoul(optarg, 0, 0);
|
||||||
|
if (errno) {
|
||||||
|
fprintf(stderr, "-p: illegal numeric string\n");
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
if (!mtd_fixtrx) {
|
if (!mtd_fixtrx) {
|
||||||
fprintf(stderr, "-o: is not available on this platform\n");
|
fprintf(stderr, "-o: is not available on this platform\n");
|
||||||
@ -704,7 +718,7 @@ int main (int argc, char **argv)
|
|||||||
case CMD_WRITE:
|
case CMD_WRITE:
|
||||||
if (!unlocked)
|
if (!unlocked)
|
||||||
mtd_unlock(device);
|
mtd_unlock(device);
|
||||||
mtd_write(imagefd, device, fis_layout);
|
mtd_write(imagefd, device, fis_layout, part_offset);
|
||||||
break;
|
break;
|
||||||
case CMD_JFFS2WRITE:
|
case CMD_JFFS2WRITE:
|
||||||
if (!unlocked)
|
if (!unlocked)
|
||||||
|
Loading…
Reference in New Issue
Block a user