RE: Accessing flash directly from User Space [SOLVED]
From: Jonathan Haws <hidden>
Date: 2009-10-30 14:50:32
On Thu, Oct 29, 2009 at 10:00:28AM +0100, Joakim Tjernlund wrote:quoted
quoted
I have found the problem. It occurred to me in the shower (okaynot really,quoted
quoted
but most good ideas happen there). What was happening is that I was in fact able to write to thecorrectquoted
quoted
registers. However, I would try and write to them in a batch.But the wayquoted
quoted
mmap works (at least according to the man page) with MAP_SHAREDis that thequoted
quoted
file may not be updated until msync() is called. Now, I thoughtthat O_SYNCquoted
quoted
would take care of that when I open /dev/mem, but that was notthe case.quoted
quoted
Anyway, to make a long story short, I inserted an msync() aftereachquoted
quoted
assignment to the flash. This resolved my problem and I can nowprogram my flash.quoted
Ouch, this was news to me too. Calling msync() after every writekills performance.quoted
We use mmap(/dev/mem) to access HW and havn't seen any issues yet.Is thisquoted
perhaps a new behaviour for mmap(/dev/mem) and is there a way to avoid calling msync()?=20 I suspect that the msync() was merely serving as a very heavyweight memory barrier.
I did try hacking the mb() calls from the kernel source to use them in user= space, but they had no effect. I still had to include the calls to msync(= ).