Skip to content

Failed to load w1-gpio overlay with non-default gpiopin value #2002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
softerra opened this issue May 10, 2017 · 5 comments
Closed

Failed to load w1-gpio overlay with non-default gpiopin value #2002

softerra opened this issue May 10, 2017 · 5 comments

Comments

@softerra
Copy link

softerra commented May 10, 2017

In short, the issue looks like:

pi@raspberrypi:~ $ sudo dtoverlay w1-gpio gpiopin=13
* Failed to apply overlay '0_w1-gpio' (kernel)

pi@raspberrypi:~ $ dmesg
...
[  145.010455] OF: resolver: __of_adjust_tree_phandle_references: Could not find target child 'onewire' @/__local_fixups__/fragment@0/__overlay__
[  145.010472] create_overlay: Failed to resolve tree

I used the RPi image of 2017-04-10 and w1-gpio loaded well (kernel revision: e223d71).
Then, since I did apt-get upgrade (kernel revision: ef3b440) I've got the issue.

It seems that something was broken after kernel update 2c47f0d
Is it a kernel issue? Or it's a problem of dtoverlay utility?

@pelwell
Copy link
Contributor

pelwell commented May 10, 2017

Interesting - it's not immediately obvious why it is failing, but I think some part of the kernel overlay application mechanism has changed. I'll report back when I know more.

@pelwell
Copy link
Contributor

pelwell commented May 11, 2017

It turns out that this is a problem in the dtoverlay utility, caused by failure to take account of a difference between how the firmware merges overlays and how the kernel does it.

Overlays have to be "fixed up" - ensuring that label numbers don't clash with the base DTB - when loaded. They also need to have their parameters applied before they are merged with the base DTB. The firmware sequence is:

  1. Load
  2. Fix up
  3. Apply parameters
  4. Merge

The standard kernel overlay mechanism uses a different sequence:

  1. Receive (something else does the loading)
  2. Fix up
  3. Merge

Note that the kernel doesn't understand parameters, so that stage is performed by the dtoverlay utility, leading to a combined sequence of:

  1. (A) Load
  2. (A) Apply parameters
  3. (A) Send to kernel
  4. (K) Receive
  5. (K) Fix up
  6. (K) Merge

where (A) means the dtoverlay application and (K) means the kernel.

The problem occurs because, in the most recent images, a parameter can change a node name, and node names form part of the information using during the fixing up process. Here's an extract from the w1-gpio overlay, where you can see the onewire@0 in both sets of fix-ups:

    __local_fixups__ {
        fragment@0 {
            __overlay__ {
                onewire@0 {
                    pinctrl-0 = <0x00000000>;
                };
            };
        };
        __overrides__ {
            gpiopin = <0x00000000 0x0000000c 0x00000016 0x00000026>;
            pullup = <0x00000000>;
        };
    };
    __fixups__ {
        gpio = "/fragment@0/__overlay__/onewire@0:gpios:0", "/fragment@1:target:0";
    };

What is needed is an extension to the "Apply parameters" step that also patches the fix-ups as necessary. It's not that difficult, but it may be a while before I get around to it.

@pelwell
Copy link
Contributor

pelwell commented May 15, 2017

You will find an updated libdtovl.so here. Download it and copy it into /opt/vc/lib (you will need root permission, and you might want to save the original version in case you want to revert), then try the failing command again.

Provided you don't find any problems the fixed library will be in the next firmware release.

popcornmix added a commit to raspberrypi/firmware that referenced this issue May 15, 2017
kernel: dwc_otg: Fixes for root port disconnect issues
See: raspberrypi/linux#2010

kernel: BCM270X_DT: Tidy up mmc, sdhost, sdio overlays
See: raspberrypi/linux#2003

firmware: platform: Move trait initialisation out of #ifdef'd function

firmware: usb: Change USB PHY settings to make device mode work correctly

firmware: dtoverlay: Update fixups when a node is renamed
firmware: dtoverlay app: Add the -D (dry-run) option
See: raspberrypi/linux#2002

firmware: dispserver: Adjust open/close refcount on application exit
See: #778

firmware: filex: Optimise directory search of the root directory
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this issue May 15, 2017
kernel: dwc_otg: Fixes for root port disconnect issues
See: raspberrypi/linux#2010

kernel: BCM270X_DT: Tidy up mmc, sdhost, sdio overlays
See: raspberrypi/linux#2003

firmware: platform: Move trait initialisation out of #ifdef'd function

firmware: usb: Change USB PHY settings to make device mode work correctly

firmware: dtoverlay: Update fixups when a node is renamed
firmware: dtoverlay app: Add the -D (dry-run) option
See: raspberrypi/linux#2002

firmware: dispserver: Adjust open/close refcount on application exit
See: raspberrypi/firmware#778

firmware: filex: Optimise directory search of the root directory
@pelwell
Copy link
Contributor

pelwell commented May 16, 2017

Yesterday's rpi-update release includes the new libdtovl.so, so you can run sudo rpi-update instead of manually patching your installation.

popcornmix pushed a commit to raspberrypi/userland that referenced this issue May 16, 2017
When the firmware applies an overlay it processes the fixups before
applying any parameters. Under Linux, parameters are handled by the
dtoverlay/dtparam application before submission to the kernel, which
is where the fixups are applied. As a consequence, fixups must be
modified if they refer to nodes which are renamed as the result of
using a parameter.

The process of updating the fixups (and symbols, in case the kernel
cares in the future) is too heavyweight to want the firmware to
do it unnecessarily, so internally use the fact that the fixups
have been applied as an indication that they no longer need to be
patched.

See: raspberrypi/linux#2002
@softerra
Copy link
Author

Thank you

@P33M P33M closed this as completed May 18, 2017
mkreisl added a commit to xbianonpi/xbian-package-firmware that referenced this issue Sep 13, 2017
- firmware: platform: Move trait initialisation out of #ifdef'd function

- firmware: usb: Change USB PHY settings to make device mode work correctly

- firmware: dtoverlay: Update fixups when a node is renamed
- firmware: dtoverlay app: Add the -D (dry-run) option
  See: raspberrypi/linux#2002

- firmware: dispserver: Adjust open/close refcount on application exit
  See: #778

- firmware: filex: Optimise directory search of the root directory

- firmware: Revert Change USB PHY settings to make device mode work correctly.
  See: #816

- firmware: Comments: Replace copyright symbol with (c)

- firmware: arm_display: Remove unused sdtv variables

- firmware: tvservice: Avoid referencing uninitialised state when unsuccessful
  See: raspberrypi/userland#397

- firmware: dtoverlay: Short-circuit empty parameter handling
  See: raspberrypi/linux#2028

- firmware: rtos: Protect against null timer callback
  See: http://forum.kodi.tv/showthread.php?tid=280408

- firmware: arm_dt: Add txp node to device tree parsing to mask off transposer interrupt

- firmware: venc: Correct the validation on custom mb/mbps/br settings
  See: #819

- firmware: venc: Correct the validation on custom mb/mbps/br settings
  See: #819

- firmware: vc_image: Remove structure definition duplication
- firmware: vc_image/mmal/il/isp: Add support for 16bit/component YUV420 and YUVUV

- firmware: vcdbg: Don't use dma when file provided

- firmware: rtos: Avoid sleeping delay when RTOS is not present

- firmware: bootcode: Remove reliance on scanf to reduce bootcode.bin size
- firmware: bootcode: Changes to force to full speed
- firmware: bootcode: Make sure bootcode drops out
- firmware: bootcode: Mass storage changes to power off/on USB block
- firmware: bootcode: Change USB 1.1 to have 64 byte endpoints
- firmware: bootcode: Set MSD serial number to be the Pi serial number

- firmware: imx219: Extend line length for long frame times

- firmware: 2ndstage: Improve i2c_gpio support
- firmware: i2c_gpio: Improve implementation and usage

- firmware: Camplus: Enable RAW12 support in the ISP input formatter

- firmware: scalerlib: Don't flip tiled format and swap R/B
- firmware: arm_display: Provide mechanism to request tiled format framebuffer
  See: #820

- firmware: platform: Set BT LPO frequency to 32768Hz
  See: #831

- firmware: arm_display: Fix mixup with xres/xres_virtual
  See: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=187058

- firmware: video_render: Relax the alignment requirements for pitches
- firmware: vc_image: Use vpitch when determining size of YUV buffers

- firmware: Fix regression in uart clock frequency
  See: #833

- bootcode: usb: Dont overwrite configured parameters

- firmware: usb: Force MSD app to use CM3 pin conf

- firmware: IL ISP: Fix typo in logging
- firmware: IL ISP: Add black level and lens shading controls
- firmware: isp: Correct ISP Bayer stride calcs for supported formats
- firmware: Remove unused duplicate versions of vc_sm_defs.h
- firmware: IL camera: add get_parameter for OMX_IndexConfigCustomAwbGains
- firmware: IL resize: Support get_parameter OMX_IndexConfigCommonInputCro
- firmware: MMAL/RIL: Add MMAL_PARAMETER_RESIZE_PARAMS / OMX_IndexParamResize mapping
- firmware: ISP IL: Add lresize output
- firmware: MMAL/RIL: Add mapping for OMX_IndexConfigCommon[In|Out]putCrop
- firmware: MMAL/RIL: Correct handling of MMAL_PARAMETER_VIDEO_SOURCE_PATTERN
- firmware: IL ISP: Add H & V flip support
- firmware: IL ISP: Implement OMX_IndexConfigCommonInputCrop

- firmware: imx219: Refactor exposure calculations

- firmware: dmalib: Stop spinning on dma_pause if END is signalled
  See: #824

- firmware: MMAL: Avoid lockup with opaque stripes into opaque frame callback
  See: raspberrypi/userland#390

- firmware: RIL null_sink: Support MMAL opaque input
  See: raspberrypi/userland#388

- firmware: arm_display: Avoid hang when display_rotate is used with vc4-kms-v3d driver
  See: guysoft/FullPageOS#137

- firmware: 2ndstage: Fix printing of zero as a decimal in uart_printf

- firmware: cdi_camera: Allow GPIO control on FS and FE events

- firmware: IL ISP: Add option to alter the shift in the output stage
- firmware: IL ISP: Add option for adjusting the input CCM
- firmware: vc_image: fix size calcs for YUV_UV_16
- firmware: vc_image_helper: Add YUV 16 bit formats to second header
- firmware: isp: Avoid setting vpitch in YUVUV16 cases
- firmware: isp: Handle 16 bit yuv in ip_is_supported_format

- firmware: hello_fft: Fixup offset calculation when mapping/unmapping buffers
  See: raspberrypi/userland#408

- bootcode: Default to using total_mem=1024

- firmware: logging: Avoid wraparound issue with total_mem=1024

- firmware: armstubs: Add wfe to ARMv7/ARMv8-32 stubs
  See: raspberrypi/linux#1989

- firmware: arm_loader: Use ethernet0 as fallback for placing DT MAC address
  See: #846

- firmware: dt-blob: Remove Zero W static I2C0 mapping on 28 & 29
  See: raspberrypi/linux#2130

- firmware: Revert arm_display: Avoid hang when display_rotate is used with vc4-kms-v3d driver

- firmware: arm_display: Avoid hang when display_rotate is used with vc4-kms-v3d driver 2
  See: #849
  See: #853

- firmware: vc_image headers: Tidy up duplication
- firmware: video_splitter: Only copy eColorFormat if not already set
  See: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=189830

- firmware: vcsm: Add new clean/invalidate command for 2D blocks
- firmware: gpuserver: Switch to using custom queue
- firmware: gpuserver: Add priority to queue

- firmware: MMAL/IL I420 and YUVUV 10bpp formats, + VCSM DMABUF import

- firmware: CEC: Fix crash when remote button release is received without a pressed
  See: https://forum.kodi.tv/showthread.php?tid=280408

- firmware: arm_loader display: Correct variable scope by renaming
  See: https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=84889
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants