When such a cape is plugged in, the description of the devices connected to the board should be updated accordingly. As the available hardware is described by a Device Tree, the added devices on the cape should be described using a Device Tree Overlay.
Every time you plug in a different cape, you have to tweak the sequence of commands to load the right overlay (the
.dtbo file). It would be great if each cape could be detected automatically and so could be the corresponding overlays.
Actually, all this is possible and already supported in mainline U-Boot starting from version 2021.07.
Each cape has to contain an I2C EEPROM describing itself, according to the Cape EEPROM Contents specification.
To identify which capes are plugged in, all you have to do is read the connected EEPROMs.
In the latest Debian images proposed by BeagleBoard.org at the time of this writing, there is already a mechanism to detect the plugged capes based on the information on their I2C EEPROM. However, that was a custom mechanism, and BeagleBoard.org contracted Bootlin to implement a more generic mechanism in the official version of U-Boot.
You can read the details in the post on the BeagleBoard Blog.