Initialize Can bus

I have added my own yocto layer on top of the balena os and in it I’m trying to initialize the can interfaces on boot. I’ve create a service but when I build the image, the service or it’s files are not present. I’ve looking into the temp folder and the service files are present.

I have no errors or warning on build.

This is my bb file:

DESCRIPTION = "Initialise CAN0 and CAN1"
    LICENSE = "Apache-2.0"
    LIC_FILES_CHKSUM = "file://${BALENA_COREBASE}/COPYING.Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"

SRC_URI = " \
	file://bb-canbus \
	file://bb-canbus.service \
"

inherit allarch systemd

RDEPENDS_${PN} = "bash"

do_install() {
	install -d ${D}/usr/bin
	install -m 0755 ${WORKDIR}/bb-canbus ${D}/usr/bin/bb-canbus
	install -d ${D}${systemd_unitdir}/system
	install -m 0644 ${WORKDIR}/bb-canbus.service ${D}${systemd_unitdir}/system/bb-canbus.service
}

SYSTEMD_SERVICE_${PN} = "bb-canbus.service"

Hey there, how have you added this recipe as a component of the final image? Does another recipe RDEPENDS on it?

I think you need to specify that the source directory is the same as your workdir for this recipe (S = "${WORKDIR}") in order for the service files to be found and installed correctly. Though if that were the case I would expect to see some errors during do_install but it’s worth a try.

When you disabled rm_work and searched for the files in build/tmp, were they located in more than one directory? Knowing where bitbake copied the files during the build would help identify if the problem is during do_install or some other step. For example:

> find build/tmp/work -name resin-ntp-config.service
build/tmp/work/all-poky-linux/resin-ntp-config/1.0-r0/resin-ntp-config.service
build/tmp/work/all-poky-linux/resin-ntp-config/1.0-r0/packages-split/resin-ntp-config/lib/systemd/system/resin-ntp-config.service
build/tmp/work/all-poky-linux/resin-ntp-config/1.0-r0/image/lib/systemd/system/resin-ntp-config.service
build/tmp/work/all-poky-linux/resin-ntp-config/1.0-r0/sysroot-destdir/lib/systemd/system/resin-ntp-config.service
build/tmp/work/all-poky-linux/resin-ntp-config/1.0-r0/package/lib/systemd/system/resin-ntp-config.service

If your service files are not in /package/ or /packages-split/ it’s safe to say they were not installed correctly, or were somehow missing from the default FILES_${PN} value.

If the above steps don’t point to a solution we may want to have a look at verbose build logs if possible!

I think this is actually what is wrong! So far I have created only addons to other recipes (bbappend) and was assuming that doing the same (just adding the bb files) would work. Where should I add this as a component?

This is the output in the TMP folder is definitely missing the package and package-split directory.

I just added a systemd_%.bbappend in my layer and added my bb-canbus recipe to RDEPENDS_${PN}_append and seems to have done the trick.

Is this the correct way this should have been done?

That is exactly what I was coming to suggest, great work on finding a solution!

Let us know if there is anything else we can do to help, and congrats on becoming a yocto developer!

Thank you for the help!

Hi @klutchell I am not able to execute cansend and candump commands on balena terminal .

image

Can you please help