In case of the need of a hard real time operating system in addition to a Linux OS, here it is described howto do that. Additionally the EtherCat library SOEM is also parrt of the system.

Install Debian, a xenomai kernel and needed tools on a BBB.

Download and write the whole AM3358 Debian 10.3 2020-04-06 4GB SD IoT image to a 4GB SD-Card mounted on /dev/sdx.

wget https://debian.beagleboard.org/images/bone-debian-10.3-iot-armhf-2020-04-06-4gb.img.xz
xz -d ./bone-debian-10.3-iot-armhf-2020-04-06-4gb.img.xz
sudo dd if=./bone-debian-10.3-iot-armhf-2020-04-06-4gb.img of=/dev/sdx bs=1M status=progress

After writing the SD card, insert it into the BBB and power on. The only connection needed is via USB. Over USB comes

  • Power
  • USB file access
  • Network

Login to the BBB:

~$: ssh debian@beaglebone.local
Password: temppwd

Internet access on BBB

The BBB is connected via USB CDC Ethernet to the host PC. Both must be configured to have BBB connectivity to the internet.

Routing

Add a temporary default route to the routing table. The gateway must be the ip on the host USB ethernet adapter.

debian@beaglebone:~$ sudo route add default gw 192.168.6.1
debian@beaglebone:~$ sudo route add default gw 192.168.7.1

Check routing table.

debian@beaglebone:~$ ip route
default via 192.168.6.1 dev usb1 
default via 192.168.7.1 dev usb0
192.168.6.0/24 dev usb1 proto kernel scope link src 192.168.6.2 
192.168.7.0/24 dev usb0 proto kernel scope link src 192.168.7.2

DNS

Configure dnsmasq to use a well known nameserver in /etc/resolv.conf and restart dnsmasq.

debian@beaglebone:~$ sudo sh -c "echo \"nameserver 8.8.8.8\" >> /etc/resolv.conf"

Check if internet connection is established.

debian@beaglebone:~$ ping www.debian.org
PING www.debian.org (130.89.148.77) 56(84) bytes of data.
64 bytes from klecker-misc.debian.org (130.89.148.77): icmp_seq=1 ttl=51 time=24.7 ms
64 bytes from klecker-misc.debian.org (130.89.148.77): icmp_seq=2 ttl=51 time=31.1 ms

If this works already, skip the Host configuration for ip forwarding and masquerading.

Persisting routing and DNS

To set routing and DNS in a persistent way, helper scripts are installed into /opt/scripts/network directory by TI which are doing the job. They must be added as systemd services to run at startup and after having network connection. Add following content to the file /lib/systemd/usb_linux_usb0_ics.service:

[Unit]
Description=Sets DNS and routing of usb0 interface
After=multi-user.target
[Service]
Type=simple
ExecStart=/opt/scripts/network/usb_linux_usb0_ics.sh
[Install]
WantedBy=multi-user.target

Do the same for usb1 and create symbolic links for systemd:

debian@beaglebone:~$ cd /etc/systemd/system/
debian@beaglebone:~$ sudo ln /lib/systemd/usb_linux_usb0_ics.service usb_linux_usb0_ics.service
debian@beaglebone:~$ sudo ln /lib/systemd/usb_linux_usb1_ics.service usb_linux_usb1_ics.service

Additionally install resolvconf for handling of /etc/resolv.conf file. It will be overwritten at startup for a clean nameservice resolution.

debian@beaglebone:~$ sudo apt-get install resolvconf

Restart systemd daemon, start and enable the services:

debian@beaglebone:~$ sudo systemctl daemon-reload
debian@beaglebone:~$ sudo systemctl start usb_linux_usb0_ics.service
debian@beaglebone:~$ sudo systemctl enable usb_linux_usb0_ics.service
debian@beaglebone:~$ sudo systemctl start usb_linux_usb1_ics.service
debian@beaglebone:~$ sudo systemctl enable usb_linux_usb1_ics.service

Host

The host need ip forwarding enabled.

debian@host:~$ sudo iptables -P FORWARD ACCEPT

Furthermore masquerading must be enabled for the ip subnet address assigned to the USB ethernet adapter which is connected with BBB.

debian@host:~$ sudo iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.6.0/24

Also copy ssh key from host to beaglebone to be able to login without credential intervention.

debian@host:~$ ssh-copy-id debian@beaglebone.local

SOEM library

Install SOEM library sources, examples and prerequisites.

debian@beaglebone:~$ sudo apt-get install cmake
debian@beaglebone:~$ git clone https://github.com/OpenEtherCATsociety/SOEM.git

Compile library.

debian@beaglebone:~$ cd SOEM
debian@beaglebone:~/SOEM$ mkdir build
debian@beaglebone:~/SOEM$ cd build
debian@beaglebone:~/SOEM/build$ cmake ..
debian@beaglebone:~/SOEM/build$ make

Xenomai

Install Xenomai kernel

Install Xenomai user space tools

This is an extract of the Xenomai documentation.

debian@beaglebone:~$ sudo apt-get install devscripts debhelper git-core git-buildpackage libltdl-dev netcat
debian@beaglebone:~$ git clone https://source.denx.de/Xenomai/xenomai.git
debian@beaglebone:~$ cd xenomai && git fetch origin

Create a new branch for customisation and create debian changelog entry.

debian@beaglebone:~/xenomai$ git checkout -b v3.1-deb v3.1
debian@beaglebone:~/xenomai$ DEBEMAIL="debian@beaglebone" DEBFULLNAME="embedded-engineer.de" debchange -v 3.1 Release 3.1
debian@beaglebone:~/xenomai$ git commit -a --author="embedded" -m 3.1

Build the tools and export as debian packges to the parent directory.

debian@beaglebone:~/xenomai$ gbp buildpackage --git-debian-branch=v3.1-deb --git-export-dir=.. -uc -us

Install debian packages.

debian@beaglebone:~/xenomai$ cd ..
debian@beaglebone:~/$ sudo dpkg -i libxenomai1_3.1_armhf.deb libxenomai-dev_3.1_armhf.deb xenomai-runtime_3.1_armhf.deb

The testsuit for checking realtime capabilities are installed under /usr/lib/xenomai. If they are working, the git repo and the needed development tools could be removed.

debian@beaglebone:~/$ rm -rf xenomai
debian@beaglebone:~/$ sudo apt-get remove devscripts debhelper git-core git-buildpackage libltdl-dev
debian@beaglebone:~/$ sudo apt-get autoremove && sudo apt-get clean

Previous Post Next Post