1.6. Driver model

barebox has a driver model. This matches the devices on a board with their corresponding drivers. From a user’s point of view this is mostly visible in the devinfo - show information about devices and drvinfo - list compiled-in device drivers commands. Without arguments the devinfo - show information about devices command will show a hierarchical list of devices found on the board. As this may be instantiated from the Devicetree support there may be devices listed for which no driver is available. The drvinfo - list compiled-in device drivers command shows a list of drivers together with the devices they handle.

devinfo - show information about devices also shows a list of device files a device has registered:

`-- 70008000.esdhc
   `-- mmc1
      `-- 0x00000000-0x1d9bfffff (   7.4 GiB): /dev/mmc1
      `-- 0x00100000-0x040fffff (    64 MiB): /dev/mmc1.0
      `-- 0x04100000-0x240fffff (   512 MiB): /dev/mmc1.1
      `-- 0x24100000-0xe40fffff (     3 GiB): /dev/mmc1.2
      `-- 0xe4100000-0x1640fffff (     2 GiB): /dev/mmc1.3
      `-- 0x00080000-0x000fffff (   512 KiB): /dev/mmc1.barebox-environment

In this case the /dev/mmc1* are handled by the mmc1 device. It must be noted that it’s desirable that devices (mmc1) have the same name as the device files (/dev/mmc1*), but this doesn’t always have to be the case.

1.6.1. Device detection

Some devices like USB or MMC may take a longer time to probe. Probing USB devices should not delay booting when USB may not even be used. This case is handled with device detection. The user visible interface to device detection is the detect - detect devices command. detect -l shows a list of detectable devices:

barebox:/ detect -l

A particular device can be detected with detect <devname>:

barebox:/ detect 73f80200.usb
Found SMSC USB331x ULPI transceiver (0x0424:0x0006).
Bus 002 Device 004: ID 13d3:3273 802.11 n WLAN
mdio_bus: miibus0: probed
eth0: got preset MAC address: 00:1c:49:01:03:4b
Bus 002 Device 005: ID 0b95:7720 ZoWii
Bus 002 Device 002: ID 0424:2514
Bus 002 Device 001: ID 0000:0000 EHCI Host Controller

For detecting all devices detect -a can be used.

1.6.2. Device parameters

Devices can have parameters which can be used to configure devices or to provide additional information for a device. The parameters can be listed with the devinfo - show information about devices command. A devinfo <devicename> will print the parameters of a device:

barebox:/ devinfo eth0
  ethaddr: 00:1c:49:01:03:4b

The parameters can be used as shell variables:

echo "my current ip is: $eth0.ipaddr"

device variables may have a type, so assigning wrong values may fail:

barebox:/ eth0.ipaddr="This is not an IP"
set parameter: Invalid argument
barebox:/ echo $?

HINT: barebox has tab completion for variables. Typing eth0.<TAB><TAB> will show the parameters for eth0.