# Preload Device Tree Overlays?

**URL:** <https://forums.balena.io/t/preload-device-tree-overlays/5495>\
**Category:** Product support\
**Created:** [February 28, 2019, 9:52pm UTC](https://forums.balena.io/t/preload-device-tree-overlays/5495 "2019-02-28T21:52:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![drewcovi](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/drewcovi/32/1115_2.png) [@drewcovi](https://forums.balena.io/u/drewcovi)\
**Post date:** [February 28, 2019, 9:52pm UTC](https://forums.balena.io/t/preload-device-tree-overlays/5495/1 "2019-02-28T21:52:15Z")

</div>

This platform is incredible. I love the ability to preload and I’ve successfully leveraged a wifi container (with wifi connect) to bring devices online.

That said, is there _any_ way to preload device tree overlays in the cloud, or in our repos?

This functionality is desperately needed for the hyperpixel.

Thanks!

Drew

---

<div class="post-metadata">

**Author:** ![spanceac](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@spanceac](https://forums.balena.io/u/spanceac)\
**Post date:** [March 1, 2019, 10:37am UTC](https://forums.balena.io/t/preload-device-tree-overlays/5495/4 "2019-03-01T10:37:28Z")

</div>

Hi @drewcovi,

We’re glad to hear how you feel about Balena platform.

The `balena preload` command works preloading an application into the image.

There is a possibility to add a device tree overlay in your image using some commands that you can script in Linux.

Let me know what device type you are using and I’ll let you know how to do it.

Regards!

---

<div class="post-metadata">

**Author:** ![drewcovi](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/drewcovi/32/1115_2.png) [@drewcovi](https://forums.balena.io/u/drewcovi)\
**Post date:** [March 1, 2019, 9:43pm UTC](https://forums.balena.io/t/preload-device-tree-overlays/5495/5 "2019-03-01T21:43:29Z")

</div>

hi @spanceac we’re looking to load up a hyperpixel4.dtbo and some corresponding config.txt.

It would be great if we could preload that custom config.txt rather than waiting for an initial cloud update.

Any advice would be a massive help!

---

<div class="post-metadata">

**Author:** ![spanceac](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@spanceac](https://forums.balena.io/u/spanceac)\
**Post date:** [March 4, 2019, 9:01am UTC](https://forums.balena.io/t/preload-device-tree-overlays/5495/8 "2019-03-04T09:01:27Z")

</div>

Hi @drewcovi,

I was curious about the device type you use(RPi, Beaglebone etc.).

Assuming you are using a RPi the steps to include the dtbo in your image would be the following:

1. Download an RPi image from the dashboard

2. Extract the image archive

3. Create a loop device from your image  
`sudo losetup -fP balena-name-image.img`

4. Mount the boot partition of your image  
`mkdir tmp-mount`  
`sudo mount /dev/loop0p1 tmp-mount`

5. Copy the dtbo in the boot partition  
`cp hyperpixel4.dtbo tmp-mount/overlays`

6. Edit the `config.txt` file from the `tmp-mount/` folder as you wish

7. Unmount the boot partition  
`sudo umount tmp-mount`

8. Remove the loop device partitions  
`sudo losetup -D`

Now the extracted image contains your modifications on the boot partition. You can flash it.

---

<div class="post-metadata">

**Author:** ![jschon](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jschon](https://forums.balena.io/u/jschon)\
**Post date:** [March 4, 2019, 10:32am UTC](https://forums.balena.io/t/preload-device-tree-overlays/5495/10 "2019-03-04T10:32:25Z")

</div>

@spanceac

Is there some way of locking config.txt so that it isn’t modified by some Balena agent later on?

I haven’t spent time creating a reproducible test case yet, but I _think_ I have experienced it getting overwritten without doing any action in the balenaCloud admin console that involved changing those (exact) parameters in the Device Configuration section.

Edit: Just found this, which seems to indicate that the correct behavior is for it to be overwritten:

> [@How to set config.txt vars without fleet/device cloud configuration](https://forums.balena.io/t/how-to-set-config-txt-vars-without-fleet-device-cloud-configuration/5423/5):
>
> @jacobrosenthal So you have the following options for running balenaOS; use balenaOS standalone, without associating it to a balenaCloud application use balenaOS in tandem with a balenaCloud application If you use it as a standalone, then you can change the values in config.txt and they should persist. If you use it in tandem with a balenaCloud application then the supervisor will ensure that the device configuration state matches whatever is held in the cloud. So if you change the config.t…

---

<div class="post-metadata">

**Author:** ![zvin](https://avatars.discourse-cdn.com/v4/letter/z/a5b964/32.png) [@zvin](https://forums.balena.io/u/zvin)\
**Post date:** [March 6, 2019, 2:03pm UTC](https://forums.balena.io/t/preload-device-tree-overlays/5495/12 "2019-03-06T14:03:30Z")

</div>

@jschon I don’t think there is a way to lock the config.txt file. It can be updated when you set or update `RESIN_HOST_CONFIG_` prefixed configuration variables via the API. See [https://www.balena.io/docs/reference/OS/advanced/#config-txt](https://www.balena.io/docs/reference/OS/advanced/#config-txt) .

---

<div class="post-metadata">

**Author:** ![nazrhom](https://avatars.discourse-cdn.com/v4/letter/n/ee59a6/32.png) [@nazrhom](https://forums.balena.io/u/nazrhom)\
**Post date:** [March 6, 2019, 2:07pm UTC](https://forums.balena.io/t/preload-device-tree-overlays/5495/14 "2019-03-06T14:07:29Z")

</div>

Hey @jschon

The information you found is correct, as a note: balena agents can inspect but can NOT modify any fleet or device variable from the dashboard of a shared device (this holds for config, environment and service variables).
