Update development authored by Felix Kopp's avatar Felix Kopp
...@@ -4,8 +4,16 @@ This article shows how this kernel module was developed. ...@@ -4,8 +4,16 @@ This article shows how this kernel module was developed.
## Hello World! ## Hello World!
First of all, we did not have any previous knowledge about Linux kernel development (But we *did* know how Linux itself works, however). We usually believe in our *learning-by-doing* strategy, but due to our lack of any substantial knowledge of this topic, we decided to start with some of the theoretical basics this time. So we went to Linus Torvald's official GitHub repo and had a look at the [Documentation](https://github.com/torvalds/linux/tree/master/Documentation) folder. We found this to be a relatively inefficient way of learning kernel module development really quick, since there are literally hundreds, if not thousands of documents in there. It would have taken way too long to read through all of these pages, furthermore we didn't even know where to start. After some research, we discovered [The Linux Documentation Project (TLDP)](http://tldp.org) and, specifically, [The Linux Kernel Module Programming Guide](http://tldp.org/LDP/lkmpg/2.6/html/index.html). It provided us all of the basics we needed to know in order to start with our first Hello World module. First of all, we did not have any previous knowledge about Linux kernel development (But we *did* know how Linux itself works, however). We usually believe in our *learning-by-doing* strategy, but due to our lack of any substantial knowledge of this topic, we decided to start with some of the theoretical basics this time. So we went to Linus Torvald's official GitHub repo and had a look at the [Documentation](https://github.com/torvalds/linux/tree/master/Documentation) folder. We found this to be a relatively inefficient way of learning kernel module development really quick, since there are literally hundreds, if not thousands of documents in there. It would have taken way too long to read through all of these pages, furthermore we didn't even know where to start. After some research, we discovered [The Linux Documentation Project (TLDP)](http://tldp.org) and, specifically, [The Linux Kernel Module Programming Guide](http://tldp.org/LDP/lkmpg/2.6/html/index.html). It provided us all of the basics we needed to know in order to start off with our first Hello World module.
## Starting From Scratch ## Starting From Scratch
When we successfully compiled our first Hello World module, we believed that we were ready for the actual project. So we read through some online articles and tutorials and When we successfully compiled our Hello World module, we believed that we were ready for the actual project. So we read through some online articles and tutorials and got started. It was a pretty straight-forward process, everything we needed was just one Google search query away. This lead us to our main project structure: One file should keep all codes for initializing / exiting the module, one contains all GPIO code, another one for the device file and some additional header files for utilities like character to integer conversion or the pin map.
\ No newline at end of file
## /dev/sevenseg
The device file was the first thing to make serious trouble. We were recommended to use Linux' sysfs API in the first place, which was (at least in our view of things) very hard to implement. Days passed by, and we did not get forward. The module always refused to load due to failures in our implementation. We finally got to the point where we had to search for something else in order to create the needed device file. This was when we discovered udev's character device API, which turned out to be a very easy to use API. We just created methods for opening, closing, writing to and reading from the device file, linked these to the kernel and were then good to go.
## GPIO Pins
The GPIO pins, even though rather simple, were a little bit confusing in the first place. The technical drawings of the Raspberry Pi has linearly incrementing pin numbers. However, this numeration is different at kernel level. Since we did not expect that, we spent several hours of checking all other code snippets before we considered that our error must lie there. When we discovered the correct pin numbers, we were also drawing the cirquit diagram to make our decision about which pins to use final. We also defined some macros (found in [src/include/defines.h](/fk16790/SevenSegController/src/include/utils.h)) in order to access the pins easier.
\ No newline at end of file