Application name for custom ResinOS and Dashboard

Use case:

I have managed to yocto build Intel-NUC by use of https://github.com/resin-os/resin-intel

The image has been installed on target, but cannot see it on the dashboard.

Question:

How is it possible to allow the Dashboard to recognize devices using a custom ResinOS?

Should the custom ResinOS be build with some application name/tag, and how?

I have found the --resinio option on https://resinos.io/docs/custombuild/.

Waiting for build to finish before I know more.

Found https://github.com/resin-io/resin-cli/issues/784

An applications config must be exported from dashboard injected into image:

Example:

resin config inject --type beaglebone-black --drive Downloads/resin-BBBB-2.7.5+rev2-v6.3.6.img Downloads/BBBB.config.json

By doing the above then the Dashboard will discover the device running the custom build ResinOS

1 Like

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?

CONFIG_CAN kernel parameter is missing from the resin provided Intel-NUC image.

I am trying to get CAN bus to work on a resin device. And fighting a little with yocto.

And it sounds like uphill as a custom resinOS image can not be updated automatically from the dashboard.

Can a custom resinOS image be updated manually?

This is related to Custom ResinOS and OS update

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.

Hello,

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?

Regards,
Andrei

Yes.

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.

Update:

See Custom ResinOS and OS update

Hi,
can you list the modules you need to be added?
If you can send the kernel configs, it would be even better.

The kernel config is based on https://files.resin.io/images/intel-nuc/2.13.1%2Brev1.dev/kernel_modules_headers.tar.gz with the following changes:

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" ]
Entrypoint
#!/bin/bash

#insmod /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/can.ko
#insmod /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/can-raw.ko
#insmod /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/can-gw.ko
#insmod /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/can-dev.ko
#insmod /root/extra_kernel_modules/${KERNEL_VERSION_FULL}/extra/slcan.ko

exec /bin/bash
Dockercompose
version: '2.1'

networks: {}

volumes:
  resin-data: {}  

services:

  main-test:
    build: .
    privileged: true
    restart: always
    network_mode: host
    devices:
      - '/dev/ttyUSB0:/dev/ttyUSB0'
    volumes:
      - 'resin-data:/data'
    environment:
      - whee=1
    labels:
      io.resin.features.kernel-modules: '1'
      io.resin.features.firmware: '1'
      io.resin.features.dbus: '1'
      io.resin.features.supervisor-api: '1'
      io.resin.features.resin-api: '1'
      io.resin.update.strategy: download-then-kill
      io.resin.update.handover-timeout: ''
1 Like

Hi,

The modules have been added in this PR (https://github.com/resin-os/resin-intel/pull/1340) , you can subscribe to notifications so you can see live updates of the progress.

See Custom ResinOS and OS update to gain full understading of custom kernel modules.