Trouble enabling DCAN1 on BeagleBone, think I'm close but missing something.

428 views
Skip to first unread message

mil...@gmail.com

unread,
May 2, 2016, 4:39:18 PM5/2/16
to BeagleBoard
Hi Folks,

I am easily able to receive CAN traffic with my Peak USB-CAN interface on my linux workstation.  I know our device is producing regular updates at 250000 and it dumps find using candump.

For a couple days I have been trying (without success) to duplicate the behavior on my Element Rev B6 Beaglebone.  I've read many posts and have worked bast a bunch of issues but still get no can traffic.

The results are the same with a WaveShare CAN Cape or a discrete NXP TJA1051 High-speed CAN transceiver that I have connected on a breadboard.  If I hook a scope to the input RX signal I can see the external CAN traffic but nothing gets through.

I did modify ~/bb.org-overlays/src/arm/cape-universaln-00A0.dts to remove references to pins P9_24 and P9_26 (UART1 RX/TX)

For clarity's sake here is the script that I run after rebooting the Beaglbone.

set -x
echo
"# make sure, I'm running as root, unmolested bone-debian-8.3-lxqt-4gb-armhf-2016-01-24-4gb.img image"
id
uname
-a

echo
"# look, can pin muxing for P9_24 and P9_26 are at default (GPIO, mode 7)"
devmem2
0x44E10980 w
devmem2
0x44E10984 w

echo
"# cat my overlay File, has been built/installed/rebooted successfully"
cat
/hone/debian/bb.org-overlays/src/arm/BB-CAN1-00A0.dts

echo
"# install my overlay to setup the CAN pins"
sh
-c "echo 'BB-CAN1' > /sys/devices/platform/bone_capemgr/slots"

echo
"# see that the overlay was installed and make sure pins went to mode 2"
cat
/sys/devices/platform/bone_capemgr/slots
devmem2
0x44E10980 w
devmem2
0x44E10984 w

echo
"#load the can drivers"
modprobe can
modprobe can
-dev
modprobe can
-raw

echo
"# show what's loaded"
lsmod

echo
"# fire up the interface"
ip link
set can0 type can bitrate 250000 triple-sampling on
ip link
set can0 up

echo
"# see that we're up"
ifconfig can0

echo
"#Shoud receive can data, same as my linux workstation..."
candump can0


Here is the output from the script..

debian@beaglebone:~$ sudo ./canSetup.sh
+ echo # make sure, I'm running as root, unmolested bone-debian-8.3-lxqt-4gb-armhf-2016-01-24-4gb.img image
# make sure, I'm running as root, unmolested bone-debian-8.3-lxqt-4gb-armhf-2016-01-24-4gb.img image
+ id
uid
=0(root) gid=0(root) groups=0(root)
+ uname -a
Linux beaglebone 4.1.15-ti-rt-r43 #1 SMP PREEMPT RT Thu Jan 21 20:13:58 UTC 2016 armv7l GNU/Linux
+ echo # look, can pins P9_24 and P9_26 are at default (GPIO, mode 7)
# look, can pins P9_24 and P9_26 are at default (GPIO, mode 7)
+ devmem2 0x44E10980 w
/dev/mem opened.
Memory mapped at address 0xb6f93000.
Value at address 0x44E10980 (0xb6f93980): 0x37
+ devmem2 0x44E10984 w
/dev/mem opened.
Memory mapped at address 0xb6f9b000.
Value at address 0x44E10984 (0xb6f9b984): 0x37
+ echo # cat my overlay File, has been built/installed/rebooted successfully
# cat my overlay File, has been built/installed/rebooted successfully
+ cat /home/debian/bb.org-overlays/src/arm/BB-CAN1-00A0.dts
/*
 * Copyright (C) 2015 Robert Nelson <robert...@gmail.co
>
 *
 * Virtual cape for CAN1 on connector pins P9.24 P9.26
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/board/am335x-bbw-bbb-base.h>
#include <dt-bindings/pinctrl/am33xx.h>

/ {
    compatible
= "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green";

   
/* identification */
    part
-number = "BB-CAN1";
    version
= "00A0";

   
/* state the resources this cape uses */
    exclusive
-use =
       
/* the pin header uses */
       
"P9.24",    /* can1_rx */
       
"P9.26",    /* can1_tx */
       
/* the hardware ip uses */
       
"dcan1";

    fragment@0
{
        target
= <&am33xx_pinmux>;
        __overlay__
{
            bb_dcan1_pins
: pinmux_dcan1_pins {
                pinctrl
-single,pins = <
                    BONE_P9_24
(SLEWCTRL_FAST | PIN_INPUT_PULLUP | MUX_MODE2) /* uart1_txd.d_can1_rx */
                    BONE_P9_26
(SLEWCTRL_FAST | PIN_OUTPUT_PULLUP | MUX_MODE2) /* uart1_rxd.d_can1_tx */
               
>;
           
};
       
};
   
};

    fragment@1
{
        target
= <&dcan1>;
        __overlay__
{
            status
= "okay";
            pinctrl
-names = "default";
            pinctrl
-0 = <&bb_dcan1_pins>;
       
};
   
};
};
+ echo # install my overlay to setup the CAN pins
# install my overlay to setup the CAN pins
+ sh -c echo 'BB-CAN1' > /sys/devices/platform/bone_capemgr/slots
+ echo # see that the overlay was installed and make sure pins went to mode 2
# see that the overlay was installed and make sure pins went to mode 2
+ cat /sys/devices/platform/bone_capemgr/slots
 
0: PF----  -1
 
1: PF----  -1
 
2: PF----  -1
 
3: PF----  -1
 
4: P-O-L-   0 Override Board Name,00A0,Override Manuf,cape-universaln
 
5: P-O-L-   1 Override Board Name,00A0,Override Manuf,BB-CAN1
+ devmem2 0x44E10980 w
/dev/mem opened.
Memory mapped at address 0xb6f21000.
Value at address 0x44E10980 (0xb6f21980): 0x12
+ devmem2 0x44E10984 w
/dev/mem opened.
Memory mapped at address 0xb6fa5000.
Value at address 0x44E10984 (0xb6fa5984): 0x32
+ echo #load the can drivers
#load the can drivers
+ modprobe can
+ modprobe can-dev
+ modprobe can-raw
+ echo # show what's loaded
# show what's loaded
+ lsmod
Module                  Size  Used by
can_raw                
5408  0
can                    
28227  1 can_raw
c_can_platform          
6564  0
c_can                  
9605  1 c_can_platform
can_dev                
11455  1 c_can
spidev                  
6739  0
pwm_tiecap              
3492  0
pwm_tiehrpwm            
4546  0
tieqep                  
8510  0
8021q                  17336  0
garp                    
5975  1 8021q
mrp                    
7322  1 8021q
stp                    
1911  1 garp
llc                    
5257  2 stp,garp
snd_soc_evm            
5749  0
pruss_remoteproc      
15296  0
snd_soc_davinci_mcasp    
17266  2
snd_soc_edma            
1150  1 snd_soc_davinci_mcasp
omap_rng                
4358  0
rng_core                
7437  1 omap_rng
tilcdc                
26254  0
spi_omap2_mcspi        
10681  0
usb_f_acm              
7180  1
u_serial              
10596  3 usb_f_acm
usb_f_rndis            
22734  1
g_multi                
5316  0
usb_f_mass_storage    
42745  2 g_multi
u_ether                
12028  2 usb_f_rndis,g_multi
libcomposite          
43810  4 usb_f_acm,usb_f_rndis,g_multi,usb_f_mass_storage
tda998x                
11749  0
snd_soc_hdmi_codec      
2474  1
uio_pdrv_genirq        
3521  0
uio                    
8463  1 uio_pdrv_genirq
+ echo # fire up the interface
# fire up the interface
+ ip link set can0 type can bitrate 250000 triple-sampling on
+ ip link set can0 up
+ echo # see that we're up
# see that we're up
+ ifconfig can0
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:208

+ echo #Shoud receive can data, same as my linux workstation...
#Shoud receive can data, same as my linux workstation...
+ candump can0

....   Nothing produced.




Here is the dmesg output while the script is running...

[  101.514143] bone_capemgr bone_capemgr: part_number 'BB-CAN1', version 'N/A'
[  101.514196] bone_capemgr bone_capemgr: slot #5: override
[  101.514222] bone_capemgr bone_capemgr: Using override eeprom data at slot 5
[  101.514250] bone_capemgr bone_capemgr: slot #5: 'Override Board Name,00A0,Override Manuf,BB-CAN1'
[  102.998539] c_can_platform 481d0000.can: c_can_platform device registered (regs=fa1d0000, irq=209)
[  103.002556] bone-pinmux-helper ocp:P8_09_pinmux: could not find pctldev for node /ocp/l4_wkup@44c00000/prcm@200000/clocks/dpll_per_m2_ck, deferring probe
[  103.003340] bone_capemgr bone_capemgr: slot #5: dtbo 'BB-CAN1-00A0.dtbo' loaded; overlay id #1
[  104.557399] can: controller area network core (rev 20120528 abi 9)
[  104.557665] NET: Registered protocol family 29
[  105.965220] can: raw protocol (rev 20120528)
[  106.107030] c_can_platform 481cc000.can can0: setting BTR=1c05 BRPE=0000


If anyone can tell me why I can't get the IO to work I'd be grateful!

William Hermans

unread,
May 2, 2016, 7:42:00 PM5/2/16
to beagl...@googlegroups.com
You're providing far too much information, and not enough of the right information. It would be good to know the output of the following commands.

cat /sys/devices/platform/bone_capemgr/slots
ifconfig can0

Additionally, I know nothing of the cape you mention, and knowing your circuit layout would be good too, but not really necessary. Many seem to have had this same, or similar issues, which I'll assume is related to improper CANBUS termination. But since no one has bothered to come back on and follow up . . . who really knows ? I do know that using the Logicsupply CAN cape works. We have one, and I've dumped loads of data off a "local" industrial CAN network.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/bfe72a1d-e216-4fcd-a588-5eb756f22b98%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ppa...@northamericanrepower.com

unread,
Jun 30, 2016, 9:23:01 AM6/30/16
to BeagleBoard
Not sure if you solved this yet...

Try this, it worked for me:

1. disable the default overlay on slot 4:
    sudo sh -c "echo '-4' > /sys/devices/platform/bone_capemgr/slots"

2. add the CAN cape device
    sudo sh -c "echo 'BB-CAN1' > /sys/devices/platform/bone_capemgr/slots"

otherwise, you may get the following error:
    root@beaglebone:/# sudo sh -c "echo 'BB-CAN1' > /sys/devices/platform/bone_capemgr/slots"
    [  494.986203] bone_capemgr bone_capemgr: slot #6: BB-CAN1 conflict P9.24 (#4:cape-universaln)
    [  494.995099] bone_capemgr bone_capemgr: slot #6: Failed verification
    sh: echo: I/O error

Robert Nelson

unread,
Jun 30, 2016, 9:48:59 AM6/30/16
to Beagle Board
On Fri, Jun 24, 2016 at 12:09 PM, <ppa...@northamericanrepower.com> wrote:
> Not sure if you solved this yet...
>
> Try this, it worked for me:
>
> 1. disable the default overlay on slot 4:
> sudo sh -c "echo '-4' > /sys/devices/platform/bone_capemgr/slots"

you can just remove cape_universal=enable from /boot/uEnv.txt

>
> 2. add the CAN cape device
> sudo sh -c "echo 'BB-CAN1' > /sys/devices/platform/bone_capemgr/slots"
>
> otherwise, you may get the following error:
> root@beaglebone:/# sudo sh -c "echo 'BB-CAN1' >
> /sys/devices/platform/bone_capemgr/slots"
> [ 494.986203] bone_capemgr bone_capemgr: slot #6: BB-CAN1 conflict
> P9.24 (#4:cape-universaln)
> [ 494.995099] bone_capemgr bone_capemgr: slot #6: Failed verification
> sh: echo: I/O error

Regards,

--
Robert Nelson
https://rcn-ee.com/

William Hermans

unread,
Jun 30, 2016, 1:40:30 PM6/30/16
to beagl...@googlegroups.com
Also for Logisupply CAN / Serial cape, you do not load the overlay file manually. It's done automatically at boot. The same goes for many premade capes, I'm sure.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages