how to use kmod-pwm-gpio-custom

961 views
Skip to first unread message

Philipp Peter Tahiri

unread,
Jun 9, 2011, 2:06:47 PM6/9/11
to Bifferboard
Hi,

i try to use kmod-pwm-gpio-custom, but i dont know how to enable it
and how to comunicate with
the module?

I would like to genereate a PWM und GPIO 7 with this module.

Thank You

nicolas le falher

unread,
Jun 9, 2011, 4:08:22 PM6/9/11
to biffe...@googlegroups.com
You can register a pwm gpio with kmod-pwm-gpio-custom :

Add modules :
--- kmod-pwm
--- kmod-pwm-gpio
<*> kmod-pwm-gpio-custom

root@OpenWrt:/# ls /lib/modules/2.6.32.20/ | grep pwm
pwm-gpio-custom.ko
root@OpenWrt:/# insmod pwm-gpio-custom bus0=0,11
Custom GPIO-based pwm driver version 0.1.0

But sysfs class for pwm was added by 2.6.38 kernel I think :
http://comments.gmane.org/gmane.linux.kernel.embedded/3363
http://www.mjmwired.net/kernel/Documentation/hwmon/sysfs-interface

I take a look at trunk version if is available.

https://dev.openwrt.org/browser/trunk/package/pwm-gpio-custom/src/pwm-gpio-custom.c?rev=22350
MODULE_AUTHOR("Bifferos <bifferos at yahoo.co.uk >");

Bifferos, have you a module code example of how use pwm ? :)

2011/6/9 Philipp Peter Tahiri <phili...@arcor.de>

--
To unsubscribe send email to bifferboard...@googlegroups.com



--

Nicolas Le Falher.

biff...@yahoo.co.uk

unread,
Jun 9, 2011, 6:34:41 PM6/9/11
to Bifferboard

On Jun 9, 9:08 pm, nicolas le falher <n.lefal...@gmail.com> wrote:
> https://dev.openwrt.org/browser/trunk/package/pwm-gpio-custom/src/pwm...
> MODULE_AUTHOR("Bifferos <bifferos at yahoo.co.uk >");

I don't know why my name's on that, I had nothing to do with it. I
think it's because someone copied that module from my 1-wire one.

> Bifferos, have you a module code example of how use pwm ? :)

I did software PWM like this (see LED pulse example):
https://sites.google.com/site/bifferboard/openwrt-svn/rtai

regards,
Biff.

nicolas le falher

unread,
Jun 10, 2011, 6:01:19 AM6/10/11
to biffe...@googlegroups.com
I did software PWM like this (see LED pulse example):
https://sites.google.com/site/bifferboard/openwrt-svn/rtai

Nice.
So Philipp, try to use RTAI instead of PWM gpio module :).

Thx Biff.

--

Nicolas Le Falher.

biff...@yahoo.co.uk

unread,
Jun 10, 2011, 12:04:07 PM6/10/11
to Bifferboard
:)

Well, I have nothing against PWM in a kernel module... if it works.
The problem might be with an interruptible kernel you might get some
jitter in the PWM output. Kernel modules run at a very high priority,
but it's not absolute. An RTAI periodic task, on the other hand can't
be interrupted in the same way, because the rest of the kernel is
running underneath it. I guess if you're not loading the system too
much you may never notice the difference.

cheers,
Biff.

Philipp Peter Tahiri

unread,
Jun 12, 2011, 7:14:48 AM6/12/11
to Bifferboard
In which environment do you compile your code?

Makefile use this:
CC = $(shell ../install/bin/rtai-config --cc)
LXRT_CFLAGS = $(shell ../install/bin/rtai-config --lxrt-cflags)
LXRT_LDFLAGS = $(shell ../install/bin/rtai-config --lxrt-ldflags)

in your git, there is no trai-config. ("git clone git://github.com/bifferos/openwrt.git")

Where can i found your environment?

On Jun 10, 6:04 pm, "biffe...@yahoo.co.uk" <biffe...@yahoo.co.uk>
wrote:

nicolas le falher

unread,
Jun 12, 2011, 7:20:58 AM6/12/11
to biffe...@googlegroups.com
If you launch a "make package/rtai/compile".
You find file at ./staging_dir/target-i386_uClibc-0.9.30.1/usr/bin/rtai-config

2011/6/12 Philipp Peter Tahiri <phili...@arcor.de>
--
To unsubscribe send email to bifferboard...@googlegroups.com



--

Nicolas Le Falher.

nicolas le falher

unread,
Jun 12, 2011, 7:24:37 AM6/12/11
to biffe...@googlegroups.com
And Biff documentation https://sites.google.com/site/bifferboard/openwrt-svn/rtai

2011/6/12 nicolas le falher <n.lef...@gmail.com>



--

Nicolas Le Falher.

Philipp Peter Tahiri

unread,
Jun 16, 2011, 1:36:26 PM6/16/11
to Bifferboard
I can not compile it...

So i copied:
- cp /home/madmoses/biff/openwrt/staging_dir/toolchain-
i386_gcc-4.1.2_uClibc-0.9.30.1/bin/i486-openwrt-linux-uclibc-gcc /usr/
bin/
- placed /install/bin/rtai-config on the right dir

So if i compile it, he did not find the rtai headers. I modified the
Makefile.
CC = $(shell ../install/bin/rtai-config --cc)
LXRT_CFLAGS = $(shell ../install/bin/rtai-config --lxrt-cflags)
LXRT_LDFLAGS = $(shell ../install/bin/rtai-config --lxrt-ldflags)

all:: led_blink led_pulse

led_blink: led_blink.c
$(CC) $(LXRT_CFLAGS) -o $@ $< $(LXRT_LDFLAGS) -llxrt -I/home/
madmoses/biff/openwrt/staging_dir/target-i386_uClibc-0.9.30.1/usr/
include/asm-i386/

led_pulse: led_pulse.c
$(CC) $(LXRT_CFLAGS) -o $@ $< $(LXRT_LDFLAGS) -llxrt -I/home/
madmoses/biff/openwrt/staging_dir/target-i386_uClibc-0.9.30.1/usr/
include/asm-i386/

clean::
$(RM) -f act *~


.PHONY: clean

and got a endless error: http://paste.org/pastebin/view/34949

What is wrong?


On Jun 12, 1:24 pm, nicolas le falher <n.lefal...@gmail.com> wrote:
> And Biff documentationhttps://sites.google.com/site/bifferboard/openwrt-svn/rtai
>
> 2011/6/12 nicolas le falher <n.lefal...@gmail.com>
>
>
>
> > If you launch a "make package/rtai/compile".
> > You find file at
> > ./staging_dir/target-i386_uClibc-0.9.30.1/usr/bin/rtai-config
>
> > 2011/6/12 Philipp Peter Tahiri <philipp....@arcor.de>

Philipp Peter Tahiri

unread,
Jun 16, 2011, 1:26:46 PM6/16/11
to Bifferboard
I can not compile it...

So i copied:
- cp /home/madmoses/biff/openwrt/staging_dir/toolchain-
i386_gcc-4.1.2_uClibc-0.9.30.1/bin/i486-openwrt-linux-uclibc-gcc /usr/
bin/
- placed /install/bin/rtai-config on the right dir

So if i compile it, he did not find the rtai headers. I modified the
Makefile.
CC = $(shell ../install/bin/rtai-config --cc)
LXRT_CFLAGS = $(shell ../install/bin/rtai-config --lxrt-cflags)
LXRT_LDFLAGS = $(shell ../install/bin/rtai-config --lxrt-ldflags)

all:: led_blink led_pulse

led_blink: led_blink.c
$(CC) $(LXRT_CFLAGS) -o $@ $< $(LXRT_LDFLAGS) -llxrt -I/home/
madmoses/biff/openwrt/staging_dir/target-i386_uClibc-0.9.30.1/usr/
include/asm-i386/

led_pulse: led_pulse.c
$(CC) $(LXRT_CFLAGS) -o $@ $< $(LXRT_LDFLAGS) -llxrt -I/home/
madmoses/biff/openwrt/staging_dir/target-i386_uClibc-0.9.30.1/usr/
include/asm-i386/

clean::
$(RM) -f act *~


.PHONY: clean

and got a endless error: http://paste.org/pastebin/view/34949

What is wrong?


On Jun 12, 1:24 pm, nicolas le falher <n.lefal...@gmail.com> wrote:
> And Biff documentationhttps://sites.google.com/site/bifferboard/openwrt-svn/rtai
>
> 2011/6/12 nicolas le falher <n.lefal...@gmail.com>
>
>
>
> > If you launch a "make package/rtai/compile".
> > You find file at
> > ./staging_dir/target-i386_uClibc-0.9.30.1/usr/bin/rtai-config
>
> > 2011/6/12 Philipp Peter Tahiri <philipp....@arcor.de>

nicolas le falher

unread,
Jun 16, 2011, 6:49:04 PM6/16/11
to biffe...@googlegroups.com
Hi,

Link for asm to asm-i386 is broken in RTAI Makefile.

Edit file ~/package/rtai/Makefile and change this line :
$(LN) $(1)/usr/include/asm-i386 $(1)/usr/include/asm
by this :
$(LN) $(STAGING_DIR)/usr/include/asm-i386 $(STAGING_DIR)/usr/include/asm

Biff, can you confirm that and edit git if its ok ?

2011/6/16 Philipp Peter Tahiri <phili...@arcor.de>

nicolas le falher

unread,
Jun 16, 2011, 7:24:33 PM6/16/11
to biffe...@googlegroups.com
One error about RTAI.
File "rtai_config.h" is not copied from cvs to $(STAGING_DIR)/usr/include
cp ./build_dir/target-i386_uClibc-0.9.30.1/rtai_stable_cvs_20110206/rtai_config.h
./staging_dir/target-i386_uClibc-0.9.30.1/usr/include/

You can start with package "rtai-examples" in git.
With this Makefile, I got just a pthread error :

---------------------------------------------
CC = $(shell $(STAGING_DIR)/usr/bin/rtai-config --cc)
LXRT_CFLAGS = $(shell $(STAGING_DIR)/usr/bin/rtai-config --lxrt-cflags)
LXRT_LDFLAGS = -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib -lpthread

all: rtai-led-blink

rtai-led-blink: rtai-led-blink.c
$(CC) $(LXRT_CFLAGS) --static -o $@ $< $(LXRT_LDFLAGS) -llxrt

clean:
rm -f *.o *~ rtai-led-blink
---------------------------------------------

I will try again when I have more time.

2011/6/17 nicolas le falher <n.lef...@gmail.com>:

--

Nicolas Le Falher.

biff...@yahoo.co.uk

unread,
Jun 16, 2011, 8:33:14 PM6/16/11
to Bifferboard

On Jun 17, 12:24 am, nicolas le falher <n.lefal...@gmail.com> wrote:
> One error about RTAI.
> File "rtai_config.h" is not copied from cvs to $(STAGING_DIR)/usr/include
> cp ./build_dir/target-i386_uClibc-0.9.30.1/rtai_stable_cvs_20110206/rtai_config.h
> ./staging_dir/target-i386_uClibc-0.9.30.1/usr/include/

Yes, I never got this working, only up to here:
https://github.com/bifferos/openwrt/commit/2f4a93496f786f168dda622eb92b1fa68b3ac832
OpenWrt build system + RTAI seriously messed with my head :-(.

> You can start with package "rtai-examples" in git.
> With this Makefile, I got just a pthread error :

Yes, you need pthread, it says on this page:
https://sites.google.com/site/bifferboard/openwrt-svn/rtai
I should add pthread as a dependency for the example programs, but
since I never got it working anyway I didn't bother.

> CC = $(shell $(STAGING_DIR)/usr/bin/rtai-config --cc)
> LXRT_CFLAGS = $(shell $(STAGING_DIR)/usr/bin/rtai-config --lxrt-cflags)
> LXRT_LDFLAGS = -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib -lpthread

I'm not sure this stuff is supposed to be in the lower-level makefile,
which for most packages is fairly generic, maybe better to put it in
the OpenWrt makefile instead?

>
> all: rtai-led-blink
>
> rtai-led-blink: rtai-led-blink.c
>         $(CC) $(LXRT_CFLAGS) --static -o $@ $< $(LXRT_LDFLAGS)  -llxrt

You can also compile programs linked against RTAI libs fairly easily
on another Linux machine if all you need is a static binary. Example
makefile and project is here:
https://sites.google.com/site/bifferboard/Home/desktop-linux-distributions/slackware/rtai/rtai/satellite-dish-positioner-using-rtai

Maybe you save a bit by static-linking to openwrt libc though.

>
> clean:
>         rm -f *.o *~ rtai-led-blink
> ---------------------------------------------
>
> I will try again when I have more time.

If you can get it working I'll be very interested in a patch :).

thanks,
Biff.

nicolas le falher

unread,
Jun 17, 2011, 4:47:37 PM6/17/11
to biffe...@googlegroups.com
Hi,

Two diff files for packages "rtai" and "rtai-examples".
Compile works and modules load without problems.
Binary "rtai-led-blink" running, but error led not blinking (maybe
normal with a pull on every 0.5 seconds).

If someone can confirm its works.

2011/6/17 biff...@yahoo.co.uk <biff...@yahoo.co.uk>:

Makefile_rtai.diff
Makefile_rtai-examples.diff

Philipp Peter Tahiri

unread,
Jun 18, 2011, 7:38:24 AM6/18/11
to Bifferboard
Hi,

i dont really understand what are you writing. Did you make it work?
Your write a solution
but you said ", but error led not blinking".

So do we have a solution or nor?

sry for my bad english.

On Jun 17, 10:47 pm, nicolas le falher <n.lefal...@gmail.com> wrote:
> Hi,
>
> Two diff files for packages "rtai" and "rtai-examples".
> Compile works and modules load without problems.
> Binary "rtai-led-blink" running, but error led not blinking (maybe
> normal with a pull on every 0.5 seconds).
>
> If someone can confirm its works.
>
> 2011/6/17 biffe...@yahoo.co.uk <biffe...@yahoo.co.uk>:
>
>
>
>
>
>
>
>
>
>
>
> > On Jun 17, 12:24 am, nicolas le falher <n.lefal...@gmail.com> wrote:
> >> One error about RTAI.
> >> File "rtai_config.h" is not copied from cvs to $(STAGING_DIR)/usr/include
> >> cp ./build_dir/target-i386_uClibc-0.9.30.1/rtai_stable_cvs_20110206/rtai_config.h
> >> ./staging_dir/target-i386_uClibc-0.9.30.1/usr/include/
>
> > Yes, I never got this working, only up to here:
> >https://github.com/bifferos/openwrt/commit/2f4a93496f786f168dda622eb9...
> > OpenWrt build system + RTAI seriously messed with my head :-(.
>
> >> You can start with package "rtai-examples" in git.
> >> With this Makefile, I got just a pthread error :
>
> > Yes, you need pthread, it says on this page:
> >https://sites.google.com/site/bifferboard/openwrt-svn/rtai
> > I should add pthread as a dependency for the example programs, but
> > since I never got it working anyway I didn't bother.
>
> >> CC = $(shell $(STAGING_DIR)/usr/bin/rtai-config --cc)
> >> LXRT_CFLAGS = $(shell $(STAGING_DIR)/usr/bin/rtai-config --lxrt-cflags)
> >> LXRT_LDFLAGS = -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib -lpthread
>
> > I'm not sure this stuff is supposed to be in the lower-level makefile,
> > which for most packages is fairly generic, maybe better to put it in
> > the OpenWrt makefile instead?
>
> >> all: rtai-led-blink
>
> >> rtai-led-blink: rtai-led-blink.c
> >> $(CC) $(LXRT_CFLAGS) --static -o $@ $< $(LXRT_LDFLAGS) -llxrt
>
> > You can also compile programs linked against RTAI libs fairly easily
> > on another Linux machine if all you need is a static binary. Example
> > makefile and project is here:
> >https://sites.google.com/site/bifferboard/Home/desktop-linux-distribu...
>
> > Maybe you save a bit by static-linking to openwrt libc though.
>
> >> clean:
> >> rm -f *.o *~ rtai-led-blink
> >> ---------------------------------------------
>
> >> I will try again when I have more time.
>
> > If you can get it working I'll be very interested in a patch :).
>
> > thanks,
> > Biff.
>
> > --
> > To unsubscribe send email to bifferboard...@googlegroups.com
>
> --
>
> Nicolas Le Falher.
>
> Makefile_rtai.diff
> < 1KViewDownload
>
> Makefile_rtai-examples.diff
> 1KViewDownload

nicolas le falher

unread,
Jun 18, 2011, 8:21:38 AM6/18/11
to biffe...@googlegroups.com

Biff example code for RTAI works.
You can adapt your code for make a pkg.
Led not blinking because period (0.5 seconds), if you set a lower value, led blinking.

biff...@yahoo.co.uk

unread,
Jun 18, 2011, 8:59:26 AM6/18/11
to Bifferboard

I tried the patch but I get this error:

root@OpenWrt:/# rtai-led-blink
rtai-led-blink[681] general protection ip:80494b1 sp:bfa00030 error:
7a2 in rtai-led-b]
Segmentation fault

But everything seemed to link OK:

root@OpenWrt:/usr/bin# ls -l rtai-led-blink
-rwxr-xr-x 1 root root 39473 Jun 18 11:51 rtai-led-
blink
root@OpenWrt:/usr/bin# ldd rtai-led-blink
libpthread.so.0 => /lib/libpthread.so.0 (0xb77bf000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb77b6000)
libc.so.0 => /lib/libc.so.0 (0xb7769000)
ld-uClibc.so.0 => /lib/ld-uClibc.so.0 (0xb77d4000)


cheers,
Biff.

biff...@yahoo.co.uk

unread,
Jun 18, 2011, 12:11:58 PM6/18/11
to Bifferboard

I'm just being an idiot. Patch is fine and I've applied it.

https://github.com/bifferos/openwrt/commit/a3defdda39e4df5a53b5f664175a3300567c1649

thanks,
Biff.

biff...@yahoo.co.uk

unread,
Jun 18, 2011, 1:45:37 PM6/18/11
to Bifferboard

I also updated the site page on this, it's now become much simpler
thanks to Nicolas:
https://sites.google.com/site/bifferboard/openwrt-svn/rtai

Message has been deleted

Philipp Peter Tahiri

unread,
Jul 24, 2011, 5:19:03 PM7/24/11
to Bifferboard
Hi,

sorry for my late response, but i had no time

I tried this: https://sites.google.com/site/bifferboard/openwrt-svn/rtai
but i got a segmentation fault.

Here are my steps, did i forget something?

root@OpenWrt:~# killall watchdog
root@OpenWrt:~# rmmod rdc321x_wdt
root@OpenWrt:~# insmod rtai_hal.ko
root@OpenWrt:~# insmod rtai_lxrt.ko
root@OpenWrt:~# insmod rtai_fifos.ko
root@OpenWrt:~# rtai-led-demo
Usage: rtai-led-demo [blink|pulsate]
root@OpenWrt:~# rtai-led-demo blink
Segmentation fault
root@OpenWrt:~# rtai-led-demo pulsate
Segmentation fault

How can i find out, if my insmod worked or not? if I type "insmod
blabla" i get no feedback?

lsmod dont show any of the rtai_*.ko modules

Thank you :)

On Jun 18, 7:45 pm, "biffe...@yahoo.co.uk" <biffe...@yahoo.co.uk>
wrote:

- Hide quoted text -
- Show quoted text -

nicolas le falher

unread,
Jul 24, 2011, 5:21:41 PM7/24/11
to biffe...@googlegroups.com
Hi,

Try to load your modules without .ko.

root@OpenWrt:/# insmod rtai_hal
I-pipe: Domain RTAI registered.
RTAI[hal]: <3.8.1> mounted over IPIPE-NOTHREADS 2.7-03.
RTAI[hal]: compiled with gcc version 4.1.2.
RTAI[hal]: mounted (IPIPE-NOTHREADS, IMMEDIATE (INTERNAL IRQs
DISPATCHED), ISOL_CPUS_MASK: 0).
PIPELINE layers:
c39a5380 9ac15d93 RTAI

2011/7/24 Philipp Peter Tahiri <phili...@arcor.de>:

Philipp Peter Tahiri

unread,
Jul 24, 2011, 6:07:24 PM7/24/11
to Bifferboard
Ohh thank you nicolas :)

Now it works, but i still got no feedback by using insmod.

I would like to play a little bit around with this sample:
https://raw.github.com/bifferos/openwrt/master/package/rtai-examples/src/rtai-led-demo.c
And i am looking for a good way to compile it. Is there a sdk or
something like that to do this in an easy way? I just have downloaded
the
git (git://github.com/bifferos/openwrt.git)

I would like to compile this file with gcc rtai-led-demo.c and then
move it over scp. But it is not so easy ;)

On Jul 24, 11:21 pm, nicolas le falher <n.lefal...@gmail.com> wrote:
> Hi,
>
> Try to load your modules without .ko.
>
> root@OpenWrt:/# insmod rtai_hal
> I-pipe: Domain RTAI registered.
> RTAI[hal]: <3.8.1> mounted over IPIPE-NOTHREADS 2.7-03.
> RTAI[hal]: compiled with gcc version 4.1.2.
> RTAI[hal]: mounted (IPIPE-NOTHREADS, IMMEDIATE (INTERNAL IRQs
> DISPATCHED), ISOL_CPUS_MASK: 0).
> PIPELINE layers:
> c39a5380 9ac15d93 RTAI
>
> 2011/7/24 Philipp Peter Tahiri <philipp....@arcor.de>:

nicolas le falher

unread,
Jul 25, 2011, 4:03:13 AM7/25/11
to biffe...@googlegroups.com
You can edit directly rtai-led-demo.c and compile package like this :
#make package/rtai-examples/compile V=99
After scp your .ipk from bin/rdc/package to Bifferboard

Or make a new package and adapt from rtai-examples directory.

@Biff, can you edit Rtai documentation about insmod ?


2011/7/25 Philipp Peter Tahiri <phili...@arcor.de>:

biff...@yahoo.co.uk

unread,
Jul 25, 2011, 5:08:08 AM7/25/11
to Bifferboard

On Jul 25, 9:03 am, nicolas le falher <n.lefal...@gmail.com> wrote:
> @Biff, can you edit Rtai documentation about insmod ?

Ahhh... if you are in the modules directory, it worked as documented.
I've fixed it now though.

thanks,
Biff.
Reply all
Reply to author
Forward
0 new messages