Accessing flash directly from User Space

Alessandro Rubini rubini at gnudd.com
Wed Oct 28 09:42:34 EST 2009


> I realize that.  I have a driver written that does exactly that.
> However, I need to be able to write to certain registers to setup
> the erasure.  The driver works perfectly in VxWorks, now I am
> porting it to Linux.

Most likey you are hit by the compiler reordering the accesses and
caching data in registers. You should try to use volatile pointers
(but also read the "volatile considered harmful" file in the kernel
sources -- anyways you are doing bad things nonetheless), or add
memory barriers (copy the mb() and wmb() macros defined for kernel
space).

Then, the first-word-access you show is wrong, as Scott Wood told you,
so the fact that _that_ access is not working even across msync
that's another matter.

I usually have no serious problems with driving hardware from
/dev/mem, although I've never done flash specifically as mtd is there.

hope this helps
/alessandro


More information about the Linuxppc-dev mailing list