Custom build for beaglebone not working

Good morning!
I am attempting to make a change to this custom build, but unsure where I need to make it.
I am trying to use linuxptp to get ptp information to a balena container and I want to set the following in the linux build:
CONFIG_PTP_1588_CLOCK=y
CONFIG_PPS=y
Can you tell me which file and in which of the meta layers I need to set these?
Also, how do you configure the yocto build such that linuxptp can run up in the host as opposed to a container?
Thanks

Hi Paul,

Probably the easiest custom kernel change is to apply it to meta-balena like it’s done for example for the dummy module in:

As per running linuxptp in the host, could you please explain why not in the container? Modifying the hostOS is not maintainable and also you won’t be able to update to custom hostOS versions via balenaCloud.

That brings me back to the Linux kernel configuration change. If you require this to be maintainable / updatable, we could consider adding the change to the default BalenaOS on a future release, or you could build them as modules and install them in your container application.

Regards,

1 Like

Hi Alex,
Thank you for your response. It seems like PTP is already turned on by default and I can run them up manually in the container.
I totally understand about modifying the hostOS. However, I’m trying to understand if starting the linuxptp services (ptp4l and phc2sys) are doable from a container. I don’t have systemctl command in a container (although maybe I will have this if I add dbus to docker-compose). Also, I need to add a ptp4l.conf file to /etc/ and also a ptp file to /etc/sysconfig/ Are these container locations or hostos? Also, would both these services be configured in the dockerfile or docker-compose? For example the linuxptp documentation describes using ‘systemctl start ptp4l’ and ‘systemctl start phc2sys’.
Would other containers be accessing the same system time set by ptp4l in a container? Also, I see balenaos uses chrony for time management, would this service need to be stopped to avoid a conflict?

Sorry for all the questions?
Regards,
Paul

Hi Paul,
Let’s say you are using Debian as your base image and you install the linuxptp package. This installs both /usr/sbin/ptp4l and /usr/sbin/phc2sys, along with the configuration files (see https://packages.debian.org/buster/amd64/linuxptp/filelist), so you can use them in your own application code.
It also installs systemd services but I you are not required to use them. Running systemd in your application container is probably unneeded, but it’s also possible if you require it (see https://github.com/balena-io-playground/balenalib-systemd-example/blob/master/app/Dockerfile.template).
Hope it help,

1 Like

I forgot to answer the time management question. p4p4l will be setting the time for the whole system. You can disable the hostOS chrony from the application container using a dbus call so they do not fight. See https://www.balena.io/docs/learn/develop/runtime/#dbus-communication-with-host-os and https://www.balena.io/docs/learn/more/masterclasses/host-os-masterclass/ for an example with chrony.

1 Like

Alex,
Thank you so much that, it’s very helpful indeed and I can see the config files actually exist in /etc/linuxptp
Regarding the systemd, if it’s not really needed, would I then add them to the CMD arguments in the dockerfile so they run up as say background tasks in addition to my main application?

Hello,
Yes, your CMD would have to be a shell script starting everything you need: ptp4l, phc2sys and your application.

One more thing: I think your container would need to be privileged for running ptp4l and phc2sys.

1 Like

Hi, thanks for confirming this, as although I would prefer to start them as services, if starting via shell script is best practice then I would rather follow it.

A shell script will work, if you need something more advanced, you can try http://supervisord.org .
You can also run systemd in a balenalib image container (although it is not what we recommend): https://www.balena.io/docs/reference/base-images/base-images/#installing-your-own-initsystem

Or you could run ptp4l and phc2sys in separate privileged containers using a docker-compose.yml file

Thanks once again for this, it’s really helpful.
I think I will probably have a single privileged container running both tasks in a shell script. I understand I will need to provide all the arguments rather than use the ptp4l.conf file, but that’s ok.

On ptp4l’s manpage, I can see a -f config option to read the config from a file.

1 Like

Hi, a quick question regarding the custom build.
I understand that if there is a new version of balenaos, there is a mechanism to update it with openbalena. However, I have my own custom Yocto build. Would the balenaos update break my custom build? What is the normal practice in this situation using custom images and openbalena?
Thanks

I understand that if there is a new version of balenaos, there is a mechanism to update it with openbalena

Right now there is no such mechanism that we actively support.

Hi Rich, thanks for your reponse. There is a thread here which seems to suggest there is support for updating the hostOS in openbalena Roadmap for BalenaOS Updates in OpenBalena

Hi @pawelevans

Thank you for your message. Rich and another one of our engineers are looking into this matter to make sure of the exact current status, and will come back to you.

Kind regards
Alida

1 Like

Hi there, just to follow up, we have written a PSA here regarding openBalena hostOS updates and the plan for the future. I hope this clears the confusion that might have been caused by other conflicting information sources. Have a nice day!

1 Like