Modifying a BSP to Support io-sock

Updated: April 19, 2023

If QNX does not provide a BSP that supports io-sock for your target hardware, you need to create one. To simplify the process, QNX recommends that you start with the io-sock-compatible BSP provided by QNX that most closely matches your target's specifications.

If you choose to use an existing custom BSP, you must rebuild it with a modified buildfile that adds the appropriate libraries and utilities and loads io-sock resources.

The new or modified buildfile must use io-sock versions of resources wherever they exist. The use -i command allows you to see which package a library came from. For a list of utilities that have io-sock versions, see “Networking utilities and services.”

In addition, you should remove or exclude all io-pkt resource manager (io-pkt-*) and io-pkt network drivers (devnp-*).

For detailed information on building a BSP, see the documentation for your BSP and the Working with QNX BSPs chapter in Building Embedded Systems.

Specifying io-sock versions of files

Where both io-pkt and io-sock versions of files are available, your buildfile must add the io-sock versions. The io-sock versions of binaries and configuration files are found in the following locations:

Revise your buildfile to add the appropriate versions, for both files that are specified using relative paths and ones it adds using full paths:

Detecting io-pkt binaries to remove

To detect binaries that link to the wrong libraries, add the [autoso=list] attribute to the beginning of the buildfile. For example:
[autoso=list]
[-optional]
[+keeplinked]
[image=0x2000000]
[virtual=x86_64,bios +compress] boot = {
    startup-x86 
    PATH=/proc/boot:/sbin:/bin:/usr/bin:/usr/sbin:/usr/libexec
    LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll:/lib/dll/pci procnto-smp-instr 
}
...                   
For each missing shared library, mkifs prints a line to standard error output. You can then locate the binary that generated the error and replace it with the correct one. For example, if the buildfile adds an io-pkt application that needs libsocket.so.3, mkifs prints the following error:
$ mkifs -r ../../install  x86_64-generic-bios.build x86_64-generic-bios.bin
Host file 'libsocket.so.3' not available.
$

You can also identify binaries that are not built for io-sock by executing the following command on the target:

for x in `find . -type f`; do strings $x | grep -q 'libsocket.so.3' && echo $x ; done

If libsocket.so.3 is found, you need to modify your BSP to build with the correct binary (see Specifying io-sock versions of files).

Networking applications

Include the following networking applications and files, from the specified locations.

The list includes the following optional utilities, which are useful for debugging tasks:

...

[search=../../install/${PROCESSOR}:../../install:${QNX_TARGET}/${PROCESSOR}/io-sock:
    ${QNX_TARGET}/io-sock:${QNX_TARGET}/${PROCESSOR}:${QNX_TARGET}]

...

/sbin/dhclient=sbin/dhclient
/sbin/dhclient-script=sbin/dhclient-script
/sbin/ifconfig=sbin/ifconfig
/sbin/io-sock=sbin/io-sock
/sbin/pfctl=sbin/pfctl
[uid=0 gid=0 perms=4755] /sbin/ping=sbin/ping
/sbin/route=sbin/route
/sbin/sysctl=sbin/sysctl

/usr/bin/ftp=usr/bin/ftp
/usr/bin/netstat=usr/bin/netstat
/usr/bin/sockstat=usr/bin/sockstat
/usr/bin/vmstat=usr/bin/vmstat

/usr/sbin/arp=usr/sbin/arp
/usr/sbin/devctl=usr/sbin/devctl
/usr/sbin/devinfo=usr/sbin/devinfo
/usr/sbin/fs-nfs3=usr/sbin/fs-nfs3
/usr/sbin/if_up=usr/sbin/if_up
/usr/sbin/ifmcstat=usr/sbin/ifmcstat
/usr/sbin/ifwatchd=usr/sbin/ifwatchd
/usr/sbin/ip6addrctl=usr/sbin/ip6addrctl
/usr/sbin/ndp=usr/sbin/ndp
/usr/sbin/rtsold=usr/sbin/rtsold
/usr/sbin/tcpdump=usr/sbin/tcpdump
[uid=0 gid=0 perms=4755] /usr/sbin/traceroute=usr/sbin/traceroute
[uid=0 gid=0 perms=4755] /usr/sbin/traceroute6=usr/sbin/traceroute6

/etc/dhclient.conf=etc/dhclient.conf
/etc/ftpusers=etc/ftpusers
/etc/hosts=etc/hosts
/etc/netconfig=etc/netconfig
/etc/protocols=etc/protocols
/etc/services=etc/services

Required networking services and telnet support

Include the following networking services, from the specified locations.

Alert: Because it allows telnet access to root without a password and passes passwords over the network without encryption, the inetd.conf, ftpd.conf, and esh configuration in this example is very insecure. While it is useful for initial setup and testing of a new board, do not use it a production environment or over a network.

If you need network access, use a secure protocol like ssh (e.g., OpenSSH).

...

[search=../../install/${PROCESSOR}:../../install:${QNX_TARGET}/${PROCESSOR}/io-sock:
    ${QNX_TARGET}/io-sock:${QNX_TARGET}/${PROCESSOR}:${QNX_TARGET}]

...

[uid=0 gid=0 perms=0755] /usr/sbin/inetd=usr/sbin/inetd
[uid=0 gid=0 perms=0755] /usr/sbin/sshd=usr/sbin/sshd

[uid=0 gid=0 perms=0755] /usr/bin/scp=usr/bin/scp
[uid=0 gid=0 perms=0755] /usr/bin/ssh=usr/bin/ssh

[uid=0 gid=0 perms=0755] /usr/libexec/ftpd=usr/libexec/ftpd
[uid=0 gid=0 perms=0755] /usr/libexec/telnetd=usr/libexec/telnetd

[uid=0 gid=0 perms=0755]/etc/newif.sh = {
#!/bin/sh
ifconfig $1 up
}

[uid=0 gid=0 perms=0755]/etc/up.sh = {
#!/bin/sh
dhclient -m -lf /dev/shmem/dhclient.leases.$1 -pf /dev/shmem/dhclient.pid.$1 -nw $1
}

[uid=0 gid=0 perms=0755]/etc/down.sh = {
#!/bin/sh
dhclient -m -lf /dev/shmem/dhclient.leases.$1 -pf /dev/shmem/dhclient.pid.$1 -x $1
}

/etc/inetd.conf = {
telnet stream tcp nowait root /usr/libexec/telnetd in.telnetd
ftp stream tcp nowait root /usr/libexec/ftpd in.ftpd -l
}

/etc/ftpd.conf = {
/* Make things a+rw by default */
umask all 0000
}

/etc/esh = {
}

Adding drivers and libraries

Include one or more of the io-sock network drivers:

To support: Include:
ifconfig (for io-sock) libexpat.so
arp, vmstat, or netstat libxo.so.0
inetd librpc.so
USB network drivers devs-libusbdci.so and libusbdci.so
PCI network drivers devs-libpci.so and PCI libraries (see example below)
FDT network drivers devs-libfdt.so and libfdt.so

For example, if your target has PCI and USB interfaces:

[search=${QNX_TARGET}/${PROCESSOR}/io-sock/lib] /lib/libsocket.so=libsocket.so 

[search=${QNX_TARGET}/${PROCESSOR}/io-sock/lib/dll] /lib/dll/devs-libpci.so=devs-libpci.so

[search=${QNX_TARGET}/${PROCESSOR}/io-sock/lib/dll] /lib/dll/devs-em.so=devs-em.so

[search=${QNX_TARGET}/${PROCESSOR}/io-sock/lib/dll] /lib/dll/devs-iwm.so=devs-iwm.so

[search=${QNX_TARGET}/${PROCESSOR}/io-sock/lib/dll] /lib/dll/devs-ixgbe.so=devs-ixgbe.so 

[search=${QNX_TARGET}/${PROCESSOR}/io-sock/lib/dll] /lib/dll/devs-re.so=devs-re.so

[search=${QNX_TARGET}/${PROCESSOR}/io-sock/lib/dll] /lib/dll/devs-libusbdci.so=devs-libusbdci.so 

[search=${QNX_TARGET}/${PROCESSOR}/io-sock/lib/dll] /lib/dll/devs-axe.so=devs-axe.so 

[search=${QNX_TARGET}/${PROCESSOR}/io-sock/lib/dll] /lib/dll/devs-axge.so=devs-axge.so 

[search=${QNX_TARGET}/${PROCESSOR}/io-sock/lib/dll] /lib/dll/devs-cdce.so=devs-cdce.so

[search=${QNX_TARGET}/${PROCESSOR}/io-sock/lib/dll] /lib/dll/devs-smsc.so=devs-smsc.so

[search=${QNX_TARGET}/${PROCESSOR}/io-sock/lib/dll] /lib/dll/devs-urndis.so=devs-urndis.so

################################################################################################
## Network driver shared libraries
################################################################################################
/usr/lib/libexpat.so=usr/lib/libexpat.so
/usr/lib/libxo.so.0=usr/lib/libxo.so.0

/lib/libsocket.so=lib/libsocket.so

/usr/lib/librpc.so=usr/lib/librpc.so

################################################################################################
## USB device shared libraries
################################################################################################
/lib/libusbdci.so=lib/libusbdci.so

################################################################################################
## PCI driver HW Modules and configuration file
################################################################################################
/lib/dll/pci/pci_hw-AMD_x86.so=lib/dll/pci/pci_hw-AMD_x86.so
/lib/dll/pci/pci_hw-Intel_x86.so=lib/dll/pci/pci_hw-Intel_x86.so


################################################################################################
## PCIe driver shared libraries
################################################################################################
/lib/libpci.so=lib/libpci.so
/lib/dll/pci/pci_bkwd_compat.so=lib/dll/pci/pci_bkwd_compat.so
/lib/dll/pci/pci_cap-0x01.so=lib/dll/pci/pci_cap-0x01.so
/lib/dll/pci/pci_cap-0x04.so=lib/dll/pci/pci_cap-0x04.so
/lib/dll/pci/pci_cap-0x05.so=lib/dll/pci/pci_cap-0x05.so
/lib/dll/pci/pci_cap-0x07.so=lib/dll/pci/pci_cap-0x07.so
/lib/dll/pci/pci_cap-0x09-ffffffff.so=lib/dll/pci/pci_cap-0x09-ffffffff.so
/lib/dll/pci/pci_cap-0x0d.so=lib/dll/pci/pci_cap-0x0d.so
/lib/dll/pci/pci_cap-0x10-16c3abcd.so=lib/dll/pci/pci_cap-0x10-16c3abcd.so
/lib/dll/pci/pci_cap-0x10-19570400.so=lib/dll/pci/pci_cap-0x10-19570400.so
/lib/dll/pci/pci_cap-0x10.so=lib/dll/pci/pci_cap-0x10.so
/lib/dll/pci/pci_cap-0x11-ffffffff.so=lib/dll/pci/pci_cap-0x11-ffffffff.so
/lib/dll/pci/pci_cap-0x11.so=lib/dll/pci/pci_cap-0x11.so
/lib/dll/pci/pci_cap-0x12.so=lib/dll/pci/pci_cap-0x12.so
/lib/dll/pci/pci_cap-0x13.so=lib/dll/pci/pci_cap-0x13.so
/lib/dll/pci/pci_debug.so=lib/dll/pci/pci_debug.so
/lib/dll/pci/pci_debug2.so=lib/dll/pci/pci_debug2.so
/lib/dll/pci/pci_server-buscfg-generic.so=lib/dll/pci/pci_server-buscfg-generic.so
/lib/dll/pci/pci_server-buscfg-hotplug.so=lib/dll/pci/pci_server-buscfg-hotplug.so
/lib/dll/pci/pci_server-buscfg2-generic.so=lib/dll/pci/pci_server-buscfg2-generic.so
/lib/dll/pci/pci_server-buscfg2-hotplug.so=lib/dll/pci/pci_server-buscfg2-hotplug.so
/lib/dll/pci/pci_server-enable_features.so=lib/dll/pci/pci_server-enable_features.so
/lib/dll/pci/pci_server-event_handler.so=lib/dll/pci/pci_server-event_handler.so
/lib/dll/pci/pci_server-namespace.so=lib/dll/pci/pci_server-namespace.so
/lib/dll/pci/pci_slog.so=lib/dll/pci/pci_slog.so
/lib/dll/pci/pci_slog2.so=lib/dll/pci/pci_slog2.so
/lib/dll/pci/pci_strings.so=lib/dll/pci/pci_strings.so
/lib/dll/pci/pcie_xcap-0x0001.so=lib/dll/pci/pcie_xcap-0x0001.so
/lib/dll/pci/pcie_xcap-0x0003.so=lib/dll/pci/pcie_xcap-0x0003.so
/lib/dll/pci/pcie_xcap-0x000b-ffffffff.so=lib/dll/pci/pcie_xcap-0x000b-ffffffff.so
/lib/dll/pci/pcie_xcap-0x0015.so=lib/dll/pci/pcie_xcap-0x0015.so

Default interface names

In some cases, io-sock uses different default device or interface names than io-pkt.

io-pkt io-sock
Driver Default device/interface name Driver name Default device/interface name
devnp-asix.so (100 Mb/s) ax devs-axe.so axe
devnp-asix.so (1 Gb/s) ax devs-axge.so axge
devnp-dwceqos.so dwc0 devs-dwceqos.so dwceqos0
devnp-dwcmac.so dwc0 devs-dwc.so dwc0
devnp-e1000.so wm devs-em.so em or igb
devnp-genet.so genet0 devs-genet.so genet0
devnp-ixgbe.so ix devs-ixgbe.so ix
devnp-mx8xp.so mx8xp0 devs-ffec.so ffec0
devnp-rtl8169.so rt devs-re.so re
devnp-smsc9500.so sc devs-smsc.so smsc
devnp-speedo.so fxp FreeBSD's fxp module (not provided by QNX Neutrino) fxp
devnp-usbdnet.so (device mode) ecm, ncm devs-cdce.so cdce
rndis Currently not supported N/A
devnp-usbnet.so (host mode) ecm, ncm devs-cdce.so cdce
rndis devs-urndis.so urndis
mbim, iph Currently not supported N/A
devnp-vmxnet3.so vx devs-vmx.so vmx

Starting io-sock and bringing up the interfaces

Start io-sock with all networking interfaces. For example, if your target has PCI and USB interfaces:

io-sock -d em -d iwm -d ixgbe -d re -d axe -d axge -d cdce -d smsc -d urndis

Run ifwatchd to detect active interfaces. This utility is used to monitor dynamic interfaces for address changes, and to monitor static interfaces for carrier changes. For example:

ifwatchd -A /etc/newif.sh -D /etc/down.sh -c /etc/up.sh -n /etc/down.sh
    em0 igb0 wlan0 ixgbe0 re0 axe0 axge0 cdce0 smsc0 urndis0

where:

  • /etc/newif.sh defines commands to invoke for new interfaces.
  • /etc/up.sh defines commands to invoke when the carrier status changes from no carrier to carrier.
  • /etc/down.sh defines commands to invoke when new interfaces depart (e.g., card is removed).

For example:

[uid=0 gid=0 perms=0755]/etc/newif.sh = {
#!/bin/sh
ifconfig $1 up
}

[uid=0 gid=0 perms=0755]/etc/up.sh = {
#!/bin/sh
dhclient -m -lf /dev/shmem/dhclient.leases.$1 -pf /dev/shmem/dhclient.pid.$1 -nw $1
}

[uid=0 gid=0 perms=0755]/etc/down.sh = {
#!/bin/sh
dhclient -m -lf /dev/shmem/dhclient.leases.$1 -pf /dev/shmem/dhclient.pid.$1 -x $1
}
Alternatively, for simple static network configurations, you can use if_up to wait for an interface to be ready for configuration. For example:
io-sock -d em
if_up -p em0
ifconfig em0 172.16.129.1/24 up
Although waitfor is often used for synchronization tasks, it is not reliable to use it on networking resources such as /dev/socket or /dev/io-sock/devs-em.so/em0 to determine if the interface is ready.

Setting up DNS

When you set up DNS (Domain Name Service), make sure that you provide a default IPv6 route. For example, you can add it using ip6addrctl (see https://www.freebsd.org/cgi/man.cgi?query=ip6addrctl&sektion=8&manpath=FreeBSD+13.0-RELEASE+and+Ports):

ip6addrctl add ::ffff:0.0.0.0/96 50 0