Navigation » MPC Club Community Board > Community Development > Community Development!! > KiSS Stage 2 Development » Compilation error for kernel module with proc_fs.h

Notices

» Slysoft Recommended!
1 CLick BD and DVD backups
Download AnyDVD HD!
For Blu-Ray and DVD!
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Stats
Members: 85,613
Threads: 29,437
Posts: 248,423
Welcome to our newest member, mjl1297
» MPC Club Advertisers and Sponsors
Reply
 
Thread Tools
Old 24-02-07, 19:22   #1
thomas_fogh

Active Member
 
Join Date: Jun 2006
Location: Aarhus - Denmark
Posts: 46
Contribution: 0.02%
Thanks: 0
Thanked 0 Times in 0 Posts
Downloads: 0
Uploads: 0
Default Compilation error for kernel module with proc_fs.h

Has anyone tried making a kernel module with proc entry?
I get a compilation error for one of the arm-elf include files when I include "proc_fs.h".
thomas_fogh is offline   Reply With Quote
Advertising
Advertising temporarily disabled
Old 24-02-07, 23:48   #2
martinb
Premium Potential
TIP: Upgrade to Premium
Think Tank
 
Join Date: Jan 2005
Posts: 2,658
Contribution: 1.07%
Thanks: 0
Thanked 40 Times in 11 Posts
Downloads: 0
Uploads: 0
Default Re: Compilation error for kernel module with proc_fs.h

Originally Posted by thomas_fogh
Has anyone tried making a kernel module with proc entry?
I get a compilation error for one of the arm-elf include files when I include "proc_fs.h".
what crosscompiler do you use?
if you send me the source i can try to compile it
(i have build some other crosscompilers)
martinb is offline   Reply With Quote
Old 25-02-07, 10:39   #3
thomas_fogh

Active Member
 
Join Date: Jun 2006
Location: Aarhus - Denmark
Posts: 46
Contribution: 0.02%
Thanks: 0
Thanked 0 Times in 0 Posts
Downloads: 0
Uploads: 0
Default

I'm using:
http://www.uclinux.org/pub/uClinux/a...ls-20030314.sh

Thanks!
BR, Thomas


test_proc.c:
Code:
#include <linux>
#include <linux>
#include <linux>
#include <linux>
#include <linux>
#include <linux>
#include <linux>
#include <linux>

static char procname[] = "test_proc";
static struct proc_dir_entry *proc_entry;

int test_read_proc(char *buf, char **start, off_t off,
                   int count, int *eof, void *data)
{
  int len = 0;

  len += sprintf(buf+len, "Testing..1..2..3\n");

  return len;
}

int test_write_proc(struct file *file, const char *buffer,
                    unsigned long count, void *data)
{
}

int init_module()
{
  proc_entry = create_proc_entry(procname, 0666, NULL);
  if (proc_entry != NULL) {
    proc_entry->read_proc  = test_read_proc;
    proc_entry->write_proc = test_write_proc;
  } else {
    printk("<1>test_proc: Couldn't create proc entry!");
    return -ENOMEM;
  }
  return 0;
}

void cleanup_module()
{
  remove_proc_entry(procname, NULL);
}

MODULE_LICENSE("GPL");
And Makefile:
Code:
#Setting the include dir
IDIR=	.
#IDIR+=  -I/usr/src/local/arm-elf/include
#Setting compiler & flags
CC=	arm-elf-gcc
CFLAGS=	-I$(IDIR) -DMODULE -D__KERNEL__ -D__uClinux__ -mtune=arm7tdmi -O2
LDFLAGS=-Wl,-elf2flt="-s262144"
#Setting the object output dir
ODIR=	obj
#Setting the library dir
LDIR=
#Adding libs
LIBS=

#Setting dependencies
_DEPS=
DEPS =	$(patsubst %,$(IDIR)/%,$(_DEPS))

#Specifying objects
SRCC  =	test_proc.c
SRCCPP=	

OBJ =	$(patsubst %.c,$(ODIR)/%.o,$(SRCC))
OBJ+=	$(patsubst %.cpp,$(ODIR)/%.o,$(SRCCPP))

#Setting rules for object files
$(ODIR)/%.o: %.c $(DEPS)
	@mkdir -p $(ODIR)
	@echo Compiling____$^
	@$(CC) -c -o $@ $< $(CFLAGS)

.PHONY: clean

clean:
	@echo Cleaning...
	@rm -f $(ODIR)/*.o *~
thomas_fogh is offline   Reply With Quote
Old 25-02-07, 14:30   #4
martinb
Premium Potential
TIP: Upgrade to Premium
Think Tank
 
Join Date: Jan 2005
Posts: 2,658
Contribution: 1.07%
Thanks: 0
Thanked 40 Times in 11 Posts
Downloads: 0
Uploads: 0
Default

i am missing all the includes?

can you first be sure it will compilewith gcc
(without cross compile)

if you got a working version for gcc and it will not crosscompile please provide me the source again
martinb is offline   Reply With Quote
Old 25-02-07, 16:18   #5
thomas_fogh

Active Member
 
Join Date: Jun 2006
Location: Aarhus - Denmark
Posts: 46
Contribution: 0.02%
Thanks: 0
Thanked 0 Times in 0 Posts
Downloads: 0
Uploads: 0
Default

This is compiling on the "normal" gcc, but not the arm-elf-gcc.
The includes were missing because HTML was on. Sorry

daemon_mod.c
Code:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>

static char procname[] = "torrents";
static struct proc_dir_entry *proc_entry;

int torrent_read_proc(char *buf, char **start, off_t off,
                      int count, int *eof, void *data);
int torrent_write_proc(struct file *file, const char *buffer,
                       unsigned long count, void *data);
int init_module(void);
void cleanup_module(void);

int torrent_read_proc(char *buf, char **start, off_t off,
                      int count, int *eof, void *data)
{
  int len = 0;

  len += sprintf(buf+len, "Testing..1..2..3\n");

  return len;
}

int torrent_write_proc(struct file *file, const char *buffer,
                       unsigned long count, void *data)
{
  return 0;
}

int init_module(void)
{
  proc_entry = create_proc_entry(procname, 0666, NULL);
  if (proc_entry != NULL) {
    proc_entry->read_proc  = torrent_read_proc;
    proc_entry->write_proc = torrent_write_proc;
  } else {
    printk("<1>torrent_daemon_kiss: Couldn't create proc entry!");
    return -ENOMEM;
  }
  return 0;
}

void cleanup_module(void)
{
  remove_proc_entry(procname, NULL);
}

MODULE_LICENSE("GPL");
Makefile:
Code:
TARGET  := daemon_mod
WARN    := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
#INCLUDE := -isystem /lib/modules/`uname -r`/build/include
INCLUDE := -isystem /usr/local/arm-elf/include
CFLAGS  := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
#CC      := gcc
CC      := arm-elf-gcc

${TARGET}.o: ${TARGET}.c

.PHONY: clean

clean:
	rm -f ${TARGET}.o *~
errors:
Code:
arm-elf-gcc -O2 -DMODULE -D__KERNEL__ -W -Wall -Wstrict-prototypes -Wmissing-prototypes -isystem /usr/local/arm-elf/include   -c -o daemon_mod.o daemon_mod.c
In file included from /usr/local/arm-elf/include/linux/mm.h:26,
                 from /usr/local/arm-elf/include/linux/slab.h:14,
                 from /usr/local/arm-elf/include/linux/proc_fs.h:5,
                 from daemon_mod.c:3:
/usr/local/arm-elf/include/asm/pgtable.h:180: asm-generic/pgtable.h: No such file or directory
make: *** [daemon_mod.o] Error 1
thomas_fogh is offline   Reply With Quote
Old 25-02-07, 20:58   #6
martinb
Premium Potential
TIP: Upgrade to Premium
Think Tank
 
Join Date: Jan 2005
Posts: 2,658
Contribution: 1.07%
Thanks: 0
Thanked 40 Times in 11 Posts
Downloads: 0
Uploads: 0
Default

Originally Posted by thomas_fogh
This is compiling on the "normal" gcc, but not the arm-elf-gcc.
..
if i do:
arm-elf-gcc -O0 -DMODULE -D__KERNEL__ -DNO_MM -W -Wall -c -o daemon_mod.o test_proc.c -march=armv4 -msoft-float -I/apps/stage2_source/uClinux-2.4/include/


i get the folowing output

Code:
arm-elf-gcc -O0 -DMODULE -D__KERNEL__ -DNO_MM -W -Wall -c -o daemon_mod.o test_proc.c -march=armv4 -msoft-float -I/apps/stage2_source/uClinux-2.4/include/
In file included from /apps/stage2_source/uClinux-2.4/include/linux/list.h:6,
                 from /apps/stage2_source/uClinux-2.4/include/linux/module.h:12,
                 from test_proc.c:1:
/apps/stage2_source/uClinux-2.4/include/linux/prefetch.h: In function `prefetch':
/apps/stage2_source/uClinux-2.4/include/linux/prefetch.h:43: warning: unused parameter `x'
/apps/stage2_source/uClinux-2.4/include/linux/prefetch.h: In function `prefetchw':
/apps/stage2_source/uClinux-2.4/include/linux/prefetch.h:48: warning: unused parameter `x'
In file included from /apps/stage2_source/uClinux-2.4/include/linux/fs.h:12,
                 from /apps/stage2_source/uClinux-2.4/include/linux/capability.h:17,
                 from /apps/stage2_source/uClinux-2.4/include/linux/binfmts.h:5,
                 from /apps/stage2_source/uClinux-2.4/include/linux/sched.h:9,
                 from /apps/stage2_source/uClinux-2.4/include/linux/mm.h:4,
                 from /apps/stage2_source/uClinux-2.4/include/linux/slab.h:14,
                 from /apps/stage2_source/uClinux-2.4/include/linux/proc_fs.h:5,
                 from test_proc.c:3:
/apps/stage2_source/uClinux-2.4/include/linux/wait.h: In function `__remove_wait_queue':
/apps/stage2_source/uClinux-2.4/include/linux/wait.h:223: warning: unused parameter `head'
In file included from /apps/stage2_source/uClinux-2.4/include/linux/string.h:19,
                 from /apps/stage2_source/uClinux-2.4/include/linux/fs.h:23,
                 from /apps/stage2_source/uClinux-2.4/include/linux/capability.h:17,
                 from /apps/stage2_source/uClinux-2.4/include/linux/binfmts.h:5,
                 from /apps/stage2_source/uClinux-2.4/include/linux/sched.h:9,
                 from /apps/stage2_source/uClinux-2.4/include/linux/mm.h:4,
                 from /apps/stage2_source/uClinux-2.4/include/linux/slab.h:14,
                 from /apps/stage2_source/uClinux-2.4/include/linux/proc_fs.h:5,
                 from test_proc.c:3:
/apps/stage2_source/uClinux-2.4/include/asm/string.h: At top level:
/apps/stage2_source/uClinux-2.4/include/asm/string.h:16: warning: conflicting types for built-in function `memcpy'
/apps/stage2_source/uClinux-2.4/include/asm/string.h:26: warning: conflicting types for built-in function `memset'
In file included from /apps/stage2_source/uClinux-2.4/include/linux/fs.h:23,
                 from /apps/stage2_source/uClinux-2.4/include/linux/capability.h:17,
                 from /apps/stage2_source/uClinux-2.4/include/linux/binfmts.h:5,
                 from /apps/stage2_source/uClinux-2.4/include/linux/sched.h:9,
                 from /apps/stage2_source/uClinux-2.4/include/linux/mm.h:4,
                 from /apps/stage2_source/uClinux-2.4/include/linux/slab.h:14,
                 from /apps/stage2_source/uClinux-2.4/include/linux/proc_fs.h:5,
                 from test_proc.c:3:
/apps/stage2_source/uClinux-2.4/include/linux/string.h:79: warning: conflicting types for built-in function `memcmp'
In file included from /apps/stage2_source/uClinux-2.4/include/linux/sched.h:26,
                 from /apps/stage2_source/uClinux-2.4/include/linux/mm.h:4,
                 from /apps/stage2_source/uClinux-2.4/include/linux/slab.h:14,
                 from /apps/stage2_source/uClinux-2.4/include/linux/proc_fs.h:5,
                 from test_proc.c:3:
/apps/stage2_source/uClinux-2.4/include/linux/signal.h: In function `sigorsets':
/apps/stage2_source/uClinux-2.4/include/linux/signal.h:108: warning: comparison of unsigned expression < 0 is always false
/apps/stage2_source/uClinux-2.4/include/linux/signal.h: In function `sigandsets':
/apps/stage2_source/uClinux-2.4/include/linux/signal.h:111: warning: comparison of unsigned expression < 0 is always false
/apps/stage2_source/uClinux-2.4/include/linux/signal.h: In function `signandsets':
/apps/stage2_source/uClinux-2.4/include/linux/signal.h:114: warning: comparison of unsigned expression < 0 is always false
/apps/stage2_source/uClinux-2.4/include/linux/signal.h: In function `signotset':
/apps/stage2_source/uClinux-2.4/include/linux/signal.h:140: warning: comparison of unsigned expression < 0 is always false
In file included from /apps/stage2_source/uClinux-2.4/include/linux/mm.h:4,
                 from /apps/stage2_source/uClinux-2.4/include/linux/slab.h:14,
                 from /apps/stage2_source/uClinux-2.4/include/linux/proc_fs.h:5,
                 from test_proc.c:3:
/apps/stage2_source/uClinux-2.4/include/linux/sched.h: In function `task_unlock':
/apps/stage2_source/uClinux-2.4/include/linux/sched.h:957: warning: unused parameter `p'
In file included from /apps/stage2_source/uClinux-2.4/include/asm/pgtable.h:153,
                 from /apps/stage2_source/uClinux-2.4/include/linux/mm.h:25,
                 from /apps/stage2_source/uClinux-2.4/include/linux/slab.h:14,
                 from /apps/stage2_source/uClinux-2.4/include/linux/proc_fs.h:5,
                 from test_proc.c:3:
/apps/stage2_source/uClinux-2.4/include/asm/proc/pgtable.h: In function `__mk_pmd':
/apps/stage2_source/uClinux-2.4/include/asm/proc/pgtable.h:51: warning: unused parameter `ptep'
/apps/stage2_source/uClinux-2.4/include/asm/proc/pgtable.h:51: warning: unused parameter `prot'
/apps/stage2_source/uClinux-2.4/include/asm/proc/pgtable.h: In function `pmd_page':
/apps/stage2_source/uClinux-2.4/include/asm/proc/pgtable.h:72: warning: unused parameter `pmd'
In file included from /apps/stage2_source/uClinux-2.4/include/linux/slab.h:14,
                 from /apps/stage2_source/uClinux-2.4/include/linux/proc_fs.h:5,
                 from test_proc.c:3:
/apps/stage2_source/uClinux-2.4/include/linux/mm.h: In function `__vma_unlink':
/apps/stage2_source/uClinux-2.4/include/linux/mm.h:527: warning: unused parameter `mm'
/apps/stage2_source/uClinux-2.4/include/linux/mm.h:527: warning: unused parameter `vma'
/apps/stage2_source/uClinux-2.4/include/linux/mm.h:527: warning: unused parameter `prev'
/apps/stage2_source/uClinux-2.4/include/linux/mm.h: In function `can_vma_merge':
/apps/stage2_source/uClinux-2.4/include/linux/mm.h:537: warning: unused parameter `vma'
/apps/stage2_source/uClinux-2.4/include/linux/mm.h:537: warning: unused parameter `vm_flags'
test_proc.c: In function `torrent_read_proc':
test_proc.c:15: warning: unused parameter `start'
test_proc.c:15: warning: unused parameter `off'
test_proc.c:16: warning: unused parameter `count'
test_proc.c:16: warning: unused parameter `eof'
test_proc.c:16: warning: unused parameter `data'
test_proc.c: In function `torrent_write_proc':
test_proc.c:25: warning: unused parameter `file'
test_proc.c:25: warning: unused parameter `buffer'
test_proc.c:26: warning: unused parameter `count'
test_proc.c:26: warning: unused parameter `data'
but it does compile
(sorry im a linux noob so i dont know if the output is working)
martinb is offline   Reply With Quote
Old 25-02-07, 21:19   #7
thomas_fogh

Active Member
 
Join Date: Jun 2006
Location: Aarhus - Denmark
Posts: 46
Contribution: 0.02%
Thanks: 0
Thanked 0 Times in 0 Posts
Downloads: 0
Uploads: 0
Default

Ok, thanks!
I'll try that!

BR, Thomas
thomas_fogh is offline   Reply With Quote
Old 27-02-07, 20:17   #8
thomas_fogh

Active Member
 
Join Date: Jun 2006
Location: Aarhus - Denmark
Posts: 46
Contribution: 0.02%
Thanks: 0
Thanked 0 Times in 0 Posts
Downloads: 0
Uploads: 0
Default

Hi Martin,

Just using the same flags didn't work. I had to use the uClinux sources from the KiSS GPL.zip.
Now it compiles! And the module works!

Thank you for your help!

BR, Thomas


Maybe someone should update the howto page.
  1. Get and run
    HTML Code:
    http://www.uclinux.org/pub/uClinux/arm-elf-tools/arm-elf-tools-20030314.sh
  2. Unpack the uClinux part of the GPL.zip.
  3. Use following flags for kernel modules:
    -O2 -DMODULE -D__KERNEL__ -D__uClinux__ -DNO_MM -W -Wall -march=armv4 -msoft-float
  4. Add following flags to the ones already specified for userspace programs (just in case...):
    -DNO_MM -msoft-float
What we really need is a wiki we can update as we get more information...
thomas_fogh is offline   Reply With Quote
Old 27-02-07, 21:59   #9
martinb
Premium Potential
TIP: Upgrade to Premium
Think Tank
 
Join Date: Jan 2005
Posts: 2,658
Contribution: 1.07%
Thanks: 0
Thanked 40 Times in 11 Posts
Downloads: 0
Uploads: 0
Default

Originally Posted by thomas_fogh
..
What we really need is a wiki we can update as we get more information...
I agree with the wiki
what does hi-jack think of a wiki ?

the forum is not the place to maintain howto's because it change to fast
martinb is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom firmware compilation Timar General Archived Topics 0 22-05-06 13:28
Problem of cross-compilation of some sources for the DP-508 pirlouwi Community Development General!! 20 13-04-05 22:11
DP-508 PAL 2.8.3 New kernel FW Beta2 Snushanen General Archived Topics 1 23-08-04 12:37
NEW DP-508 Firmware: NEW KERNEL!!! Hi-Jack General Archived Topics 37 24-05-04 16:26
Compilation information for KISS players Gobountz Community Development General!! 3 29-04-04 15:24

» MPC top List...

TOP 5 Regular media players

  • Popcorn Hour C-300 (81%)
  • Mede8er Med500x2 (80%)
  • Dune SMART (D1) (65%)
  • HDI Dune Base 3.0 (52%)
  • DViCo TViX X-Roid (00%)

TOP 5 Hybrid media players

  • HDI Dune BD Prime 3.0 (75%)
  • HDI Dune HD SMART B1 (74%)
  • PoPCorn Hour C-200 (68%)
  • HDI Dune MAX (54%)

We do not recommend currently...

  • Xtreamer products
  • Hantech products
  • MViX products
  • DviCo products
  • HDX products
Powered by vBadvanced CMPS v3.2.1 - twisted by vbTwist and Hi-Jack (MPC Club)