Exercise Bike Upgrades: Compiler Version Matters

I recently upgraded my home desktop with a fancy new SSD. With that came all the advantages of being able to clean house, and start with the latest LTS Ubuntu (20.04).

After upgrading, I decided to (read: was suggested repeatedly to…) start the next steps of getting the tilt sensor to work. Before getting into those details, I had to re-trace my steps. Fortunately I pretty much had everything I needed.

However… when I tried to build the kernel before building a new module, I got several errors:

Well that isn’t good. What gives?

Turns out Ubuntu 20.04 uses a newer version of GCC. Specifically right now, it runs 9.3.0.

My old HD ran Ubuntu 18.04, and that ran GCC 7.5.0. Seemingly there was an update in there that broke compatibility with old kernels.

I’d somewhat expected this – Seemingly I got lucky the first go around. The next options are to:

  1. Install a VM for compiling. Not something I want to do since I’m getting more and more against VMs in lieu of Docker.
  2. Compile natively on the Beaglebone. This one seems like a step backward at this point.
  3. Install an older version of GCC. Probably doable, but more trouble than it’s worth.
  4. Create a Docker image to do build. This one feels like the right thing to do.

Well, I’d opted for #4, but didn’t get too far. Someone else has already done the work for me. He is giving credit to the Raspberry Pi community for getting most of it off the ground, but I’m sending my gratitude.

So the instructions there are pretty clear. Just run the bbbxc script before the make call. I can also just run the command arm-linux-gnueabihf-gcc –version and see that the image is running GCC 4.9.2. That also matches which compiler was used for the beaglebone kernel itself. Cool!

And that’s it for this one. Just run the command “./bbbxc make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-” and the kernel builds without warnings.

A couple things to note: The container uses the hard-float compiler. From my brief research, it seems like the BBB has the hard floating point architecture. So hopefully I’m good there.

The other thing that I need to figure out: The KDIR argument to a module build. Currently the bbbxc script seems to mount everything from my current working directory down, but that might not be the case. I tried soft linking in the kernel directory, but that didn’t work. Only a full copy of the kernel directory made things work.

I suspect that’ll be an easy fix once I find it. I haven’t spent any time yet in this quest though.

The next step will be to implement a driver for the tilt (power) sensor. Hopefully that’ll come up really soon!