WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: PWM on piCore  (Read 397 times)

Offline boudinec

  • Newbie
  • *
  • Posts: 20
PWM on piCore
« on: January 09, 2025, 11:09:03 AM »
Hello

I want to use pwm and spi on a raspberry 3 using piCore 15.0.

In /mnt/mmcblkp1, I added:
dtparam=spi=on
dtparam=pwm=on
Then I rebooted.

The SPI works, I can use /dev/spidev0.0
But I cannot manage to make the PWM module working: the directory /sys/class/pwm/ is still empty.

Can you help me to fix this ?
Bests

Cedric

Online Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1293
Re: PWM on piCore
« Reply #1 on: January 09, 2025, 12:22:55 PM »
GPIO is all changed in the newer raspi kernels.  I'm not sure dtparam=pwm is even an option anymore.  Make sure you are looking at documentation from kernel 6.6.y

You need to look at the dtoverlays for pwm   

https://github.com/raspberrypi/linux/blob/14c5fee3bb3fd654605c33314645b27a8f1e7628/arch/arm/boot/dts/overlays/README#L4024

Offline boudinec

  • Newbie
  • *
  • Posts: 20
Re: PWM on piCore
« Reply #2 on: January 10, 2025, 05:51:14 AM »
Hello
Thanks for you answer Paul

I forgot to tell that my RPi is a 3B.
I also tried:
Code: [Select]
dtoverlay=pwm,pin=12,func=4and
Code: [Select]
dtoverlay=pwm,pin=18,func=2
Which is what is explained in the docs. But it doesn't works.
The documentation is the same as with bookworm (kernel 6.6.62) and the same config works.

I cannot see any errors in dmesg. Do you know if some errors messages are available about overlays?

I also tried to load from the shell but the overlays cannot be found:
Code: [Select]
tc@box:~$ dtoverlay -a
*Failed to find overlays directory

Do you know what show be the overlays directory?

Bests

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14873
Re: PWM on piCore
« Reply #3 on: January 10, 2025, 06:03:54 AM »
The overlays directory is at /mnt/mmcblk0p1/overlays - you need to mount /dev/mmcblk0p1 first.

Offline boudinec

  • Newbie
  • *
  • Posts: 20
Re: PWM on piCore
« Reply #4 on: January 10, 2025, 07:21:32 AM »
I mounted /dev/mmcblk0p1 with the graphical tool, so it is mounted as /mnt/mmcblk0p1.
And sitll dtoverlay fails to locate the overlays.

On raspberryPIOS, overlays are searched in /boot/overlays.
So, I created a simlink :
Code: [Select]
sudo ln -s /mnt/mmcblk0p1 /boot
The error has changed:
Code: [Select]
$sudo overlay -l
mount: /config/device-tree: mount point does not exist.
dmesg(1) may have more information after failed mount system call
* Failed to mount configfs - 2

dmesg gives no information about mount errors


Cedric

Online Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1293
Re: PWM on piCore
« Reply #5 on: January 10, 2025, 10:31:00 AM »
Tinycore does not use a configfs.  If you want to use dtoverlay to add an overlay, you need to specify everything.

I would just setup your config.txt and look at dmesg.  The first thing to look at is if the driver is even there.  The base system only includes the bare minimum.  I think you need pwm-bcm2835 which is not in the base.  You would need to get the module from here for your board

http://www.tinycorelinux.net/15.x/armhf/releases/RPi/src/kernel/modules-6.6.47-piCore.tar.xz

Make sure you the module pack matches the kernel version you are running.

Offline boudinec

  • Newbie
  • *
  • Posts: 20
Re: PWM on piCore
« Reply #6 on: January 13, 2025, 06:29:18 AM »
Hello Paul
Thanks a lot Paul.
I just extracted pwm-bcm2835.ko from modules-6.6.47-piCore-v7.tar.xz and ran:
Code: [Select]
sudo insmod pwm-bcm2835.koI can now use the pwm module.

Do you think that the ko file can be included in the base for next release? It is a builtin peripheral on raspberry PI like spi and i2c.

Bests
Cedric

Online Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1293
Re: PWM on piCore
« Reply #7 on: January 13, 2025, 06:43:53 AM »
It’s not commonly used,  but it’s always available.  You can easily make an extension for it.

Offline boudinec

  • Newbie
  • *
  • Posts: 20
Re: PWM on piCore
« Reply #8 on: January 13, 2025, 11:16:46 AM »
Ok thanks

Bests

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11745
Re: PWM on piCore
« Reply #9 on: January 13, 2025, 12:28:20 PM »
Hi boudinec
... You can easily make an extension for it.
Here is an example of how to make an extension:
https://forum.tinycorelinux.net/index.php/topic,26064.msg167212.html#msg167212