Adafruit BBIO Python library

96 views
Skip to first unread message

Peter Lawler

unread,
Apr 28, 2016, 10:36:36 PM4/28/16
to BeagleBoard
Hi folks,
Just a quick note to let you know I've spent some time tracking down the
differences between 3.8 and later versions for the Adafruit BBIO Python
library.

I first noted this post
https://forums.adafruit.com/viewtopic.php?f=49&t=91903&p=468811#p469266
which discusses that the 3.8 Adafruit library won't work on 4.1, and
that there were some fixes out in the wild so to speak but that Adafruit
weren't in a rush to get them happening.

So I took a look at one of the solutions, by grizmio, and it Just Worked
for me.

I've now shoved a bunch of ifdef's around the changes in the C code that
grizmio made, so I am *hoping* it's simultaneously 3.8 and 4.1 friendly.

I don't have a spare 3.8 machine at hand right now, but if there's
anyone out there who could try it out and see what happens, it'd be
appreciated. All I know is bad C and that it compiles. Please don't
shoot me for doing things wrong ;)


https://github.com/PeteLawler/adafruit-beaglebone-io-python

Regards,

Pete.

Drew Fustini

unread,
May 29, 2016, 1:58:37 AM5/29/16
to BeagleBoard, Robert Nelson
Robert: I'm hoping you might have some advice for this issue I'm encountering.

Peter's pull request for Adafruit_BBIO uses LINUX_VERSION_CODE to determine if the kernel is 4.1 or newer:
https://github.com/adafruit/adafruit-beaglebone-io-python/pull/96#issuecomment-222343880

When I build Adafruit_BBIO, LINUX_VERSION_CODE is set to old version 200711.  It appears to come from:

/usr/include/linux/version.h:#define LINUX_VERSION_CODE 200711
/usr/src/linux-headers-4.1.17-ti-rt-r46/include/generated/uapi/linux/version.h:#define LINUX_VERSION_CODE 262417

I'm using image "BeagleBoard.org Debian Image 2016-02-07" with Linux kernel 4.1.25-ti-r62 and Debian 8.4.  "/usr/include/linux/version.h" appears to come from linux-libc-dev:armhf 3.16.7-ckt25-2.  "/usr/src/linux-headers-4.1.17-ti-rt-r46/include/generated/uapi/linux/version.h" comes from linux-headers-4.1.17-ti-rt-r46.

What would be the proper way to update /usr/include/linux/version.h to reflect 4.1+?

Related gist:
https://gist.github.com/pdp7/193cb6252440850926297ac79ed39acc

Thanks,
Drew

John Syne

unread,
May 29, 2016, 5:52:34 PM5/29/16
to beagl...@googlegroups.com
I haven’t used this feature, but a simple Google search gives what looks like the answer you are looking for:


So in your case:

#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,1,17)


Regards,
John




-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/6dfd7521-cf7e-48b4-b6fc-5ba2d1461d36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robert Nelson

unread,
May 29, 2016, 6:01:14 PM5/29/16
to Drew Fustini, BeagleBoard
On Sun, May 29, 2016 at 12:58 AM, Drew Fustini <pdp7...@gmail.com> wrote:
Robert: I'm hoping you might have some advice for this issue I'm encountering.

Peter's pull request for Adafruit_BBIO uses LINUX_VERSION_CODE to determine if the kernel is 4.1 or newer:
https://github.com/adafruit/adafruit-beaglebone-io-python/pull/96#issuecomment-222343880

When I build Adafruit_BBIO, LINUX_VERSION_CODE is set to old version 200711.  It appears to come from:

/usr/include/linux/version.h:#define LINUX_VERSION_CODE 200711
/usr/src/linux-headers-4.1.17-ti-rt-r46/include/generated/uapi/linux/version.h:#define LINUX_VERSION_CODE 262417

I'm using image "BeagleBoard.org Debian Image 2016-02-07" with Linux kernel 4.1.25-ti-r62 and Debian 8.4.  "/usr/include/linux/version.h" appears to come from linux-libc-dev:armhf 3.16.7-ckt25-2.  "/usr/src/linux-headers-4.1.17-ti-rt-r46/include/generated/uapi/linux/version.h" comes from linux-headers-4.1.17-ti-rt-r46.

What would be the proper way to update /usr/include/linux/version.h to reflect 4.1+?

OH yuck.. ;)

I've always thrown linux-libc-dev into the great /dev/null 

Since the version isn't appended in the final export:


So, maybe..

Step 1:

update deb-pkg to tie the "4.1.25-ti-r62" to via -$version here:


then just do a directory symlink like:

/usr/share/linux-libc-dev/4.1.25-ti-r62/ -> /usr/include/

(so we can easily install multiple linux-libc-dev)..

The only problem, when debian pushes a kernel update, it'll wipe out linux-libc-dev..

....

Personally i wish Adafruit_BBIO just had a "export BUILD=4.1.x+" override ;)

Regards,

--
Robert Nelson
https://rcn-ee.com/

Peter Lawler

unread,
May 29, 2016, 7:57:51 PM5/29/16
to Drew Fustini, beagl...@googlegroups.com, robert...@gmail.com


On 30/05/16 08:00, Robert Nelson wrote:
> On Sun, May 29, 2016 at 12:58 AM, Drew Fustini <pdp7...@gmail.com> wrote:
<snip>
>>
>> What would be the proper way to update /usr/include/linux/version.h to
>> reflect 4.1+?
>>
> OH yuck.. ;)
>
> I've always thrown linux-libc-dev into the great /dev/null
>
> Since the version isn't appended in the final export:
>
> https://packages.debian.org/jessie/armhf/linux-libc-dev/filelist
>
> So, maybe..
>
> Step 1:
>
> update deb-pkg to tie the "4.1.25-ti-r62" to via -$version here:
>
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/package/builddeb?id=refs/tags/v4.7-rc1#n100
>
> then just do a directory symlink like:
>
> /usr/share/linux-libc-dev/4.1.25-ti-r62/ -> /usr/include/
>
> (so we can easily install multiple linux-libc-dev)..
It would be super nice if LINUX_VERSION_CODE matched, you know, the
version that was running...

> The only problem, when debian pushes a kernel update, it'll wipe
> out linux-libc-dev..
Oh, right... yeah... ungh my brain hurts.

> ....
>
> Personally i wish Adafruit_BBIO just had a "export BUILD=4.1.x+" override ;)
Not a fan of overrides, but I think I can see the reasoning here. It's a
pity there's no better way. Well, maybe there is and that'd be to detect
at runtime instead. Which I was trying to avoid because seemed easier to
hack it up as I did.

Thanks for the chatter.

Cheers,

Pete.

Drew Fustini

unread,
May 30, 2016, 3:34:43 AM5/30/16
to BeagleBoard
Thanks Robert and Pete.

I made a change to setup.py to define BBBVERSION41 based on platform.release() which does reflect the correct kernel version.

I've opened a Pull Request against Pete's adafruit-beaglebone-io-python:
https://github.com/PeteLawler/adafruit-beaglebone-io-python/pull/1


Peter Lawler

unread,
May 30, 2016, 10:09:00 PM5/30/16
to beagl...@googlegroups.com
> <https://github.com/PeteLawler/adafruit-beaglebone-io-python>:
> https://github.com/PeteLawler/adafruit-beaglebone-io-python/pull/1
>
>

Makes sense to me.

Merged and edited a little (no, really, extra whitespace is one of those
things that make me twitch).

I hope to have a spare working BBB in the next day or so again (got a
new spare and I then discovered what fun noises can be made by putting
5V down AIN1....).

Cheers,

Pete.



Reply all
Reply to author
Forward
0 new messages