Skip to contentSkip to conversation

Mtd block access (jffs2 formatted) and mtd char access (unformatted) on different partitions of a single flash device

DISCUSSION John Burch 4 participants 6 messages May 20, 2003 – May 21, 2003 Memory technology devices (MTD)

lore
Share & tools
lore

John Burch

author
#0 lore raw

Is there a preferred way to access different mtd partitions of a single flash device when certain accesses will be (1) block oriented via standard file I/O of a jffs2 file system mounted on a /dev/mtdblockN device and other accesses will be (2) character oriented via 'dd' (or some other mechanism?) of unformatted/raw flash using /dev/mtdN? Are there any possibly bad interactions between mtd char and block device access to the same device?

I've adopted a system that uses a driver with its own flash support to read/write raw (non-jffs2) portions of the flash, while application code uses standard file I/O to read/write jffs2 partitions on the same device. I'm concerned that these accesses may clash and possibly result in corrupted flash, crashed kernel, etc. Is this a legitimate concern or does the mtd driver check flash status prior to any operations?

Thanks,
John

#1 lore raw
Quoted 7 lines · John Burch

Is there a preferred way to access different mtd partitions of a single flash device when certain accesses will be (1) block oriented via standard file I/O of a jffs2 file system mounted on a /dev/mtdblockN device and other accesses will be (2) character oriented via 'dd' (or some other mechanism?) of unformatted/raw flash using /dev/mtdN? Are there any possibly bad interactions between mtd char and block device access to the same device?

This should not be a problem.

Quoted 7 lines

I've adopted a system that uses a driver with its own flash support to read/write raw (non-jffs2) portions of the flash, while application code uses standard file I/O to read/write jffs2 partitions on the same device. I'm concerned that these accesses may clash and possibly result in corrupted flash, crashed kernel, etc. Is this a legitimate concern or does the mtd driver check flash status prior to any operations?

It is mtd's job to handle this sort of thing.

-- CHarles

#2 lore raw
In reply to John Burch
Quoted 8 lines · John Burch

Is there a preferred way to access different mtd partitions of a single flash device when certain accesses will be (1) block oriented via standard file I/O of a jffs2 file system mounted on a /dev/mtdblockN device and other accesses will be (2) character oriented via 'dd' (or some other mechanism?) of unformatted/raw flash using /dev/mtdN? Are there any possibly bad interactions between mtd char and block device access to the same device?

Usually not. It would be a bug.

Quoted 6 lines

I've adopted a system that uses a driver with its own flash support to read/write raw (non-jffs2) portions of the flash, while application code uses standard file I/O to read/write jffs2 partitions on the same device. I'm concerned that these accesses may clash and possibly result in corrupted flash, crashed kernel, etc. Is this a legitimate concern or does the mtd driver check flash status prior to any operations?

The physical flash device can only have one driver accessing it at any time. The low level chip drivers have locking for this, so you should be safe.

What does "driver" mean? If you have two in-kernel drivers for the same flash chip, they will use different locks and things will break. If that is a user-space driver, using the /dev/mtdX devices, you are perfectly safe. Which one is it?

Jörn

Signature · 3 lines
Courage is not the absence of fear, but rather the judgement that
something else is more important than fear.
-- Ambrose Redmoon
#3 lore raw
Quoted 9 lines · Jörn Engel
Quoted 4 lines

I've adopted a system that uses a driver with its own flash support to read/write raw (non-jffs2) portions of the flash, while application code uses standard file I/O to read/write jffs2 partitions on the same device.

What does "driver" mean? If you have two in-kernel drivers for the same flash chip, they will use different locks and things will break. If that is a user-space driver, using the /dev/mtdX devices, you are perfectly safe. Which one is it?

Hmmm. What he actually said was 'driver with its own flash support', which sounds bad. As long as everything accessing the flash goes through the MTD driver for the flash, using its read/write/erase functions rather than banging on the hardware directly, it'll be fine. If your raw driver is actually dealing with the flash driver directly, that's broken.

Signature · 1 line
dwmw2
author
#4 lore raw

RE: Mtd block access (jffs2 formatted) and mtd char access(unformatted) on different partitions of a single flashdevice

Quoted 4 lines
Quoted 3 lines

What does "driver" mean? If you have two in-kernel drivers for the same flash chip, they will use different locks and things

will break.

Quoted 8 lines
Quoted 1 line

If that is a user-space driver, using the /dev/mtdX

devices, you are

Quoted 1 line

perfectly safe. Which one is it?

Hmmm. What he actually said was 'driver with its own flash support', which sounds bad. As long as everything accessing the flash goes through the MTD driver for the flash, using its read/write/erase functions rather than banging on the

When accessing "raw" flash via the char driver, how can I initiate a sector erase? Also, does the mtd driver for AMD CFI devices handle AMD's ability to support erasure of multiple sectors simultaneously?

Quoted 3 lines

hardware directly, it'll be fine. If your raw driver is actually dealing with the flash driver directly, that's broken.

David has it right. The raw "in-kernel" driver deals with flash directly on its own, not through mtd.

#5 lore raw

RE: Mtd block access (jffs2 formatted) and mtd char access(unformatted) on different partitions of a single flash device

Quoted 2 lines · John Burch

When accessing "raw" flash via the char driver, how can I initiate a sector erase?

See how it's done in util/erase.c: ioctl(...MEMERASE...)

Quoted 2 lines

Also, does the mtd driver for AMD CFI devices handle AMD's ability to support erasure of multiple sectors simultaneously?

Probably not yet, but there's no reason why it shouldn't. Criticism in 'diff -u' form is preferred :)

Quoted 2 lines

David has it right. The raw "in-kernel" driver deals with flash directly on its own, not through mtd.

Then you lose :) If you have sane code which handles multiple concurrent erases, we'd be happy to merge it so that you can use the mtd driver without losing out on that feature ;)

Signature · 1 line
dwmw2