IMX6 CAN bus developers guide. Part 2.

Continuation of previous article describing IMX6 CAN bus support implementation.

We stopped at manual CAN interfaces configuration and sent test packet between two interfaces.

Now is time to automate interfaces configuration process at boot up. Also we want to implement separate OpenWrt config. Let’s call it flexcan_ethernet.

  1. Add new config name to target/linux/imx6ull/base-files/etc/board.d/02_network to the list of available configs:
flexcan_ethernet|\

same to target/linux/imx6ull/base-files/lib/imx6ull.sh :

“FlexCAN Ethernet”)
name=”flexcan_ethernet”;
;;
define Device/flexcan_ethernet
DEVICE_TITLE := FlexCAN Ethernet
DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-spi-dev
DEVICE_NAME := flexcan_ethernet
DEVICE_DTS := flexcan_ethernet
BOARDNAME := WIRELESSROAD_STREAM_IMX6ULL
SUPPORTED_DEVICES := wirelessroad_stream-imx6ull flexcan_ethernet
IMAGE_SIZE := 7m
IMAGE_SIZE_FACTORY := 8m
CONSOLE := ttymxc0,115200
KERNEL := kernel-bin | buildDtb | append-dtb | uImage none | imx6ull-bootscript
IMAGES := u-boot.bin sdcard.bin mtd-sysupgrade.bin mtd-factory.bin
IMAGE/u-boot.bin := imx6ull-ubootimg
IMAGE/sdcard.bin := imx6ull-sdcard | append-metadata
IMAGE/mtd-sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE)
IMAGE/mtd-factory.bin := append-kernel | append-rootfs | pad-rootfs | imx6ull-mtd-factory | append-metadata | check-size $$$$(IMAGE_SIZE_FACTORY)
endef
TARGET_DEVICES += flexcan_ethernet
2. Then create new flexcan_ethernet.dts file based on DTS changed at previous chapter. Make sure that CAN bus interfaces configured for sure.
Don’t forget to change model name:
model = “FlexCAN Ethernet”;
3. Create new flexcan_ethernet.config file based on root ./.config file that was created during image build process and changed by make menuconfig CAN bus enablind at previous chapter.
Later (when you will test everything and get closer to release new config and merge it to your master branch) you may disable unused packets gotten from DTS used as starting point at previous chapter.
4. And the last one create 99_can_network boot script that will initiate both CAN networks on kernel loads:

#!/bin/sh

. /lib/functions/uci-defaults.shboard=$(board_name)board_config_update

case $board in
flexcan_ethernet)
ip link set can0 down
ip link set can0 up type can bitrate 500000
ip link set can1 down
ip link set can1 up type can bitrate 500000
;;
esac

board_config_flush

exit 1

Now rebuild and reflash image again. This time both CAN bus interface should become initialized automatically by script.
Here and here – commits with CAN bus support implementation.
Keep following as here at our telegram channel.