How does QgroundControl identify which MCU is used in the target hardware platform and which peripherals are connected?

In the PX4 user guide it is mentioned that “PX4 users generally do not need to know very much about FMU versions” and "QgroundControl automatically downloads the correct firmware for a connected autopilot (based on its FMU version “under the hood”). how is this achieved?
How does QgroundControl identify which MCU is used in the target hardware platform and which peripherals are connected?
Thanks.

The bootloaders have a board type built in, e.g. Pixhawk 4 (fmu-v5):

The firmware then has to match that, e.g.:

In the board directory there is then a lot of the configuration, e.g. which modules and drivers are built and started:

Common peripherals are mostly shared between boards and auto-detected (e.g. Ublox GPS), others are enabled using parameters (e.g. a lidar).

Also check out:

Thanks.
But nothing to do with hardware? In pixhawk’s DS-019 documentation, two voltage values, REVISION and VERSION, and an EEPROM logic are defined, which are not used at all?
Looking forward to your reply, thank you!

That’s for finer grained versions and revisions within a board, e.g. for Pixhawk 6X boards.

Thank you very much!