2

I know this is a topic, on which there are several other posts. However none? of them has an accepted answer or even a helpful comment. But in short, how can load a device tree module (without recompiling the kernel)?

So far I could find following methods:

  1. Loading at runtime, per cat enI2C4.dtbo>/sys/kernel/config/device-tree/overlays.
  2. Loading at the boot process with specifying the .dtbo file in /boot/bootenv.txt and/or /boot/uEnv.txt. In both cases the content is (enI2C4.dtbo is stored under /boot):
overlays=enI2C4.dtbo

Sadly none of them did work for me:

  1. The device-tree directory does not exist and mkdir returns Operation not permitted. Most solutions to this problem do seem to compile their own kernel, which I neither think is realy necessary, nor it's something I want to do.
  2. Editing/Creating either of these two files, does not seem to have any effect. Neither can I find my overlay with find /proc/device-tree/ -type f -exec head {} + | grep I2C, nor does dmesg return anything special.

So what am I missing here? Is there a third option, or something (probably stupid), which I am missing here?

As background and additional Infos:

I'm trying to enable I2C4 on an i.MX 8M plus with:

$ lsb_release -a
Distributor ID: ampliPHY
Description:    ampliPHY GNU/Linux BSP-Yocto-NXP-i.MX8MP-PD22.1.0 (hardknott)
Release:        BSP-Yocto-NXP-i.MX8MP-PD22.1.0
Codename:       hardknott

The .dts file is:

/dts-v1/;

#include "imx8mp.dtsi" 

&i2c4 {
    clock-frequency = <400000>;
    pinctrl-names = "default", "gpio";
    status = "okay";
};

And here is the bootpromp (after mounting /boot/) with both the /boot/bootenv.txt and /boot/uEnv.txt files in place.

[  OK  ] Mounted /boot.
[  OK  ] Reached target Local File Systems.
         Starting Create Volatile Files and Directories...
[  OK  ] Finished Create Volatile Files and Directories.
         Starting Network Name Resolution...
         Starting Network Time Synchronization...
[  OK  ] Started Network Name Resolution.
[  OK  ] Started Network Time Synchronization.
[  OK  ] Reached target Network.
[  OK  ] Reached target Host and Network Name Lookups.
[  OK  ] Reached target System Initialization.
[    6.550051] imx-sdma 30bd0000.dma-controller: sdma firmware not ready!
[    6.557338] imx-sdma 30bd0000.dma-controller: sdma firmware not ready!
[    6.564225] imx-sdma 30bd0000.dma-controller: sdma firmware not ready!
[    6.570968] imx-sdma 30bd0000.dma-controller: sdma firmware not ready!
[    6.577572] imx-sdma 30bd0000.dma-controller: sdma firmware not ready!
[    6.597437] imx-cdnhdmi sound-hdmi: snd_soc_register_card failed (-517)
[  OK  ] Started     6.605376] fsl-aud2htx 30cb0000.aud2htx: Unbalanced pm_runtime_enable!
;39mDaily Cleanup of Temporary Di[    6.613814] fsl-aud2htx 30cb0000.aud2htx: failed to init imx pcm dma: -517
rectories.
[  OK  ] Reached target System Time Set.
[  OK  ] Reached target System Time Synchronized.
[  OK  ] Reached target Timers.
[  OK  ] Listening on D-Bus System Message Bus Socket.
[  OK  ] Listening on PC/SC Smart Card Daemon Activation Socket.
         Starting sshd.socket.
[  OK  ] Started NFS status monitor for NFSv2/3 locking..
[  OK  ] Listening on sshd.socket.
[  OK  ] Reached target Sockets.
[  OK  ] Reached target Basic System.
         Starting Save/Restore Sound Card State...
[  OK  ] Started D-Bus System Message Bus.
[  OK  ] Started Start fan control, if configured.
[  OK  ] Started Linux Firmware Loader Daemon.
         Starting User Login Management...
         Starting Permit User Sessions...
[    6.927296] imx-sdma 30bd0000.dma-controller: firmware found.
         Starting OpenSS[    6.934041] imx-sdma 30bd0000.dma-controller: loaded firmware 4.6
H Key Generation...
[  OK  ] Finished Save/Restore Sound Card State.
[  OK  ] Finished Permit User Sessions.
[  OK  ] Finished OpenSSH Key Generation.
[  OK  ] Reached target Sound Card.
[  OK  ] Started Getty on tty1.
[  OK  ] Started Serial Getty on ttymxc0.
[  OK  ] Reached target Login Prompts.
[  OK  ] Started User Login Management.
[  OK  ] Reached target Multi-User System.
[    7.198435] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[    7.204785] IPv6: ADDRCONF(NETDEV_CHANGE): can1: link becomes ready

 ____   _   _ __   __ _____  _____   ____
|  _ \ | | | |\ \ / /|_   _|| ____| / ___|
| |_) || |_| | \ V /   | |  |  _|  | |
|  __/ |  _  |  | |    | |  | |___ | |___
|_|    |_| |_|  |_|    |_|  |_____| \____|

    _     __  __  ____   _      ___  ____   _   _ __   __
   / \   |  \/  ||  _ \ | |    |_ _||  _ \ | | | |\ \ / /
  / _ \  | |\/| || |_) || |     | | | |_) || |_| | \ V /
 / ___ \ | |  | ||  __/ | |___  | | |  __/ |  _  |  | |
/_/   \_\|_|  |_||_|    |_____||___||_|    |_| |_|  |_|

1
  • I am having exactly same problem, and I am even using the processor. I am trying to load a dto to configure the ecspi using the overlays.txt and it just doesn't seem to work at all. Did you ever figure this out? Commented Apr 25 at 3:45

2 Answers 2

3

As explained in another answer, loading overlays at runtime (without rebooting) requires a customized Linux kernel, i.e. you need to patch the kernel sourcecode, adapt the configuration, then compile and install your custom Linux kernel, unless your Linux distribution already happen to provide such a modified kernel.

Normally the overlays are not applied like that, at runtime, but instead in the bootloader, which usually is u-boot. There are several ways to add overlays to the kernel devicetree in u-boot, the most common one is by using various u-boot commands to "manually" load the devicetree and all overlays into memory, and then update the devicetree using each overlay in turn, and finally boot the Linux kernel with the resulting devicetree. These steps are normally put in a bootscript (a script that u-boot executes when booting). This script is often called boot.scr, which is a binary image format and not human readable nor possible to modify. (boot.scr can be produced by compiling the script sourcecode file named e.g. boot.cmd).

But most people never need to deal with these details. Depending on which Linux distribution you use this has all been taken care of and there is a bootscript (or some alternative mechanism) that will load and apply any overlays listed in e.g. a u-boot environment variable, which may be named e.g. "overlays", and which you may be able to modify e.g. by editing a file often called e.g. /boot/uEnv.txt.

Again - all these things work differently depending on how u-boot, the bootscript, the kernel and the Linux system has been set up by the distribution architects. For instance the u-boot environment may also be stored in a hardware chip such as eeprom or spi nvram, a special partition or sector on a harddrive or some other secret place. As modifying the u-boot environment variable or bootscript could potentially be a security weakness the system often prevents users from doing so, even with root privileges. Even if you can modify your u-boot environment the bootscript may not include functionality to add overlays. It depends on what your distribution provides.

Finally an example: if you happen to use Armbian and happen to have a platform for which Armbian supports overlays, then you are in luck: you only need to modify the variable "overlays" stored in /boot/armbianEnv.txt. This variable is a space separated list of overlays that u-boot will attempt to add before booting the Linux kernel. Add the desired overlay's filename without the .dtbo suffix. The overlays you add here must exist under /boot/dtb/XXX where XXX is a subdirectory corresponding to your platform. Be careful, adding a non-working overlay may prevent your system from booting, although usually the faulty overlay is just skipped with an error message by u-boot.

There is even a tool "armbian-add-overlay" which allows you to compile your custom overlay .dtbo file from a .dts overlay sourcecode file. The resulting .dtbo is automatically copied to /boot/overlay_user/ and a reference is added to user_overlays u-boot environment variable in /boot/armbianEnv.txt. Neat!

See also e.g. https://docs.armbian.com/User-Guide_Allwinner_overlays/

0

For /sys/kernel/config/device-tree/overlays/ you should have a kernel built with CONFIG_OF_CONFIGFS=y (which is not an upstream feature but available in some kernels).

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.