Mount SYS from dev containers

Hi,
I am following: How to Use PWM on Torizon OS | Toradex Developer Center
However, instead of downloading and building image from PC, I try to use Visual Code → Toradex: Create C/C++ project. Copy paste the code from: toradex/torizon-samples/pwm/
It compiled successfully. However I got:

Error Number 2
pwm: No such file or directory
failed to export

Is it possible to mount SYS from the Torizon configuration (appconfig_0)?

Please advise.
Best regards,

  • The module you’re using: Verdin Plus
  • The carrier board you’re using: Dahlia
  • The TorizonCore version installed:

torizon@verdin-imx8mp-07331021:~$ cat /etc/os-release
ID=torizon
NAME=“TorizonCore”
VERSION=“5.7.0+build.17 (dunfell)”
VERSION_ID=5.7.0-build.17
PRETTY_NAME=“TorizonCore 5.7.0+build.17 (dunfell)”
DISTRO_CODENAME=“dunfell”
BUILD_ID=“17”
ANSI_COLOR=“1;34”
VARIANT=“Docker”

Hi @ducnn ,

Is it possible to mount SYS from the Torizon configuration (appconfig_0)?

Yes, it is possible: Add a new entry in the volumes property, then put /sys as key and as value of the new element. You can find more information about the extension properties here: IDE Extension | Toradex Developer Center.

This message:

pwm: No such file or directory

possibly indicates that directory pwm in /sys/class/pwm/pwmchip0/export is not being found by the container. It shouldn’t happen if /sys is bind mounted as described above.

How are you trying to run the program on the module exactly? Deploying it through VSCode (e.g. by pressing F5), or running docker run directly on the module?

Best regards,
Lucas Akira

Hi Lucas,

Yes, deploying through VSCode.
image

But it still doesn’t work:

Hi @ducnn ,

Can you see if the pwm folder exists on your device? Just run

ls -l /sys/class/pwm

on your Verdin and post the output here.

Did you change anything related to the device tree, like adding or removing device tree overlays? What is the output of:

cat /boot/ostree/torizon-*/dtb/overlays.txt

Best regards,
Lucas Akira

A quick update: When double-checking your images internally we just noticed that you put the key in volumes as sys when it should be /sys.

Before doing anything I said above, try correcting that and see if your program works.

Best regards,
Lucas Akira

1 Like

Hi Lucas,
I think that it is just the display itself as my input is already /sys
image

Hi Lucas,
Here is the output of ls -l

torizon@verdin-imx8mp-07331021:~$ ls -l /sys/class/pwm
total 0
lrwxrwxrwx 1 root root 0 Jan 1 00:00 pwmchip0 → …/…/devices/platform/soc@0/30400000.bus/30660000.pwm/pwm/pwmchip0
lrwxrwxrwx 1 root root 0 Jan 1 00:00 pwmchip1 → …/…/devices/platform/soc@0/30400000.bus/30670000.pwm/pwm/pwmchip1
torizon@verdin-imx8mp-07331021:~$

The PWM works fine using the ‘echo’ command.

No, I don’t think that device tree overlays have been changed.

torizon@verdin-imx8mp-07331021:~$ cat /boot/ostree/torizon-*/dtb/overlays.txt
fdt_overlays=verdin-imx8mp_native-hdmi_overlay.dtbo verdin-imx8mp_lt8912_overlay.dtbo
torizon@verdin-imx8mp-07331021:~$

Best regards,

Hi Lucas,

I managed to make it work by creating a new project from scratch. Then reboot the target device.
Add /sys in volumes.
First run gives:

Error Number 13
failed to set period
pwm: Permission denied

And it starts working from the second run.

Hi @ducnn ,

Glad you managed to get it working!

Here you were changing the value of the element when you should’ve changed the key. Notice that it was still written sys on the left and not /sys. If you ever need to change the key of an entry in volumes just remove it by pressing the ‘-’ icon and add an entry again: it will first ask for a key, then for a value.

The result should’ve been something like this:
Screenshot_20221024_093214

Best regards,
Lucas Akira