Help with Device Tree, Trying to expose kernel pps

@rony_vargas I have some interest in having a beagle as a sourced pps reference, so i hope you can share if you make a break thru. :smiley:

Could you re-detail what steps you have taken to get you where in a single post?
I think Robert recommended you install the dts overlay file and i believe he implied that should make everything work but did you already have an overlay file installed? The file that @RobertCNelson said should work, did it actually compile in the place he told you about?

Hello my friend @BobTheBuilder is a pleasure, Well I proved the github program of the pps of this link: jsln/pps-gen-gpio: Linux kernel PPS generator using GPIO pins (github.com), but when I proved it, it gived me an error that the library #include <linux/init.h> is not there, so I didn’t understand why is that problem.

But, When I changed the Makefile to this:
obj-m+=pps_gen_gpio.o

all:
make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) clean

it make the kernel module but I proved it, it didn’t give the output of the pps.
image

The DTS overlay file that Roberts recommended me I installed in the directory that it told me : cd /opt/source/bb.org-overlays/ and I used make and sudo make install

The overlay file That I used is this:
forRobert.dts (2,2 KB)

Thank you,
Rony Vargas

Hello my friend @RobertCNelson, How are you? Well I was checking this dts file " am335x-boneblack.dts", jsln/pps-gen-gpio: Linux kernel PPS generator using GPIO pins (github.com) , but I saw three dtsi include:

#include “am33xx.dtsi”
#include “am335x-bone-common.dtsi”
#include “am335x-boneblack-common.dtsi”

Where I can find those dtsi files?.

Thank you,
Rony Vargas

1 Like

That is kernel 4.19.x. There are more kernels in the menu for selecting the kernels that are available.

Seth

P.S. I think some .dts/.dtsi files are in the kernel now, too. Here is the link to the kernel docs. for the am335x which the BBB holds: dts « boot « arm « arch - kernel/git/torvalds/linux.git - Linux kernel source tree

That is of course the latest/greatest but you can view whatever kernel they have available (I think).

Would it be better to add this into a kernel instead of as a kernel module? I think you would still need the cape overlays.

Could someone help me with this (pps)? I am not sure where i have gotten lost on this module.

@silver2row @BobTheBuilder @RobertCNelson

@rony_vargas, I am sorry I cannot be much help on this. I do generic linux R&D with user space applications. I am not versed in kernel space that well and hit a hiccup with your device tree file. I can ask, did you properly install the headers like Robert mentioned?
@RobertCNelson or @silver2row would be better help.

Strange thing: I found that someone has “port forwarded” it to 5.4 and claimed they tested it on kernel 5.4.152 w/ P9 pin16 as PPS output. It looks like 1-to-1 copy of the code from GitHub - jsln/pps-gen-gpio: Linux kernel PPS generator using GPIO pins that @rony_vargas linked.

Side note: A pps that is generated out of the beagle would be 3.3v correct? An adapter board could be implemented if 5v logic was needed, say for interfacing with some video/audio capture equipment.

1 Like

Yes my friend but I did all the steps that @RobertCNelson told me, I installed the headers like Robert mentioned. I don’t know what is the problem,I did the steps about the link but it is not working.

@RobertCNelson my friend I saw that you contributed in the post about the pps overlays( Issues creating a PPS overlay · Issue #91 · beagleboard/bb.org-overlays · GitHub. Do you think this is what I need? the overlays to create the pps gpio output for the signal?

Best Regards,
Rony Vargas.

Any help @RobertCNelson @silver2row @BobTheBuilder?

Thank you,
Rony Vargas


I am adding the dts file of am335x-boneblack.dts to make the pps work with the kernel but I have this error when I compile the dts files. Any help @RobertCNelson @silver2row @BobTheBuilder ?

Thank you,
Rony Vargas.

Below is DMESG after insmod the k-module for pps generation.

[ 1099.931732] pps_gen_gpio: loading out-of-tree module taints kernel.
[ 1099.939595] GPIO PPS signal generator

“Show-pins” is now giving me:

P9.16 19 fast rx down 7 gpio 1.19 lo >> pps-gen (pinmux_pps_gen_pins)

which looks right when compared to:

P9.26 96 fast rx 0 uart 1 rxd serial@48022000 (pinmux_bb_uart1_pins)
P9.24 97 fast 0 uart 1 txd serial@48022000 (pinmux_bb_uart1_pins)

The DTS file I am using is similar to the one Rony has posted for robert. I lack the

status = “okay”;

in the pps-gen / pps_gen fragment (Not sure proper naming convention for this param, github’s or Rony’s?).

I made a small edit and ensured that “make” & “make install” ran. The new DD-GPS-00A0-2 .dtbo file from the dts file

DD-GPS-00A0-2.dts (2.2 KB)

@rony_vargas besides reviewing your linux headers as previously mentioned, i’d check the device tree and if you got your pins setup correctly sir.

Best,
a simple builder

1 Like

Hello Rony,

Seth here. I have found little and tried a bit less than I would have liked thus far. There are some kernel related dtbo files that can be built into kernels if building outside of what the BBB persons are building in their kernel.

There is also a new git.beagleboard.org site I found via this forum. They have some Device-Tree ideas.

Right now, I am not sure whether you need to build in the kernel, u-boot, or if beagleboard.org persons have already made some .dts files to alter for your use. I am sorry. I have fallen aside.

Seth

Hi, I am interested in this aswell. Has somebody got it working in the meantime?

1 Like

@rony_vargas ,

Rony, Seth here. Okay…so it seems that if allowed via the DTS and beagleboard.org persons, PPS should work. I found this in the kernel docs: PPS - Pulse Per Second — The Linux Kernel documentation .

Seth

P.S. I have not tried this idea yet but it seems it is plausible. I will try to find time. I cannot promise anything.

Also…there is another page on this forum regarding PPS in the kernel.

Update

Okay…so. pps-ktimer is not found by modprobe. This means it is not installed via sysfs for now for whatever reason. Since we are dealing w/ actual hardware and the source files need to be installed alongside sysfs, one would have to bundle it w/ a new build?

Reviewing the kernel docs gives some inclination on how to install pps-tools via a package manager (apt and it works) but I am new to pps-tools. I will learn some more…

Another Update

Look here and it has armhf availability. Try it. I will try it later… Enjoy! Oops. Here: GitHub - redlab-i/pps-tools: User-space tools for LinuxPPS

Why do this in a kernel module? If the sum total of the requirements are that it come from the bbb platform over a gpio header, why not use one of the pru?

I don’t know how accurate this pulse needs to be, but aren’t even kernel modules subject to interrupt delays?

sorry if I missed where the requirements specify a kernel module

gomer

I got the option of the pps-generator, that @RobertCNelson pointed out earlier, somewhat working on the beaglebone black on a custom 5.10.162 Kernel . But it s not very consistent. Nearly every 5-10th Pulse goes missing. Sometimes even every 3rd.

I can share the exact steps to build the custom kernel, adding the driver and adding the overlay for the specified pin, if anyone needs that. But in essence, I put the files from damon-kwok into the correct places in BB-Kernel, build the driver as a module(I had some problems when it was build into the kernel), replaced the boot Image with the new build Image and added a Device Tree Overlay. The devicetree overlay seems to autoload the pps-gen module when booting.

I stumbled upon another repo by damon-kwok that seems to be based of jsln.

The main difference I saw is that the time was changed from “timespec” to “timespec64” and instead of “getnstimeofday” “ktime_get_real_ts64” is used. I am not very versed in kernel drivers and don’t know the difference. The only reason I used damon-kwok’s repo is that I saw his first.

I am using a GPS module to generate and synchronize the BBB with Chrony. The time difference between the GPS Pulse and the generated Pulse is ~150us . Depending on your application this might already be enough.

For this I had to compile the pps-generator driver into the Kernel. So using the “normal” Kernel image provided by BeagleBone is not an option. Additionally, I created an Device Tree Overlay that can be loaded to use the driver, instead of editing another device tree file, like it is done in damon-kwok. The overlay file is here BB-BONE-P9_16-PPS-GEN.dts (1.3 KB)

I also tried to use this driver on the BeagleBone AI64 but there it does not seem to work properly.

I have appended some images from my oscilloscope so you can see the difference between the Generated PPS Signal (Channel 1 yellow) and the PPS-Signal from the Module (Channel 2 blue).

Unsychonized:

Synchronized:
But when the PPS is generated it works okay. The pulsewidth may need to be adjusted in the driver.

Update
Currenlty, I have experienced some problems using the current pps-gen driver. BeagleBone-Black crashes when restarting chrony.service when using custom kernel - #3 by benedict.hewson
There is a workaround if you encounter the same errors, described in the thread above.
Removing the pps_gen_gpio kernel module before restarting chrony and once chrony is up an running reinsterting the module works aswell.

Update 2
I have the same setup running on BB-AI64. Here the generated PPS-Pulse is way more consistent and closer to the original pps of the gps module. Probably because of the higher computional power. But sometimes some pps signals are lost but way less than with the BBB. A custom kernel is required here aswell. I made another Device Tree Overlay for the BeagleBone AI64:
BBAI64-P9_16-PPS-GEN.dts (814 Bytes)

Another problem popped up here: I had to remove and reinsert the pps_gen_gpio module in order to receive the generated PPS Signal. The signal is generated shortly after boot, but stops after ~4 seconds.

The following pictures show 2 PPS signals from two seperate gps-modules (Channel2 green and Channel4 blue) and both generated pps signals from BBB(Channel1 yellow) and BBAI64(Channel3 purple).



And just for the sake of completness: The time difference from the two gps pps signals. Only roughly 90ns!

The driver needs some love but in principle works fine.

1 Like

the history log below creates what appears to be a 10% 1PPS. Even using the pru is overkill. Where is it written that this effort requires a kernel module?

501 config-pin -q P9.22
502 config-pin -a P9.22 pwm
503 config-pin -q P9.22
504 cd /sys/class/pwm
505 ls
506 echo 0 > pwmchip1/export
507 ls
508 cd pwm-1:0
509 ls
510 cat *
511 sudo sh -c “echo 1000000000 > period”
512 sudo sh -c “echo 100000000 > duty_cycle”
513 sudo sh -c “echo 1 > enable”

gomer

is this synchronized to the system time or does this create the pps signal “anytime”?

certainly not synchronized to anything. Thanks for clearing up the requirements, now I can sleep

gomer

1 Like

I just wanted to share a link to a forked repo for the gps-pps-gpio driver which includes the instructions for my previous post: GitHub - NotAGnelf/pps-gen-gpio: Linux kernel PPS generator using GPIO pins