Error while building out-of-tree kernel modules

Hi,

I was trying to add GPIO drivers into kernel. i’m using “Variscite DART-6UL” board and the OS version is “BalenaOS 2.98.33+rev1” - Development variant.
I have followed the example of building out-of-tree kernel module (GitHub - balena-os/kernel-module-build: Example project for building an OOT kernel module in balena) and it worked fine. I could insert the hello.ko files into the
kernel. But when i try to add my own source code by following the same folder structure as example module, it’s giving me an error saying “/bin/sh: 1: ./build.sh: Permission denied”
I have my source files in a git repository and my docker_template is as below.

FROM ubuntu:jammy-20220531 as kernel-build

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/UTC

RUN apt-get update &&
apt-get install -y
awscli
bc
bison
build-essential
curl
flex
git
libelf-dev
libssl-dev
wget

WORKDIR /usr/src/app

Clones the kernel builder repository

RUN git clone https://github.com/xxxxx/kernel-module-build.git .

RUN apt-get -y update
RUN apt-get -y install vim nano
RUN apt-get -y install kmod

You can switch to a specific commit of the kernel builder if you want to ensure consistent builds

git reset --hard f889851c5d00890b51b27c63eaa59a976063265a

Copy your kernel source from your local build context to the build directory

COPY example_module .

Set the name of the directory where you have copied your kernel source in the step above

ENV MOD_DIR “example_module”

Set the balena OS version you intend to use

ENV OS_VERSION ‘2.98.33’

Start the build

RUN BALENA_MACHINE_NAME=%%BALENA_MACHINE_NAME%% ./build.sh build --device imx6ul-var-dart --os-version ‘2.98.33+rev1’ --src example_module

Please let me know anything else that is needed and I appreciate the assistance.

Hi,

I would suspect you will need to add a command to change the permissions for the file you are trying to execute. You could add RUN: chmod +x build.sh.

It would be helpful if you were able to provide your full Dockerfile, and wrapped in code quotes to make it easier to understand: Basic writing and formatting syntax - GitHub Docs

Hi maggie0002,

Thanks for your reply. Yes, it was file permission issue. I’ve missed adding permissions to the .sh scripts. Now it’s working alright and i’ve built my source code. Thanks for the support.

When building out of tree kernel modules, it is possible to encounter errors to different reasons. without specific error details it is challenging to provide a precise solution. Some common issues and troubleshooting steps which can help to resolve the problem.