1

I have started to write a library for reading FDT (DTB) format files, but run into a problem with a test DTB file. The DTB file is form a board (Digilent ZYBO-Z7) which I own. I compiled the source device-trees from the actual Linux Kernel.

There are two property names ('linux' and 'phandle') which are concatenated with a comma character instead of a NUL character.

The property structure (Blue and Red) points (Red) to the string after the comma:

enter image description here

Blue: 0x00000004 (Property value size)
Red: 0x00000105 (Property string offset)
Green: 0x00000007 (Property value)

The strings block starts at offset 0x1D4C.

Here is a shortened hexdump output of the strings section in the DTB file:

enter image description here

The two with comma concatenated strings starts at offset 0x1E4B and ends at offset 0x1E57. At offset 0x1E50 is the comma.

Is this a correct behavior?

UPDATE:

I found this quote:

Property "linux,phandle" is obsolete. If it exists, its value should be equivalent to the value of property "phandle".

Source

I my test file there is only one property name "linux,phandle". No "normal" property names "phandle". Also tried another DTB file with the same result.

Is this for Backward compatibility? Because linux,phandle and the sub string phandle (starts at offset 0x1E51) have the same property value (0x00000007) in the first screenshot.

  • there are tools which allow to "decompile" DTB files back to DTS. There is libfdt already so it does not makes much sense to develop new one. you can install device tree compiler at ubuntu this way: **sudo apt install device-tree-compiler** . And you can use it to decompile arbitrary dtb file this way: **dtc -I dtb -O dts sun4i-a10-a1000.dtb** . – Maxim Sagaydachny Dec 08 '19 at 17:25
  • I don't want appearing arrogant, but just because something already exists doesn't mean that it's good enough (for me). My library is alternative. Need it for my further projects. (I already have **dtc** installed on my system.) –  Dec 09 '19 at 03:56
  • The normal FDT development library is called libfdt, so perhaps you could have chosen a name that doesn't differ only in case. – Ian Abbott Dec 09 '19 at 17:54
  • The "linux,phandle" properties are for backwards compatibility. the device tree compiler and the Linux kernel only used to support "linux,phandle". Later, support was added for ePAPR-style "phandle", and the use of "linux,phandle" was deprecated. There is an option in dtc to generate ePAPR-style "phandle", legacy "linux,phandle" or both properties. The default used to be to generate both properties, but currently the default is to only generate ePAPR-style "phandle" properties. – Ian Abbott Dec 09 '19 at 18:35
  • First comment: Okay, renamed it. Second comment: Okay, thanks. That's what I thought. From which version is the default ePAPR-style only? I have currently **dtc** version 1.4.4 installed. But wouldn't it better to add both property names (**linux,phandle** and **phandle**) in the strings block section in the DTB? Because I think IMHO this current behavior violates the current Device-Tree specifications v0.2. –  Dec 11 '19 at 05:50

0 Answers0