Adafruit BBIO Python library

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 :wink:

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

Regards,

Pete.

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

I haven’t used this feature, but a simple Google search gives what looks like the answer you are looking for:

http://stackoverflow.com/questions/16721346/linux-kernel-version-macro-definition

So in your case:

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

Regards,
John

OH yuck.. :wink:

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)..

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 :wink:

Regards,

<snip>

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

OH yuck.. :wink:

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 :wink:

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.

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

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.