Compiling a main tree kernel module using the kernel module build example

Hi @rlev -

I found the Makefile in some random corner of the web… it does show that I can redistribute it as long as I keep the copyright info, so I feel OK about sharing it. I can’t remember where I found it though.

I would post the complete bundle up on my GitHub, but I am unsure of the legality of redistributing the firmware files. You can get them from here - https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/rsi

If you’re interested in what the whole thing looked like, here’s what I believe is the final working code. I was not able to use Balena in the end of this project because of the kernel needing GPIO, (which has been included now!). I was only working on this for a short term contract project between jobs.

  1. Taking the kernel-module-build example, add these directories: rsi/, mac80211/, firmware/.
  2. Copy the contents of the RSI kernel source into rsi/, replacing the Makefile with this one Makefile.log (4.4 KB) (renamed with a .log to get around the forum file filter).
  3. Copy the compiled mac80211.ko file from the existing kernel into a directory inside the container so that I could initialize it from this run script. There is probably a better way.
  4. Copy the RPS files to firmware/.
  5. Use the following Docker template and run script.

Dockerfile.template:

FROM balenalib/%%RESIN_MACHINE_NAME%%-debian

RUN apt-get update && apt-get install -y curl wget build-essential libelf-dev awscli bc flex libssl-dev python bison
COPY . /usr/src/app
WORKDIR /usr/src/app

ENV VERSION '2.36.0+rev2.prod'
RUN ./build.sh %%RESIN_MACHINE_NAME%% $VERSION rsi

CMD ./run.sh

run.sh:

#!/bin/bash
OS_VERSION=$(echo $RESIN_HOST_OS_VERSION | cut -d " " -f 2)
echo "OS Version is $OS_VERSION"

mkdir -p /lib/firmware/rsi
cp firmware/* /lib/firmware/rsi/

insmod mac80211/mac80211.ko

mod_dir="rsi_${RESIN_DEVICE_TYPE}_${OS_VERSION}*"
insmod $mod_dir/rsi_91x.ko
insmod $mod_dir/rsi_sdio.ko
lsmod | grep rsi

while true; do
  sleep 60
done

Hope this is of value to you!