PWM in NanoPi M4
Preparing NanoPi M4 for PWM
Installation
Download the file
rk3399-eflasher-friendlycore-bionic-4.4-arm64-20191227.img
from the FriendlyElec repository.
Then, install it in a 16GB flash memory through balenaEtcher or equivalent software.
You need to connect USB Keyboard and Mouse, and an HDMI monitor. Select the OS and click on Install.
The OS will be installed in the eMMC card (it's not included in the board, so it's necessary to buy as option).
Test
Connect the USB2Serial to the 4pins between the USB ports. It's necessary to cut a slice because it doesn't fit properly. The black wire is the most external.
Configuration:
1500000 Baud 8 Data bits 1 Stop bit Parity None Flow Control XON/XOFF
Username root, password fa .
PWM
Stop and disable the pwm-fan service
service pwm-fan stop systemctl disable pwm-fan
Then, start the PWM
echo 0 > /sys/class/pwm/pwmchip1/export echo normal > /sys/class/pwm/pwmchip1/pwm0/polarity echo 100000 > /sys/class/pwm/pwmchip1/pwm0/period echo 5000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle echo 1 /sys/class/pwm/pwmchip1/pwm0/enable
It's possible to test it connecting the PINS 19 (Ground) and 23 (PWM1) of the 24-Pins secondary header to a simple handheld oscilliscope. It will show a PWM signal of about 2V.