Raspberry Pi 3 Custom driver RS485

Hi There,

Can somebody point me in the right direction about how to add a custom driver?

I have a special rs485 uart driver for Raspberry Pi 3, compiled for the kernel version that’s in the Resin OS now.

Should i copy the .ko file to /lib/modules, and then add a modprobe command to the dockerfile to load this driver?
Right now, i cant get it to work just yet, i’m not sure about best practice though…

Thanks

It was easier then i thought.
I managed to get things working by following the setup as described in https://github.com/resin-io-playground/kernel-module-build.

Hi there,

I came across your post by looking for resources to use RS485 on a Raspberry 3 board, so I was interested to know which RS485 driver you are actually using here?

Thanks.

i’m using the MAX3140, with this driver: https://github.com/amescon/raspicomm-module
Right now, im using the Amescon module RaspiCom all together, but we are planning to only use the MAX3140.

@salorob We have also used the raspicomm module on some old rpi1 devices on wheezy 3.12 kernel, but I noticed that some users were reporting compilation issues with newer kernels: https://github.com/amescon/raspicomm-module/issues/9

It’s nice to see that you’re able to compile it with resinos.
Would you like to share your code to compile the raspicomm module on the resinos platform?

@bbinet sure, i have this docker file:

i’m installing mono, but you don’t have to off course… :slight_smile:

FROM resin/raspberrypi3-debian:stretch

RUN apt-get update && apt-get install -y curl wget build-essential mono-complete mono-vbnc libunwind8 gettext && rm -rf /var/lib/apt/lists/*

ADD . /app
WORKDIR /app
RUN ./build.sh raspberrypi3 '2.2.0+rev1.prod' mod_rs485
CMD ./run.sh 'mod_rs485_raspberrypi3_2.2.0+rev1.prod'

Then, i’m using the build.sh thats used here: https://github.com/resin-io-playground/kernel-module-build
And my run.sh looks like this:

#!/bin/bash

MODULE="raspicommrs485"

if lsmod | grep "$MODULE" &> /dev/null ; then
    echo "$MODULE is loaded!"
  else
    echo "Loading $MODULE driver"
    insmod $1/$MODULE.ko
fi

start_app_here

Its important to use this resin image, 2.2.0 as i use some static references. (should be dynamic, but i’m not that good just yet ;-)…)

This ‘just worked’…

Thanks, this is useful information for me.

And you don’t have any special patch applied on https://github.com/amescon/raspicomm-module source code: it compile without error out of the box?

Nope, just like that.

I did use a slightly different makefile:

obj-m += raspicommrs485.o

raspicommrs485-objs := module.o queue.o

all:
	$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean