driver development platform

Task: Complete the writing of the LED driver based on the platform driver model to realize the lighting of three lamps Application layer program #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #define LED_ON _IOW(‘l’,1,int) #define LED_OFF _IOW(‘l’,0,int) int main(int argc, char const *argv[]) { //Open the […]

Platform bus realizes LED lights turning on and off

head File #ifndef __HEAD_H__ #define __HEAD_H__ #define LED_ON _IO(‘l’, 1) #define LED_OFF _IO(‘l’, 0) #endif application code #include <stdio.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/ioctl.h> #include <unistd.h> #include “head.h” int main(int argc, char const *argv[]) { int fd = open(“/dev/myled0”, O_RDWR); if(fd < 0) { printf(“Failed to open device file\ “); return -1; […]

Control LED lights based on platform model

#define LED_ON _IOW(‘l’,1,int *) #define LED_OFF _IOW(‘l’,0,int *) text.c #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include “head.h” int main(int argc,const char * argv[]) { int a; int b; while(1) { int fd; //Get the function we want to implement from the interrupt printf(“Please select the lights to […]

Based on the platform driver model, the LED driver is written through the (gpiod_get_from_of_node) function.

pdri.ko #include <linux/init.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/mod_devicetable.h> #include <linux/of.h> #include <linux/of_gpio.h> struct resource *res; unsigned int irq1; struct gpio_desc *gpiono1; struct gpio_desc *gpiono2; struct gpio_desc *gpiono3; struct platform_device *pdev1; struct class *cls; struct device *dev; int major; char kbuf[128] = {0}; //Define operation method int mycdev_open(struct inode *inode, struct file *file) { printk(“%s:%s:%d\ […]

Zhengdian Atom embedded linux driver development – platform driver under the device tree

In the previous note, I explained in detail the driver separation and layering under Linux, as well as the driver framework such as buses, devices and drivers. Based on the driver framework of buses, devices and drivers, the Linux kernel proposes the platform virtual bus, and correspondingly there are platform devices and platform drivers. The […]

An LED platform driver case

This case is used for copying homework. You can quickly write the driver by directly copying and modifying it. When you are very familiar with the driver, you don’t need to write every time. Unless you are unfamiliar with the driver, it is recommended to type the code manually; writing the program should be copy […]

[Python third-party package] Quickly obtain hardware information and usage (psutil, platform)

Article directory Preface 1. psutil package 1.1 Install psutil package 1.2 How to use psutil Get CPU usage Get memory usage Change memory usage into GB and MB Get disk usage Disk memory for conversion Get network information Network info 2. platform 2.1 Introduction to platform 2.2 How to use platform Get the name of […]

platform bus matching principle

Linux Platform probe matching There is a lot of information on the platform driver model online. Here we mainly analyze the probe process from driver registration. driver registration platform_driver_register(xxx) called platform_driver_register (include/linux/platform_device.h) #define platform_driver_register(drv) __platform_driver_register(drv, THIS_MODULE) __platform_driver_register function (drivers/base/platform.c), filled in the drv->driver structure int __platform_driver_register(struct platform_driver *drv, struct module *owner) {<!– –> drv->driver.owner = […]

Introduction to OpenCV: Other Platforms – Building OpenCV for Tegra using CUDA OpenCV v4.8.0

Previous tutorial: Cross-compilation of ARM-based Linux system Next tutorial: Getting started with images Original author Randy J. Ray Compatibility OpenCV >= 3.1.0 Warning This tutorial is outdated. OpenCV for Tegra using CUDA This document is a basic guide to building a CUDA-enabled OpenCV library in a Tegra environment. It covers the basic elements of building […]