This invention belongs to the field of PCIe device technology, specifically providing a method, apparatus, device, and medium for automatically adjusting
transmitter balance values. The method includes the following steps: When the
BIOS starts PCIe link training, it iterates and checks whether there are any PCIe devices connected to the PCIe root ports on the CPU side; when a PCIe device is detected, pre-write values to the secondary
bus register and auxiliary
bus register of each PCIe root port; read the
manufacturer code and device code of the PCIe device connected to the secondary
bus; compare the read
manufacturer code and device code with the
manufacturer code and device code of the PCIe device whose
transmitter balance value needs to be adjusted; when the comparison results match, call the write function to write the
transmitter balance value and make the written transmitter balance value effective. This can save testing, production, and maintenance time.