How to Use CAN CAPE for Beaglebone Black?

@dpengsberg, for this application and timing requirement, I’d use the PRUSS subsystem.

However, once you start looking into this sub-system, I need to stay out of the current “uio_pruss” vs the TI “remoteproc_pruss” holy war going on in the BeagleBoard.org forums…

So take a look at, these projects, and decide what you need:

https://elinux.org/ECE497_BeagleBone_PRU

http://processors.wiki.ti.com/index.php/PRU_Training:_Hands-on_Labs

Regards,

Hi Robert,

I have several new of the BB Black and CAN Capes. I am trying to document the process for setting up the Beagle to recreate the entire working and development environment, because we will be building about 20 of these per week. I have a working compiled C program made from modifying the candump.c program. I am using the most recent IoT image. bone-debian-9.5-iot-armhf-2018-10-07-4gb

If I boot from a freshly burned sd card and try to configure the CAN pins p9.24 and .26 ( using config-pin p9.24 can) I receive a “P9_24 pinmux file not found!” error message. At this I never seem to be able to get rid of this error condition, even though I have built several others that work just fine. I can’t say exactly how I built them differently, but it must be something because they work.

Can you help me configure these pins to be CAN so they configure properly every time automatically?

Thanks,

Dave

RobertCNelson
Applications Engineer

    February 19

alt dpengsberg:
Can you tell me what I need to do to my Beaglebone Black with the CAN Cape to get the code candump.c to actually run?


sudo apt update
sudo apt install build-essential cmake git ninja-build
git clone https://github.com/linux-can/can-utils
cd ./can-utils/
mkdir build
cd ./build/
cmake -GNinja .. && ninja

  ebian@beaglebone:~/can-utils$ cd build/
debian@beaglebone:~/can-utils/build$ cmake -GNinja .. && ninja
-- The C compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/debian/can-utils/build
[48/63] Building C object CMakeFiles/c...bit-timing.dir/can-calc-bit-timing.c.o
/home/debian/can-utils/can-calc-bit-timing.c: In function ‘print_bit_timing’:
/home/debian/can-utils/can-calc-bit-timing.c:447:35: warning: ‘tseg1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
unsigned int brp, tsegall, tseg, tseg1, tseg2;
^~~~~
/home/debian/can-utils/can-calc-bit-timing.c:447:42: warning: ‘tseg2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
unsigned int brp, tsegall, tseg, tseg1, tseg2;
^~~~~
[63/63] Linking C executable isotpsniffer
debian@beaglebone:~/can-utils/build$ ls
asc2log canlogserver isotprecv libcan.a
bcmserver canplayer isotpsend libj1939.a
build.ninja cansend isotpserver log2asc
canbusload cansniffer isotpsniffer log2long
can-calc-bit-timing CMakeCache.txt isotptun rules.ninja
candump CMakeFiles jacd slcan_attach
canfdtest cmake_install.cmake jcat slcand
cangen isotpdump jspy slcanpty
cangw isotpperf jsr testj1939

Regards,

One more thing on the error message, after the "P9_24 pinmux file not found! "

it says

“Pin has no cape: P9_24”

But I do have the cape plugged in.

Hi Robert,

I have several new of the BB Black and CAN Capes. I am trying to document the process for setting up the Beagle to recreate the entire working and development environment, because we will be building about 20 of these per week. I have a working compiled C program made from modifying the candump.c program. I am using the most recent IoT image. bone-debian-9.5-iot-armhf-2018-10-07-4gb

If I boot from a freshly burned sd card and try to configure the CAN pins p9.24 and .26 ( using config-pin p9.24 can) I receive a “P9_24 pinmux file not found!” error message. At this I never seem to be able to get rid of this error condition, even though I have built several others that work just fine. I can’t say exactly how I built them differently, but it must be something because they work.

Can you help me configure these pins to be CAN so they configure properly every time automatically?

Thanks,

Dave

RobertCNelson
Applications Engineer

    February 19

alt dpengsberg:
Can you tell me what I need to do to my Beaglebone Black with the CAN Cape to get the code candump.c to actually run?


sudo apt update
sudo apt install build-essential cmake git ninja-build
git clone https://github.com/linux-can/can-utils
cd ./can-utils/
mkdir build
cd ./build/
cmake -GNinja .. && ninja

  ebian@beaglebone:~/can-utils$ cd build/
debian@beaglebone:~/can-utils/build$ cmake -GNinja .. && ninja
-- The C compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/debian/can-utils/build
[48/63] Building C object CMakeFiles/c...bit-timing.dir/can-calc-bit-timing.c.o
/home/debian/can-utils/can-calc-bit-timing.c: In function ‘print_bit_timing’:
/home/debian/can-utils/can-calc-bit-timing.c:447:35: warning: ‘tseg1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
unsigned int brp, tsegall, tseg, tseg1, tseg2;
^~~~~
/home/debian/can-utils/can-calc-bit-timing.c:447:42: warning: ‘tseg2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
unsigned int brp, tsegall, tseg, tseg1, tseg2;
^~~~~
[63/63] Linking C executable isotpsniffer
debian@beaglebone:~/can-utils/build$ ls
asc2log canlogserver isotprecv libcan.a
bcmserver canplayer isotpsend libj1939.a
build.ninja cansend isotpserver log2asc
canbusload cansniffer isotpsniffer log2long
can-calc-bit-timing CMakeCache.txt isotptun rules.ninja
candump CMakeFiles jacd slcan_attach
canfdtest cmake_install.cmake jcat slcand
cangen isotpdump jspy slcanpty
cangw isotpperf jsr testj1939

Regards,

Once you create your first “golden” image on the eMMC of the first board, run this script, with a blank microSD plugged in, then you can use that microSD to flash all additional boards.

debian@beaglebone:~$ cd /opt/scripts/tools/eMMC/
debian@beaglebone:/opt/scripts/tools/eMMC$ sudo ./beaglebone-black-make-microSD-flasher-from-eMMC.sh

This is a sign you just have an old version of the bootloader in the eMMC, if you use the steps above to create a golden image, you’ll be updating the ancient bootloader on all new boards.

Regards,

Hi Robert,

I have been booting from the sd card with the IoT image and working with that to create my golden image. The reason I did that is because the version that the BBB ships with in the eMMC seems to be very slow. But the board I am working with right now trying to understand what is happening, will successfully see the CAN Cape when booted from original eMMC, but will not see the CAN Cape when booted from the latest image using the sd card.

You said “This is a sign you just have an old version of the bootloader in the eMMC”, so do you mean the old version of the bootloader is able to see my Cape,but the recent IoT image bootloader is not? And if that is the case, maybe I should start with an older version of the downloaded IoT image?

I have ordered some more fresh BBB and CAN Capes to start again from scratch. But I really don’t know how I should proceed with them. I have several BBB and several CAN Capes, but with the IoT image from sd all of them give me an error if I do a ‘config-pin P9.24 can’, and report ‘pinmux file not found’ and ‘pin has no cape’

Dave

RobertCNelson
Applications Engineer

    March 25

alt dpengsberg:
I have several new of the BB Black and CAN Capes. I am trying to document the process for setting up the Beagle to recreate the entire working and development environment, because we will be building about 20 of these per week. I have a working compiled C program made from modifying the candump.c program. I am using the most recent IoT image. bone-debian-9.5-iot-armhf-2018-10-07-4gb

Once you create your first “golden” image on the eMMC of the first board, run this script, with a blank microSD plugged in, then you can use that microSD to flash all additional boards.

debian@beaglebone:~$ cd /opt/scripts/tools/eMMC/
debian@beaglebone:/opt/scripts/tools/eMMC$ sudo ./beaglebone-black-make-microSD-flasher-from-eMMC.sh

alt dpengsberg:
If I boot from a freshly burned sd card and try to configure the CAN pins p9.24 and .26 ( using config-pin p9.24 can) I receive a “P9_24 pinmux file not found!” error message. At this I never seem to be able to get rid of this error condition, even though I have built several others that work just fine. I can’t say exactly how I built them differently, but it must be something because they work.

This is a sign you just have an old version of the bootloader in the eMMC, if you use the steps above to create a golden image, you’ll be updating the ancient bootloader on all new boards.

Regards,

The default image shipped with boards on the eMMC is a lxqt based desktop, so yes, it does slow things down…

Run, this command to see what we are dealing with:

sudo /opt/scripts/tools/version.sh

Regards,

debian@beaglebone:~$ config-pin -q p9.24
P9_24 pinmux file not found!
Pin has no cape: P9_24
debian@beaglebone:~$ sudo /opt/scripts/tools/version.sh
git:/opt/scripts/:[1aa73453b2c980b75e31e83dab7dd8b6696f10c7]
eeprom:[A335BNLT000C1828BBBG1475]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Image 2018-10-07]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2018.09-00002-g0b54a51eee]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2016.03-00001-gd12d09f]:[location: dd MBR]
kernel:[4.14.71-ti-r80]
nodejs:[v6.14.4]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.4.20180928.0-0rcnee0~stretch+20180928]
pkg:[bb-wl18xx-firmware]:[1.20180517-0rcnee0~stretch+20180517]
pkg:[kmod]:[23-2rcnee1~stretch+20171005]
pkg:[librobotcontrol]:[1.0.3-git20181005.0-0rcnee0~stretch+20181005]
pkg:[firmware-ti-connectivity]:[20170823-1rcnee1~stretch+20180328]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c bluetooth netdev cloud9ide gpio pwm eqep admin spi tisdk weston-launch xenomai]
cmdline:[console=ttyO0,115200n8 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet]
dmesg | grep pinctrl-single
[    1.039300] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
dmesg | grep gpio-of-helper
[    1.040879] gpio-of-helper ocp:cape-universal: ready
END

debian@beaglebone:~$

RobertCNelson
Applications Engineer

    March 26

alt dpengsberg:
I have been booting from the sd card with the IoT image and working with that to create my golden image. The reason I did that is because the version that the BBB ships with in the eMMC seems to be very slow. But the board I am working with right now trying to understand what is happening, will successfully see the CAN Cape when booted from original eMMC, but will not see the CAN Cape when booted from the latest image using the sd card.

The default image shipped with boards on the eMMC is a lxqt based desktop, so yes, it does slow things down…

alt dpengsberg:
You said “This is a sign you just have an old version of the bootloader in the eMMC”, so do you mean the old version of the bootloader is able to see my Cape,but the recent IoT image bootloader is not? And if that is the case, maybe I should start with an older version of the downloaded IoT image?

Run, this command to see what we are dealing with:

sudo /opt/scripts/tools/version.sh

Regards,

There you go, you have an ancient verison of u-boot installed on the eMMC, thus all the u-boot overlay settings are ignored…

Fix it by:

sudo dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=10

Regards,

Hi Robert,

That command worked after a reboot. Thanks.

debian@beaglebone:~$ config-pin P9.24 can
debian@beaglebone:~$ config-pin -q p9.24
P9_24 Mode: can
debian@beaglebone:~$

If you have a moment, could explain what the dd command did?

RobertCNelson
Applications Engineer

    March 27

alt dpengsberg:
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2018.09-00002-g0b54a51eee]:[location: dd MBR]

bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2016.03-00001-gd12d09f]:[location: dd MBR]

There you go, you have an ancient verison of u-boot installed on the eMMC, thus all the u-boot overlay settings are ignored…

Fix it by:

sudo dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=10

Regards,

The bootloader files (MLO and u-boot.img) are stored in the first part of the eMMC’s partition… We zero out the first 10Mb as that pretty much guarantees to clear out all old locations of the u-boot files going back to the ancient Angstrom images…

What is happening, the am335x bootrom looks at the eMMC first, then the microSD for u-boot.

Regards,

Do you have documentation for COMCPE-BBBCAPE-ND? All I can find is a one page data sheet with very little info. Among other things, I’d like to know if termination resistor is built into the board. Maybe a schematic would due, but for me, a technical doc would be good.

The docs for this board (and schematic) https://github.com/beagleboard/capes/tree/master/beaglebone/Comms

Regards,

Is there a way to execute the echo 1 > /sys/class/leds/name/brightness function from within the c program?

I know I could do a system() call, but that seems very slow. If that is not slow, then I will go ahead, but I just imagine shelling out takes quite a bit.

RobertCNelson
Applications Engineer

    March 15

alt dpengsberg:
I have modified the candump.c project to send the received can msg out the ethernet port as UDP. This is working but I would very much like to blink an external LED from a GPIO pin. After reviewing the samples and putting some test code in the candump.c file, I always get a “segmentation error” when the code executes the fwrite instruction.

Just add an gpio-leds device tree node… Look at this 4 relay “led” example:

Well this depends…

The led class as an default-state option, so on startup you can force a default on/off…

Otherwise, system call is probally best…

Regards,

Hi Robert,

I have two questions.

I have the built-in Ethernet port on the BBB to be set for a static IP.
The network is just a patch cable from the ethernet port connected to an another device, which also has a static IP. There is no server, internet or dhcp. The BBB just sends UDP messages to the other device.

So I added the following lines to the /etc/network/interfaces file:

iface eth0 inet static

address 192.168.100.22

netmask 255.255.255.0

gateway 192.168.100.1

After a reboot, sometimes, ifconfig will show the static IP for eth0 and sometimes it does not. As if it is ignoring my interfaces setting.

Any ideas why the static IP might not be working, or, generally, how can I go about troubleshooting this issue?

Second question is about displaying graphics through the hdmi port.

I am currently installing the following packages over the latest BBB IoT release. None of these packages are set in stone - its just what I have at this stage.

apt install openbox obconf obmenu lxterminal tint2 leafpad pcmanfm lightdm nitrogen network-manager-gnome gnome-backgrounds

I would like to display a status screen on a monitor connected to the hdmi port. It would have 3 simple horizontal bars (to show percent usage data), some colored text, and colored indicator LEDs showing status.

Could you recommend a language and library?

I am thinking I will duplicate my existing UDP message to also send to localhost. This message contains the data I want to display. Then create a separate display program to listen for UDP messages and display the data on the hdmi port.

Thanks,

Dave

RobertCNelson
Applications Engineer

    March 29

alt dpengsberg:
Is there a way to execute the echo 1 > /sys/class/leds/ name /brightness function from within the c program?

I know I could do a system() call, but that seems very slow. If that is not slow, then I will go ahead, but I just imagine shelling out takes quite a bit.

Well this depends…

The led class as an default-state option, so on startup you can force a default on/off…

Otherwise, system call is probally best…

Regards,

All my images use “connman” by default, either remove connman or setup the static interface thru connman, an example is documented in /etc/network/interfaces…

sudo connmanctl config <service> --ipv4 manual <ip_addr> <netmask> <gateway> --nameservers <dns_server>

I’d use QT…

Regards,

Hi Robert,

I can execute the command:

$ sudo connmanctl config ethernet_3403de680df9_cable --ipv4 manual 192.168.100.22. 255.255.255.0 192.168.100.1 --nameservers 8.8.8.8

and it sets the eth0 port successfully to static ip.

But it does not make it permanent. When I reboot, the static setting goes away.

I have an autostart.sh script in my openbox configuration, and if I set run the command from there (without the sudo) it does not set the eth0 port to static. But If I run it from the command line after the system has started up, then the exact same command works fine.

Actually, from the command line, it does not seem to matter if I use sudo or not. From the command line it work every time.

I have put a very long sleep time of 90 seconds in the autostart.sh before running the command, thinking that maybe some services need to up, but that makes no difference.

Any thoughts why the command does not make the static setting permanent?

Thanks,

Dave

RobertCNelson
Applications Engineer

    May 8

alt dpengsberg:
So I added the following lines to the /etc/network/interfaces file:

iface eth0 inet static

address 192.168.100.22

netmask 255.255.255.0

gateway 192.168.100.1

After a reboot, sometimes, ifconfig will show the static IP for eth0 and sometimes it does not. As if it is ignoring my interfaces setting.

Any ideas why the static IP might not be working, or, generally, how can I go about troubleshooting this issue?

All my images use “connman” by default, either remove connman or setup the static interface thru connman, an example is documented in /etc/network/interfaces…

sudo connmanctl config <service> --ipv4 manual <ip_addr> <netmask> <gateway> --nameservers <dns_server>

alt dpengsberg:
apt install openbox obconf obmenu lxterminal tint2 leafpad pcmanfm lightdm nitrogen network-manager-gnome gnome-backgrounds

I would like to display a status screen on a monitor connected to the hdmi port. It would have 3 simple horizontal bars (to show percent usage data), some colored text, and colored indicator LEDs showing status.

Could you recommend a language and library?

I’d use QT…

Regards,

That’s odd, when you run that command connman saves it to it’s config directory and it should set it on every bootup…

I guess, for this image, just disable connman (sudo apt remove connman --purge) and set the static ip in /etc/network/interfaces…

Regards,

Regards,

Hi Robert,

We are using the BBB together with the CAN Cape. The question has come up as to use the USB connector to power the device or to use the round +5vdc power jack. We will occasionally plug in a small usb stick for blue-tooth to a mouse/keyboard combo. So that is a bit more power consumption.

Do you have an opinion on which way to power the BBB?

If you suggest using the round power jack, does digi-key sell a cable for that?

Thanks,

Dave

RobertCNelson
Applications Engineer

    May 10

alt dpengsberg:
Any thoughts why the command does not make the static setting permanent?

That’s odd, when you run that command connman saves it to it’s config directory and it should set it on every bootup…

I guess, for this image, just disable connman (sudo apt remove connman --purge) and set the static ip in /etc/network/interfaces…

Regards,

Regards,

Using the round power jack is more reliable for the BBB. The USB can’t handle current fluctuations as well…

Take a look at one of these options:

Power Adapter

Regards,