Linux device driver development using QEMU - introduction
- May 19, 2024
In the previous posts I introduced simple methods to prepare and run a QEMU image for board emulation. Target board was Cubieboard and mainline U-Boot and Linux kernel were used for testing. The goal of those posts was to show how to use QEMU for board emulation.
In this blog post series I will go deeper into the topics of device driver and userspace application development for embedded Linux systems.
We will continue using QEMU for testing. There are multiple benefits from using QEMU over some standard COTS board:
- it is cheaper, there is no need to buy additional hardware, also making it easier to try and follow
- ‘new’ hardware can be designed in QEMU, compared to COTS board where hardware cannot change and drivers are already
available
- even if we consider connecting peripherals over external parallel or serial buses as ‘changing the COTS board’, drivers already exist even for those peripherals
- it is easier to debug during development in QEMU
There is also a possibility to use FPGA-SoC boards, where custom peripherals can be created in the FPGA part, but it is more complex and also requires the board to be available.
The goals of this post series would be to show development of
- Custom memory-mapped peripheral in QEMU: covers basic steps for creating a new memory-mapped peripheral in QEMU, how to integrate it and simple testing.
- Linux Device Driver for QEMU custom memory-mapped peripheral: covers structure of a Linux device driver that can be used to initialize and interact with developed custom memory-mapped device.
- Userspace application for custom QEMU memory-mapped peripheral: covers a simple C++/CMake userspace application which interacts with the device using sysfs attributes.