How to Use CAN CAPE for Beaglebone Black?

#14

Hi Robert,

I have installed slim:

sudo apt update

sudo apt install slim

On reboot I expected a login screen to appear on the monitor connected to my hdmi port, but I just get a login prompt.

I edited the /etc/slim.conf file to auto login - yes , and rebooted, but still no login screen or auto login.

I am missing something.

I did not install openbox yet. Do I need that first?

Thanks,

Dave

RobertCNelson
Applications Engineer

    March 5

alt dpengsberg:
Hi again - I wonder if you could point me to a way to get a browser to display a static website on powerup. I have installed chromium.

Somehow I thought by running chromium from a putty command line it would show up on the hdmi, but that doesn’t work or really make sense. How can I get hdmi output without logging through some sort of hdmi console?

This will depend on the what Windows Manager you are using. Lxqt/gnome/qt/openbox/etc…

My usual go to is “slim/openbox”…

1: slim log’s the user in, and runs openbox.

2: openbox, runs the script: {home}/.config/openbox/autostart

Sadly, the answer is complex as it depends on a bunch of variables, even thou it seems like a simple question.

Regards,

#15

Hi Robert,

I have made considerable progress now having an autologin (lightdm) and ability to autostart an application (openbox).

I hope you will help me with understanding something. Chromium browser is crashing. It is version 70 and seems that others have had success downgrading to version 67. I have been experimenting with both the IoT image and the LXQT image, and notice LXQT is using version 67 without crashing. When I install chromium in the IoT image I get version 70.

Can you please tell me how to install downgraded chromium? Do I first install current version and then install the lower version on top? Do I simply install the 67 version on a fresh image? LXQT image uses 67.0.3396.87 - can’t seem to find instructions on how to install a downgraded version.

Thank you very much,

David

RobertCNelson
Applications Engineer

    March 5

alt dpengsberg:
On the hdmi topic, I will see if I can figure out the slim/openbox you mention.

Hi Dave,

Here is one example: (you’ll have to read between the lines, as it’s mixing a qt application into my autostart)

https://www.digikey.com/eewiki/display/linuxonarm/FLIR+Lepton+on+BeagleBone+Black+and+Green#FLIRLeptononBeagleBoneBlackandGreen-ConfigureSLIMforautologin

Regards,

#16

So yes, version 70 and 72 in Debian Stretch are currently “busted” for armhf hardware. (not just the Beagle’s…)

So first, remove your current version of chromium:

sudo apt update
sudo apt remove chromium --purge

Next, using apt-cache, to list every specific version of chromium available.

sudo apt update
sudo apt-cache madison chromium
  chromium | 72.0.3626.122-1~deb9u1 | http://deb.debian.org/debian-security stretch/updates/main armhf Packages
  chromium | 70.0.3538.110-1~deb9u1 | http://deb.debian.org/debian stretch/main armhf Packages
  chromium | 67.0.3396.87-1~deb9u1rcnee0~stretch+20180925 | http://repos.rcn-ee.com/debian stretch/main armhf Packages

Now Install the old version via:

sudo apt -y --allow-downgrades install chromium=67.0.3396.87-1~deb9u1rcnee*

Next, lock the package so apt update/apt upgrade will not automatically upgrade it:

sudo apt-mark hold chromium

Regards,

#17

PS, i did recently try to build 71.0.3578.80-1, but that failed with:

ERROR at //skia/BUILD.gn:54:3: Replacing nonempty list.
  defines = skia_for_chromium_defines
  ^------
This overwrites a previously-defined nonempty list with another nonempty list.
See //third_party/skia/third_party/skcms/skcms.gni:7:15: for previous definition
    defines = [ "SKCMS_PORTABLE=1" ]
              ^--------------------
Did you mean to append/modify instead? If you really want to overwrite, do:
  foo = []
before reassigning.
See //BUILD.gn:69:5: which caused the file to be included.
    "//skia:skia_unittests",
    ^----------------------
debian/rules:96: recipe for target 'override_dh_auto_configure' failed
make[1]: *** [override_dh_auto_configure] Error 1
make[1]: Leaving directory '/<<PKGBUILDDIR>>'

I should check if 72.0.3626.122-1 will build/work on armhf… (it only takes 2-3 days to actually build the package…)

Regards,

#18

Hi Robert,

That worked my project is very close to done. Chromium is complaining, but runs.

debian@beaglebone:~$ chromium

[4103:4194:0315/044831.292466:ERROR:object_proxy.cc(617)]

Failed to call method: org.freedesktop.Notifications.GetCapabilities: object_path= /org/freedesktop/Notifications:

org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Notifications was not provided by any .service files

Can’t read /proc/cpuinfo: Operation not permitted

Can’t read /proc/cpuinfo: Operation not permitted

[4103:4103:0315/044852.626628:ERROR:latency_info.cc(164)]

Surface::TakeLatencyInfoFromFrame, LatencyInfo vector size 101 is too big.

Can’t read /proc/cpuinfo: Operation not permitted

Can’t read /proc/cpuinfo: Operation not permitted

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.

MAYBE there is a simpler way. I tried an fprintf, but also get the segmentation error. This approach seems very complicated for turning digital outputs on and off.

FILE *export_file = NULL;

FILE *IO_direction = NULL;

char *strlow = “low”;

char *strhigh = “high”;

char strgpio = “23”; // GPIO0_23 means 032 + 23 = 23. Hence pass this value to the ‘export’ file.

export_file = fopen ("/sys/class/gpio/export", “w”);

fwrite (strgpio, 1, sizeof(strgpio), export_file);

fclose (export_file);

for (int i=0;i< 100; i++) {

IO_direction = fopen ("/sys/class/gpio/gpio23/direction", “w”);

fwrite (strhigh, 1, sizeof(strhigh), IO_direction); //set the pin to HIGH

fclose (IO_direction);

usleep (1000000);

IO_direction = fopen ("/sys/class/gpio/gpio23/direction", “w”);

fwrite (strlow, 1, sizeof(strlow), IO_direction); //set the pin to LOW

fclose (IO_direction);

usleep (1000000);

}

export_file = fopen ("/sys/class/gpio/unexport", “w”); //remove the mapping

fwrite (strgpio, 1, sizeof(strgpio), export_file);

fclose (export_file);

RobertCNelson
Applications Engineer

    March 14

alt dpengsberg:
Can you please tell me how to install downgraded chromium? Do I first install current version and then install the lower version on top? Do I simply install the 67 version on a fresh image? LXQT image uses 67.0.3396.87 - can’t seem to find instructions on how to install a downgraded version.

So yes, version 70 and 72 in Debian Stretch are currently “busted” for armhf hardware. (not just the Beagle’s…)

So first, remove your current version of chromium:

sudo apt update
sudo apt remove chromium --purge

Next, using apt-cache, to list every specific version of chromium available.

sudo apt update
sudo apt-cache madison chromium

  chromium | 72.0.3626.122-1~deb9u1 | http://deb.debian.org/debian-security stretch/updates/main armhf Packages
chromium | 70.0.3538.110-1~deb9u1 | http://deb.debian.org/debian stretch/main armhf Packages
chromium | 67.0.3396.87-1~deb9u1rcnee0~stretch+20180925 | http://repos.rcn-ee.com/debian stretch/main armhf Packages

Now Install the old version via:

sudo apt -y --allow-downgrades install chromium=67.0.3396.87-1~deb9u1rcnee*

Next, lock the package so apt update/apt upgrade will not automatically upgrade it:

sudo apt-mark hold chromium

Regards,

#19

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

Then you can toggle it like so:

echo 1 > /sys/class/leds/*name*/brightness
echo 0 > /sys/class/leds/*name*/brightness
echo 1 > /sys/class/leds/*name*/brightness

Regards,

#20

Thank you very much Robert.

I have another requirement, which is to measure 3 incoming pwm signals, modify the pulse width based on a value being received from the CAN bus, then output the 3 modified pwm signals.

The incoming pwm is 20 milliseconds over all (50 hz) with the pulse width varying between 1.0 to 2.0 milliseconds. The output is the same specs, although the pulse width will be slightly different than the incoming based on an offset from the CAN value.

Do you think the BeagleBone Black has the capability and speed to do this?

Can I accurately measure the incoming pwm, as well as accurately output one?

Again, C would be the language.

Thanks,

Dave

#21

@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,

#22

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,

#23

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,

#24

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,

#25

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,

#26

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,

#27
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,

#28

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,

#29

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,

#30

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,

#31

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.

#32

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

Regards,

#33

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: