How to enable PWM in Ubuntu Server 18.04 Image

I followed the instructions available here: https://wiki.radxa.com/Rockpi4/hardware/devtree_overlays.

I Installed rockchip-fstab and rockpi4-dtbo, edited /boot/hw_intfc.conf to set pwm0 and pwm1 to on, but after a reboot I am still getting that device is busy.

root@rockpi:/sys/class/pwm/pwmchip0# cat npwm 
1
root@rockpi:/sys/class/pwm/pwmchip0# echo 0 > export
-bash: echo: write error: Device or resource busy
root@rockpi:/sys/class/pwm/pwmchip0# echo 1 > export
-bash: echo: write error: No such device

I believe /boot/hw_intfc.conf is being ignored. Is there anywhere else that could set this?

My image is Ubuntu Server 18.04

Hi rodvlopes,

Can you provide the print of df?

And the print of ls -l /sys/class/pwm

root@rockpi:/sys/class/gpio/gpio146# df
Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/root       14722052   4297868   9785880  31% /
devtmpfs          985872         0    985872   0% /dev
tmpfs             986480         0    986480   0% /dev/shm
tmpfs             986480      2500    983980   1% /run
tmpfs               5120         0      5120   0% /run/lock
tmpfs             986480         0    986480   0% /sys/fs/cgroup
/dev/mmcblk1p4    102182     38844     63338  39% /boot
/dev/sda2      858090292 438977276 375501436  54% /mnt/sda2
tmpfs             197296         0    197296   0% /run/user/0

root@rockpi:/sys/class/gpio/gpio146# ls -l /sys/class/pwm
total 0
lrwxrwxrwx 1 root root 0 Jan 28  2018 pwmchip0 -> ../../devices/platform/ff420020.pwm/pwm/pwmchip0

Please execute the following command and let me know the result

cat /boot/hw_intfc.conf
sudo umount /boot
ls -al /boot
cat /boot/hw_intfc.conf

root@rockpi:~/workspace/scripts# cat /boot/hw_intfc.conf                                                                                               [27/29]
                        
# Hardware Interface Config
                                                            
# For more details, check https://wiki.radxa.com/Rockpi4/hardware/devtree_overlays.

# Set "on" to enable the optional hardware interfaces while set "off" to disable.
                          
intfc:pwm0=on
intfc:pwm1=on                                                                  
intfc:uart2=off               
intfc:uart4=off
intfc:spi1=on                                                                  
intfc:spi2=off                       
intfc:i2c2=off
intfc:i2c6=off                                                              
intfc:i2c7=off                    

# Devicetree Overlay Enable, uncomment to enable .dtbo under /boot/overlays/.
                          
# EEPROM on I2C2
#intfc:dtoverlay=at24c02
                              
# Serial console on UART2
intfc:dtoverlay=console-on-ttyS2                   
                                  
# Serial console on UART4
#intfc:dtoverlay=console-on-ttyS4               
                                       
# Dummy spi device on SPI1 for test. Need set: intfc:spi1=on
#intfc:dtoverlay=devspi1         
                        
# Dummy spi device on SPI2 for test. Need set: intfc:spi2=on
#intfc:dtoverlay=devspi2                                               
                       
# PCIE running on GEN2 mode
#intfc:dtoverlay=pcie-gen2                                             
                       
# ALLNET 4duino B10/B11 two-coloe-led module on 40-pin Header Pin#35 and Pin#36
#intfc:dtoverlay=two-color-led                          
                            
# waveshare 3.5inch lcd (B v2) on SPI1. Need set: intfc:uart4=off intfc:spi1=on
#intfc:dtoverlay=spi1-waveshare35b-v2

# waveshare 3.5inch lcd (C) on SPI1. Need set: intfc:uart4=off intfc:spi1=on
#intfc:dtoverlay=spi1-waveshare35c

# spi flash on SPI1. Need set: intfc:uart4=off intfc:spi1=on
intfc:dtoverlay=spi1-flash

#hifiberry-dac
#intfc:dtoverlay=hifiberry-dac

#hifiberry-dacplus on I2C7. Need set: intfc:i2c7=on
#intfc:dtoverlay=hifiberry-dacplus

#enable raspberry pi official 7 inch LCD support
#intfc:dtoverlay=raspberrypi-7-inch-lcd

# setting cpu frequency over-2GHz
#intfc:dtoverlay=cpufreq

# Add imx219 camera module support. Need disabled ov5647 camera module.
#intfc:dtoverlay=imx219

# Add ov5647 camera module support. Need disabled imx219 camera module.
#intfc:dtoverlay=ov5647

# Add w1 on GPIO4_D6 to support devices such as DS18B20.
#intfc:dtoverlay=w1-gpio4-30

root@rockpi:~/workspace/scripts# umount /boot
root@rockpi:~/workspace/scripts# ls -al /boot
total 8
drwxr-xr-x  2 root root 4096 Apr 24  2018 .
drwxr-xr-x 23 root root 4096 Jan 28  2018 ..
root@rockpi:~/workspace/scripts# 

root@rockpi:~/workspace/scripts# cat /boot/hw_intfc.conf
cat: /boot/hw_intfc.conf: No such file or directory
root@rockpi:~/workspace/scripts#

Sorry for the late reply. You can try updating the kernel via:

sudo apt-get install linux-base
sudo apt-get install linux-4.4-latest

I dont have linux-4.4-latest yet but my kernel is exactly in this version. I will prepared a new SD card to test this change to avoid messing up my running server.

root@rockpi:~# dpkg --get-selections | grep linux-4.4-latest
root@rockpi:~# dpkg --get-selections | grep  linux-base
linux-base					install
root@rockpi:~# uname -a
Linux rockpi.localdomain 4.4.154-59-rockchip-g5e70f14 #4 SMP Fri Dec 14 20:55:41 CST 2018 aarch64 aarch64 aarch64 GNU/Linux

You can use rockpi-backup.sh to back up your system.