Unable to open temperature file '/sys/class/thermal/thermal_zone0/temp when host reboots

Basic Information:

Printer Model: Creality K1
MCU / Printerboard: Manta M5P
Host / SBC: BTT CB2
klippy.log

klippy.log (21.6 KB)

Today I moved my CB2 from BTT’s old bullseye image over to the beta bookworm image. I moved my Klipper config over after installing via Kiauh. I followed the instructions in the Klipper docs to enable the Linux service:

I had followed these instructions before without any problems. But now, every time I reboot the machine Klipper fails with message:

Unable to open temperature file '/sys/class/thermal/thermal_zone0/temp'

Once the underlying issue is corrected, use the "RESTART"
command to reload the config and restart the host software.
Printer is halted

When I ssh into the machine and look for that file, it is present. I believe there is some kind of timing issue where Klipper is looking for /sys/class/thermal/thermal_zone0/temp before it is made available?

If I restart Klipper (without rebooting the machine) the problem disappears and I can see the temperature of the CB2 SoC in fluidd.

This sounds like a bug in the used Linux version.

Maybe delaying the start of Klipper by a few seconds could mitigate the problem. If you want to try, you can add something like

ExecStartPre=/bin/sleep 5

to /etc/systemd/system/klipper.service in the [Service] section.

Thanks for the thoughtful response.

‘sleep 5’ was not long enough to fix the problem. I changed it to ‘sleep 10’ and that was apparently enough time for things to work as expected.

There is already a thread for this problem on BTT’s CB2 Github.

If you cared, you could refine this approach with something like

#!/bin/bash

file="/sys/class/thermal/thermal_zone0/temp"
dir="$(dirname "$file")"

# Wait for the file to appear for max 15 seconds (returns as soon as the file appears)
while [ ! -f "$file" ]; do
    inotifywait -qq -t 15 -e create -e moved_to "$dir"
done

exit 0

Put the content into a script file, e.g., wait_temp_file.sh, make it executable, and call it from the ExecStartPre directive.

This should return as soon as the file becomes available, but at maximum for 15 seconds.

Requires:

sudo apt-get install inotify-tools

Edit: Untested as I have no means of verifying. So, YMMV

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.