This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IO programming problems
#1
Hi there,
I'm writing a C program to access some hw devices.
To achieve that I memory map the device then I read/write values at some offsets.

The first area is the PCM device.
I mapped the 0xFF890000 block and I read some registers.
I'm trying to follow the application notes found on the rk3288 manual: 
Code:
pcm->xfer &= 0xFFFFFFFE;
pcm->clr  |= 0x00000001;

while(pcm->clr & 1)
  printf("> %X\n", pcm->clr);
The clr[0] bit should return to 0 value but instead stay always at level 1.

The second area is about suspend and wake-up mechanism.
Again I mapped the 0xFF730000 area - PMU registers.
I printed some registers but when I set the PMU_PWRMODE_CON[0] register the system does not enter in LowPower mode.
Code:
pmu->pmu_pwrmode_con |= 1;


So, what I'm doing wrong?
Are this operations allowed from user space?

Thanks, regards
Reply
#2
I realized just now that the mapmem() is a function as follow:

Code:
...
mem_fd = open(mem_dev, O_RDWR | O_SYNC);
    if (mem_fd < 0) {
       perror("Can't open /dev/mem");
       return NULL;
    }

    mem = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, base & pagemask);
    if (mem == MAP_FAILED) {
        perror("mmap error\n");
        return NULL;
    }

    close(mem_fd);
...
.. just for info
Reply
#3
FYI, I saw the wiringPi source that may put some privileges to access the memory as a normal user. I suggest to have a look.
Light blue words might be a link. Have you try to click on them? Big Grin
Reply
#4
Sure,
but I'm testing the application as root.
Reply
#5
I forgive me, the reference in particular is on the gpio executable.
Light blue words might be a link. Have you try to click on them? Big Grin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)