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:

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

«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
SUPPORTED_DEVICES := wirelessroad_stream-imx6ull flexcan_ethernet
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)
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:


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

case «$board« in
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


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.