Skip to content

Add script to auto-generate linux drivers for peripherals#411

Merged
jjts merged 35 commits intoIObundle:mainfrom
arturum1:linux_csrs_script
Dec 5, 2025
Merged

Add script to auto-generate linux drivers for peripherals#411
jjts merged 35 commits intoIObundle:mainfrom
arturum1:linux_csrs_script

Conversation

@arturum1
Copy link
Contributor

@arturum1 arturum1 commented Dec 2, 2025

This is a dependency of PR IObundle/soc-linux#5

  • Remove old buildroot files
  • Add new iob_linux_device_drivers software module.
    Include this module in the sw_modules list of peripheral cores to auto-generate the kernel module and corresponding user-space programs for them, using the Linux sysfs interface
  • Remove deprecated iob_timer Linux sources and add iob_linux_device_drivers to list of iob_timer sw_modules.
    Now, the Linux kernel module and user-space sources for the iob_timer core are generated during its setup process, under the 'software/linux/' folder of it's build directory.
    Setup the iob_timer core and list the generated sources with:
    make sim-run CORE=iob_timer
    tree ../../../iob_timer_V0.81/software/linux
    
  • Update device_driver_tutorial.md with info about iob_linux_device_drivers module.
  • Update iob_system_linux rootfs to include a pre-compiled version of the new auto-generated iob_timer kernel module driver and associated user-space functions. It also includes a pre-compiled user-space program to test the iob_timer driver.

Linux-compatible peripheral cores can add this software module to their
subblocks list to auto-generate linux device drivers.
Macros are no longer genereated in <corename>_csrs.h file.
Now, they are directly generated in <corename>_csrs_conf.h file (and
<corename>_csrs_conf.vh).

The <corename>_csrs.vh file is also no longer required.
`<corename>_csrs.vh` is no longer used, since its macros are now included
in `<corename>_csrs_conf.vh`.
….c` file.

Remove hardcoded linux driver files of iob_timer. Now, they are
automatically generated by the `iob_linux_device_drivers.py` module.

Temporarily disable generation of `*_user.c` file, since it contains
core-specific functions, that cannot currently be generated automatically.
Possible future improvement: emulate `iob_timer_csrs_set_<csr_name>` functions for sysfs.
Remove unused files and include auto-generated timer kernel module, and
usesrspace test program. Update minicom script to test timer driver.
Update 'iob_linux_device_drivers' module to generate
user-space CSR access functions similar to the ones generated for
embedded firmware.
Removing the extra space makes it consistent with the other compatible
strings in iob_system device tree.
Fix call to 'timer_get_count()' function.
@jjts jjts requested review from P-Miranda and Copilot and removed request for Copilot December 2, 2025 19:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces automated generation of Linux device drivers for peripheral cores using the new iob_linux_device_drivers software module. The implementation automates the creation of kernel modules and user-space programs that interface with peripherals via the Linux sysfs interface.

Key Changes:

  • Added iob_linux_device_drivers software module with script to auto-generate Linux kernel drivers and user-space code
  • Updated CSR generation to append macros to core's configuration list instead of generating separate header files
  • Replaced deprecated iob_timer Linux sources with auto-generated versions
  • Updated multiple peripherals to use *_csrs_conf.vh includes instead of *_csrs.vh

Reviewed changes

Copilot reviewed 44 out of 48 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
py2hwsw/lib/software/iob_linux_device_drivers/scripts/create_peripheral_device_drivers.py Main script that generates Linux device driver files (kernel module, sysfs interface, user-space code)
py2hwsw/lib/software/iob_linux_device_drivers/iob_linux_device_drivers.py Software module entry point that invokes driver generation for peripheral cores
py2hwsw/lib/hardware/iob_csrs/scripts/csr_gen.py Modified to generate CSR macros in core's confs list and update parameter evaluation logic
py2hwsw/lib/hardware/iob_csrs/scripts/reg_gen.py Removed duplicate CSR header generation, now handled via confs macros
py2hwsw/lib/peripherals/iob_timer/iob_timer.py Added iob_linux_device_drivers to sw_modules list to enable auto-generation
py2hwsw/lib/peripherals/iob_timer/software/linux/user/iob_timer_user.c Updated to use new auto-generated timer functions
py2hwsw/lib/peripherals/iob_timer/software/linux/* Removed old manually-written driver files (replaced by auto-generated)
py2hwsw/lib/peripherals/*/hardware/**/*.v Updated include directives from *_csrs.vh to *_csrs_conf.vh
py2hwsw/lib/iob_system/iob_system_linux/software/buildroot/board/IObundle/iob-soc/rootfs-overlay/** Updated rootfs with pre-compiled iob_timer driver and removed old DMA demo helper files
py2hwsw/lib/iob_system/iob_system_linux/document/device_driver_tutorial.md Added documentation about automated driver generation using new module
.ignore_file_headers Added entries for LICENSES directory and mdev configuration files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jjts jjts merged commit 871e36a into IObundle:main Dec 5, 2025
2 checks passed
@arturum1 arturum1 deleted the linux_csrs_script branch December 29, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants