PWM on Beaglebone FreeBSD

Hi,

I flashed FreeBSD (latest) on a Beaglebone Black.
There are no PWM's whatsoever, though some GPIO's, I2C, ADC are enabled.
How do I get started to enable at least few PWM's pins as
P9_21, P9_14, P9_16, P9_22, P8_7, P8_10

Code:
FreeBSD generic 13.0-CURRENT FreeBSD 13.0-CURRENT r351363 GENERIC  ar

dmesg | grep pwm yields nothing.
grepping in dts's for pwm as well nothing


Any start points where to look.
Thank you.


Code:
% dmesg | grep pwm
% dmesg | grep gpio
gpio0: <TI AM335x General Purpose I/O (GPIO)> mem 0-0xfff irq 12 on ti_sysc1
gpiobus0: <OFW GPIO bus> on gpio0
gpioc0: <GPIO controller> on gpio0
gpio1: <TI AM335x General Purpose I/O (GPIO)> mem 0-0xfff irq 35 on ti_sysc21
gpiobus1: <OFW GPIO bus> on gpio1
gpioc1: <GPIO controller> on gpio1
gpio2: <TI AM335x General Purpose I/O (GPIO)> mem 0-0xfff irq 44 on ti_sysc31
gpiobus2: <OFW GPIO bus> on gpio2
gpioc2: <GPIO controller> on gpio2
gpio3: <TI AM335x General Purpose I/O (GPIO)> mem 0-0xfff irq 45 on ti_sysc32
gpiobus3: <OFW GPIO bus> on gpio3
gpioc3: <GPIO controller> on gpio3
gpioled0: <GPIO LEDs> on ofwbus0
% dmesg | grep i2c
% dmesg | grep adc
ti_adc0: <TI ADC controller> mem 0-0xfff irq 15 disabled on ti_sysc4
ti_adc0: scheme: 0x1 func: 0x730 rtl: 0 rev: 0.1 custom rev: 0
% dmesg | grep i2C
% dmesg | grep SPI
% dmesg | grep spi

% find . | grep i2
% find . | grep sp
./ufssuspend
% find . | grep gpio
./gpioc0
./gpioc1
./gpioc2
./gpioc3
% find . | grep pwm
 
Last edited by a moderator:
It will take some work.
You need to create a Device Tree Overlay for PWM.
 
It will take some work.
You need to create a Device Tree Overlay for PWM.

Thank you very much
All according to the post, still no caps!.


Code:
% cd /boot/dtb/
% cat pwm.dts
/* Beaglebone enable PWM on FreeBSD 11 */                                                                                                             
/* preso da: https://goo.gl/v5eFZm   */                                                                                                               
                                                                                                                                                      
/dts-v1/;                                                                                                                                             
/plugin/;                                                                                                                                             
                                                                                                                                                      
/{
    compatible = "ti,beaglebone", "ti,beaglebone-black";


    fragment@0 {
        target = <&epwmss0>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@1 {
        target = <&ehrpwm0>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@2 {
        target = <&ecap0>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@3 {
        target = <&epwmss1>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@4 {
        target = <&ehrpwm1>;
        __overlay__ {
            status = "okay";
        };
    };

        fragment@5 {
                target = <&ecap1>;
                __overlay__ {
                        status = "okay";
                };
        };

    fragment@6 {
        target = <&epwmss2>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@7 {
        target = <&ehrpwm2>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@8 {
        target = <&ecap2>;
        __overlay__ {
            status = "okay";
        };
    };

    /* per associare i pin P9.21 e P9.22 */
    fragment@00 {
        target = <&am33xx_pinmux>;
        __overlay__ {
            ehrpwm0_AB: pinmux_ehrpwm0_AB {
                pinctrl-single,pins = <
                    0x154 0x03 /* P9.21 */
                    0x150 0x03 /* P9.22 */
                >;
            };
        };
    };

};

And compiled


Code:
root@generic:/boot/dtb # dtc -O dtb -o pwm.dtbo -@ pwm.dts
root@generic:/boot/dtb # ls -la | grep pwm
-rw-r--r--   1 root  wheel    1532 Aug 28 19:12 pwm.dtbo
-rw-r--r--   1 root  wheel    2402 Aug 28 19:12 pwm.dts
root@generic:/boot/dtb #
Then

Code:
root@generic:/boot # cat ./loader.conf
# Configure USB OTG; see usb_template(4).
hw.usb.template=3
umodem_load="YES"
# Disable the beastie menu and color
beastie_disable="YES"
loader_color="NO"
fdt_overlays="pwm.dtbo"

root@generic:/boot # reboot
....
....


root@generic:/boot # dmesg | grep pwm
root@generic:/boot #
 
AN
Thank you very much
All according to the post, still no caps!.


Code:
% cd /boot/dtb/
% cat pwm.dts
/* Beaglebone enable PWM on FreeBSD 11 */                                                                                                            
/* preso da: https://goo.gl/v5eFZm   */                                                                                                              
                                                                                                                                                     
/dts-v1/;                                                                                                                                            
/plugin/;                                                                                                                                            
                                                                                                                                                     
/{
    compatible = "ti,beaglebone", "ti,beaglebone-black";


    fragment@0 {
        target = <&epwmss0>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@1 {
        target = <&ehrpwm0>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@2 {
        target = <&ecap0>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@3 {
        target = <&epwmss1>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@4 {
        target = <&ehrpwm1>;
        __overlay__ {
            status = "okay";
        };
    };

        fragment@5 {
                target = <&ecap1>;
                __overlay__ {
                        status = "okay";
                };
        };

    fragment@6 {
        target = <&epwmss2>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@7 {
        target = <&ehrpwm2>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@8 {
        target = <&ecap2>;
        __overlay__ {
            status = "okay";
        };
    };

    /* per associare i pin P9.21 e P9.22 */
    fragment@00 {
        target = <&am33xx_pinmux>;
        __overlay__ {
            ehrpwm0_AB: pinmux_ehrpwm0_AB {
                pinctrl-single,pins = <
                    0x154 0x03 /* P9.21 */
                    0x150 0x03 /* P9.22 */
                >;
            };
        };
    };

};

And compiled


Code:
root@generic:/boot/dtb # dtc -O dtb -o pwm.dtbo -@ pwm.dts
root@generic:/boot/dtb # ls -la | grep pwm
-rw-r--r--   1 root  wheel    1532 Aug 28 19:12 pwm.dtbo
-rw-r--r--   1 root  wheel    2402 Aug 28 19:12 pwm.dts
root@generic:/boot/dtb #
Then

Code:
root@generic:/boot # cat ./loader.conf
# Configure USB OTG; see usb_template(4).
hw.usb.template=3
umodem_load="YES"
# Disable the beastie menu and color
beastie_disable="YES"
loader_color="NO"
fdt_overlays="pwm.dtbo"

root@generic:/boot # reboot
....
....


root@generic:/boot # dmesg | grep pwm
root@generic:/boot #

Anyone have this working...

If yes, what version what board what caps.
Thank you...
 
I stepped away from Arm for a while to learn servers, so I can't help with any recent info.
What I would recommend if your having troubles is to bake it in, instead of overlay.
You can slipstream it in by using DeviceTreeCompiler and decompile DTB add settings and recompile into DTS.

I saw you post on the mailing list and that is a good spot to ask. Also IRC on bsdmips channel
 
I used PWM to control motors. please check my posts around here; i am pretty sure i wrote the details. typing on phone now. FreeBSD 12. it will just work.
 
Back
Top