* How do I access nvRAM from user space?
@ 2008-09-25 3:18 Bruce_Leonard
2008-09-25 5:45 ` yanjun.luo
2008-09-25 15:53 ` David Hawkins
0 siblings, 2 replies; 6+ messages in thread
From: Bruce_Leonard @ 2008-09-25 3:18 UTC (permalink / raw)
To: linuxppc-embedded
Sorry for the dumb question, I just can figure out the right google search
to find what I'm trying to do. I'm running 2.6.27-rc4 on an mpc8347 with
a 32KiB nvSRAM (Cypress CY14B256L) on the local bus. We just want to be
able to access this memory from user space seperately from "main" memory.
We've got a process that needs to be able to remember info through power
cycles. Can anyone point me to an article or some code snippet that does
something like this so I can sink my teeth into it?
Bruce
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How do I access nvRAM from user space?
2008-09-25 3:18 How do I access nvRAM from user space? Bruce_Leonard
@ 2008-09-25 5:45 ` yanjun.luo
2008-09-25 15:53 ` David Hawkins
1 sibling, 0 replies; 6+ messages in thread
From: yanjun.luo @ 2008-09-25 5:45 UTC (permalink / raw)
To: Bruce_Leonard@selinc.com, linuxppc-embedded@ozlabs.org
[-- Attachment #1: Type: text/plain, Size: 1010 bytes --]
Hi Bruce,
You can use mmap to access NVRAM from user space, but you should config
local bus first, like width, speed etc.
Regards,
Yanjun Luo.
发件人: Bruce_Leonard@selinc.com
发送时间: 2008-09-25 11:44:56
收件人: linuxppc-embedded@ozlabs.org
抄送:
主题: How do I access nvRAM from user space?
Sorry for the dumb question, I just can figure out the right google search
to find what I'm trying to do. I'm running 2.6.27-rc4 on an mpc8347 with
a 32KiB nvSRAM (Cypress CY14B256L) on the local bus. We just want to be
able to access this memory from user space seperately from "main" memory.
We've got a process that needs to be able to remember info through power
cycles. Can anyone point me to an article or some code snippet that does
something like this so I can sink my teeth into it?
Bruce
_______________________________________________
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded
[-- Attachment #2: Type: text/html, Size: 4006 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How do I access nvRAM from user space?
2008-09-25 3:18 How do I access nvRAM from user space? Bruce_Leonard
2008-09-25 5:45 ` yanjun.luo
@ 2008-09-25 15:53 ` David Hawkins
2008-09-25 17:18 ` Bruce_Leonard
1 sibling, 1 reply; 6+ messages in thread
From: David Hawkins @ 2008-09-25 15:53 UTC (permalink / raw)
To: Bruce_Leonard; +Cc: linuxppc-embedded
Hi Bruce,
> Sorry for the dumb question, I just can figure out the right google search
> to find what I'm trying to do. I'm running 2.6.27-rc4 on an mpc8347 with
> a 32KiB nvSRAM (Cypress CY14B256L) on the local bus. We just want to be
> able to access this memory from user space seperately from "main" memory.
> We've got a process that needs to be able to remember info through power
> cycles. Can anyone point me to an article or some code snippet that does
> something like this so I can sink my teeth into it?
Assuming your bootloader sets up the local bus access windows
(physical address of the SRAM) and timing so that you can
read/write to the SRAM, then once Linux boots, you should be
able to just use /dev/mem as you would to access any other
device registers at a specific address.
Cheers,
Dave
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How do I access nvRAM from user space?
2008-09-25 15:53 ` David Hawkins
@ 2008-09-25 17:18 ` Bruce_Leonard
2008-09-25 18:13 ` Bruce_Leonard
2008-09-25 18:14 ` David Hawkins
0 siblings, 2 replies; 6+ messages in thread
From: Bruce_Leonard @ 2008-09-25 17:18 UTC (permalink / raw)
To: David Hawkins
Cc: linuxppc-embedded-bounces+brucle=selinc.com, linuxppc-embedded
Dave,
> > Sorry for the dumb question, I just can figure out the right google
search
> > to find what I'm trying to do. I'm running 2.6.27-rc4 on an mpc8347
with
> > a 32KiB nvSRAM (Cypress CY14B256L) on the local bus. We just want to
be
> > able to access this memory from user space seperately from "main"
memory.
> > We've got a process that needs to be able to remember info through
power
> > cycles. Can anyone point me to an article or some code snippet that
does
> > something like this so I can sink my teeth into it?
>
> Assuming your bootloader sets up the local bus access windows
> (physical address of the SRAM) and timing so that you can
> read/write to the SRAM, then once Linux boots, you should be
> able to just use /dev/mem as you would to access any other
> device registers at a specific address.
>
Thanks for the reply. So if my nvSRAM device is located at 0xb0000000 in
physical memory, what would the mmap() call look like? Also, do I need to
have a device tree entry for the kernel to know about the memory? I can
access the device in uboot so I know it works, but I can't figure out the
mmap to get it from linux
Bruce
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How do I access nvRAM from user space?
2008-09-25 17:18 ` Bruce_Leonard
@ 2008-09-25 18:13 ` Bruce_Leonard
2008-09-25 18:14 ` David Hawkins
1 sibling, 0 replies; 6+ messages in thread
From: Bruce_Leonard @ 2008-09-25 18:13 UTC (permalink / raw)
To: Bruce_Leonard
Cc: linuxppc-embedded-bounces+brucle=selinc.com, linuxppc-embedded
>
> Thanks for the reply. So if my nvSRAM device is located at 0xb0000000
in
> physical memory, what would the mmap() call look like? Also, do I need
to
> have a device tree entry for the kernel to know about the memory? I can
> access the device in uboot so I know it works, but I can't figure out
the
> mmap to get it from linux
>
Never mind. I figured out how to use mmap. It's all in the parameter
'off' not 'addr' :). Thanks to everyone who responded with help.
Bruce
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How do I access nvRAM from user space?
2008-09-25 17:18 ` Bruce_Leonard
2008-09-25 18:13 ` Bruce_Leonard
@ 2008-09-25 18:14 ` David Hawkins
1 sibling, 0 replies; 6+ messages in thread
From: David Hawkins @ 2008-09-25 18:14 UTC (permalink / raw)
To: Bruce_Leonard
Cc: linuxppc-embedded-bounces+brucle=selinc.com, linuxppc-embedded
Hi Bruce,
> Thanks for the reply. So if my nvSRAM device is located at 0xb0000000 in
> physical memory, what would the mmap() call look like? Also, do I need to
> have a device tree entry for the kernel to know about the memory? I can
> access the device in uboot so I know it works, but I can't figure out the
> mmap to get it from linux
Its pretty much:
/* Open /dev/mem and map it */
printf(" * open /dev/mem\n");
fd = open("/dev/mem", O_RDWR | O_SYNC);
if (fd < 0) {
printf("Open /dev/mem failed - %s\n",
strerror(errno));
return -1;
}
printf(" * map %d page(s) (%d-bytes) at address 0x%.8X\n",
mem_pages, mem_size, mem_phys);
mem_addr = (char *)mmap(
0,
mem_size,
PROT_READ|PROT_WRITE,
MAP_SHARED,
fd,
mem_phys);
if (mem_addr == (char *)MAP_FAILED) {
printf("Error: mmap failed\n");
close(fd);
return -1;
}
I'll send you the code I ripped that from, and another
example from the Busybox code.
Cheers,
Dave
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-09-25 18:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-25 3:18 How do I access nvRAM from user space? Bruce_Leonard
2008-09-25 5:45 ` yanjun.luo
2008-09-25 15:53 ` David Hawkins
2008-09-25 17:18 ` Bruce_Leonard
2008-09-25 18:13 ` Bruce_Leonard
2008-09-25 18:14 ` David Hawkins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).