Hello,
I’d like to control a motor through a CAN bus.
Configuration:
Colibri iMX6ULL 512MB Wi-Fi / Bluetooth (IT)
Viola Plus Carrier Board | V1.2B Plus
LinuxImageV2.8
I’m using pin 17 and 18 on the X9 connector of the Viola. According to the Colibri datasheet it respectively maps to pin 55 and 63 of its X1 connector.
I have seen in the documentation (can-linux) how to patch a dts file, there is no details for the iMX6ULL though (iMX6 documentation only).
This is the patch I’m using:
diff --git a/arch/arm/boot/dts/imx6ull-colibri-eval-v3.dtsi b/arch/arm/boot/dts/imx6ull-colibri-eval-v3.dtsi
index 75ba991..65561d4 100644
--- a/arch/arm/boot/dts/imx6ull-colibri-eval-v3.dtsi
+++ b/arch/arm/boot/dts/imx6ull-colibri-eval-v3.dtsi
@@ -102,12 +102,23 @@
status = "okay";
};
- spidev0: spidev@0 {
- compatible = "toradex,evalspi";
- reg = <0>;
- spi-max-frequency = <23000000>;
- status = "disabled";
- };
+ #if 0
+ spidev0: spidev@0 {
+ compatible = "toradex,evalspi";
+ reg = <0>;
+ spi-max-frequency = <23000000>;
+ status = "disabled";
+ };
+ #else
+ can0: can@1 {
+ compatible = "microchip,mcp2515";
+ reg = <0>;
+ clocks = <&clk16m>;
+ interrupt-parent = <&gpio3>;
+ interrupts = <27 0x2>;
+ spi-max-frequency = <10000000>;
+ };
+ #endif
};
&i2c1 {
diff --git a/arch/arm/boot/dts/imx6ull-colibri-wifi.dtsi b/arch/arm/boot/dts/imx6ull-colibri-wifi.dtsi
index 36a9dc1..b228d6f 100644
--- a/arch/arm/boot/dts/imx6ull-colibri-wifi.dtsi
+++ b/arch/arm/boot/dts/imx6ull-colibri-wifi.dtsi
@@ -22,9 +22,13 @@
};
};
+&flexcan1 {
+ status = "okay";
+};
+
&iomuxc {
pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_hog_1 &pinctrl_hog_2 &pinctrl_hog_3
+ pinctrl-0 = <&pinctrl_hog_1 &pinctrl_hog_3
&pinctrl_hog_4 &pinctrl_hog_5>;
};
I use &flexcan1 and not &can1 because it would not pass bitbake otherwise. Another helpful documentation page was can-colibri.
I have installed canutils and iproute2.
I did:
root@colibri-imx6ull:~# ip link set can0 up type can bitrate 500000 berr-reporting on
The result of:
root@colibri-imx6ull:~# zcat /proc/config.gz | grep CONFIG_CAN_MCP251X
CONFIG_CAN_MCP251X=m
Which looks fine if I look at:
root@colibri-imx6ull:~# lsmod
Module Size Used by
rfcomm 34153 2
bnep 11114 2
usb_f_rndis 15638 2
u_ether 12497 1 usb_f_rndis
mwifiex_sdio 27085 0
mwifiex 269330 1 mwifiex_sdio
btmrvl_sdio 16033 0
btmrvl 12942 1 btmrvl_sdio
bluetooth 332396 29 btmrvl_sdio,bnep,rfcomm,btmrvl
cfg80211 241241 1 mwifiex
compat 21291 7 mwifiex,btmrvl_sdio,bluetooth,bnep,rfcomm,mwifiex_sdio,cfg80211
flexcan 9440 0
mcp251x 10164 0
can_dev 12333 2 flexcan,mcp251x
libcomposite 44338 10 usb_f_rndis
configfs 30885 3 usb_f_rndis,libcomposite
Also:
root@colibri-imx6ull:~# ip -details link show can0
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
link/can promiscuity 0
can <BERR-REPORTING> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
bitrate 500000 sample-point 0.866
tq 133 prop-seg 6 phase-seg1 6 phase-seg2 2 sjw 1
flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1
clock 30000000numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
When it becomes interesting:
root@colibri-imx6ull:~# dmesg | fgrep -i mcp
[ 18.465207] mcp251x spi0.0: Cannot initialize MCP2515. Wrong wiring?
[ 18.552767] mcp251x spi0.0: Probe failed, err=19
Also:
root@colibri-imx6ull:~# dmesg | fgrep -i can
[ 0.173796] i2c i2c-0: can't use DMA, using PIO instead.
[ 0.175562] i2c i2c-1: can't use DMA, using PIO instead.
[ 1.330437] spi_master spi0: spi_device register error /soc/aips-bus@02000000/spba-bus@02000000/ecspi@02008000/can@1
[ 1.348337] spi_master spi0: Failed to create SPI device for /soc/aips-bus@02000000/spba-bus@02000000/ecspi@02008000/can@1
[ 4.438634] ubi0: scanning is finished
[ 18.324426] CAN device driver interface
[ 18.394998] 2090000.can supply xceiver not found, using dummy regulator
[ 18.465207] mcp251x spi0.0: Cannot initialize MCP2515. Wrong wiring?
[ 18.503948] flexcan 2090000.can: device registered (reg_base=a0bf0000, irq=23)
[ 5434.225234] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
To test I try to send:
root@colibri-imx6ull:~# cansend can0 1F#1122334455667788
interface = can0, family = 29, type = 3, proto = 1
root@colibri-imx6ull:~#
But at the same time on another window, I get nothing with:
root@colibri-imx6ull:~# candump
interface = can0, family = 29, type = 3, proto = 1
Thanks for reading through this