My test of wiringPi on new Lollipop image

Locked
joerg
Posts: 942
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Has thanked: 13 times
Been thanked: 39 times
Contact:

My test of wiringPi on new Lollipop image

Unread post by joerg » Tue Aug 02, 2016 5:21 am

While I am testing my nRF24L01 library on C1 with new lollipop image, I have some issues.

WiringPi
Need to change the code once more, because of error that can't open /dev/mem.

wiringPi.c#3001

Code: Select all

#if defined(ODROID_IOCTL)
  if ((model == PI_MODEL_ODROIDC) || (model == PI_MODEL_ODROIDC2)) {
      if ((ioctl_fd = open ("/dev/gpioctrl", O_RDWR | O_SYNC | O_CLOEXEC) ) < 0) {
        return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: Unable to open /dev/gpioctrl: %s\n", strerror (errno)) ;
      }
  } else {
      if ((fd = open ("/dev/mem", O_RDWR | O_SYNC | O_CLOEXEC) ) < 0)
        return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: Unable to open /dev/mem: %s\n", strerror (errno)) ;
  }
#else
  if ( model == PI_MODEL_ODROIDC2 )	{
    if ((fd = open ("/dev/gpiomem", O_RDWR | O_SYNC | O_CLOEXEC) ) < 0)
      return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: Unable to open /dev/gpiomem: %s\n", strerror (errno)) ;
  } else {
    if ((fd = open ("/dev/mem", O_RDWR | O_SYNC | O_CLOEXEC) ) < 0)
      return wiringPiFailure (WPI_ALMOST, "wiringPiSetup: Unable to open /dev/mem: %s\n", strerror (errno)) ;
  }
#endif
It was trying to open /dev/gpiomem, but on C1 there is no, only /dev/mem.

Next I became error mmap invalid argument, same as on C2. Also replaced mmap to mmap64 here.
wiringPi.c#3027

Code: Select all

    //gpio = (__mmap_t *)mmap(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, ODROID_GPIO_BASE) ;
    gpio = (__mmap_t *)mmap64(0, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, (off64_t)ODROID_GPIO_BASE);
After that wiringPi function wiringSetup() is working. Here is the complete wiringPi, the one I uploaded to dropbox is not actual.
wiringPi.zip
(845.45 KiB) Downloaded 84 times
Next, tried to use wiringPi from app, needed to change permission:

Code: Select all

chmod 666 /dev/mem
chmod 666 /dev/spidev0.0

User avatar
odroid
Site Admin
Posts: 33676
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 508 times
Been thanked: 506 times
Contact:

Re: My test of wiringPi on new Lollipop image

Unread post by odroid » Tue Aug 02, 2016 3:55 pm

Thank you for the report and patch.
We will update C1 Kernel/WiringPi like the latest C2 Android release.

User avatar
odroid
Site Admin
Posts: 33676
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 508 times
Been thanked: 506 times
Contact:

Re: My test of wiringPi on new Lollipop image

Unread post by odroid » Thu Aug 18, 2016 1:05 pm

Ver 1.1 update has the /dev/gpiomem (with 666 permission) now.
http://odroid.com/dokuwiki/doku.php?id= ... 5.1.1_v1.1

But it still needs the mmap64 instead of the mmap.

Can you tell me which NDK version do you use?

joerg
Posts: 942
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Has thanked: 13 times
Been thanked: 39 times
Contact:

Re: My test of wiringPi on new Lollipop image

Unread post by joerg » Thu Aug 18, 2016 1:59 pm

I use the NDK r11. But I don't think that it depends on the version of NDK. Let me try with the new image. I'll come back to you.

joerg
Posts: 942
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2
Location: Germany
Has thanked: 13 times
Been thanked: 39 times
Contact:

Re: My test of wiringPi on new Lollipop image

Unread post by joerg » Thu Aug 18, 2016 5:58 pm

I tested now with /dev/gpiomem and with mmap. I get the error as known before: "mmap (GPIO) failed: Invalid argument".
Then I tested with /dev/gpiomem and with mmap64, the Odroid C1 freezes when my app starts the wiringPi. Tried several times, always need to power off and on to restart.
Last I tested, same as I used last weeks, with /dev/mem and with mmap64. With this setting my app is working.

Maybe you remember the time when wiringPi was ported to Android, we all thought falsely that on Android is not allowed the direct memory access. But in real it was only the access rights of /dev/mem (600) and this error when trying to map the memory with mmap. I in this time didn't saw clear. Some weeks ago I tried on C2 when there was this discussion of accessing the memory above 4G, and I found this solution with mmap64. And for my surprise on C1 also is working this solution. I don't know why on C1 mmap is not working, but I wouldn't invest more time in it, because I can't find a disadvantage using mmap64.

User avatar
odroid
Site Admin
Posts: 33676
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 508 times
Been thanked: 506 times
Contact:

Re: My test of wiringPi on new Lollipop image

Unread post by odroid » Thu Aug 18, 2016 6:04 pm

Thank you for the test.

I fully agree.
Let's keep using the WiringPi with /dev/mem and mmap64 since there is no disadvantage.
But we will look into the gpiomem driver one more week because whole /dev/mem access might not be a good idea due to the security concern.

Locked

Return to “Android”

Who is online

Users browsing this forum: No registered users and 4 guests