form_driver - Linux


form_driver is a command-line utility that generates the code for a Linux register-driver from a provided SVD (SystemView Description) file. It simplifies the process of creating drivers for peripheral devices, easing the development of hardware drivers.


form_driver [-h] [-n [NAME]] [-o [OUTDIR]] [-p [PLATFORM]] [-s [SOC]]
             [-f [FILE]] [-m [MODULE]] [-x [EXTRACTOR]]


  • -h or --help: Display help information.
  • -n [NAME], --name [NAME]: Custom name for the driver (default: derived from SVD file).
  • -o [OUTDIR], --output-dir [OUTDIR]: Directory to generate source files (default: current directory).
  • -p [PLATFORM], --platform [PLATFORM]: Target platform (default: none).
  • -s [SOC], --soc [SOC]: Target System-on-Chip (SoC) (default: none).
  • -f [FILE], --svd [FILE]: Path to SVD file.
  • -m [MODULE], --module [MODULE]: Path to the linker script of a pre-built kernel module.
  • -x [EXTRACTOR], --extractor [EXTRACTOR]: Path to custom extractor for the SVD file (default: form-svd).


Basic Usage

form_driver -f my_peripheral.svd

Generating code for a specific platform

form_driver -p stm32 -s stm32f103 -f my_peripheral.svd

Generating code for a kernel module

form_driver -f my_peripheral.svd -m kernel_module.ld

Common Issues

  • Missing SVD file: Ensure the provided SVD file is present and in the correct format.
  • Unsupported platform or SoC: Verify that the target platform and SoC are supported by the available extractors.
  • Incorrect Linux kernel headers: Ensure the correct headers for the target kernel version are installed on your system.


form_driver can be used with other tools for advanced tasks:

  • generate_dts: Generate Device Tree Source (DTS) bindings for the driver.
  • mk_flash: Create flash images for embedded systems.
  • make: Build the generated driver code as part of a Makefile.

Related Commands

  • svd_parser: Parse SVD files and extract information.
  • dtc: Compile DTS bindings into device tree binary files.