Enabling and Verifying Flexcan support

Discussion in 'UDOO NEO' started by jas-mx, Mar 3, 2016.

  1. jas-mx

    jas-mx Active Member

    Joined:
    Dec 31, 2013
    Messages:
    407
    Likes Received:
    118
    Here are instructions those of you wanting to enable and verify flexcan support:

    1. Firstly one or both of the flexcan interfaces needs to be enable in the dts file. Unfortunately the flexcan pins are actually hogged in the dts meaning that just enabling the flexcan interfaces won't work. I have amended the udoo-neo-full-hdmi.dts to enable this correctly and you can use this as a starting point. I have assumed you have configured your NEO (full) to run with hdmi and the m4 disabled.

    2. Download the attached file 'imx6sx-udoo-neo-full-hdmi-can.zip' and copy to your neo eg:

    Code:
    scp imx6sx-udoo-neo-full-hdmi-can.dtb udooer@udooneo:
    3. On the NEO unzip the file to extract the dts file.

    Code:
    unzip imx6sx-udoo-neo-full-hdmi-can.zip
    4. Now we need to overlay the new dts over the existing dts file (udoo-neo-full-hdmi.dtb). Which we can do by creating an over 'dts-overlay' directory on the boot partition:

    Code:
    sudo mount /dev/mmcblk0p1 /mnt
    cd /mnt
    sudo mkdir dts-overlay
    sudo cd dts-overlay
    sudo cp ~/imx6sx-udoo-neo-full-hdmi-can.dtb imx6sx-udoo-neo-full-hdmi.dtb
    
    5. Next we need to tell uboot to use the overlay dts file by editing uEnv.txt and appending an additional line 'use_custom_dtb=true' (without the quotes) to end of file eg:

    Code:
    sudo /mnt
    sudo vi uEnv.txt
    
    6. Next reboot the NEO to pick up the new dts file:

    Code:
    sudo reboot
    7. If everything goes to plan you should see 2 can interfaces using 'ifconfig -a | less' eg:

    Code:
    ifconfig -a | less
    
    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:5 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:10
              RX bytes:0 (0.0 B)  TX bytes:11 (11.0 B)
              Interrupt:142
    
    can1      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
              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:143
    
    8. At this point the NEO would normally require a CAN transceiver attached to the CAN pins to verify the interface actually work against a real device. Well to get round that we can put in the can interface into loopback mode, ie what is sent out on TX is returned on RX by the CAN controller. To do this we do:

    Code:
    sudo ip link set can0 type can bitrate 125000 loopback on
    sudo ifconfig can0 up
    ip -s -d link show can0

    9. Install can-utils for testing sending/receiving of packets:

    Code:
    sudo apt-get install can-utils
    10. Finally to test send/receiving you need to open 2 shells, in the first shell lets dump the output:

    Code:
    candump can0
    11 In the second shell lets send some data:

    Code:
    cansend can0 500#1E.00.10
    To revert back to original dts file (no can enabled) edit uEnv.txt file (need to be root) and remove the 'use_custom_dtb=true' line and reboot.
     

    Attached Files:

    Last edited: Apr 14, 2016
    Andrea Rovai and graugans like this.
  2. yaryn

    yaryn New Member

    Joined:
    Mar 1, 2016
    Messages:
    10
    Likes Received:
    3
    @jas-mx i cant thank you enough for your assistance,

    You are a legend mate,
     
    Andrea Rovai likes this.
  3. yaryn

    yaryn New Member

    Joined:
    Mar 1, 2016
    Messages:
    10
    Likes Received:
    3
    ok so I have been able to get this far, so thanks agin for the assistance,
    I know we have spoken previously about getting a can system up and running if all the devices were 3.3v,
    how can I get two Udoo's to talk to each other over canbus without transceivers? is this possible as they will both be working over 3.3v,
    would I simply tx to rx and rx to tx or should they all be connected together? how would a 120 ohm resistor fit into the equation?

    thanks
     
  4. jas-mx

    jas-mx Active Member

    Joined:
    Dec 31, 2013
    Messages:
    407
    Likes Received:
    118
    No you can't cross over TX/RX its not that simple. There is a application note (from siemens) which attempts to do this via diodes, I haven't tried (I'm waiting for some transceivers to turn up).
     
  5. yaryn

    yaryn New Member

    Joined:
    Mar 1, 2016
    Messages:
    10
    Likes Received:
    3
    jas-mx

    followed the seimens note and it worked successfully,

    now to wait for transceivers,

    thanks again
     
    jas-mx likes this.
  6. jas-mx

    jas-mx Active Member

    Joined:
    Dec 31, 2013
    Messages:
    407
    Likes Received:
    118
    Great, that you've made more progress!
    Regarding transceivers, these are pretty cheap although shipping can be slow.
     
    Andrea Rovai likes this.
  7. yaryn

    yaryn New Member

    Joined:
    Mar 1, 2016
    Messages:
    10
    Likes Received:
    3
    Yeh mate i have ordered 8 of them from 4 different sources so far to try and find a reliable source,

    Thanks again,

    Ill be testing two udoos communicating via the single wire canbus no transciever mode next week sometime

    Cheers
     
  8. Andrea Rovai

    Andrea Rovai Well-Known Member

    Joined:
    Oct 27, 2014
    Messages:
    1,703
    Likes Received:
    240
    AWESOME!!!
     
  9. jas-mx

    jas-mx Active Member

    Joined:
    Dec 31, 2013
    Messages:
    407
    Likes Received:
    118
    Finally tested with these transceivers and everything seems to work. I brought up both the can interfaces (can0 + can1) and connected a transceiver on each. Sent messages are received on both interfaces.
     
    Last edited: Mar 25, 2016
    graugans, waltervl and modjo like this.
  10. Sassus-Bourda

    Sassus-Bourda Member

    Joined:
    Dec 21, 2015
    Messages:
    42
    Likes Received:
    4
    Hi guys,

    How can I create the second directory dts-overlay the system said that the file already exist.

    THanks for your help.
     
  11. jas-mx

    jas-mx Active Member

    Joined:
    Dec 31, 2013
    Messages:
    407
    Likes Received:
    118
    If the dts-overlay already exist then just proceed to the next step.
     
  12. Sassus-Bourda

    Sassus-Bourda Member

    Joined:
    Dec 21, 2015
    Messages:
    42
    Likes Received:
    4
    Hi,
    I have a bridge connect on window machine and my udoo board on udoobuntu. I use the software docklight to send can frame. When I dump the can frame on my udoo board nothing appear but the can message send in my board to my board working like in the example of jas-mx.

    I don't know how to get the ID of my bridge to send directly the can frame to this adress..

    Thanks in advance for your help!
     
  13. modjo

    modjo Active Member

    Joined:
    Sep 29, 2014
    Messages:
    417
    Likes Received:
    127
    The CAN bus is not addressed, the id is to determine the priority of the message ... When you send a message on the bus all the connected system can saw the message ... perhaps you need to take some times to understand how bus CAN works ... Another point what is your CAN bridge (peak ...) Are you sure that you configure the same bitrates on the 2 sides, did you add the terminal resistors ...?
     
  14. Sassus-Bourda

    Sassus-Bourda Member

    Joined:
    Dec 21, 2015
    Messages:
    42
    Likes Received:
    4
    Yes I begin with can thanks for the precision.

    I use a no commercial bridge so I don't know the backend use but it's not peak or tinycan and I can't test it on linux with socketCan because he is not recognize by my VM, it's why I use docklight.

    How can I know the value of bitrate that I have to set up?

    It seem that with that bridge I don't need a terminal resistors because he does the conversion of voltage alone.
     
  15. Frank Traenkle

    Frank Traenkle New Member

    Joined:
    Apr 30, 2016
    Messages:
    3
    Likes Received:
    2
    I am working on getting FlexCAN to run on the Yocto meta-udoo jethro branch.

    Please provide the source DTS of imx6sx-udoo-neo-full-hdmi-can.dtb

    Thank you.
     
  16. modjo

    modjo Active Member

    Joined:
    Sep 29, 2014
    Messages:
    417
    Likes Received:
    127
    To do that, download and burn udoobuntu2rc2 on a sdcard. After that you can use the device tree editor to activate CAN on neo. This tool create a folder in boot partition (dts-overlay) with the good dtb files. Copy this folder on your yocto sd card and change uEnv.txt to use it !
     
  17. Frank Traenkle

    Frank Traenkle New Member

    Joined:
    Apr 30, 2016
    Messages:
    3
    Likes Received:
    2
    Will I also get the .dts and .dtsi files?
     
  18. jas-mx

    jas-mx Active Member

    Joined:
    Dec 31, 2013
    Messages:
    407
    Likes Received:
    118
    I don't think that will work because dts files aren't setup correctly to allow the pins to be reassigned, have you tested it (or reviewed the contents of the dts files)? This is the reason why I manually created my own files (to be honest the device tree editor mechanism hasn't been thought through fully to allows pins to be reassigned in all use cases).
     
  19. modjo

    modjo Active Member

    Joined:
    Sep 29, 2014
    Messages:
    417
    Likes Received:
    127
    @jas-mx yes it works ! I have configured the 2 can on neo plus uart6 ;). For the can (with yocto) you just need to add a default arduino sketch to enable it ! I use it since 1 month and all work fine . @graugans already add it on yocto built.
    @Frank Traenkle for the source file you can find it in the folder where is the dtweb app or on github !
     
    Andrea Rovai likes this.
  20. graugans

    graugans Administrator Staff Member

    Joined:
    Sep 17, 2015
    Messages:
    328
    Likes Received:
    141
    I'll hopefully write some tutorial on this soon

    Gesendet von meinem FP2 mit Tapatalk
     
    Andrea Rovai likes this.

Share This Page