Add script to auto-generate linux drivers for peripherals#411
Merged
jjts merged 35 commits intoIObundle:mainfrom Dec 5, 2025
Merged
Add script to auto-generate linux drivers for peripherals#411jjts merged 35 commits intoIObundle:mainfrom
jjts merged 35 commits intoIObundle:mainfrom
Conversation
(iob_timer as demo)
Linux-compatible peripheral cores can add this software module to their subblocks list to auto-generate linux device drivers.
Functions based on outdated `drivers.py` script at: https://github.com/IObundle/iob-linux/blob/3f78ef1c684cd734e74f55a45b4e1c52c36865af/scripts/drivers.py
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.
P-Miranda
approved these changes
Dec 3, 2025
Contributor
There was a problem hiding this comment.
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_driverssoftware 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.vhincludes 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.
py2hwsw/lib/software/iob_linux_device_drivers/scripts/create_peripheral_device_drivers.py
Outdated
Show resolved
Hide resolved
py2hwsw/lib/software/iob_linux_device_drivers/iob_linux_device_drivers.py
Show resolved
Hide resolved
py2hwsw/lib/software/iob_linux_device_drivers/scripts/create_peripheral_device_drivers.py
Outdated
Show resolved
Hide resolved
py2hwsw/lib/software/iob_linux_device_drivers/scripts/create_peripheral_device_drivers.py
Outdated
Show resolved
Hide resolved
py2hwsw/lib/software/iob_linux_device_drivers/scripts/create_peripheral_device_drivers.py
Outdated
Show resolved
Hide resolved
py2hwsw/lib/software/iob_linux_device_drivers/scripts/create_peripheral_device_drivers.py
Show resolved
Hide resolved
py2hwsw/lib/software/iob_linux_device_drivers/scripts/create_peripheral_device_drivers.py
Show resolved
Hide resolved
py2hwsw/lib/software/iob_linux_device_drivers/scripts/create_peripheral_device_drivers.py
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a dependency of PR IObundle/soc-linux#5
iob_linux_device_driverssoftware module.Include this module in the
sw_moduleslist of peripheral cores to auto-generate the kernel module and corresponding user-space programs for them, using the Linux sysfs interfaceiob_linux_device_driversto list of iob_timersw_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:
iob_linux_device_driversmodule.iob_system_linuxrootfs 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.