Program:
Makefile:
Output: driver interaction
Explanation:
Read and write from or to user space and kernel space (using proc file system)
1) Write data provided by user to proc file system in kernel space as long as there is enough space, else return respective error
2) Read back the written data from kernel space to user space
Functions used: proc_create(), proc_write(), proc_read(), proc_remove()
proc_fs.h: https://github.com/torvalds/linux/blob/master/include/linux/proc_fs.h
Linux commands:
Installation:
1. sudo apt update
2. sudo apt upgrade
3. sudo apt install -y build-essential liunx-headers-$(uname -r) kmod
(build essentials like make, GCC .,. | linux header - for compiling kernel modules | kmod - provides utilities for handling kernel modules)
4. sudo apt install git-all (linux - git install)
Make Automation:
5. make
6. make clean
Module commands:
7. sudo insmod driver.ko (insert our generated object file into kernel)
8. lsmod (list kernel modules - check wheter our module is listed after successful insertion)
lsmod | grep <module_name>
9. sudo dmesg -c (print kernel module messages form log)
10. modinfo driver.ko (get information about module)
11. sudo rmmod driver (remove the module from kernel)
Git commands: (config email and name)
$ git init . -b main
$ git add .
$ git commit -m "commit msg"
$ git status
$ git diff
$ tree .git/
$ git log
/* Push using HTTP url - create new repo in github w/o additional files */
$ git remote add origin <http-url>
$ git push -u origin main
Installed Multipass(Environment inside linux), Virtual box(for Windows user to use Linux), VScode(code editor):
Steps to follow:
1. Launch Multipass from command prompt for Windows (name it primary)
2. Install Remote development in VScode
3. Connect VScode to ubuntu remotely via ssh key using Multipass IP address(in multipass: enable SSH, reload SSH, set password for ubuntu)
- The terminal in VScode is now a Linux shell
4. Update and upgrade softwares in Linux (ubuntu)
5. Install Linux headers for kernl module build
6. Install git (version control)
SSH config:
sudo vim /etc/ssh/sshd_config
sudo systemctl daemon-reload
sudo service ssh restart
sudo passwd ubuntu
Multipass commands:
1. multipass launch --name primary
(Windows: multipass launch --network <wi-fi name> --name primary)
2. multipass list
3. multipass shell (ubuntu shell)
4. multipass stop primary
5. multipass start primary
Comments
Post a Comment