dienet
Posts: 11
Joined: Sat Mar 19, 2016 10:58 am

Failed to load overlay

Sat Mar 19, 2016 11:11 am

Hello All!

I have problem with disabling spidev on spi0. I'm working on my custom driver that need spi, so I needed to disable spidev on spi0.
I wrote my custom DT overlay few days ago and it was working just fine. Yesterday the overlay stops working.

I've tried some in tree overlays and the same problem happens:

Code: Select all

vcdbg log msg
is returning me:
Failed to load overlay 'mcp2515-can0'
(Assuming I do not need modules that overlay mcp2515-can0 is requesting for. I just want to see no spidev loaded at that point).

I'm using 4.5.y (d553aa6b15b40562813eb5c0d1b640fb83e8fc50) with bcm2709_defconfig (but spidev is module not build-in).
$ tail /boot/config.txt
#arm_freq=1000
#core_freq=500
#sdram_freq=500
#over_voltage=6

gpu_mem=64

# Custom overlays
dtdebug=1
dtoverlay=mcp2515-can0
RPI v2 with: /boot/bcm2709-rpi-2-b.dtb:
001011.664: Loading 'kernel7.img' from SD card
001273.567: Kernel trailer DTOK property says yes
001273.593: Kernel trailer DDTK property says yes
001273.807: Loading 'bcm2709-rpi-2-b.dtb' from SD card
Is there any thing I can do to debug it more then vcdbg log msg?

dienet
Posts: 11
Joined: Sat Mar 19, 2016 10:58 am

Re: Failed to load overlay

Sun Mar 20, 2016 10:10 am

So the problem was the lack of dtbo files in /boot/overlays.
But how to generate them when using dtc out of linux kernel tree (when using custom made overlays)?
It was working last time only with dtb file.

User avatar
DougieLawson
Posts: 31211
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Failed to load overlay

Sun Mar 20, 2016 10:11 am

Have you got the latest dtc compiler?
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

dienet
Posts: 11
Joined: Sat Mar 19, 2016 10:58 am

Re: Failed to load overlay

Sun Mar 20, 2016 10:49 am

DougieLawson wrote:Have you got the latest dtc compiler?
I've used the one that arch linux provides. That will be:

Code: Select all

$ dtc --version
Version: DTC 1.4.1
In kernel dtc is:

Code: Select all

$ ./scripts/dtc/dtc --version
Version: DTC 1.4.1-g9d3649bd-dirty

User avatar
DougieLawson
Posts: 31211
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Failed to load overlay

Sun Mar 20, 2016 1:03 pm

OK. The one in Raspbian is

Code: Select all

root@apollo ~ # apt-get install device-tree-compiler
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  device-tree-compiler
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 369 kB of archives.
After this operation, 499 kB of additional disk space will be used.
Get:1 http://archive.raspberrypi.org/debian/ jessie/main device-tree-compiler armhf 1.4.0+dfsg-1.1+rpi1 [369 kB]
Fetched 369 kB in 0s (507 kB/s)
Selecting previously unselected package device-tree-compiler.
(Reading database ... 175584 files and directories currently installed.)
Preparing to unpack .../device-tree-compiler_1.4.0+dfsg-1.1+rpi1_armhf.deb ...
Unpacking device-tree-compiler (1.4.0+dfsg-1.1+rpi1) ...
Processing triggers for man-db (2.7.0.2-5) ...
Setting up device-tree-compiler (1.4.0+dfsg-1.1+rpi1) ...
root@apollo ~ # dtc -v
Version: DTC 1.4.0
root@apollo ~ #
I've had a look at the kernel source and I can't see how the *.dts files get compiled to *.dtbo (the Makefiles all create *.dtb files). You'll need to ask Phil Elwell how that piece works.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

dienet
Posts: 11
Joined: Sat Mar 19, 2016 10:58 am

Re: Failed to load overlay

Sun Mar 20, 2016 2:06 pm

DougieLawson wrote: I've had a look at the kernel source and I can't see how the *.dts files get compiled to *.dtbo (the Makefiles all create *.dtb files). You'll need to ask Phil Elwell how that piece works.
For the 4.5.y there is a arch/arm/boot/dts/overlays/Makefile that have it:
(...)
dtbo-$(RPI_DT_OVERLAYS) += ads7846.dtbo
dtbo-$(RPI_DT_OVERLAYS) += at86rf233.dtbo
dtbo-$(RPI_DT_OVERLAYS) += bmp085_i2c-sensor.dtbo
(...)
But still I haven't found the cmd that is used to generate the dtbo. I'll try to take a deeper look today and if get unlucky then I'll PM Phil to take a look at this thread.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1460
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Failed to load overlay

Sun Mar 20, 2016 3:00 pm

Sorry about the delay, the Forum has just decided to tell me about this thread.

If you are wanting to load the overlay on a running system using the new dtoverlay command (4.4 and higher) then currently it has to be built using the dtc from the kernel. We will roll out the required changes to the Raspbian version when Raspbian moves to 4.4, but until then you can continue to use the old version if the overlay is to be loaded from config.txt. Just change the command to:

Code: Select all

dtc -@ -I dts -O dtb -o <name>.dtbo <name>-overlay.dts
Alternatively, download the kernel source and run "make dtbs" to cause scripts/dtc/dtc to be built.

Something else to be aware of is that from 4.4 onwards the kernel .dts files are run through cpp (the C preprocessor) before dtc. This allows symbolic names to be used for constants, but it does mean that instead of using /include/ you may now see #include.

dienet
Posts: 11
Joined: Sat Mar 19, 2016 10:58 am

Re: Failed to load overlay

Mon Mar 21, 2016 3:42 pm

PhilE wrote:

Code: Select all

dtc -@ -I dts -O dtb -o <name>.dtbo <name>-overlay.dts
That is working. Thank you for your help.

SteveRLC
Posts: 4
Joined: Sun May 22, 2016 4:34 pm

Re: Failed to load overlay

Thu May 26, 2016 9:05 am

Hello.
I ran into a problem when trying to compile an overlay, which causes a 'failed to load overlay' in the

Code: Select all

vcdbg log msg
:

Code: Select all

001368.106: dtdebug: Failed to open overlay file 'overlays/spi-gpio-cs.dtbo'
001368.119: Failed to load overlay 'spi-gpio-cs'
The overlay I'm trying to compile extends from viewtopic.php?f=44&t=98318&start=25
where I tried to compile the proposed overlay for 2 extra SPI CS lines, with

Code: Select all

sudo dtc -@ -I dts -O dtb -o spi-gpio-cs-overlay.dtb spi-gpio-cs-overlay.dts
and I get the following output:
Warning (unit_address_vs_reg): Node /fragment@0 has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /fragment@1 has a unit name, but no reg property
.
dtc --version
reports that the compiler is version 1.4.1

Code: Select all

Version: DTC 1.4.1-gbd1c3aca-dirty
This is done (and fails) with a new RPi 3 running Rasbian Jessie lite .
However, I've tried compiling and adding the overlay on an RPi 2 and another RPi3 with the RPi 3 running Rasbian Jessie (full), with both working.

Could the difference in OS's be the problem, do I have a module missing on the Jessie lite?
Any help would be appreciated.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1460
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Failed to load overlay

Thu May 26, 2016 9:31 am

The new 4.4 kernel supports loading overlays at runtime, but in order for that to work the internals of the compiled overlay need to be slightly different. The kernel source tree for each branch includes a compatible version of dtc (scripts/dtc/dtc) and makefiles to invoke it with suitable parameters. The makefiles for 4.4 will compile <name>-overlay.dts into <name>.dtbo, whereas 4.1 would have built <name>-overlay.dtb. This difference makes it possible to keep overlays of both flavours in /boot without collision, and it also brings us into line with the naming conventions on other platforms. The firmware uses the trailer on the kernel to see whether it support runtime loading and uses the appropriate naming scheme.

The debug messages include the answer to the problem:

Code: Select all

001368.106: dtdebug: Failed to open overlay file 'overlays/spi-gpio-cs.dtbo'
001368.119: Failed to load overlay 'spi-gpio-cs'
Here the name is 'spi-gpio-cs' and it is looking for 'overlays/spi-gpio-cs.dtbo', but you are compiling it into 'spi-gpio-cs-overlay.dtb'. If you generate the output file as 'spi-gpio-cs.dtbo', or rename it afterwards, it should load correctly.

The warning is just an annoying feature of the latest version of dtc. The usual rule for DTs is that nodes with @<n> at the end of their name also include a matching "reg = <n>" property within the node. Fragments of overlays don't obey this rule. [ There is an ongoing behind-the-scenes debate about making support for overlays part of the official dtc source tree, rather than a set of patches maintained by others. I hope the resolution of that will see and end to such niggles. ]

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1460
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Failed to load overlay

Thu May 26, 2016 9:45 am

I've edited the linked post to use the new names. You should probably take another look at the Device Tree guide, particularly section 3.5 on the dtoverlay and dtparam commands, and section 4.2 on dtmerge and dtdiff.

SteveRLC
Posts: 4
Joined: Sun May 22, 2016 4:34 pm

Re: Failed to load overlay

Thu May 26, 2016 9:59 am

Renaming/saving the file with the right naming convention works.
Thank you very much.

Return to “Device Tree”

Who is online

Users browsing this forum: habropoda, JonnyHelp, vicary and 3 guests