This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM3359: CAN configuration on ICEv2

Part Number: AM3359
Other Parts Discussed in Thread: PROFIBUS, , ISO1050

Tool/software: Linux

Hello,

I am trying to set up the CAN bus can0 on my AM3359 Ice V2 but I can't send or write a message. I send a CAN message with PCAN-View app through the profibus/can port (J9) and try to read it on the board and inversely.
I have no SPI1, UART0, I2C2, or PWM device connected (on the device tree). My device tree is the following (parts concerning can0):

&am33xx_pinmux {

[...]

dcan0_pins_default: dcan0_pins_default {

pinctrl-single,pins = <

0x174 ( PIN_INPUT | MUX_MODE2 ) /* (E16) uart0_txd.dcan0_rx */

0x170 ( PIN_OUTPUT | MUX_MODE2 ) /* (E15) uart0_rxd.dcan0_tx */

>;

};

[...]

};

&dcan0 {

status = "okay";

pinctrl-names = "default";

pinctrl-o = <&dcan0_pins_default>;

};

I put the jumpers on J6 and on pin 2 and 3 of J8 (but alternatively I also tried to add one on J7 as it seems that, following the datasheet, the gndprofi signal is used by the CAN bus).

To set up the can0 I used the following commands on the target:

ip link set can0 type can bitrate 50000 triple-sampling on            (50 KHz set on PCan view)

ip link set can0 up

Then I use the following commands to write and read:

cansend can0 5A1#11.22.33.44.55.66.77.88

candump can0

When I try to read the signal that comes from PCan-view, I can see the signal on the Rx pin of the ISO1050 CAN transceiver on the board but when I write a message from the am3359, I can't find it on the Tx pin.

Do you have any idea of what I do wrong?

Best regards

Vincent

  • Hi,

    Do you provide the external CAN voltage on pin 9 of J9?
  • I use an adapter USB to CAN very similar to this one: www.peak-system.com/PCAN-USB.199.0.html

    And when I measure the voltage between GND2 and VCC2 of ISO1050 I have 5V. I have similarly 3.3V and the other side. However, I have this voltage even if my adapter is not connected. By measuring the voltage between pin 3 (can gnd) and 9 (VCAN) of my adapter, it seems that there is no voltage.
  • The cansend command looks strange the way you have posted it. Can you try as shown here: processors.wiki.ti.com/.../Linux_Core_DCAN_User's_Guide
  • I checked the datsheet and it is written that I need to solder different pins in my adapter to have the 5V, otherwise there is no power supply. The 5 V is mandatory to work with the can0?
  • When I use the command: cansend can0 -i 0x10 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88

    I have the answer:
    Usage: cansend <device> <can_frame>.

    As if the command was wrong
  • Hi,

    Could you run the lsmod command and attach the results? Also please perform ifconfig -a and attach the results to that too please. The strapping you posted looks correct as well as the device tree entries.

    Best Regards,
    Schuyler
  • The result to lsmod is:
    ~# lsmod
    Module                  Size  Used by
    pvrsrvkm              403455  0
    pru_rproc              10682  0
    pruss_intc              7249  1 pru_rproc
    pruss                   9725  1 pru_rproc
    sha512_generic          9967  0
    sha512_arm             12252  0
    ti_am335x_adc           6864  0
    sha256_generic         10178  0
    sha1_generic            2864  0
    sha1_arm_neon           6261  0
    sha1_arm                3862  1 sha1_arm_neon
    md5                     2219  0
    des_generic            17608  0
    cbc                     2388  0
    g_multi                 6145  0
    usb_f_mass_storage     36886  1 g_multi
    usb_f_rndis            15603  1 g_multi
    u_ether                12467  2 g_multi,usb_f_rndis
    libcomposite           44507  3 usb_f_mass_storage,g_multi,usb_f_rndis
    udc_core               19466  4 usb_f_mass_storage,u_ether,usb_f_rndis,libcomposite
    usb_common              4737  2 udc_core,libcomposite
    xfrm_user              22147  2
    xfrm4_tunnel            2040  0
    ipcomp                  2257  0
    xfrm_ipcomp             4225  1 ipcomp
    esp4                    6363  0
    ah4                     5627  0
    af_key                 26992  0
    xfrm_algo               6970  5 xfrm_user,esp4,ah4,af_key,xfrm_ipcomp
    bluetooth             338029  2
    pm33xx                  4348  0
    wkup_m3_ipc             8141  1 pm33xx
    wkup_m3_rproc           3670  1
    remoteproc             28840  3 pru_rproc,wkup_m3_rproc,wkup_m3_ipc
    omap_aes_driver        19021  0
    omap_sham              21671  0
    ti_emif_sram            5406  1 pm33xx
    pruss_soc_bus           3649  0
    crypto_engine           6466  1 omap_aes_driver
    c_can_platform          6638  0
    c_can                   9578  1 c_can_platform
    can_dev                13125  1 c_can
    gpio_pisosr             2972  0
    gpio_pca953x           11032  4
    gpio_tpic2810           2639  0
    ti_am335x_tscadc        5853  1 ti_am335x_adc
    rtc_omap                9341  1
    omap_wdt                4719  0
    gpio_decoder            2387  0
    input_polldev           4488  1 gpio_decoder
    sch_fq_codel            9039  3
    uio_module_drv          7349  0
    uio                     9158  1 uio_module_drv
    cryptodev              38385  1
    
    
    

    And the result to ifconfig -a:

    ~# ifconfig -a
    can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
              UP RUNNING NOARP  MTU:16  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:10
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
              Interrupt:162
    
    eth0      Link encap:Ethernet  HWaddr 68:C9:0B:E4:53:A1
              inet addr:192.168.1.59  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::6ac9:bff:fee4:53a1%763860/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:385 errors:0 dropped:40 overruns:0 frame:0
              TX packets:58 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:33273 (32.4 KiB)  TX bytes:9286 (9.0 KiB)
              Interrupt:173
    
    eth1      Link encap:Ethernet  HWaddr 68:C9:0B:E4:53:A3
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
    lo        Link encap:Local Loopback
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1%763860/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:1606 errors:0 dropped:0 overruns:0 frame:0
              TX packets:1606 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1
              RX bytes:122128 (119.2 KiB)  TX bytes:122128 (119.2 KiB)
    
    sit0      Link encap:IPv6-in-IPv4
              NOARP  MTU:1480  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    

  • Hi,

    It doesn't look like the interface and drivers are being completely setup, this could be due to a couple of things.
    The lsmod command was this before performing the cansend call? If not could you please run the cansend call and then the lsmod and please attach the results of that. Also after performing the commands please run this command: ip -d -s linux show can0 and attach the results of that. I am looking for what the state of the link is.

    Best Regards,
    Schuyler
  • Hello,

    Thank you for the answer.
    The lsmod command was done after the ip link set can0 up command but before a cansend call.
    Here is what I obtain after cansend for lsmod:

    root@am335x-evm:~# ip link set can0 type can bitrate 50000 triple-sampling on
    root@am335x-evm:~# ip link set can0 up
    [  195.615814] c_can_platform 481cc000.can can0: setting BTR=1c1d BRPE=0000
    root@am335x-evm:~# cansend can0 -i 0x10 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
    Usage: cansend <device> <can_frame>.
    root@am335x-evm:~# cansend can0 5A1#11.22.33.44.55.66.77.88
    [  220.670455] can: controller area network core (rev 20120528 abi 9)
    [  220.676851] NET: Registered protocol family 29
    [  220.708626] can: raw protocol (rev 20120528)
    root@am335x-evm:~# lsmod
    Module                  Size  Used by
    can_raw                 6743  1
    can                    29582  1 can_raw
    pvrsrvkm              403455  0
    pru_rproc              10682  0
    pruss_intc              7249  1 pru_rproc
    pruss                   9725  1 pru_rproc
    sha512_generic          9967  0
    sha512_arm             12252  0
    sha256_generic         10178  0
    sha1_generic            2864  0
    sha1_arm_neon           6261  0
    sha1_arm                3862  1 sha1_arm_neon
    md5                     2219  0
    des_generic            17608  0
    cbc                     2388  0
    g_multi                 6145  0
    usb_f_mass_storage     36886  1 g_multi
    usb_f_rndis            15603  1 g_multi
    u_ether                12467  2 g_multi,usb_f_rndis
    ti_am335x_adc           6864  0
    libcomposite           44507  3 usb_f_mass_storage,g_multi,usb_f_rndis
    udc_core               19466  4 usb_f_mass_storage,u_ether,usb_f_rndis,libcomposite
    usb_common              4737  2 udc_core,libcomposite
    xfrm_user              22147  2
    xfrm4_tunnel            2040  0
    ipcomp                  2257  0
    xfrm_ipcomp             4225  1 ipcomp
    esp4                    6363  0
    ah4                     5627  0
    af_key                 26992  0
    xfrm_algo               6970  5 xfrm_user,esp4,ah4,af_key,xfrm_ipcomp
    bluetooth             338029  2
    wkup_m3_rproc           3670  1
    pm33xx                  4348  0
    wkup_m3_ipc             8141  1 pm33xx
    remoteproc             28840  3 pru_rproc,wkup_m3_rproc,wkup_m3_ipc
    omap_aes_driver        19021  0
    omap_sham              21671  0
    crypto_engine           6466  1 omap_aes_driver
    ti_emif_sram            5406  1 pm33xx
    pruss_soc_bus           3649  0
    c_can_platform          6638  0
    c_can                   9578  1 c_can_platform
    can_dev                13125  1 c_can
    gpio_pisosr             2972  0
    gpio_pca953x           11032  4
    gpio_tpic2810           2639  0
    rtc_omap                9341  1
    omap_wdt                4719  0
    ti_am335x_tscadc        5853  1 ti_am335x_adc
    gpio_decoder            2387  0
    input_polldev           4488  1 gpio_decoder
    sch_fq_codel            9039  4
    uio_module_drv          7349  0
    uio                     9158  1 uio_module_drv
    cryptodev              38385  1
    

    However, when I try your command ip -d -s linux show can0, it says: Object "linux" is unknown, try "ip help"

  • Hi,

    I apologize, my typing mistake, linux should be link, here the correct example "ip -d -s link show can0".
    Again I apolgize for not catching that when I typed it.

    Best Regards,
    Schuyler
  • No problem, here are the results of the commands:

    root@am335x-evm:~# ip link set can0 type can bitrate 50000 triple-sampling on
    root@am335x-evm:~# ip link set can0 up
    [   78.565868] c_can_platform 481cc000.can can0: setting BTR=1c1d BRPE=0000
    root@am335x-evm:~# cansend can0 -i 0x10 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
    Usage: cansend <device> <can_frame>.
    root@am335x-evm:~# cansend can0 5A1#11.22.33.44.55.66.77.88
    [   98.803162] can: controller area network core (rev 20120528 abi 9)
    [   98.813437] NET: Registered protocol family 29
    [   98.841368] can: raw protocol (rev 20120528)
    root@am335x-evm:~# lsmod
    Module                  Size  Used by
    can_raw                 6743  1
    can                    29582  1 can_raw
    pvrsrvkm              403455  0
    pru_rproc              10682  0
    pruss_intc              7249  1 pru_rproc
    pruss                   9725  1 pru_rproc
    ti_am335x_adc           6864  0
    sha512_generic          9967  0
    sha512_arm             12252  0
    sha256_generic         10178  0
    sha1_generic            2864  0
    sha1_arm_neon           6261  0
    sha1_arm                3862  1 sha1_arm_neon
    md5                     2219  0
    des_generic            17608  0
    g_multi                 6145  0
    cbc                     2388  0
    usb_f_mass_storage     36886  1 g_multi
    usb_f_rndis            15603  1 g_multi
    u_ether                12467  2 g_multi,usb_f_rndis
    libcomposite           44507  3 usb_f_mass_storage,g_multi,usb_f_rndis
    udc_core               19466  4 usb_f_mass_storage,u_ether,usb_f_rndis,libcomposite
    usb_common              4737  2 udc_core,libcomposite
    xfrm_user              22147  2
    xfrm4_tunnel            2040  0
    ipcomp                  2257  0
    xfrm_ipcomp             4225  1 ipcomp
    esp4                    6363  0
    ah4                     5627  0
    af_key                 26992  0
    xfrm_algo               6970  5 xfrm_user,esp4,ah4,af_key,xfrm_ipcomp
    bluetooth             338029  2
    wkup_m3_rproc           3670  1
    pm33xx                  4348  0
    wkup_m3_ipc             8141  1 pm33xx
    omap_aes_driver        19021  0
    remoteproc             28840  3 pru_rproc,wkup_m3_rproc,wkup_m3_ipc
    crypto_engine           6466  1 omap_aes_driver
    omap_sham              21671  0
    ti_emif_sram            5406  1 pm33xx
    pruss_soc_bus           3649  0
    c_can_platform          6638  0
    c_can                   9578  1 c_can_platform
    can_dev                13125  1 c_can
    gpio_pisosr             2972  0
    gpio_pca953x           11032  4
    gpio_tpic2810           2639  0
    rtc_omap                9341  1
    omap_wdt                4719  0
    ti_am335x_tscadc        5853  1 ti_am335x_adc
    gpio_decoder            2387  0
    input_polldev           4488  1 gpio_decoder
    sch_fq_codel            9039  4
    uio_module_drv          7349  0
    uio                     9158  1 uio_module_drv
    cryptodev              38385  1
    root@am335x-evm:~# ip -d -s link show can0
    5: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc fq_codel state UNKNOWN mode DEFAULT group default qlen 10
        link/can  promiscuity 0
        can <TRIPLE-SAMPLING> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
              bitrate 50000 sample-point 0.875
              tq 1250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
              c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
              clock 24000000
              re-started bus-errors arbit-lost error-warn error-pass bus-off
              0          0          0          0          0          0         numtxqueues 1 gso_max_size 65536 gso_max_segs 65535
        RX: bytes  packets  errors  dropped overrun mcast
        0          0        0       0       0       0
        TX: bytes  packets  errors  dropped carrier collsns
        0          0        0       0       0       0
    

  • Hi,
    I do not have access to an ICEv2 board at the moment but I have another board with the AM335x on it trying to look at what the ip link shows. The are some differences between the result you posted and what I have. I was looking to see if there was a way to detect there is a cabling issue. There might be a pin mux issue but I am not sure yet. But your post shows no error-warns or error-pass or bus-off conditions detected. I need to try a ICEv2 board here and let you know hopefully early next week.
    Best Regards,
    Schuyler
  • Hi,

    I noticed this today in the DTS file that you posted, if the DTS is still like the line below please try changing the -o to -0:

    pinctrl-o = <&dcan0_pins_default>;

    Could you please take a look at pin mux registers with the devmem2 command and post the results here?

    0x44E10970
    0x44E10974

    If these are not showing mux mode 2 per the DTS pin mux definition it could be due to the syntax difference pointed out above.

    Best Regards,
    Schuyler
  • Hi,
    Another update, I was to get a ICEv2 board here and try out the can interface. I was able to get it to work. When I do the devmem2 commands in the earlier post I get values of for 0x44E10970 I get 0x0000000A and for 0x44E10974 I get 0x00000022. Is that what you get?

    Could you please attach the pin mux portion of the dcan0 and the dcan0 node where the pin mux is defined that you are currently using?

    Best Regards,
    Schuyler
  • Hello,

    Thank you for all the answers. I'm really sorry the problem simply came from the o instead of 0. Everything work normally now.
    Thank you again!

    Best regards
    Vincent