mmap question

I’ve been trying to get a can board memory-mapped into the system but seem
to fail each time. I want it’s IO to go into 0xD0000, which the board is
set up for. I was doing this with shm_open of Physical and mmap.

I think I’ve narrowed it down to a bad address being mmap’d. I copied the
sh_mem example 1 from the help viewer and ran it. It tells me that the "Map
addr is 00E000 even though the “off” parameter to mmap is 0xf0000. I assume
“Physical” starts at 0000 but even changing the “off” (F0000) to other
values, addr still is 00E000.

I was expecting addr to be 0xf0000.

So, using the example, how can I talk with a memory-mapped board at 0xF0000?

I am using QNX 4.25H and am compiling with -T1 and -g3.

Thanks.

“Ken Price” <kprice@harscotrack.com> wrote in message
news:9vo1or$7fl$1@inn.qnx.com

I’ve been trying to get a can board memory-mapped into the system but seem
to fail each time. I want it’s IO to go into 0xD0000, which the board is
set up for. I was doing this with shm_open of Physical and mmap.

I think I’ve narrowed it down to a bad address being mmap’d. I copied the
sh_mem example 1 from the help viewer and ran it. It tells me that the
"Map
addr is 00E000 even though the “off” parameter to mmap is 0xf0000. I
assume
“Physical” starts at 0000 but even changing the “off” (F0000) to other
values, addr still is 00E000.

I was expecting addr to be 0xf0000.

The address you get from mmap is virtual. It’s in no way related to
the physical address.

So, using the example, how can I talk with a memory-mapped board at
0xF0000?

I am using QNX 4.25H and am compiling with -T1 and -g3.

Thanks.

“Mario Charest” <mcharest@clipzinformatic.com> wrote in message
news:9vo3fc$8e3$1@inn.qnx.com

“Ken Price” <> kprice@harscotrack.com> > wrote in message
news:9vo1or$7fl$> 1@inn.qnx.com> …
I’ve been trying to get a can board memory-mapped into the system but
seem
to fail each time. I want it’s IO to go into 0xD0000, which the board
is
set up for. I was doing this with shm_open of Physical and mmap.

I think I’ve narrowed it down to a bad address being mmap’d. I copied
the
sh_mem example 1 from the help viewer and ran it. It tells me that the
"Map
addr is 00E000 even though the “off” parameter to mmap is 0xf0000. I
assume
“Physical” starts at 0000 but even changing the “off” (F0000) to other
values, addr still is 00E000.

I was expecting addr to be 0xf0000.

The address you get from mmap is virtual. It’s in no way related to
the physical address.

Pardon me for asking a dumb question, but does that mean that when I write
to
E000 after sh_mem and mmap, I’m really writing to F0000 on the board’s
memory-map?



So, using the example, how can I talk with a memory-mapped board at
0xF0000?

I am using QNX 4.25H and am compiling with -T1 and -g3.

Thanks.

\

Pardon me for asking a dumb question, but does that mean that when I write
to E000 after sh_mem and mmap, I’m really writing to F0000 on the board’s
memory-map?

If mmap was setup properoty yes.

Each program is given a virtual address space. When you mmap() you ask
the kernel to include a certain physical address space into the virtual
space of your process.

That is why whatever physical memory (D0000, F0000) you try
to access it always gets mapped at the same virtual space. If you’d
change the size of your request then it may end up getting mmap to a
different address.

Why it’s now working in your case I don’t know.
Are you 100% it’s not working?
Can you check if the board is access or not?

  • Mario

“Mario Charest” <mcharest@clipzinformatic.com> wrote in message
news:9vo710$aoh$1@inn.qnx.com

Pardon me for asking a dumb question, but does that mean that when I
write
to E000 after sh_mem and mmap, I’m really writing to F0000 on the
board’s
memory-map?

If mmap was setup properoty yes.

Each program is given a virtual address space. When you mmap() you ask
the kernel to include a certain physical address space into the virtual
space of your process.

That is why whatever physical memory (D0000, F0000) you try
to access it always gets mapped at the same virtual space. If you’d
change the size of your request then it may end up getting mmap to a
different address.

Why it’s now working in your case I don’t know.
Are you 100% it’s not working?
Can you check if the board is access or not?

Thanks for answering my question so fast.

After writing to an output register, the board is changing other output
registers
(which I don’t believe it should be). I just wanted to make sure it wasn’t
software.
I’ll get with the vendor to learn more about the registers.

Thanks again.

  • Mario

[cut[

After writing to an output register, the board is changing other output
registers (which I don’t believe it should be).

I would consider this a good indication mmap worked as expected.
At least you are can access the card’s registers :wink:


I just wanted to make sure it wasn’t software.
I’ll get with the vendor to learn more about the registers.

Thanks again.

  • Mario

    \

Ken Price <kprice@harscotrack.com> wrote:

“Mario Charest” <> mcharest@clipzinformatic.com> > wrote in message
news:9vo710$aoh$> 1@inn.qnx.com> …

Pardon me for asking a dumb question, but does that mean that when I
write
to E000 after sh_mem and mmap, I’m really writing to F0000 on the
board’s
memory-map?

If mmap was setup properoty yes.

Each program is given a virtual address space. When you mmap() you ask
the kernel to include a certain physical address space into the virtual
space of your process.

That is why whatever physical memory (D0000, F0000) you try
to access it always gets mapped at the same virtual space. If you’d
change the size of your request then it may end up getting mmap to a
different address.

Why it’s now working in your case I don’t know.
Are you 100% it’s not working?
Can you check if the board is access or not?

Thanks for answering my question so fast.

After writing to an output register, the board is changing other output
registers
(which I don’t believe it should be). I just wanted to make sure it wasn’t
software.
I’ll get with the vendor to learn more about the registers.

Also, be careful about the width of the registers and how much you
are reading/writing. Are they 8-bit registers? Are you assigning to
an int * or a char *, etc.

-David

QNX Training Services
I do not answer technical questions by email.