From the course: Linux Device Drivers: Reading, Writing, and Debugging
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Build and load a loadable module - Linux Tutorial
From the course: Linux Device Drivers: Reading, Writing, and Debugging
Build and load a loadable module
- [Host] Let's look at actually compiling, building our module, and then of course you could use INS mod to load it. But let's look at some of the details. You need a Makefile and you'll use the Makefile and you will use the kernel Makefile together for compiling your module and creating the .ko file. When you do your make, you're going to specify that you want to use the kernel Makefile. Then it will come back to your directory and use your Makefile. And in your Makefile you assign to the special variable O bj dash M. The .O file that needs to be built into a .ko. You don't need to put the dot C. For simple cases, where your module is just a single file, just skeleton .C, you put skeleton.O, make knows how to make a .O from a C. You don't have to put that part. And then the kernel Makefile will make a module out of the .O. When you make your module in your directory, you need to tell Make to go use the kernel Makefile to get started. So you need the path name to where that is. When…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.