Difference between revisions of "User:Lesterwm"

From eLinux.org
Jump to: navigation, search
Line 60: Line 60:
 
:Answers:
 
:Answers:
 
#''The major device number 234 is part of a range of unassigned numbers. What is the range?'' 231-239
 
#''The major device number 234 is part of a range of unassigned numbers. What is the range?'' 231-239
#''What's the new line added to hello_init do?''  
+
#''What's the new line added to hello_init do?'' Registers this device driver with the given major number (234) and tells the kernel where to find the required file operation functions (open, read, write, ...)
#''What does mknod do?''
+
#''What does mknod do?'' Creates a file in /dev/ that represents the device with the given major number (in our case, 234)
#''Once your device is running try $ cat /proc/devices. Do you see your device?''
+
#''Once your device is running try $ cat /proc/devices. Do you see your device?'' Yes
#''Convert the example in our text to use the newer method. It's only a couple of additional lines, but you will have to read the book to know how to do it.''
+
#''Convert the example in our text to use the newer method. It's only a couple of additional lines, but you will have to read the book to know how to do it.'' Done
#''Modify the scull_load script (call it hello_load) on page 47, of chapter 3, to load your module.''
+
#''Modify the scull_load script (call it hello_load) on page 47, of chapter 3, to load your module.'' Done
#''Test it with use-hello.c from page 222 of Embedded Linux Primer.''
+
#''Test it with use-hello.c from page 222 of Embedded Linux Primer.'' Done
#''Write a hello_unload script that will rmmod the driver and remove the nodes in /dev''
+
#''Write a hello_unload script that will rmmod the driver and remove the nodes in /dev'' Done
#''Modify hello.c to pass the major device number in as a parameter during insmod.''
+
#''Modify hello.c to pass the major device number in as a parameter during insmod.'' Done
 
Optional: Stretch time, I though these would be easy, but after reading up on them, they look rather involved.
 
Optional: Stretch time, I though these would be easy, but after reading up on them, they look rather involved.
#''How can your driver find what the minor device number is?''
+
#''How can your driver find what the minor device number is?'' When the device is opened, an inode reference is passed. There is a macro called 'iminor' which takes an inode and returns the minor number.
#''Modify the driver to return some characters when /dev/hello1 is read.''
+
static int hello_open(struct inode *inode, struct file *file)
 +
{
 +
    /* We can change the logic of this function based on the
 +
    * minor number of our device */
 +
    printk("hello_open: successful opened minor number %u\n",
 +
        iminor(inode));
 +
   
 +
    return 0;
 +
}
  
 
;[[ECE497 Lab09 Development Tools | Lab 09]]
 
;[[ECE497 Lab09 Development Tools | Lab 09]]

Revision as of 22:43, 1 May 2011


Status Report

Listings

Chapter 4
Not Done
Chapter 5
Done
Chapter 6
Not Done
Chapter 7
Not Done
Chapter 8
Not Done

Labs

Lab 00
Status: Complete
Observations: N/A (I already had linux installed)
Answers: N/A
Lab 01
Status: Complete
Observations: Using the SPED image, you can't boot your Beagle using USB OTG for power (it throws a kernel panic). This is because the kernel image included on image does not have the necessary USB gadget module built-in (its a dynamic module).
Answers: N/A
Lab 02
Status: Complete
Observations: Build.tar.gz is absolutely huge. Is all of that necessary? I find myself building the kernel outside of the OE tree because it is just too complicated otherwise. This is a great lab and one that I kept coming back to, its extremely important to the course
Answers: N/A
Lab 03
Status: Incomplete
Observations:
Answers:
Lab 04
Status: Done
Observations: This lab is incomplete, but following its spirit, I configured the kernel to my liking. I had to reconfigure from the default Angstrom configuration when I wanted to get networking and power over USB working, since the USB OTG gadget had to be compiled into the kernel (it can't by a dynamic module). I used gconfig to configure it.
Answers: N/A
Lab 05
Status: Complete
Observations: I completed this short lab as part of Lab 08. In that lab I added an Example character device module to the necessary Kconfig file.
Answers: N/A
Lab 06
Status: Complete
Observations: I've spent a lot of time on this subject while trying to get static MAC addresses working. I wrote up a wiki article based on what I learned. See ECE497 Modifying Kernel Command Line Parameters.
Answers: N/A
Lab 07
Status: Not Started
Observations:
Answers:
Lab 08
Status: Complete
Observations: This is definitely my favorite lab. Very well constructed, challenging but not impossible.
Answers:
  1. The major device number 234 is part of a range of unassigned numbers. What is the range? 231-239
  2. What's the new line added to hello_init do? Registers this device driver with the given major number (234) and tells the kernel where to find the required file operation functions (open, read, write, ...)
  3. What does mknod do? Creates a file in /dev/ that represents the device with the given major number (in our case, 234)
  4. Once your device is running try $ cat /proc/devices. Do you see your device? Yes
  5. Convert the example in our text to use the newer method. It's only a couple of additional lines, but you will have to read the book to know how to do it. Done
  6. Modify the scull_load script (call it hello_load) on page 47, of chapter 3, to load your module. Done
  7. Test it with use-hello.c from page 222 of Embedded Linux Primer. Done
  8. Write a hello_unload script that will rmmod the driver and remove the nodes in /dev Done
  9. Modify hello.c to pass the major device number in as a parameter during insmod. Done

Optional: Stretch time, I though these would be easy, but after reading up on them, they look rather involved.

  1. How can your driver find what the minor device number is? When the device is opened, an inode reference is passed. There is a macro called 'iminor' which takes an inode and returns the minor number.
static int hello_open(struct inode *inode, struct file *file) 
{
   /* We can change the logic of this function based on the 
    * minor number of our device */
   printk("hello_open: successful opened minor number %u\n", 
       iminor(inode)); 
   
   return 0;
}
Lab 09
Status:
Observations:
Answers:
Lab 10
Status:
Observations:
Answers:
Lab 11
Status:
Observations:
Answers:
Lab 12
Status:
Observations:
Answers:
Lab 13
Status:
Observations:
Answers:


ECE497 Pages

These are pages that I have created in order to help the current and next class of ECE497 - Embedded 32-bit Linux

ECE497 Networking over USB

ECE497 Modifying Kernel Command Line Parameters