Phil,
Thank you for your help. I just modified the gpio.c that Yan Seiner
posted a few weeks ago. However, even his original one could not be
compiled on my PC.
Use a similar command below to compile, change the /include to your
own Linux2.4 ARM kernel source include.
arm-linux-gcc -D__KERNEL__ -DMODULE
-I/usr/local/src/linux24/include -O -Wall -c -o gpio.o gpio.c
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <asm-arm/io.h>
#define TSDIO24region 0x11e00104
#define TSDIO24length 4
#define TSDIO24ctrl 0x11e00104
#define TSDIO24regA 0x11e00105
#define TSDIO24regB 0x11e00106
#define TSDIO24regC 0x11e00107
// device numbers
// major - 253
// minor:
// 0 - ctrl
// 1 - regA
// 2 - regB
// 3 - regC
#define TSDIO24major 253
static char *mem_virt_addr;
static ssize_t tsdio24_write(struct file *file, const char *buf,
size_t length, loff_t *ppos)
{
printk("<1>in write\n");
return 0;
}
static ssize_t tsdio24_read(struct file *file, char *buf, size_t
length, loff_t *ppos)
{
printk("0x%02x %02x %02x %02x\n",
readb(mem_virt_addr),
readb(mem_virt_addr+1),
readb(mem_virt_addr+2),
readb(mem_virt_addr+3));
return 0;
}
static struct file_operations tsdio24_fops = {
write: tsdio24_write,
read: tsdio24_read
};
int init_TSgpio(void)
{
int result;
printk("<1>Hello world.\n");
if (check_mem_region(TSDIO24region, TSDIO24length))
{
printk("TSgpio: memory already in use\n");
return -EBUSY;
}
request_mem_region(TSDIO24region, TSDIO24length, "TSDIO24gpio");
if( (result = register_chrdev(TSDIO24major, "TSDIO24",
&tsdio24_fops)) < 0)
{
printk(KERN_WARNING "tsdio24: can't get major
%d\n",TSDIO24major);
return result;
}
mem_virt_addr = __ioremap(TSDIO24region, TSDIO24length);
return 0;
}
void exit_TSgpio(void)
{
iounmap(mem_virt_addr);
unregister_chrdev(TSDIO24major,"TSDIO24");
release_mem_region(TSDIO24region, TSDIO24length);
printk("<1>Goodbye, cruel world.\n");
}
module_init(init_TSgpio);
module_exit(exit_TSgpio);
--- In "Phil" <> wrote:
>
> Hi Tom,
>
> It's a bit hard to work out what is happening just from the
> description. Is it possible for you to upload/attach the "gpio.c"
> file that you are trying to compile?
>
> Cheers
> Phil
>
>
>
> --- In "chentom60" <chentom60@> wrote:
> >
> > Hi,
> >
> > I want to build a kernel module for my TS-7250 to control gpio, but
> > can not compile.
> >
> > I am using the latest toolchain, kernel source, kernel module from
> > http://www.embeddedarm.com/linux/ARM.htm. However, there are lots
> of
> > compiling errors.
> >
> > I am using this command
> > $/usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/bin/arm-
> linux-gcc
> > -D__KERNEL__ -DMODULE -I/home/tom/linux24/include -O -Wall -c -o
> > gpio.o gpio.c
> >
> > The #include <linux/fs.h> in my gpio.c alone will lead to lots of
> > error below:
> >
> > /home/tom/linux24/include/linux/fs.h:424: error: parse error before
> > "dev_t"
> > /home/tom/linux24/include/linux/fs.h:424: warning: no semicolon at
> end
> > of struct or union
> > /home/tom/linux24/include/linux/fs.h:427: error: parse error before
> > '}' token
> > /home/tom/linux24/include/linux/fs.h:433: error: parse error before
> > "dev_t"
> > /home/tom/linux24/include/linux/fs.h:433: warning: no semicolon at
> end
> > of struct or union
> > /home/tom/linux24/include/linux/fs.h:438: error: parse error before
> > '}' token
> >
> > .................
> > /home/tom/linux24/include/linux/jffs2_fs_i.h:42: error: field
> > `vfs_inode' has incomplete type
> > .......................
> >
> > I found probably a similar discussion last year on failing to build
> > kernel module:
> > http://groups.yahoo.com/group/ts-7000/message/969
> >
> > I do not know what should I do to successfully build kernel
> modules?
> > Any new toolchain or kernel source or some patches to download?
> >
> > Tom
> >
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|