LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-04-2013, 12:36 AM   #1
TeaYoung
LQ Newbie
 
Registered: Apr 2013
Posts: 26

Rep: Reputation: Disabled
Need help with GPIO module error


I do not speak English well.

I live in South Korea.

I am GPIO through the the device driver you try to create a and is.

EXYNOS4_GPA1 (GPIO-10) by connecting the LED flashing every second that the driver is making.

If you make an error coming up I do not know how to solve.


gpio.c
Code:
 #include <linux/kernel.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/sysfs.h>
#include <linux/input.h>
#include <linux/gpio.h>
#include <mach/gpio.h>
#include <mach/regs-gpio.h>
#include <plat/gpio-cfg.h>
#include <mach/gpio-exynos4.h>
#include<linux/cdev.h>

#include <linux/init.h>
#include <linux/clk.h>
#include <linux/hrtimer.h>
#include <linux/slab.h>
#include <asm/io.h>
#include <mach/regs-pmu.h>

#define USER_SW EXYNOS4_GPA(1)

static int __init gpio_init(void)
{
 int i;

 printk(KERN_INFO "GPIO: Initializing!rnnnnn");
  
 s3c_gpio_cfgpin(USER_SW, S3C_GPIO_INPUT);  //GPA1[1] -> Input setting
 s3c_gpio_setpull(USER_SW, S3C_GPIO_PULL_UP);  //GPA[1] -> Pull up setting
 gpio_set_value(USER_SW, 0); // init GPA1[1] -> 0 (OFF)

while(1){
 gpio_set_value(USER_SW, 1);
 sleep 1;
 gpio_set_value(USER_SW, 0);
 sleep 1;
}
return 0;
}

static void __exit gpio_exit(void)
{
   printk(KERN_INFO "GPIO: exit");
}

module_init(gpio_init);
module_exit(gpio_exit);

MODULE_DESCRIPTION("Simple gpio module");
MODULE_AUTHOR("Anders Knive Lassen & Marius Lind Volstad");
MODULE_LICENSE("GPL");

Makefile
Code:
obj-m := gpio.o

KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
    $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

test:
    echo $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

clean:
    rm -rf *.mod.c *.ko *.o *.symvers *.order
}

static void __exit gpio_exit(void)
{
   printk(KERN_INFO "GPIO: exit");
}

module_init(gpio_init);
module_exit(gpio_exit);

MODULE_DESCRIPTION("Simple gpio module");
MODULE_AUTHOR("Anders Knive Lassen & Marius Lind Volstad");
MODULE_LICENSE("GPL");

ERROR
Code:
root@linaro-ubuntu-desktop:/study/led1# make
make -C /lib/modules/3.0.75/build SUBDIRS=/study/led1 modules
make[1]: Entering directory `/usr/src/linux-odroid-3.0.y'
  CC [M]  /study/led1/gpio.o
/study/led1/gpio.c: In function ‘gpio_init’:
/study/led1/gpio.c:64:2: error: implicit declaration of function ‘EXYNOS4_GPA’ [-Werror=implicit-function-declaration]
/study/led1/gpio.c:93:2: error: ‘sleep’ undeclared (first use in this function)
/study/led1/gpio.c:93:2: note: each undeclared identifier is reported only once for each function it appears in
/study/led1/gpio.c:93:8: error: expected ‘;’ before numeric constant
/study/led1/gpio.c:95:8: error: expected ‘;’ before numeric constant
cc1: some warnings being treated as errors
make[2]: *** [/study/led1/gpio.o] Error 1
make[1]: *** [_module_/study/led1] Error 2
make[1]: Leaving directory `/usr/src/linux-odroid-3.0.y'
make: *** [default] Error 2
 
Old 06-04-2013, 02:47 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,693

Rep: Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725
The kernel is a different environment from user space. It doesn't make sense to sleep in the kernel because it would block other processes, so it is not allowed. Your module will never load because the init routine never completes.
 
1 members found this post helpful.
Old 06-04-2013, 10:25 PM   #3
gdejonge
Member
 
Registered: Aug 2010
Location: Netherlands
Distribution: Kubuntu, Debian, Suse, Slackware
Posts: 317

Rep: Reputation: 73
Also setting an infinite loop in your module initialisation routine is a BAD idea.

Cheers.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GPIO access on a Fujitsu Mini-ITX Industrial Mainboard, PCI Driver for GPIO mechatrix Linux - Embedded & Single-board computer 3 11-20-2011 03:57 PM
rtl8187 driver module load error (Invalid module format) j_75080 Linux - Networking 3 07-06-2009 09:37 PM
Using GPIO (from kernel GPIO support) in MY application DannyGilbert Linux - Kernel 2 03-16-2009 07:52 AM
cpan2tgz error on installing module: Failed to find module: build_requires pwc101 Slackware 6 01-08-2009 05:24 AM
error: -1 Invalid module format when using insmod with module cross-compiled for arm AndrewShanks Linux - Embedded & Single-board computer 4 10-15-2007 03:50 AM


All times are GMT -5. The time now is 05:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration