projects
/
yaffs
/
.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
*** empty log message ***
[yaffs/.git]
/
utils
/
mkyaffs.c
diff --git
a/utils/mkyaffs.c
b/utils/mkyaffs.c
index 8b7350d6bc1430dbeb19046af8d906146eda9352..a0107bad89e917f8f98c6adc6aac6036d8447096 100644
(file)
--- a/
utils/mkyaffs.c
+++ b/
utils/mkyaffs.c
@@
-34,7
+34,7
@@
#include <linux/config.h>
#include <linux/mtd/mtd.h>
#include <linux/config.h>
#include <linux/mtd/mtd.h>
-const char *mkyaffs_c_version = "$Id: mkyaffs.c,v 1.
5 2002-12-13 00:13:06
charles Exp $";
+const char *mkyaffs_c_version = "$Id: mkyaffs.c,v 1.
6 2003-03-11 05:16:53
charles Exp $";
// countBits is a quick way of counting the number of bits in a byte.
// ie. countBits[n] holds the number of 1 bits in a byte with the value n.
// countBits is a quick way of counting the number of bits in a byte.
// ie. countBits[n] holds the number of 1 bits in a byte with the value n.
@@
-66,6
+66,19
@@
static const char countBits[256] =
unsigned char oobbuf[16];
unsigned char imgpage[528];
unsigned char oobbuf[16];
unsigned char imgpage[528];
+/*
+ * OOB layout
+ */
+
+struct nand_oobinfo yaffs_oobinfo = {
+ useecc: 1,
+ eccpos: {8, 9, 10, 13, 14, 15}
+};
+
+struct nand_oobinfo yaffs_noeccinfo = {
+ useecc: 0,
+};
+
/*
* Main program
/*
* Main program
@@
-76,19
+89,26
@@
int main(int argc, char **argv)
unsigned long offset;
int fd;
int img=-1;
unsigned long offset;
int fd;
int img=-1;
+ int optcnt = 1;
+ int usemtdecc = 0;
int imglen = 0;
struct mtd_oob_buf oob = {0, 16, (unsigned char *) &oobbuf};
mtd_info_t meminfo;
erase_info_t erase;
int imglen = 0;
struct mtd_oob_buf oob = {0, 16, (unsigned char *) &oobbuf};
mtd_info_t meminfo;
erase_info_t erase;
+ struct nand_oobinfo oobsel;
+ if (strcmp (argv[optcnt], "-e") == 0) {
+ optcnt++;
+ usemtdecc = 1;
+ }
+
/* Make sure a device was specified */
/* Make sure a device was specified */
- if(argc <
2
) {
- printf("usage: %s
<mtdname> [image name]
\n", argv[0]);
+ if(argc <
(optcnt + 2)
) {
+ printf("usage: %s
-e <mtdname> <image name>
\n", argv[0]);
exit(1);
}
exit(1);
}
-
- if(argc > 2 &&
- (img = open(argv[2],O_RDONLY)) == -1) {
+
+ if((img = open(argv[optcnt + 1],O_RDONLY)) == -1) {
perror("opening image file");
exit(1);
}
perror("opening image file");
exit(1);
}
@@
-104,7
+124,7
@@
int main(int argc, char **argv)
lseek(img,0,SEEK_SET);
/* Open the device */
lseek(img,0,SEEK_SET);
/* Open the device */
- if((fd = open(argv[
1
], O_RDWR)) == -1) {
+ if((fd = open(argv[
optcnt
], O_RDWR)) == -1) {
perror("opening flash");
exit(1);
}
perror("opening flash");
exit(1);
}
@@
-116,6
+136,14
@@
int main(int argc, char **argv)
exit(1);
}
exit(1);
}
+ // set the appropriate oob layout selector
+ oobsel = usemtdecc ? yaffs_oobinfo : yaffs_noeccinfo;
+ if (ioctl (fd, MEMSETOOBSEL, &oobsel) != 0) {
+ perror ("MEMSETOOBSEL");
+ close (fd);
+ exit (1);
+ }
+
/* Make sure device page sizes are valid */
if( !(meminfo.oobsize == 16 && meminfo.oobblock == 512))
{
/* Make sure device page sizes are valid */
if( !(meminfo.oobsize == 16 && meminfo.oobblock == 512))
{
@@
-171,12
+199,21
@@
int main(int argc, char **argv)
for(offset = 0; offset <meminfo.erasesize; offset+=512)
{
if(read(img,imgpage,528) == 528){
for(offset = 0; offset <meminfo.erasesize; offset+=512)
{
if(read(img,imgpage,528) == 528){
- lseek(fd,addr+offset,SEEK_SET);
- write(fd,imgpage,512);
+ if (usemtdecc) {
+ imgpage[512+8] = 0xff;
+ imgpage[512+9] = 0xff;
+ imgpage[512+10] = 0xff;
+ imgpage[512+13] = 0xff;
+ imgpage[512+14] = 0xff;
+ imgpage[512+15] = 0xff;
+ }
oob.start = addr+offset;
oob.length=16;
oob.ptr=&imgpage[512];
ioctl(fd,MEMWRITEOOB,&oob);
oob.start = addr+offset;
oob.length=16;
oob.ptr=&imgpage[512];
ioctl(fd,MEMWRITEOOB,&oob);
+
+ lseek(fd,addr+offset,SEEK_SET);
+ write(fd,imgpage,512);
}
}
}
}
}
}