OpenWrt Forum Archive

Topic: [SOLVED] I can't make PWM works

The content of this topic has been archived on 6 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi, i'm gonna paste my full dmesg and remark the errors.

I tried recompiling a lot but no success, how can i make pwm modules working? What i'm missing? I tried to google but almost nobody is interested in PWM.

CFE version 1.0.37-6.8-39 for BCM96348 (32bit,SP,BE)
Build Date: äº  9æ  9 18:04:58 CST 2008 (tony@broadcom2.comtrend.com)
Copyright (C) 2000-2005 Broadcom Corporation.

Boot Address 0xbfc00000

Initializing Arena.
Initializing Devices.
Parallel flash device: name MX29LV320AB, id 0x22a8, size 4096KB
error on Ethernet Switch setup
Failed initializing enet hardware
CPU type 0x29107: 240MHz, Bus: 133MHz, Ref: 26MHz
Total memory: 16777216 bytes (16MB)

Total memory used by CFE:  0x80401000 - 0x80525830 (1198128)
Initialized Data:          0x8041CF50 - 0x8041EF50 (8192)
BSS Area:                  0x8041EF50 - 0x80423830 (18656)
Local Heap:                0x80423830 - 0x80523830 (1048576)
Stack Area:                0x80523830 - 0x80525830 (8192)
Text (code) segment:       0x80401000 - 0x8041CF48 (114504)
Boot area (physical):      0x00526000 - 0x00566000
Relocation Factor:         I:00000000 - D:00000000

Board IP address                  : 192.168.144.150
Host IP address                   : 192.168.144.100
Gateway IP address                :
Run from flash/host (f/h)         : f
Default host run file name        : vmlinux
Default host flash file name      : bcm963xx_fs_kernel
Boot delay (0-9 seconds)          : 1
Board Id Name                     : 96348A-122
Psi size in KB                    : 24
Number of MAC Addresses (1-32)    : 11
Base MAC Address                  : XX:XX:XX:XX:XX:XX
Ethernet PHY Type                 : Internal
Memory size in MB                 : 16
CMT Thread Number                 : 0

Could not activate network interface 'eth0': CFE error -1
*** Press any key to stop auto run (1 seconds) ***
Auto run second count down: 0
Code Address: 0x80010000, Entry Address: 0x80010000
Decompression OK!
Entry at 0x80010000
Starting program at 0x80010000
[    0.000000] Linux version 3.6.11 (cienti@fasito) (gcc version 4.6.4 20121210 (prerelease) (Linaro GCC 4.6-2012.12) ) #1 Fri Feb 1 20:24:58 CET 2013
[    0.000000] Detected Broadcom 0x6348 CPU revision b0
[    0.000000] CPU frequency is 240 MHz
[    0.000000] 16MB of RAM installed
[    0.000000] registering 37 GPIOs
[    0.000000] board_bcm963xx: Boot address 0xbfc00000
[    0.000000] board_bcm963xx: CFE version: 1.0.37-6.8
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU revision is: 00029107 (Broadcom BMIPS3300)
[    0.000000] board_bcm963xx: board name: 96348A-122
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 01000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x00000000-0x00ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x00000000-0x00ffffff]
[    0.000000] Reserving 0MB of memory at 0MB for crashkernel
[    0.000000] Primary instruction cache 16kB, VIPT, 2-way, linesize 16 bytes.
[    0.000000] Primary data cache 8kB, 2-way, VIPT, no aliases, linesize 16 bytes
[    0.000000] Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 4064
[    0.000000] Kernel command line:  root=/dev/mtdblock2 rootfstype=squashfs,jffs2 noinitrd console=ttyS0,115200
[    0.000000] PID hash table entries: 64 (order: -4, 256 bytes)
[    0.000000] Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.000000] __ex_table already sorted, skipping sort
[    0.000000] Memory: 12948k/16384k available (2279k kernel code, 3436k reserved, 407k data, 212k init, 0k highmem)
[    0.000000] NR_IRQS:128
[    0.000000] Calibrating delay loop... 239.10 BogoMIPS (lpj=478208)
[    0.032000] pid_max: default: 32768 minimum: 301
[    0.036000] Mount-cache hash table entries: 512
[    0.048000] NET: Registered protocol family 16
[    0.072000] registering PCI controller with io_map_base unset
[    0.100000] bio: create slab <bio-0> at 0
[    0.112000] PCI host bridge to bus 0000:00
[    0.116000] pci_bus 0000:00: root bus resource [mem 0x30000000-0x37ffffff]
[    0.120000] pci_bus 0000:00: root bus resource [io  0x8000000-0x800ffff]
[    0.124000] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
[    0.140000] pci 0000:00:01.0: BAR 0: assigned [mem 0x30000000-0x30001fff]
[    0.148000] Switching to clocksource MIPS
[    0.164000] PCI: Enabling device 0000:00:01.0 (0000 -> 0002)
[    0.196000] ssb: Found chip with id 0x4318, rev 0x02 and package 0x00
[    0.260000] ssb: Sonics Silicon Backplane found on PCI device 0000:00:01.0
[    0.272000] NET: Registered protocol family 2
[    0.276000] TCP established hash table entries: 512 (order: 0, 4096 bytes)
[    0.284000] TCP bind hash table entries: 512 (order: -1, 2048 bytes)
[    0.292000] TCP: Hash tables configured (established 512 bind 512)
[    0.296000] TCP: reno registered
[    0.300000] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.308000] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.316000] NET: Registered protocol family 1
[    0.324000] audit: initializing netlink socket (disabled)
[    0.332000] type=2000 audit(0.332:1): initialized
[    0.340000] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.344000] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.356000] msgmni has been set to 25
[    0.360000] io scheduler noop registered
[    0.364000] io scheduler deadline registered (default)
[    0.372000] bcm63xx_uart.0: ttyS0 at MMIO 0xfffe0300 (irq = 10) is a bcm63xx_uart
[    0.380000] console [ttyS0] enabled, bootconsole disabled
[    0.380000] console [ttyS0] enabled, bootconsole disabled
[    0.400000] physmap platform flash device: 00400000 at 1fc00000
[    0.408000] physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x0000c2 Chip ID 0x0022a8
[    0.420000] Amd/Fujitsu Extended Query Table at 0x0040
[    0.424000]   Amd/Fujitsu Extended Query version 1.1.
[    0.428000] number of CFI chips: 1
[    0.432000] bcm63xxpart: CFE boot tag found with version 6 and board type 96348A-122
[    0.440000] bcm63xxpart: Partition 0 is CFE offset 0 and length 10000
[    0.448000] bcm63xxpart: Partition 1 is kernel offset 10100 and length eff00
[    0.456000] bcm63xxpart: Partition 2 is rootfs offset 100000 and length 2f0000
[    0.464000] bcm63xxpart: Partition 3 is nvram offset 3f0000 and length 10000
[    0.472000] bcm63xxpart: Partition 4 is linux offset 10000 and length 3e0000
[    0.476000] bcm63xxpart: Spare partition is offset 320004 and length cfffc
[    0.484000] 5 bcm63xxpart partitions found on MTD device physmap-flash.0
[    0.492000] Creating 5 MTD partitions on "physmap-flash.0":
[    0.496000] 0x000000000000-0x000000010000 : "CFE"
[    0.508000] 0x000000010100-0x000000100000 : "kernel"
[    0.516000] mtd: partition "kernel" must either start or end on erase block boundary or be smaller than an erase block -- forcing read-only
[    0.532000] 0x000000100000-0x0000003f0000 : "rootfs"
[    0.544000] mtd: partition "rootfs" set to be root filesystem
[    0.552000] mtd: partition "rootfs_data" created automatically, ofs=320000, len=D0000
[    0.560000] 0x000000320000-0x0000003f0000 : "rootfs_data"
[    0.572000] 0x0000003f0000-0x000000400000 : "nvram"
[    0.584000] 0x000000010000-0x0000003f0000 : "linux"
[    0.596000] bcm63xx-spi bcm63xx-spi: at 0xfffe0c00 (irq 9, FIFOs size 63) v0.1.2
[    0.624000] libphy: bcm63xx_enet MII bus: probed
[    0.632000] b53_common: found switch: BCM5325, rev 0
[    0.636000] bcm63xx_enet bcm63xx_enet.1: attached PHY at address 0 [Broadcom B53 (1)]
[    0.652000] bcm63xx-wdt bcm63xx-wdt:  started, timer margin: 30 sec
[    0.664000] TCP: cubic registered
[    0.668000] NET: Registered protocol family 17
[    0.676000] 8021q: 802.1Q VLAN Support v1.8
[    0.696000] VFS: Mounted root (squashfs filesystem) readonly on device 31:2.
[    0.704000] Freeing unused kernel memory: 212k freed
awk: /proc/cpuinfo: No such file or directory
- preinit -
Press the [f] key and hit [enter] to enter failsafe mode
- regular preinit -
[   10.384000] jffs2: notice: (324) jffs2_build_xattr_subsystem: complete building xattr subsystem, 1 of xdatum (0 unchecked, 0 orphan) and 7 of xref (0 dead, 2 orphan) found.
switching to jffs2
- init -

Please press Enter to activate this console. [   12.988000] Compat-drivers backport release: compat-drivers-2013-01-08-3
[   12.996000] Backport based on wireless-testing.git master-2013-01-07
[   13.004000] compat.git: wireless-testing.git
[   13.088000] cfg80211: Calling CRDA to update world regulatory domain
[   13.092000] cfg80211: World regulatory domain updated:
[   13.100000] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
[   13.108000] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[   13.116000] cfg80211:   (2457000 KHz - 2482000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
[   13.124000] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
[   13.132000] cfg80211:   (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[   13.140000] cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[   14.544000] b43-phy0: Broadcom 4318 WLAN found (core revision 9)
[   14.592000] b43-phy0: Found PHY: Analog 3, Type 2 (G), Revision 7
[   14.620000] Broadcom 43xx driver loaded [ Features: PNL ]
[   14.696000] Button Hotplug driver version 0.4.1
[   15.584000] ip_tables: (C) 2000-2006 Netfilter Core Team
[   16.148000] nf_conntrack version 0.5.0 (205 buckets, 820 max)
[   16.552000] pwm: module license 'unspecified' taints kernel.
[   16.560000] Disabling lock debugging due to kernel taint
[   16.564000] pwm: Unknown symbol device_unregister (err 0)
[   16.572000] pwm: Unknown symbol put_device (err 0)
[   16.576000] pwm: Unknown symbol __class_register (err 0)
[   16.580000] pwm: Unknown symbol device_create (err 0)
[   16.588000] pwm: Unknown symbol sysfs_create_group (err 0)
[   16.592000] pwm: Unknown symbol queue_work (err 0)
[   16.600000] pwm: Unknown symbol __alloc_workqueue_key (err 0)
[   16.604000] pwm: Unknown symbol class_find_device (err 0)
[   16.640000] gpio_pwm: Unknown symbol pwm_unregister (err 0)
[   16.648000] gpio_pwm: Unknown symbol pwm_register (err 0)
[   23.136000] eth0: link UP - 100/full - flow control off
[   23.200000] device eth0 entered promiscuous mode
[   23.208000] br-lan: port 1(eth0) entered forwarding state
[   23.212000] br-lan: port 1(eth0) entered forwarding state
[   24.144000] eth0: link UP - 100/full - flow control off
[   25.216000] br-lan: port 1(eth0) entered forwarding state
[   29.572000] b43-phy0: Loading firmware version 666.2 (2011-02-23 01:15:07)
[   37.148000] wlan0: authenticate with YY:YY:YY:YY:YY:YY
[   37.156000] wlan0: send auth to YY:YY:YY:YY:YY:YY (try 1/3)
[   37.364000] wlan0: send auth to YY:YY:YY:YY:YY:YY (try 2/3)
[   37.372000] wlan0: authenticated
[   37.380000] b43 ssb0:0: wlan0: disabling HT/VHT due to WEP/TKIP use
[   37.384000] b43 ssb0:0: wlan0: disabling HT as WMM/QoS is not supported by the AP
[   37.392000] b43 ssb0:0: wlan0: disabling VHT as WMM/QoS is not supported by the AP
[   37.404000] wlan0: associate with YY:YY:YY:YY:YY:YY (try 1/3)
[   37.412000] wlan0: RX AssocResp from YY:YY:YY:YY:YY:YY (capab=0x411 status=0 aid=5)
[   37.424000] wlan0: associated



BusyBox v1.19.4 (2013-02-01 19:48:29 CET) built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 BARRIER BREAKER (Bleeding Edge, r35412)
 -----------------------------------------------------
  * 1/2 oz Galliano         Pour all ingredients into
  * 4 oz cold Coffee        an irish coffee mug filled
  * 1 1/2 oz Dark Rum       with crushed ice. Stir.
  * 2 tsp. Creme de Cacao
 -----------------------------------------------------
root@OpenWrt:/#

The errors:

[   16.552000] pwm: module license 'unspecified' taints kernel.
[   16.560000] Disabling lock debugging due to kernel taint
[   16.564000] pwm: Unknown symbol device_unregister (err 0)
[   16.572000] pwm: Unknown symbol put_device (err 0)
[   16.576000] pwm: Unknown symbol __class_register (err 0)
[   16.580000] pwm: Unknown symbol device_create (err 0)
[   16.588000] pwm: Unknown symbol sysfs_create_group (err 0)
[   16.592000] pwm: Unknown symbol queue_work (err 0)
[   16.600000] pwm: Unknown symbol __alloc_workqueue_key (err 0)
[   16.604000] pwm: Unknown symbol class_find_device (err 0)
[   16.640000] gpio_pwm: Unknown symbol pwm_unregister (err 0)
[   16.648000] gpio_pwm: Unknown symbol pwm_register (err 0)

Thanks in advance

(Last edited by aiayua on 5 Feb 2013, 05:50)

Ok, advances:

- I enabled pwm related parts into kernel_menuconfig and got rid of that error messages but PWM still not working.

Searched a lot, and it appears the pwm driver is old a lot (2010). The newest version, from Bill Gatliff is in his git http://git.billgatliff.com/pwm.git

I tried to replace files, kernel_menuconfig accept it perfectly, and tried first enabling kmod_pwm and kmod_gpio-pwm at menuconfig ... no results. Disabling both, also no results.

Following this example I have no results, when I should have /config/gpio_pwm created, this folder is missing (and i got 'operation not permitted' if I try to create it)

With the openwrt pwm version, as I searched, I need to create a pwm structure inside board definition but ... no example anywhere of how to do it.

And with the newest version, I directly loose the ability to config it

Please developers ... just a breadcrumb to continue, an example or a url ... I dont want a full solution, but I loose many days with 0% success and I suppose for you it's so easy to imagine what is a possible solution.

Thanks in advance

(Last edited by aiayua on 4 Feb 2013, 17:05)

PWM on what hardware? Using what GPIO (I assume)?

Sorry I suppose that information is clear at my bootlog.

My router is a CT5365, the board is 96348A-122. Broadcom 6348 processor. I want to generate pwm on gpio 0 (released from 96348A-122 board patch and commenting led definition ... I tried the gpio alone with sysfs and it works correctly).

But I didn't reach the "I can config the pwm" level ... because i have no known configuration choices.

you can try an old openwrt version known to work with this driver

https://sites.google.com/site/bifferboard/Home/pwm-gpio

So build a fresh Openwrt with that kernel 2.6.37.6. One of the latest revisions with that kernel was r27230

svn -r r27230 co svn://svn.openwrt.org/openwrt/trunk/

(A problem might be errors when building if you use a recent version linux distro in your PC)

If you make it work, then your hadware is ok and you are ready to send a bug to developers smile

It will surely works, because it still uses pwm-gpio-custom. The thing is, in actual trunk there is no pwm-gpio-custom, if you look the svn log filtering by "pwm" you can see it how appears and disappears, but trunk's pwm is still older than updated pwm driver from Bill Gatliff. Is like a dead zone.

I will try first to fresh start a new trunk, search for the right structure, add it to board definition and test.

If it works, i'll then modify pwm source with the newest and test again, this time with configfs ... i think i'm missing something but ... i don't know it yet hehehe

I will try your solution too anyway, needs to eliminate possibilities.

Yeah!

After a fresh install, and following Bill Gatliff pwm developing footsteps via his changelog, I managed to run the updated driver.

Now it's configured via /configfs and works perfect.

I'll write a wiki entry with a patch and instructions and will put the link here.

Thanks for your help

Great job!
I was able to build gpio-pwm module and got existing /sys/class/pwm folder.
Unfortunately, configfs does not work for me - i can't mount it.
How shall I make it working?
Is there any way to config PWMs directly through /sys/class/something?

Did you follow all the steps from here (http://patchwork.openwrt.org/patch/3247/) and patching from here (http://patchwork.openwrt.org/patch/3248/) ??

3247 patch have a little bug so i posted 3248 (it's fine)

1. patch
2. check again you have configfs, pwm and gpio_pwm in kernel_menuconfig (not simple menuconfig)
3. If still fails, paste here or via pastebin your log

I hope we can fix it big_smile

In fact, I don't understand how to correctly apply the patch from http://patchwork.openwrt.org/. Is there any manual about that?

(Last edited by elmot on 3 Apr 2013, 22:13)

Tried to put latest pwm driver from
http://git.billgatliff.com/pwm.git/?p=p … 1a8de0dbc5

into my build tree. *.o files were built but then I got build failure with message:

sort done marker at 2d9a14
  SYSMAP  System.map
  Building modules, stage 2.
  MODPOST 125 modules
ERROR: "kobject_set_name_vargs" [drivers/pwm/pwm.ko] undefined!
make[6]: *** [__modpost] Error 1
make[5]: *** [modules] Error 2

kobject.o with kobject_set_name_vargs symbol is build.

Any help is welcome.

To apply a patch you just need a bit of google's help man ... [Info:How to create and apply a patch with subversion]

That is my first result for me after googled "svn patch" ...


As you can see at the third line of the patch:

--- target/linux/generic/files/include/linux/pwm/pwm.h    (revision 35501)

First you need to get that svn revision (35501)  [Info:Checkout a specific revision from subversion from command line]

Or if you use something like TortoiseSVN, search for it.

After checkout, apply patch, and then, update. Why? I can't ensure it properly functions in a newer revision, because I don't know if some of the files were modified or removed, then you need my same start point (35501), patch it and then, update full local copy of repo.

Try it and inform us

I get a fresh 35501 install and patch with 3248, with this error

patching file target/linux/generic/files/include/linux/pwm/pwm.h
Hunk #1 FAILED at 1.
patch: **** malformed patch at line 198: struct device *parent,

Do you Known how to fix this...

Thanks in advance

Another option is to use the PWM current code. But you will need to modify you board data.

Example: http://pastebin.com/XJtMtEFi

The code added here is:

+#include <linux/pwm/pwm.h>


+struct gpio_pwm_platform_data blue5g_pwm_gpio = {
+        .gpio = 3,
+};
+static struct platform_device blue5g_pwm_gpio_device = {
+        .name                   = "gpio_pwm",
+        .id                     = 0,
+        .dev.platform_data      = &blue5g_pwm_gpio,
+};
+static struct platform_device * __initdata blue5g9_devices[] = {
+        &blue5g_pwm_gpio_device,
+};


                },
        },
+        .devs = blue5g9_devices,
+        .num_devs = ARRAY_SIZE(blue5g9_devices),

};

(Last edited by danitool on 9 Apr 2013, 13:09)

ggrela wrote:

I get a fresh 35501 install and patch with 3248, with this error

patching file target/linux/generic/files/include/linux/pwm/pwm.h
Hunk #1 FAILED at 1.
patch: **** malformed patch at line 198: struct device *parent,

Do you Known how to fix this...

Thanks in advance

I have the same error!

Most likely the code has changed.
Have you looked at the actual source code and the patch? Do they make sense?

The discussion might have continued from here.