디바이스 드라이버를 포함해서 리눅스 커널 컴파일에 대해서...

jongju의 이미지

제가 단순한 디바이스 드라이버를 만들고 drivers/char/폴더에 char 디바이스 드라이버 코드를 넣고

drivers/char/폴더의 Kconfig에 만든 디바이스 드라이버 정보를 넣고, Makefile에 디바이스 드라이버의 object를 추가해서

넣었습니다. 그런데 아래의 코드 Simple Device Driver가 정상적으로 포함되어 컴파일이 되었습니다.

그래서 만들어진 uImage (리눅스 커널)을 보드에 넣어서 정상 동작하는 것을 확이했습니다.

그런데 이 드라이버가 추가가 잘 되었는지 확인은 어떻게 하는 것인가요? 단순히 알 수 있는 방법이 없나요?

혹시나해서 제가 mknod해서 노드를 만들고 어플리케이션에서 디바이스 드라이버를 open()해서 사용을 하려고 하니

open했을 때 printk()함수로 커널 메세지가 디스플레이가 되어야 하는데 디스플레이가 되지 않고 있습니다.

그래서 제 짧은 생각으로는 이 문제를 다음과 같이 생각했습니다.

첫째, 제대로 디바이스 드라이버가 커널 추가가 되지 않았다?

둘째, 이 디바이스 드라이가 제가 사용하는 커널 버전에는 맞지 않는 것이 아닌가?

셋째, 먼가 옵션이 빠진 것이 아닌가?

제가 사용하는 커널은 2.6.30 버전입니다. 그리고 아래 코드는 제가 인터넷에서 가져온 단순 디바이스 드라이버 입니다.

리눅스 커널에 디바이스 드라이버를 포함하려면 먼가 빠진 것이 있는거 같은데 고수님들의 조언 부탁드립니다. ㅠㅠ;

==============================Simple Device Driver =================================

#include
#include
#include
#include
#include
#include
#include
#define CALL_DEV_NAME "template"
#define CALL_DEV_MAJOR 512
#define CALL_DEV_SUB 0
/*
Note:
check device name and major device number before test.
usage: mknod /dev/template c 512 0
*/
/*
* IO functions
*/
int template_open (struct inode *inode, struct file *fp)
{
int num = MINOR(inode->i_rdev);
printk ("open function has been called -> minor: \n", num);
// MOD_INC_USE_COUNT; // When use 2.4 kernel - information only
return 0;
}
int template_release (struct inode *inode, struct file *fp)
{
// MOD_DEC_USE_COUNT; // When use 2.4 kernel - information only
printk ("release function has been called\n");
return 0;
}
loff_t template_llseek (struct file *fp,loff_t offset,int whence)
{
printk ("llseek function has been called: off , whence \n", offset,whence);
return offset;
}
ssize_t template_read (struct file *fp, char *buf, size_t count, loff_t *f_pos)
{
printk ("read function has been called: buf , count \n", buf, count);
return count;
}
ssize_t template_write (struct file*fp, const char *buf, size_t count, loff_t *f_pos)
{
printk ("write function has been called: buf , count \n", buf, count);
return count;
}
int template_ioctl (struct inode *inode, struct file *fp, unsigned int cmd, unsigned long arg)
{
printk ("ioctl function has been called: cmd , arg \n", cmd,arg);
return 0;
}
/*
* Assigning functions
*/
struct file_operations template_fops = {
.owner = THIS_MODULE,
.llseek = template_llseek,
.read = template_read,
.write = template_write,
.ioctl = template_ioctl,
.open = template_open,
.release = template_release,
/* check linux/fs.h file for addtional information of this structure */
};
/*
* Initializer and finalizer
*/
static int template_init (void)
{
int res;
printk ("initializer has been called\n");
res = register_chrdev(CALL_DEV_MAJOR, CALL_DEV_NAME, &template_fops);
if (res < 0) return res;
return 0;
};
static void template_exit (void)
{
printk ("finalizer has been called\n");
unregister_chrdev (CALL_DEV_MAJOR, CALL_DEV_NAME);
};
//#ifndef MODULE
/*
* Receiving kernel option such as 'template=1'
*/
static int given_value = 0;
static int __init template_setup (char *str)
{
int passed_values[4];
str = get_options (str, ARRAY_SIZE(passed_values), passed_values);
if (passed_values[0] > 0) given_value = passed_values[1];
return 1;
}
__initcal(template_init);
__setup ("template=", template_setup);
//#endif
//module_init(template_init);
//module_exit(template_exit);
MODULE_LICENSE("Dual BSD/GPL");

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.