Installing device driver for TI battery monitor - bq76pl536a

Dear all,

I want to install the device driver for a TI battery monitor - BQ76PL536A. The role of a battery monitor is to measure batteries voltage and do few other things.

The code is hosted here : https://github.com/tommessick/bq76pl536 . It has Makefile and some instructions. The author also says he has tested it one Beaglebone black, but with Ubuntu.

I am using debian: uname -a
Linux beaglebone 4.4.9-ti-r25 #1 SMP Thu May 5 23:08:13 UTC 2016 armv7l GNU/Linux

Will this device driver work with Ubuntu only ? If yes, what should I do to install the driver ?

I have tried running the Makefile as is, also tried giving “KERNELDIR” = /usr/src/linux-headers-4.4.9-ti-r25 , which is the location of the current kernel headers, and I have tried using gcc to compile, all without success, on my current setup, on the BBB.

Seems like there is some mention of cross-compilation, which means I need to do this on linux PC, (with Ubuntu). Does this require a cross-compilation setup compulsorily ?

While the author attempted to cross-compile on an Ubuntu toolchain, I tried to install it directly on by BBB running Debian.

So I installed the kernel headers:

`

sudo apt-get install linux-headers-4.4.9-ti-r25

`

The author’s Makefile

`

DRIVER = bq76pl536

ifneq ($(KERNELRELEASE),)
    obj-m += $(DRIVER).o
else
    PWD := $(shell pwd)

default:
ifeq ($(strip $(KERNELDIR)),)
    $(error "KERNELDIR is undefined!")
else
    $(MAKE) -C $(KERNELDIR)  M=$(PWD) modules
endif

`

requires a variable called KERNELDIR which I defined as:

`
KERNELDIR=/lib/modules/4.4.9-ti-r25/build/

`

The output of make command is as under:

`

make
make -C /lib/modules/4.4.9-ti-r25/build/      M=/var/lib/cloud9/bq76_driver/bq76pl536 modules
make[1]: Entering directory '/usr/src/linux-headers-4.4.9-ti-r25'
  Building modules, stage 2.
  MODPOST 1 modules
WARNING: "crc8_populate_msb"   [/var/lib/cloud9/bq76_driver/bq76pl536/bq76pl536.ko] undefined!
WARNING: "crc8" [/var/lib/cloud9/bq76_driver/bq76pl536/bq76pl536.ko] undefined!
make[1]: Leaving directory '/usr/src/linux-headers-4.4.9-ti-r25'

`

While the .o, .ko etc. files are created. When I try to load the module using insmod I get an error:

`

sudo insmod ./bq76pl536.ko 
insmod: ERROR: could not insert module ./bq76pl536.ko: Unknown symbol in module

`

My dmesg output is as under:

`

dmesg | tail
[   21.564768] eqep 48304180.eqep: failed to get clock
[   21.605265] c_can_platform 481cc000.can: c_can_platform device registered (regs=fa1cc000, irq=207)
[   21.661309] c_can_platform 481d0000.can: c_can_platform device registered (regs=fa1d0000, irq=208)
[   21.768584] eqep: probe of 48304180.eqep failed with error -2
[161381.366409] bq76pl536: Unknown symbol crc8 (err 0)
[161381.366768] bq76pl536: Unknown symbol crc8_populate_msb (err 0)
[162501.175612] bq76pl536: Unknown symbol crc8 (err 0)
[162501.175973] bq76pl536: Unknown symbol crc8_populate_msb (err 0)

`

I cannot understand the origin of this error - compiler not being able to find functions: crc8 and crc8_populate_msb, when they are defined in crc8.h, which is accessible in the headers: /linux/crc8.h