TechBuzzPro

Dynamic Platform Driver Problem – How to Fix It

· 5 min read · Windows & PC

In this article
  1. What You’ll Need
  2. Step‑by‑Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can resolve a dynamic platform driver problem by verifying the device tree, ensuring the driver is compiled and loaded, and correcting the binding information.

What You’ll Need

  • A Linux development workstation with root access
  • The kernel source tree that matches the running kernel
  • Access to the target board’s device tree source (DTS) files
  • Basic knowledge of make, grep, and the Linux kernel build system
  • Serial console or SSH access to the target for log inspection

Step‑by‑Step

  1. Confirm the symptom. Open a terminal on the target and run dmesg | grep -i "platform". Look for messages such as “no driver found for …” or “failed to bind driver”. Note the exact compatible string or node name that the kernel reports.
  2. Identify the driver source. Search the kernel tree for the driver that should handle the device. For example, grep -R "MODULE_ALIAS.*mydevice" $(pwd)/drivers/ will reveal the source file and the of_match_table entries.
  3. Check the device‑tree entry. Open the relevant .dts or .dtsi file and verify that the compatible property exactly matches one of the strings in the driver’s of_match_table. The match is case‑sensitive and must include any required version suffixes.
  4. Validate the kernel configuration. Run make menuconfig (or make nconfig) in the kernel source and ensure that the driver’s config option is set to m (module) or y (built‑in). Look under the appropriate subsystem (e.g., “Device Drivers → Platform drivers”). Save and exit.
  5. Rebuild and install the kernel or module. If the driver is a module, execute make modules and then make modules_install. For a built‑in driver, rebuild the whole kernel with make -j$(nproc) and flash the new image to the board.
  6. Load the driver. For a module, run modprobe mydriver on the target. Verify that the module appears in lsmod and that dmesg now shows a successful bind message.
  7. Refresh the device tree. If you edited the DTS, recompile it to a DTB with dtc -I dts -O dtb -o myboard.dtb myboard.dts and copy the DTB to the boot partition. Update the bootloader configuration (e.g., bootargs in U‑Boot) to point to the new DTB.
  8. Reboot the board. Power‑cycle or issue reboot. After the system comes up, run dmesg | grep -i mydriver to confirm that the driver bound without errors.
  9. Test functionality. Use the driver’s sysfs entries, character device, or any provided utility to exercise the hardware. For example, cat /sys/class/mydevice/status or mytool --test should return expected values.
  10. Document the fix. Record the compatible string, kernel config option, and any DTS modifications in your project’s README. This prevents the same issue from resurfacing after future updates.

Common Mistakes

  • Using a mismatched compatible string – even a missing dash or extra space prevents the of‑match from succeeding.
  • Leaving the driver compiled as CONFIG_MYDRIVER=n – the kernel will never load a disabled driver.
  • Editing the DTS but forgetting to recompile to DTB or to update the bootloader’s DTB path.
  • Loading a module before the device tree has been parsed; the driver may miss the probe opportunity.
  • Overlooking required clock or regulator definitions in the device tree, which can cause the driver to abort during init.

Tips

  • Enable CONFIG_DEBUG_DRIVER and CONFIG_OF_DYNAMIC to get more verbose binding logs.
  • Use of_property_read_string() in a temporary test module to print the exact compatible string the kernel sees.
  • When working with multiple similar devices, give each node a unique label and reference it in the driver’s platform_get_resource_byname() calls.
  • Keep a copy of the original DTB; you can always compare it with diff after changes to avoid accidental deletions.
  • If the driver is built‑in, you can still force a reload by writing 1 to /sys/bus/platform/drivers/mydriver/unbind and then bind with the device’s name.

Troubleshooting

If the driver still does not bind after following the steps above, try the following escalation path:

  1. Restart the kernel log. Run dmesg -C before rebooting to clear old messages. After reboot, immediately run dmesg | tail -n 30 to capture fresh output.
  2. Verify the DTB in use. On the target, execute cat /proc/device-tree/compatible (or navigate the /proc/device-tree/ hierarchy) to confirm the compatible string present at runtime.
  3. Check for duplicate nodes. Two nodes with the same compatible can cause the kernel to bind the first and ignore the second. Use dtc -I dtb -O dts -o - myboard.dtb | grep compatible to list all entries.
  4. Inspect regulator and clock dependencies. Missing or incorrectly named regulators will appear as “failed to get regulator xyz”. Add the missing regulators node or correct the name.
  5. Force a manual bind. Echo the device’s full path into the driver’s bind file, e.g., echo /sys/devices/platform/mydevice > /sys/bus/platform/drivers/mydriver/bind. Any error message will hint at the missing prerequisite.
  6. Recompile with debug prints. Add pr_debug() statements inside the driver’s probe() function, rebuild, and watch dmesg. This reveals exactly where the probe fails.
  7. Revert recent changes. If the problem appeared after a kernel upgrade, boot the previous kernel version to see whether the driver works there. This isolates upstream regressions.
  8. Seek upstream help. Gather the kernel version, driver source, DTS snippet, and full dmesg output. Open a bug report on the kernel mailing list or the SoC vendor’s support portal.

Frequently Asked Questions

Why does the driver bind on some boards but not others?

Different boards often use distinct compatible strings or require additional resources such as clocks. If the string does not match the driver’s of_match_table, the kernel will skip the probe.

Can I load a platform driver as a module if it was originally built‑in?

Yes, but you must enable the driver’s CONFIG_* option as m, rebuild the kernel, and install the resulting .ko. The driver will then be loadable with modprobe.

What if the device tree shows the correct compatible string but the driver still refuses to bind?

Check for missing regulator or clock definitions, and ensure the driver’s probe() does not return an error due to unavailable resources.

Is it safe to edit the device tree on a production system?

Yes, as long as you keep a backup of the original DTB and test the new DTB on a non‑critical unit first. A malformed DTB can prevent the system from booting.

How do I know which kernel version introduced the binding issue?

Boot previous kernel versions and compare dmesg output. The first version where the driver binds successfully indicates the regression point.

Do I need to restart the whole board after loading a new module?

No. After modprobe, the driver will attempt to bind to any matching devices that are already present. A full reboot is only required after changing the device tree.