The --resino option is enabling the resin related services and adding the supervisor docker/balena container to the device. The resin config. inject adds the required config.json file that lets the VPN and the supervisor to talk to the resin backend. Those two are indeed important have any device properly function with the resin cloud side.
Please be mindful, that your custom build of resinOS won’t be updatable to another custom build automatically through the dashboard for example.
May we ask why are you building a custom image? Would the change that you require something that would be generally applicable for others with the same device type as well?
Custom ResinOS is not applicable on Dashboard/resin.io. See Custom ResinOS and OS update for a solution to create kernel modules which can be added to any docker image and hereby load the modules.
In the thread you are mentioning above, there is a solution using the kernel headers package we provide to be able to compile kernel modules. Have you tried that?
I have got a working solution where I am able to compile the kernel modules slcan dev-can and vcan for ResinOS Resin OS 2.13.1+rev1.dev.
For now I can load the modules and create a can device via the can-utils command slcand, but I have not managed to test it fully yet, but it looks promising.
One headache is to keep track of kernel version per resinos base image, since a new kernel in a resinos image needs to trigger rebuild of kernel module and repack this with all released software version in order for these to run on the new resinOS.
It should be noted that i use insmod for now as modprobe and read-only /lib/modules is working against custom kernel modules for now.
sed -i 's/# CONFIG_CAN is not set/CONFIG_CAN=m\nCONFIG_CAN_RAW=m\nCONFIG_CAN_BCM=m\nCONFIG_CAN_GW=m\n\n#\n# CAN Device Drivers\n#\nCONFIG_CAN_VCAN=m\n# CONFIG_CAN_VXCAN is not set\nCONFIG_CAN_SLCAN=m\nCONFIG_CAN_DEV=m\n# CONFIG_CAN_CALC_BITTIMING is not set\n# CONFIG_CAN_LEDS is not set\n# CONFIG_CAN_C_CAN is not set\n# CONFIG_CAN_CC770 is not set\n# CONFIG_CAN_IFI_CANFD is not set\n# CONFIG_CAN_M_CAN is not set\n# CONFIG_CAN_PEAK_PCIEFD is not set\n# CONFIG_CAN_SJA1000 is not set\n# CONFIG_CAN_SOFTING is not set\n\n#\n# CAN USB interfaces\n#\n# CONFIG_CAN_EMS_USB is not set\n# CONFIG_CAN_ESD_USB2 is not set\n# CONFIG_CAN_GS_USB is not set\n# CONFIG_CAN_KVASER_USB is not set\n# CONFIG_CAN_PEAK_USB is not set\n# CONFIG_CAN_8DEV_USB is not set\n# CONFIG_CAN_MCBA_USB is not set\n# CONFIG_CAN_DEBUG_DEVICES is not set/g' .config
For full detail on kernel config setup and compile, see the below dockerfile
From what I know right now, the CONFIG_CAN, CONFIG_CAN_RAW, CONFIG_CAN_DEV and CONFIG_SLCAN is needed in order to allow the slcand from can-utils to setup a CAN communication device.
The three following code snippets can be used to compile a test application which compiles the kernel modules and pack them into the application image.
Dockerfile
#Default ARG values to be used in continous integration.
#These can be overwritten by --build-arg when using docker build
ARG PARENT_VERSION=stretch
ARG PARENT_LOCATION=resin/
ARG IMAGE_NAME=intel-nuc-debian
####################
# kernel module builder container
####################
FROM resin/intel-nuc-buildpack-deps:stretch AS kernelbuilder
RUN apt-get update && apt-get install -y --no-install-recommends \
bc \
&& rm -rf /var/lib/apt/lists/*
ENV KERNEL_MAJOR_VERSION=v4.x \
KERNEL_VERSION=4.12.12 \
RESIN_OS_VERSION=2.13.1%2Brev1.dev
# tutorial from here: https://wiki.archlinux.org/index.php/Compile_kernel_module
# ideas from here: https://github.com/resin-io-playground/kernel-module-build
RUN cd /usr/src \
&& wget https://mirrors.edge.kernel.org/pub/linux/kernel/${KERNEL_MAJOR_VERSION}/linux-${KERNEL_VERSION}.tar.gz \
&& tar xzf linux-${KERNEL_VERSION}.tar.gz \
&& wget https://files.resin.io/images/intel-nuc/${RESIN_OS_VERSION}/kernel_modules_headers.tar.gz \
&& tar xzf kernel_modules_headers.tar.gz
RUN cd /usr/src \
&& cd linux-${KERNEL_VERSION} \
&& cp ../kernel_modules_headers/.config ../kernel_modules_headers/Module.symvers . \
&& sed -i 's/# CONFIG_CAN is not set/CONFIG_CAN=m\nCONFIG_CAN_RAW=m\nCONFIG_CAN_BCM=m\nCONFIG_CAN_GW=m\n\n#\n# CAN Device Drivers\n#\nCONFIG_CAN_VCAN=m\n# CONFIG_CAN_VXCAN is not set\nCONFIG_CAN_SLCAN=m\nCONFIG_CAN_DEV=m\n# CONFIG_CAN_CALC_BITTIMING is not set\n# CONFIG_CAN_LEDS is not set\n# CONFIG_CAN_C_CAN is not set\n# CONFIG_CAN_CC770 is not set\n# CONFIG_CAN_IFI_CANFD is not set\n# CONFIG_CAN_M_CAN is not set\n# CONFIG_CAN_PEAK_PCIEFD is not set\n# CONFIG_CAN_SJA1000 is not set\n# CONFIG_CAN_SOFTING is not set\n\n#\n# CAN USB interfaces\n#\n# CONFIG_CAN_EMS_USB is not set\n# CONFIG_CAN_ESD_USB2 is not set\n# CONFIG_CAN_GS_USB is not set\n# CONFIG_CAN_KVASER_USB is not set\n# CONFIG_CAN_PEAK_USB is not set\n# CONFIG_CAN_8DEV_USB is not set\n# CONFIG_CAN_MCBA_USB is not set\n# CONFIG_CAN_DEBUG_DEVICES is not set/g' .config \
&& sed -i 's/# CONFIG_NET_DEVLINK is not set/CONFIG_NET_DEVLINK=m/g' .config \
&& sed -i 's/CONFIG_MAY_USE_DEVLINK=y/CONFIG_MAY_USE_DEVLINK=m/g' .config \
&& sed -i 's/# CONFIG_NETLINK_DIAG is not set/CONFIG_NETLINK_DIAG=m/g' .config \
&& make modules_prepare \
&& make M=net/core \
&& make M=net/core modules_install \
&& make M=net/netlink \
&& make M=net/netlink modules_install \
&& make M=net/can \
&& make M=net/can modules_install \
&& make M=drivers/net/can \
&& make M=drivers/net/can modules_install
####################
# application container
####################
ARG PARENT_VERSION
ARG PARENT_LOCATION
ARG IMAGE_NAME
FROM ${PARENT_LOCATION}${IMAGE_NAME}:${PARENT_VERSION}
#Load the default ARG or the overwritten ARG values from --build-arg
ARG PARENT_VERSION
ARG PARENT_LOCATION
ARG IMAGE_NAME
ENV CONTAINER_CHAIN="${PARENT_LOCATION}${IMAGE_NAME}:${PARENT_VERSION} ${CONTAINER_CHAIN}"
ENV KERNEL_VERSION_FULL=4.12.12-yocto-standard
#Container content from this point
USER root
## Install can-utils
RUN apt-get update && apt-get install -y \
can-utils \
xorg \
mesa-utils && \
apt-get clean && rm -rf /var/lib/apt/lists/*
## Copy kernel modules into the container
RUN mkdir -p /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/
COPY --from=kernelbuilder /lib/modules/${KERNEL_VERSION_FULL}/extra/devlink.ko /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/devlink.ko
COPY --from=kernelbuilder /lib/modules/${KERNEL_VERSION_FULL}/extra/can.ko /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/can.ko
COPY --from=kernelbuilder /lib/modules/${KERNEL_VERSION_FULL}/extra/can-raw.ko /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/can-raw.ko
COPY --from=kernelbuilder /lib/modules/${KERNEL_VERSION_FULL}/extra/can-gw.ko /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/can-gw.ko
COPY --from=kernelbuilder /lib/modules/${KERNEL_VERSION_FULL}/extra/can-bcm.ko /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/can-bcm.ko
COPY --from=kernelbuilder /lib/modules/${KERNEL_VERSION_FULL}/extra/vcan.ko /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/vcan.ko
COPY --from=kernelbuilder /lib/modules/${KERNEL_VERSION_FULL}/extra/slcan.ko /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/slcan.ko
COPY --from=kernelbuilder /lib/modules/${KERNEL_VERSION_FULL}/extra/can-dev.ko /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/can-dev.ko
COPY --from=kernelbuilder /lib/modules/${KERNEL_VERSION_FULL}/extra/netlink_diag.ko /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/netlink_diag.ko
RUN mkdir /opt/ros-app/
RUN chmod 755 /opt/ros-app/
# Setup default user to ensure that software is not build as root
#User id must match host user or docker must be started with user tag
RUN groupadd -g 1001 builduser && \
echo 'notsecure\nnotsecure' | adduser --home /home/builduser --uid 1001 --gid 1001 builduser && \
usermod -aG sudo builduser && \
usermod -aG video builduser
#Setup data folder
RUN mkdir /data && \
chown builduser:builduser /data
RUN usermod -aG dialout builduser
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
#CMD [ "/bin/bash" ]