# Initialize Can bus

**URL:** <https://forums.balena.io/t/initialize-can-bus/311537>\
**Category:** balenaOS\
**Tags:** beaglebone\
**Created:** [May 11, 2021, 8:53pm UTC](https://forums.balena.io/t/initialize-can-bus/311537 "2021-05-11T20:53:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fencer](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/fencer/32/4415_2.png) [@fencer](https://forums.balena.io/u/fencer)\
**Post date:** [May 11, 2021, 8:53pm UTC](https://forums.balena.io/t/initialize-can-bus/311537/1 "2021-05-11T20:53:15Z")

</div>

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"
```

---

<div class="post-metadata">

**Author:** ![klutchell](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/klutchell/32/861_2.png) [@klutchell](https://forums.balena.io/u/klutchell)\
**Post date:** [May 12, 2021, 2:16pm UTC](https://forums.balena.io/t/initialize-can-bus/311537/4 "2021-05-12T14:16:23Z")

</div>

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:

```auto
> 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!

---

<div class="post-metadata">

**Author:** ![fencer](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/fencer/32/4415_2.png) [@fencer](https://forums.balena.io/u/fencer)\
**Post date:** [May 14, 2021, 10:11am UTC](https://forums.balena.io/t/initialize-can-bus/311537/6 "2021-05-14T10:11:17Z")

</div>

> [@klutchell](#):
>
> Hey there, how have you added this recipe as a component of the final image? Does another recipe `RDEPENDS` on it?

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.

---

<div class="post-metadata">

**Author:** ![fencer](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/fencer/32/4415_2.png) [@fencer](https://forums.balena.io/u/fencer)\
**Post date:** [May 14, 2021, 12:09pm UTC](https://forums.balena.io/t/initialize-can-bus/311537/7 "2021-05-14T12:09:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![klutchell](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/klutchell/32/861_2.png) [@klutchell](https://forums.balena.io/u/klutchell)\
**Post date:** [May 14, 2021, 12:39pm UTC](https://forums.balena.io/t/initialize-can-bus/311537/8 "2021-05-14T12:39:42Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![fencer](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/fencer/32/4415_2.png) [@fencer](https://forums.balena.io/u/fencer)\
**Post date:** [May 14, 2021, 1:26pm UTC](https://forums.balena.io/t/initialize-can-bus/311537/10 "2021-05-14T13:26:37Z")

</div>

Thank you for the help!

---

<div class="post-metadata">

**Author:** ![amr](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@amr](https://forums.balena.io/u/amr)\
**Post date:** [May 4, 2023, 1:54pm UTC](https://forums.balena.io/t/initialize-can-bus/311537/11 "2023-05-04T13:54:20Z")

</div>

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

![image](https://global.discourse-cdn.com/balena/original/2X/a/a2f3cee23a1097a905ae7be28a60d122e38513e7.png)

Can you please help
