title: How to write an overlay that override pin_define in device tree?
body: <p>I used the default <code>dt-blob.dts</code> definition found <a href="https://github.com/raspberrypi/firmware/blob/master/extra/dt-blob.dts" rel="nofollow noreferrer">here</a> to enable the display and the cameras on my CM4 board.</p>
  <p>I made some changes and I give you the diff below.</p>
  <p>Would it be possible to write a fragment overlay instead of rewriting the entire dts?</p>
  <pre><code>➜  ~ diff -C2 dt-blob.dts mydt.dts
  *** dt-blob.dts 2021-10-08 11:39:13.710000000 +0200
  --- mydt.dts    2021-10-09 17:31:54.910000000 +0200
  ***************
  *** 1846,1850 ****
                pin_define@DISPLAY_I2C_PORT {
                   type = &quot;internal&quot;;
  !              number = &lt;1&gt;;
                };
                pin_define@DISPLAY_SDA {
  --- 1846,1850 ----
                pin_define@DISPLAY_I2C_PORT {
                   type = &quot;internal&quot;;
  !              number = &lt;0&gt;;
                };
                pin_define@DISPLAY_SDA {
  ***************
  *** 1856,1859 ****
  --- 1856,1863 ----
                   number = &lt;1&gt;;
                };
  +             pin_define@DISPLAY_DSI_PORT {
  +                type=&quot;internal&quot;;
  +                number=&lt;0&gt;;
  +              };
  
                pin_define@CAMERA_0_I2C_PORT {
  ***************
  *** 1863,1871 ****
                pin_define@CAMERA_0_SDA_PIN {
                   type = &quot;internal&quot;;
  !                number = &lt;0&gt;;
                };
                pin_define@CAMERA_0_SCL_PIN {
                   type = &quot;internal&quot;;
  !                number = &lt;1&gt;;
                };
                pin_define@CAMERA_0_SHUTDOWN {
  --- 1867,1875 ----
                pin_define@CAMERA_0_SDA_PIN {
                   type = &quot;internal&quot;;
  !                number = &lt;44&gt;;
                };
                pin_define@CAMERA_0_SCL_PIN {
                   type = &quot;internal&quot;;
  !                number = &lt;45&gt;;
                };
                pin_define@CAMERA_0_SHUTDOWN {
  ***************
  *** 1882,1894 ****
                pin_define@CAMERA_1_I2C_PORT {
                   type = &quot;internal&quot;;
  !                number = &lt;1&gt;;
                };
                pin_define@CAMERA_1_SDA_PIN {
                   type = &quot;internal&quot;;
  !                number = &lt;44&gt;;
                };
                pin_define@CAMERA_1_SCL_PIN {
                   type = &quot;internal&quot;;
  !                number = &lt;45&gt;;
                };
                pin_define@CAMERA_1_SHUTDOWN {
  --- 1886,1898 ----
                pin_define@CAMERA_1_I2C_PORT {
                   type = &quot;internal&quot;;
  !                number = &lt;0&gt;;
                };
                pin_define@CAMERA_1_SDA_PIN {
                   type = &quot;internal&quot;;
  !                number = &lt;0&gt;;
                };
                pin_define@CAMERA_1_SCL_PIN {
                   type = &quot;internal&quot;;
  !                number = &lt;1&gt;;
                };
                pin_define@CAMERA_1_SHUTDOWN {
  ***************
  *** 1902,1906 ****
                   type = &quot;absent&quot;;
                };
  -
             }; // pin_defines
          }; // pins
  --- 1906,1909 ----
  </code></pre>
  <p>Naively I tried to write this:</p>
  <pre><code>/dts-v1/;
  /plugin/;
  
  / {
      fragment@100 {
          target-path = &quot;/videocore/pins_cm4/pin_defines&quot;;
          __overlay__ {
              pin_define@DISPLAY_I2C_PORT {
                 type = &quot;internal&quot;;
                 number = &lt;0&gt;;
              };            
              pin_define@DISPLAY_DSI_PORT {
                 type=&quot;internal&quot;;
                 number=&lt;0&gt;;
              };
              pin_define@CAMERA_0_SDA_PIN {
                 type = &quot;internal&quot;;
                 number = &lt;44&gt;;
              };    
              pin_define@CAMERA_0_SCL_PIN {
                 type = &quot;internal&quot;;
                 number = &lt;45&gt;;
              };                    
              pin_define@CAMERA_1_I2C_PORT {
                 type = &quot;internal&quot;;
                 number = &lt;0&gt;;
              };
              pin_define@CAMERA_1_SDA_PIN {
                 type = &quot;internal&quot;;
                 number = &lt;0&gt;;
              };
              pin_define@CAMERA_1_SCL_PIN {
                 type = &quot;internal&quot;;
                 number = &lt;1&gt;;
              };            
          };
      };
  };
  </code></pre>
  <p>And place it in <code>/boot/overlays/display.dtbo</code> after compiling it with:</p>
  <pre><code>sudo dtc -I dts -O dtb -o /boot/overlays/display.dtbo display.dtso
  </code></pre>
  <p>Then I added to <code>/boot/config.txt</code> the following:</p>
  <pre><code>echo &quot;dtoverlay=display&quot; &gt;&gt; /boot/config.txt
  </code></pre>
  <p>... Unfortunately, it doesn't work.</p>
  <p>I also tried to use a relative path: <code>target = &lt;&amp;pin_defines&gt;</code>, but in this case I see this error with <code>sudo vcdbg log msg</code>:</p>
  <pre><code>007412.656: dtdebug: Opened overlay file 'overlays/mydisplay.dtbo'
  007412.855: brfs: File read: /mfs/sd/overlays/mydisplay.dtbo
  007416.549: dterror: can't find symbol 'pin_defines'
  007416.561: Failed to resolve overlay 'mydisplay'
  </code></pre>