Enable CAN drivers in Mendel Linux

Viewed 46

We need to use CAN devices with a Coral Dev Board. We have found that the Mendel image available for download does not have the drivers enabled.

We followed the instructions to download the kernel source files here: https://coral.googlesource.com/docs/+/refs/heads/master/GettingStarted.md

We found that the CAN driver source files, Makefiles, and Kconfig files are present in the kernel source, for example source files:

linux-imx/drivers/net/can/usb/gs_usb.c
linux-imx/drivers/net/can/spi/mcp251x.c
linux-imx/include/linux/can/platform/mcp251x.h

And the Makefile for gs_usb.c:

# SPDX-License-Identifier: GPL-2.0
#
#  Makefile for the Linux Controller Area Network USB drivers.
#

obj-$(CONFIG_CAN_EMS_USB) += ems_usb.o
obj-$(CONFIG_CAN_ESD_USB2) += esd_usb2.o
obj-$(CONFIG_CAN_GS_USB) += gs_usb.o
obj-$(CONFIG_CAN_KVASER_USB) += kvaser_usb.o
obj-$(CONFIG_CAN_PEAK_USB) += peak_usb/
obj-$(CONFIG_CAN_8DEV_USB) += usb_8dev.o
obj-$(CONFIG_CAN_MCBA_USB) += mcba_usb.o

Looking through the Makefiles and Kconfig files, everything seemed to be in order with a possible exception of one line in the file:

linux-imx/drivers/net/Kconfig

We added:

source "drivers/net/can/Kconfig"

We have also tried adding the following enable flags to the defconfig files:

CONFIG_CAN=y
CONFIG_CAN_RAW=y
CONFIG_CAN_BCM=y
CONFIG_CAN_DEV=y
CONFIG_CAN_AT91=m
CONFIG_CAN_RCAR=m
CONFIG_CAN_XILINXCAN=y
CONFIG_CAN_MCP251X=y
CONFIG_CAN_GS_USB=y

So far without success, the CAN drivers are not being compiled and installed in the image, and are not on the board after we flash it. If anyone has any suggestions, we are all ears.

1 Answers

For anyone interested, I solved it as follows:

  1. enable can in packages/linux-imx/debian/defconfig

    CONFIG_CAN=m CONFIG_CAN_RAW=m CONFIG_CAN_DEV=m CONFIG_CAN_BCM=m CONFIG_CAN_GW=m CONFIG_PROC_FS=m

  2. enable usb and spi can in linux-imx/arch/arm64/configs/defconfig

    CONFIG_CAN_GS_USB=m CONFIG_CAN_MCP251X=m

  3. add the following line to linux-imx/drivers/net/Kconfig

    source "drivers/net/can/Kconfig"

  4. follow instructions to set up the repo and prepare to check out the repository: https://coral.googlesource.com/docs/+/refs/heads/master/GettingStarted.md

  5. create a working directory to hold the source code.

  6. cd into working directory

  7. pull the repo and make changes to the files listed in 1, 2, and 3.

    repo init -u https://coral.googlesource.com/manifest repo sync -j$(nproc)

  8. source the build files

    source build/setup.sh

  9. compile the code

    m

  10. connect the board

  11. change to the output directory

    j product

  12. update the kernel

    mdt install linux-image-4.14.98-imx_12–4_arm64.deb

  13. reboot the board

Related