Question

I have made a code that read data from flash Nand (without filesystem).

fd = open("/dev/mtd0", O_RDONLY)

It works, then I want to try to read write it.. So I change the code to:

fd = open("/dev/mtd0", O_RDWR)

But It returns -1, means can not open. But for others MTD, it works.

Then I see cat /proc/mtd said that MTD0 is RO and the other is RW (i think it's Read-Only and Read-Write)

I tried to use MEMUNLOCK

ioctl(fd, MEMUNLOCK, &mtdLockInfo)

Because it needs fd, needs open so i use O_RDONLY not O_RDWR(return -1).

But it returns error Bad file description. It must be because of O_RDONLY,, have to use O_WRONLY or O_RDWR.

Is there any way to UNLOCK this MTD0, or to write on it without unlock it??

Était-ce utile?

La solution 2

I have tried to change the partition of my NAND flash in the Device Tree Source(DTS).

There's an read-only option. But, I only changed their size.

ANd it's done.. My NAND flash can be accessed.

Autres conseils

The operation is likely being forbidden by the kernel driver for your device. It's likely that your device is actually read-only or marked as such by the driver.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top