Building own image, apt-get

I tested this and if i put “IMAGE_INSTALL:append = " i2cdetect” after “# Barys: Additional variables” then there is nothing happend after compilation and this file just back to original, if I put before then i received error

NOTE: Resolving any missing task queue dependencies
ERROR: Nothing RPROVIDES 'i2cdetect' (but /home/balena/poky/balena-raspberrypi/build/../layers/meta-balena/meta-balena-common/recipes-core/images/balena-image.bb RDEPENDS on or otherwise requires it)
NOTE: Runtime target 'i2cdetect' is unbuildable, removing...
Missing or unbuildable dependency chain was: ['i2cdetect']
ERROR: Required build target 'balena-image' has no buildable providers.
Missing or unbuildable dependency chain was: ['balena-image', 'i2cdetect']

$ balena run -it --privileged alpine
/bin/sh -c “apk add --update i2c-tools && i2cdetect -y 0”

maybe is working for simple command (i’m not sure that i2cdetect run from your method show my correct value) but if i want to decode my overlay by dtc command it looks that I can’t see filesystem … Please check below

balena run -it --privileged alpine /bin/sh -c “apk add --update dtc && dtc -I dtb -O dts -o /mnt/boot/overlays/test.dts /mnt/boot/overlays/test.dtbo”
FATAL ERROR: Couldn’t open “/mnt/boot/overlays/test.dtbo”: No such file or directory

Hi,

This may not be exactly what you’re looking for, but you can enable i2cdetect in busybox.
Re-configure busybox using bitback busybox -c menuconfig.
You can probably save the new configuration as a patch file to make it automatic.

Edit: for testing, you can do this with barys using ./balena-yocto-scripts/build/barys --bitbake-target busybox --bitbake-args -cmenuconfig

Your problem here is that you don’t have a (bind mount) directory /mnt/boot/overlays; as bind mounts are normally disabled in Balena, I doubt this is gonna work.
You could make a directory in your container, but it won’t be shared with the Host OS.

It looks that you are right, do you know where is dtc (device tree compiler)? I tried to find but I can’t.

I think it’s important to keep an eye on what we’re doing, where and why.

First, let’s deconstruct what you just tried to do.

You ran a docker image alpine;
In this image, you installed dtc by running apk add --update dtc ;
Then you ran the freshly installed dtc by running dtc -I dtb -O dts -o /mnt/boot/overlays/test.dts /mnt/boot/overlays/test.dtbo”
This command should convert an existing device tree binary to a source file.
This command failed, because /mnt/boot/overlays does not exist in your image.

Now the why:
Presumably you want to use your current device tree in its source form for a patch or to check if things ended up the way as expected?

What now?
If you have compiled the OS yourself, you should be able to access the compiled device tree before even running it on your target. You can find it in build/tmp/deploy/images/<device>.
You can actually install dtc on your own machine (Debian/Ubuntu package is called device-tree-compiler), or run dtc with docker to do the same thing you tried with the balena command. See the docker docs how to use bind mounts.

If you are running a pre-built image on the target, you might be able to grab the current device tree from /proc/device-tree using dtc -I fs /proc/device-tree, and then store the output to /data.

If you haven’t read it yet, the raspberry pi docs has a fair bit on device trees.

I know what i want to do, just try to check why my i2c is not working properly when i add my own overlays;) up to now is very hard to do this, because every “normal” procedure from my point of view is blocked by balena (i2cdetect, dtc) so i need to make this topic to teach a little this ecosystem.

Now I know how to add i2cdetect by change config but still don’t know what I need to do when I need to add some packages (doesn’t matter which one). This is a base of this topic so let’s focus on it. Now I’m think what i need to do to add dtc to my own image.

What now?
If you have compiled the OS yourself, you should be able to access the compiled device tree before even running it on your target. You can find it in build/tmp/deploy/images/.
You can actually install dtc on your own machine (Debian/Ubuntu package is called device-tree-compiler), or run dtc with docker to do the same thing you tried with the balena command. See the docker docs how to use bind mounts.

Of course, I can run this in other system or in the docker but why? I want to add this to my own image because for me is a basic function. This is why I want to build my own image and not using default.

If you are running a pre-built image on the target, you might be able to grab the current device tree from /proc/device-tree using dtc -I fs /proc/device-tree, and then store the output to /data.

Yes i know :wink: but only if i have this package, few message above I’m asking if the DTC in docker is same like in the hostOS, but it looks that nobody answer me

My bad, I think I just misunderstood.

As far as I know, there are no specific versions of dtc, they all do the same thing.
That’s why I mentioned you could just run your native dtc to get the job done.

I think that IMAGE_INSTALL_append might be the way to go for packages/recipes.
I’m not sure if there’s a big difference between adding the external i2c-tools recipe and using the "configure busybox" version.

You said that it did “nothing” for you; did you check the build/conf/local.conf to see if it actually picked up your changes?
If I recall correctly, barys likes to overwrite it with the version in meta-balena-<device>.
You could add your change to layers/meta-balena-<device>/conf/samples/local.conf.sample and then build it to see if it works.

You should be able to find it after building, using something like find build/tmp/sysroots-components/ -name dtc\*

Thanks, i will check.

Other topic, I know that yocto have a possibility to run compiled system in emulator, can i do the same for my own balena image? I’m so tired to flash next disk to check one change in DT overlay …

Hi, coming back to one of your comments, i2cdetect is not a Yocto package, it’s provided by the i2c-tools package. So the correct way of adding it to the image is:

IMAGE_INSTALL:append = " i2c-tools"

You can use the devtool tool to query the Yocto metadata for the package a specific utility is included in, like:

MACHINE=raspberrypi4-64 devtool search i2cdetect
NOTE: Starting bitbake server...
NOTE: Reconnecting to bitbake server...
NOTE: Retrying server connection (#1)...
Loading cache: 100% |########################################################################################################################################################################################################| Time: 0:00:00
Loaded 3867 entries from dependency cache.
i2c-tools             Set of i2c tools for linux

I have same error any type of solution…

I know what i want to do, just try to check why my i2c is not working properly when i add my own overlays;) up to now is very hard to do this, because every “normal” procedure from my point of view is blocked by balena (i2cdetect, dtc) so i need to make this topic to teach a little this ecosystem..
.

./balena-yocto-scripts/build/barys --bitbake-target busybox --bitbake-args -cmenuconfig -m raspberrypicm4-ioboard
Just run and find i2cdetect package in the list

:wink: This is a solution to add i2cdetect

Hey @garkbeda43, it might be worthwhile to follow the Yocto getting started guides to familiarize yourself with the Yocto build ecosystem that balena is based on. This could be the learning experience you are looking for!
https://docs.yoctoproject.org/brief-yoctoprojectqs/index.html

Once you’ve gone through those guides you may find it easier to apply customizations to balenaOS images. Let us know how it goes!