Jetson Nano PWM not working

Hi. I read all previous discussions but i have not found any clear instruction how to make PWM works.

Here is my steps:

  1. sudo /opt/nvidia/jetson-io/jetson-io.py
  2. Configure 40-pin expansion header
  3. Check “pwm0 (32)” and “pwm2 (33)” enabled.
  4. Reboot
  5. echo 0 > /sys/class/pwm/pwmchip0/export
  6. echo 50000 > /sys/class/pwm/pwmchip0/pwm0/period
  7. echo 25000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
  8. echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable
  9. Connect oscilloscope to PIN32 and GND

Expected: Oscilloscope shows 50 KHz signal, 50% DC
Actual: Oscilloscope shows random noise

I am 100% sure that oscilloscope is working and displaying correct results.

Is it wrong steps? Or a bug?

hello filipp,

please also examine your pin configuration, which has definition in the device tree.
you may disassembler the dtb file into text file for checking,
for example, $ dtc -I dtb -O dts -o output.txt tegra210-p3448-0000-p3449-0000-a02.dtb
thanks

What is the location of tegra210-p3448-0000-p3449-0000-a02.dtb?

I run your command and got:

dtc -I dtb -O dts -o output.txt tegra210-p3448-0000-p3449-0000-a02.dtb
FATAL ERROR: Couldn't open "tegra210-p3448-0000-p3449-0000-a02.dtb": No such file or directory

I have not configured or build kernel, I only run jetson-io.py - it’s not enough?

hello filipp,

it depends-on the device tree you’re flashing to you Nano platforms, you may check flashing messages for confirmation.
for example,

[ 260.8830 ] Writing partition DTB with tegra210-p3448-0000-p3449-0000-a02.dtb.encrypt
[ 260.9492 ] [................................................] 100%

you may found the *.dtb files under your output folder.
i.e. $OUT/Linux_for_Tegra/kernel/dtb/

I used official image from here, https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit#write.
I copied it with dd command and there was no output like you provided.

hello filipp,

according to pinmux spreadsheets, pin-32, GPIO07 and pin-33, GPIO13 were configure as GPIO by default.
please help to narrow down the issue,
please also have an alternative ways to have customization besides using Jetson-IO tools.
you may also refer to Pinmux Changes session to customize the pinmux spreadsheet.
thanks

Ok, I’ll try alternative way and let you know.
I thought jetson-io.py allows to reconfigure pins without flashing.

hello filipp,

please also check PWM status and share the results.
i.e. $ sudo cat /sys/kernel/debug/pwm

platform/70110000.pwm, 1 PWM device
 pwm-0   (pwm-regulator       ): requested enabled period: 2500 ns duty: 0 ns polarity: normal

platform/7000a000.pwm, 4 PWM devices
 pwm-0   (sysfs               ): requested enabled period: 50000 ns duty: 25000 ns polarity: normal
 pwm-1   (pwm-regulator       ): requested enabled period: 8000 ns duty: 4000 ns polarity: normal
 pwm-2   ((null)              ): period: 0 ns duty: 0 ns polarity: normal
 pwm-3   (pwm-fan             ): requested enabled period: 45334 ns duty: 0 ns polarity: normal

hello filipp,

you can only access pwmchip0 (@7000a000); pwmchip4(@70110000) is not expected to be used by user.

you may use pwm@pwmchip0 by exporting them.
i.e. echo '<0/1/2/3>' > /sys/class/pwm/pwmchip0/export

Have you read my messages?
In the first message i wrote the exact steps, i export pwmchip0
echo 0 > /sys/class/pwm/pwmchip0/export
Command /sys/kernel/debug/pwm shows debug info about everything. I am not using 70110000. I am using pwmchip0, can you see the lines:

platform/7000a000.pwm, 4 PWM devices
 pwm-0   (sysfs               ): requested enabled period: 50000 ns duty: 25000 ns polarity: normal

This is pwmchip0, enabled with period that I previously set with commands:

echo 0 > /sys/class/pwm/pwmchip0/export
echo 50000 > /sys/class/pwm/pwmchip0/pwm0/period
echo 25000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable

But no signal available on PIN32.

hello filipp,

there’s limits based on controller’s clock source and the frequency and pulse divisor values.
while there’s no messages means the channel and the settings has applied successfully.
could you please modify the period and dutycycle as below for confirmation?
for example,

echo 10000 > /sys/class/pwm/pwmchip0/pwm0/period
echo 2000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable

Modified:

platform/7000a000.pwm, 4 PWM devices
 pwm-0   (sysfs               ): requested enabled period: 10000 ns duty: 2000 ns polarity: normal

Still no signal - only random noise.

@filipp
Hi, did you solve this issue?
i have same with you.

No, issue was not solved.
My workaround was to buy arduino (leonardo) connect with USB and use PWM from there (actually it’s even more convenient).

@filipp
thanks, i solved by devmem as below.

may you can have a try.

1 Like

That didn’t help. I tried following:

sudo busybox devmem 0x700031fc 32 0x45
sudo busybox devmem 0x6000d504 32 0x2
echo 0 > /sys/class/pwm/pwmchip0/export
echo 25000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
echo 50000 > /sys/class/pwm/pwmchip0/pwm0/period
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable

Connected oscilloscope to PIN32 and GND.
No signal. Random noise.

@libsong
Could you please provide a step by step instruction that worked for you? May be you used some other commands in combination? Or may be you used some external power? Please tell more details, can’t get it work :(

@filipp
you dun assign value to period ?

Yes, I assign period with:
echo 50000 > /sys/class/pwm/pwmchip0/pwm0/period
Still only noise, no signal.

hello filipp,

may I know are you working with a customize board?
please refer to Topic 157462, for the steps to enabled Pin-32 as PWM.
thanks