public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Brett Graham <graham@rowland.harvard.edu>
Cc: linux-omap@vger.kernel.org
Subject: Re: mmap /dev/mem in python
Date: Tue, 20 Oct 2009 15:17:02 -0700	[thread overview]
Message-ID: <20091020221701.GM12576@atomide.com> (raw)
In-Reply-To: <47b23c40910201506u381ee2b4ye3867d3559443bdb@mail.gmail.com>

* Brett Graham <graham@rowland.harvard.edu> [091020 15:06]:
> I'm trying to mmap /dev/mem in python to access various registers on a
> gumstix overo (with an omap 3530 processor). Here is the code I'm
> using (as a minimal example):
> ----------------------------
> import os, mmap
> MAP_MASK = mmap.PAGESIZE - 1
> addr = (see below)
> 
> f = os.open("/dev/mem", os.O_RDWR | os.O_SYNC)
> m = mmap.mmap(f, mmap.PAGESIZE, mmap.MAP_SHARED, mmap.PROT_WRITE |
> mmap.PROT_READ, offset=addr & ~MAP_MASK)
> m.seek(addr & MAP_MASK)
> c = m.read_byte()
> print c
> m.close()
> os.close(f)
> ----------------------------
> 
> If I use: addr = 0x48002178 everything works swimmingly. However, if I
> use: addr = 0x48088024 (or all the addresses I've tried > 0x48044000)
> I get the following error
> 
> Unhandled fault: external abort on non-linefetch (0x1018) at 0x40020024
> Bus error
> 
> and python crashes. I'm basing the mmap flags and options off of
> devmem2.c. If I remove the O_SYNC flag from the os.open command, I can
> read and write to registers fine, but randomly I will get the
> Unhandled fault error and things will not work correctly.
> 
> Am I using the right command to write to the omap registers? should I
> be using the O_SYNC flag? Any ideas where these errors are coming
> from?

Sounds like you need to enable ick and fck for the device you're trying
to read.

Tony

  reply	other threads:[~2009-10-20 22:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-20 22:06 mmap /dev/mem in python Brett Graham
2009-10-20 22:17 ` Tony Lindgren [this message]
     [not found]   ` <47b23c40910201615l1b1ab25ewd1dcae6b27728397@mail.gmail.com>
2009-10-20 23:16     ` Fwd: " Brett Graham
2009-10-20 23:26       ` Paul Walmsley
2009-10-21  0:01         ` Brett Graham
2009-10-21  0:27           ` Paul Walmsley
2009-10-21 12:20             ` Brett Graham
2009-10-20 23:18 ` Paul Walmsley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091020221701.GM12576@atomide.com \
    --to=tony@atomide.com \
    --cc=graham@rowland.harvard.edu \
    --cc=linux-omap@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox