Set static IP address for Beaglebone black

I am doing yocto project (kirkstone) on Beaglebone Black Board using meta-ti layer. How to set static IP address for eth0 in BBB.
These are the contents of my /etc/network/interfaces file.

root@beaglebone:/etc/network#
root@beaglebone:/etc/network# cat interfaces
#/etc/network/interfaces – configuration file for ifup(8), ifdown(8)

#The loopback interface
auto lo
iface lo inet loopback

#Wireless interfaces
iface wlan0 inet dhcp
wireless_mode managed
wireless_essid any
wpa-driver wext
wpa-conf /etc/wpa_supplicant.conf

iface atml0 inet dhcp

#Wired or wireless interfaces
auto eth0
iface eth0 inet dhcp
iface eth1 inet dhcp

#Ethernet/RNDIS gadget (g_ether)
#…or on host side, usbnet and random hwaddr
iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.0
network 192.168.7.0
gateway 192.168.7.1

#Bluetooth networking
iface bnep0 inet dhcp

On the target

$pstree

Let see what that build has installed for networking. Also, you might have to add pstree into your local.conf

Thank you for your reply. I add pstree into my local.conf. it is show like this.

root@beaglebone:~# pstree
init-±apmd
|-avahi-daemon—avahi-daemon
|-bluetoothd
|-connmand
|-dbus-daemon
|-dropbear
|-getty
|-klogd
|-neard
|-ofonod
|-rpcbind
|-start_getty—sh—pstree
|-syslogd
|-udevd
`-wpa_supplicant

What is the static IP you are planning to use?

On the target:

$ip addr show

How are you connecting this to the network?

Unless you have a specific reason for you using the yocto build, the best solution for this to get you up and running would be the use the IoT image for the bbb.

These images are running systemd. If memory is correct about the only thing you might need to add to those images might be gdb and cmake. This image has cockpit installed, you will like that.

I connected an ethernet cable to my BBB.
The ip addr show gave the following output.

root@beaglebone:~# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq qlen 1000
    link/ether 64:8c:bb:f7:74:15 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.125/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::668c:bbff:fef7:7415/64 scope link
       valid_lft forever preferred_lft forever

Next I connected from a PC to BBB using an ethernet cable. The output is


root@beaglebone:~# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq qlen 1000
    link/ether 64:8c:bb:f7:74:15 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::668c:bbff:fef7:7415/64 scope link
       valid_lft forever preferred_lft forever

Actually I need yocto project for my linux based HMI which launches a Qt application on boot. I also want to communicate to other boards through RS485, ethernet and USB from my HMI.

On your host (PC) set your IP to a static address on the same subnet as your BBB.

This is much easier to do if you are running debian or ubuntu. On windows you will have to go several layers deep.

eth0 is working fine and this can be seen from the IP that was assigned by your DHCP server.

I set a static ip address in my linux PC. I gave values for address, subnet and gateway. After that I connected an ethernet cable from PC ethernet port to BBB ethernet port.
I haven’t made any changes in the BBB side. When I checked ifconfig, I got some random IP address. Each time I reboot this address will change.

I run this /etc/init.d/networking restart in my BBB.
It gave me the following error.

[   74.164290] cpsw-switch 4a100000.switch: starting ndev. mode: dual_mac
[   74.189893] cpsw-switch 4a100000.switch: phy "/ocp/interconnect@4a000000/segment@0/target-module@100000/switch@0/mdio@1000/ethernet-phy@0" not found on slave 0

I don’t have anything running connman so I cannot work along with you.

Did check the bing chat bot regarding the connman config.

If you use an exit node from EU instead of USA you will get better information. They are playing games with content delivered to USA endpoints.

You should be able to set static ip per the bing instructions and ping each device.
At this point without having a parallel setup it is hard to troubleshoot.

Bing chat bot:

Certainly! If you’re using ConnMan to manage network connections on your Linux system and want to set a static IP address, here are the steps you can follow:

Identify the Service Name: First, you need to find the service name associated with the network interface you want to configure. You can do this by running the following command:

connmanctl services

Look for the service name corresponding to the network interface (e.g., ethernet_6ceceb5cc3e2_cable or wifi_<HASH>_managed_psk).

Set the Static IP Address: Once you have the service name, use the following command to set a static IP address (replace <service_name> with the actual service name and adjust the IP address, subnet mask, and gateway as needed):

sudo connmanctl config <service_name> --ipv4 manual 10.0.10.0 255.255.0.0

For example, if your service name is ethernet_6ceceb5cc3e2_cable, the command would be:

sudo connmanctl config ethernet_6ceceb5cc3e2_cable --ipv4 manual 10.0.10.0 255.255.0.0

Verify the Configuration: To verify that the static IP address has been set, you can check the configuration file associated with the service. For Wi-Fi networks, the configuration file is located at /var/lib/connman/wifi_<HASH>_managed_psk/settings. You can manually create or edit this file with the desired settings. Here’s an example of the content:

[wifi_<HASH>_managed_psk]
Name=<SSID>
SSID=544f52414445585f4252
Favorite=true
IPv4.method=manual
IPv4.netmask_prefixlen=24
IPv4.local_address=192.168.0.133
IPv4.gateway=192.168.0.1
Passphrase=<PASS>
AutoConnect=true

Replace <SSID> with the network name, <PASS> with the Wi-Fi password, and adjust the IP address as needed.

Remember to replace placeholders like <service_name>, , , and with actual values relevant to your network configuration. If you encounter any issues, refer to the man page for connman-service.config1. Additionally, if you’re configuring Wi-Fi, ensure that the desired IP address is not conflicting with other devices on the network. :globe_with_meridians::wrench:

seem yocto does not install connmanctl, at least with my build
looked at network manager, didn’t seem to work for me either.

You will not get a good image using the ti recipe.
I used good old poky, added the ti layers and my own meta layer. Yocto just takes us so much space i had to delete so much of the stuff done for the BBB to make room for the i7 builds.

The IoT BBB image works just fine and is much simpler the use. Doing a proof of concept with a BBB in the system and regret deleting our previous work…

The yocto image in the yocto example for the BBB works perfectly. If memory is correct networking is up, out of the box with that one.

This is a local.conf we used to get the weston compositor up on bbb. Pretty sure if you just delete the opengl wayland and pam, then repoint the ss-cache and download directory you should get a good image.

MACHINE ?= "beaglebone-yocto"

DL_DIR ?= "/home/fred/build-files/downloads"


SSTATE_DIR ?= "/home/fred/build-files/ss-cache-armhf"


DISTRO ?= "poky"


PACKAGE_CLASSES ?= "package_deb"


INIT_MANAGER = "systemd"
EXTRA_IMAGE_FEATURES ?= " debug-tweaks tools-debug tools-testapps tools-sdk dbg-pkgs dev-pkgs"


USER_CLASSES ?= "buildstats"
DISTRO_FEATURES ?= "opengl wayland pam"



PATCHRESOLVE = "noop"


BB_DISKMON_DIRS ??= "\
    STOPTASKS,${TMPDIR},1G,100K \
    STOPTASKS,${DL_DIR},1G,100K \
    STOPTASKS,${SSTATE_DIR},1G,100K \
    STOPTASKS,/tmp,100M,100K \
    HALT,${TMPDIR},100M,1K \
    HALT,${DL_DIR},100M,1K \
    HALT,${SSTATE_DIR},100M,1K \
    HALT,/tmp,10M,1K"


CONF_VERSION = "2"
```

Here is the layer.conf for that build. I cannot 
post the custom layer so just delete that.

```

```
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"

BBPATH = "${TOPDIR}"
BBFILES ?= ""

BBLAYERS ?= " \
  /home/fred/core-builds/poky/meta \
  /home/fred/core-builds/poky/meta-poky \
  /home/fred/core-builds/poky/meta-yocto-bsp \
  /home/fred/meta-layers/meta-arm/meta-arm-toolchain \
  /home/fred/meta-layers/meta-arm/meta-arm \
  /home/fred/meta-layers/meta-arm/meta-arm-bsp \
  /home/fred/meta-layers/meta-basic-weston-dev \
  /home/fred/meta-layers/meta-openembedded/meta-oe \
  /home/fred/meta-layers/meta-wayland \
  "
```
2 Likes

Here is another one, just pull the line with x11 and remove gtk* and this should also work fine. It might be an SD only due to the other stuff.

MACHINE ?= "beaglebone-yocto"
DISTRO ?= 'poky'
LICENSE_FLAGS_ACCEPTED = 'commercial'
PACKAGE_CLASSES ?= 'package_deb'
EXTRA_IMAGE_FEATURES ?= "debug-tweaks \
						tools-debug \
						tools-testapps \
						tools-sdk \
						dbg-pkgs \
						eclipse-debug \
						tools-profile \
						dev-pkgs"
DISTRO_FEATURES_APPEND = " X11"
PACKAGE_EXCLUDE = "packagegroup-core-ssh-dropbear"
IMAGE_INSTALL:append = " python3 \
	rsync \
	pstree \
	cmake \
	gdb \
	gcc \
	sudo \
	git \
	python3-pip \
	acl \
	openssh \
	nano \
	make \
	xz \
	gzip \
	tree \
	pstree \
	nmap \
	sqlite3 \
	cunit \
	libgpiod \
	libusb1 \
	gtk+3 \
	gtk4 \
	findutils "
	

USER_CLASSES ?= "buildstats"
PATCHRESOLVE = "noop"
BB_DISKMON_DIRS ??= "\
    STOPTASKS,${TMPDIR},1G,100K \
    STOPTASKS,${DL_DIR},1G,100K \
    STOPTASKS,${SSTATE_DIR},1G,100K \
    STOPTASKS,/tmp,100M,100K \
    HALT,${TMPDIR},100M,1K \
    HALT,${DL_DIR},100M,1K \
    HALT,${SSTATE_DIR},100M,1K \
    HALT,/tmp,10M,1K"
PACKAGECONFIG:append:pn-qemu-system-native = " sdl"
CONF_VERSION = "2"

DL_DIR ?= "/home/fred/code/downloads/"
SSTATE_DIR ?= "/home/fred/code/sstate-cache"

#Enable buildhistory
INHERIT += "buildhistory"
BUILDHISTORY_COMMIT = "1"
BUILDHISTORY_DIR ?= "${TOPDIR}/buildhistory"
1 Like

Actually I am using MACHINE = 'beaglebone' of the meta-ti layer for my yocto build.

I run this command to check connman and got this result:

$ connmanctl services
sh: connmanctl: command not found

I added connman to my local.conf file and still got the same result.

I run some commands in my yocto linux.

root@beaglebone:~# service --status-all
 [ - ]  alignment.sh
 [ - ]  alsa-state
 [ + ]  apmd
 [ + ]  avahi-daemon
 [ - ]  banner.sh
 [ + ]  bluetooth
 [ - ]  bootlogd
 [ - ]  bootmisc.sh
 [ - ]  checkroot.sh
 [ ? ]  connman
 [ + ]  dbus-1
 [ - ]  devpts.sh
 [ - ]  dmesg.sh
 [ ? ]  dropbear
 [ - ]  hostname.sh
 [ ? ]  hwclock.sh
 [ - ]  modutils.sh
 [ - ]  mountall.sh
 [ - ]  mountnfs.sh
 [ ? ]  neard
 [ ? ]  networking
 [ ? ]  ofono


root@beaglebone:~# ps aux | grep -E 'connmand'
root       513  0.0  0.6   9920  3088 ?        Ss   12:34   0:00 /usr/sbin/connmand
root      1249  1.0  0.2   2156  1276 ttyS0    S+   12:40   0:00 grep -E connmand

root@beaglebone:/etc# cd init.d
root@beaglebone:/etc/init.d# ls
alignment.sh  banner.sh    checkroot.sh  dmesg.sh     hwclock.sh   mountnfs.sh	populate-volatile.sh  rcS			rpcbind      sshd	    tcf-agent	  urandom
alsa-state    bluetooth    connman	     functions    mdmonitor    neard	    ppp		              read-only-rootfs-hook.sh	save-rtc.sh  stop-bootlogd  udev	  xserver-nodm
apmd	      bootlogd	   dbus-1	     halt	      modutils.sh  networking	psplash.sh	          reboot			sendsigs     sysfs.sh	    umountfs
avahi-daemon  bootmisc.sh  devpts.sh	 hostname.sh  mountall.sh  ofono	    rc		              rmnologin.sh		single	     syslog	    umountnfs.sh

Given below is the content of /etc/init.d/connman

#!/bin/sh

DAEMON=/usr/sbin/connmand
PIDFILE=/var/run/connmand.pid
DESC="Connection Manager"

if [ -f /etc/default/connman ] ; then
	. /etc/default/connman
fi

set -e

nfsroot=0

exec 9<&0 < /proc/mounts
while read dev mtpt fstype rest; do
	if test $mtpt = "/" ; then
		case $fstype in
		    nfs | nfs4)
			nfsroot=1
			break
			;;
		    *)
			;;
		esac
	fi
done

do_start() {
	if test $nfsroot -eq 1 ; then
	    NET_DEVS=`cat /proc/net/dev | sed -ne 's/^\([a-zA-Z0-9 ]*\):.*$/\1/p'`
	    NET_ADDR=`cat /proc/cmdline | sed -ne 's/^.*ip=\([^ :]*\).*$/\1/p'`

	    if [ ! -z "$NET_ADDR" ]; then
		if [ "$NET_ADDR" = dhcp ]; then
		    ethn=`ifconfig | grep "^eth" | sed -e "s/\(eth[0-9]\)\(.*\)/\1/"`
		    if [ ! -z "$ethn" ]; then
			EXTRA_PARAM="$EXTRA_PARAM -I $ethn"
		    fi
		else
		    for i in $NET_DEVS; do
			ADDR=`ifconfig $i | sed 's/addr://g' | sed -ne 's/^.*inet \([0-9.]*\) .*$/\1/p'`
			if [ "$NET_ADDR" = "$ADDR" ]; then
			    EXTRA_PARAM="$EXTRA_PARAM -I $i"
			    break
			fi
		    done
		fi
	    fi
	fi
	if [ -f /usr/share/connman/wired-setup ] ; then
		. /usr/share/connman/wired-setup
	fi
	$DAEMON $EXTRA_PARAM
}

do_stop() {
	start-stop-daemon --stop --name connmand --quiet
}

case "$1" in
  start)
	echo "Starting $DESC"
	do_start
	;;
  stop)
	echo "Stopping $DESC"
	do_stop
	;;
  restart|force-reload)
	echo "Restarting $DESC"
	do_stop
	sleep 1
	do_start
	;;
  *)
	echo "Usage: $0 {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0

Dump the Ti provided information that is from their website and go to the yocto project. Setup yocto exactly as they say and run it.

https://docs.yoctoproject.org/

"MACHINE =beaglebone-yocto"

That should be in the default local.conf. Don’t touch any thing, then do the initial build as they say and test the qemu. When that checks out modify your local config. Also, since you have a download directory from the previous builds, point your “poky” build to that. Or move the download directory into a common ground location, that will save you hours of downloading. Also set up the sscache, use one sscache for armhf and another for arch64.

Also, if you have NVMe move your yocto stuff onto it.

I don’t believe all the Ti layers are much past the kirkstone release, so if you need to use Ti layers you will have to checkout kirkstone.

1 Like

that’s what i did for a nanbield build, don’t remember all the issue he’s having.
testing kirkstone now, will get back

NetworkManager does not seem to work on kirkstone branch
will look at nanbield branch over the week end. already built, just need to program an sdcard and test.

1 Like

I should have thought about this sooner, if you have multiple ethernet interfaces running such as wire and wifi turn one off, the wifi. You will have instability, it does work on both at the same time just be aware so you can restart or turn one off.

Connect your wire directly between bbb and your host.
Assign your host an IP in the IPv4 tab,
manual
address 192.168.60.20
Netmask 255.255.255.0
Gateway 192.168.60.1

You can use what ever subnet and address you need, just make sure all devices are on same subnet and gateway is .1

If you have wifi leave it alone, just toggle it off and on. Preferable leave it off until you get your wire up.

Ok i will try it. But is there any modification should i make in BBB side?

It should be fine, assuming the interface is configured for static.

At this point the best plan would be to load the IoT image on SD and run it. Get your networking configured with static IP first then go back to the yocto build when you know the proper settings. I know for fact the IoT (12) image (flasher) networking works fine, too many unknowns is too much trouble to deal with at one time.

Using the BB IoT image, set this file like mine. You should see the same interface id. This will allow you to have a static IP then if you need to connect to the internet to download packages or whatever you just connect the ethernet to your local gateway/router.

It is best practice to run your dev network on a subnet that is different than your “main” network with internet access.

fred@bb3:/etc/systemd/network$ cat eth0.network 
[Match]
Name=eth0
Type=ether

[Link]
RequiredForOnline=yes

[Network]
Address=192.168.50.65
Address=192.168.0.91
DHCP=ipv4

after including systemd
also this build was with beaglebone-yocto, kirkstone branch

networkctl list
sudo $EDITOR /etc/systemd/network/70-static.network [Match] Name=[INTERFACE_NAME] [Network] Address=[IP_ADDRESS]/[CIDR_NETMASK] Gateway=[GATEWAY_IP_ADDRESS] DNS=[PRIMARY_DNS_IP] DNS=[SECONDARY_DNS_IP]

sudo systemctl restart systemd-networkd
networkctl status

looking back at my note, it seems like they change the network configuration a lot. LOL

1 Like

The systemd networking is the most reliable way to go.

Dropping dropbear and adding systemd to the yocto build he should be good to go. The other issue might be how the host is configured.

2 Likes