CM4 8GB/32GB eMMC, official Bullseye image: error installing upgrade to devterm-thermal-printer

hi, getting this when trying to upgrade after doing an apt upgrade and finding it broken afterwards:

❯ sudo apt reinstall devterm-thermal-printer
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be upgraded:
  devterm-thermal-printer
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
58 not fully installed or removed.
Need to get 0 B/41.2 kB of archives.
After this operation, 168 kB disk space will be freed.
Reading changelogs... Done
(Reading database ... 128341 files and directories currently installed.)
Preparing to unpack .../devterm-thermal-printer_0.38_arm64.deb ...
Failed to stop devterm-printer.service: Unit devterm-printer.service not loaded.
Failed to stop devterm-socat.service: Unit devterm-socat.service not loaded.
Failed to disable unit: Unit file devterm-printer.service does not exist.
Failed to disable unit: Unit file devterm-socat.service does not exist.
dpkg: warning: old devterm-thermal-printer package pre-removal script subprocess returned error exit status 1
dpkg: trying script from the new package instead ...
Failed to stop devterm-printer.service: Unit devterm-printer.service not loaded.
Failed to stop devterm-socat.service: Unit devterm-socat.service not loaded.
Failed to disable unit: Unit file devterm-printer.service does not exist.
Failed to disable unit: Unit file devterm-socat.service does not exist.
dpkg: error processing archive /var/cache/apt/archives/devterm-thermal-printer_0.38_arm64.deb (--unpack):
 new devterm-thermal-printer package pre-removal script subprocess returned error exit status 1
Failed to enable unit: Unit file devterm-socat.service does not exist.
Failed to start devterm-socat.service: Unit devterm-socat.service not found.
Failed to enable unit: Unit file devterm-printer.service does not exist.
Failed to start devterm-printer.service: Unit devterm-printer.service not found.
chmod: cannot access '/usr/local/bin/devterm_socat.sh': No such file or directory
dpkg: error while cleaning up:
 installed devterm-thermal-printer package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/devterm-thermal-printer_0.38_arm64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
╭─  │  ~ ▓▒░────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────░▒▓ 100 ✘ │ took 5s  │ at 02:05:02 AM  ─╮
╰─              

anyone know if there is a known fix for this?

Looks like your are missing that file in that location

Can you try?

sudo apt update
sudo apt remove devterm-thermal-printer-cups  devterm-thermal-printer -y
sudo apt install -y devterm-thermal-printer-cups  devterm-thermal-printer 
sudo reboot
1 Like
❯ sudo apt update && sudo apt -y --purge remove devterm-thermal-printer-cups devterm-thermal-printer
[sudo] password for jtd: 
Hit:1 http://deb.debian.org/debian bullseye InRelease
Hit:2 http://deb.debian.org/debian bullseye-updates InRelease                  
Hit:3 http://security.debian.org/debian-security bullseye-security InRelease   
Hit:4 https://dl.yarnpkg.com/debian stable InRelease                           
Get:5 https://raw.githubusercontent.com/clockworkpi/apt/main/debian stable InRelease [5,408 B]
Hit:6 http://archive.raspberrypi.org/debian bullseye InRelease                 
Hit:7 https://download.owncloud.com/desktop/ownCloud/stable/latest/linux/Debian_11  InRelease
Fetched 5,408 B in 2s (2,629 B/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
3 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
  devterm-thermal-printer* devterm-thermal-printer-cups*
0 upgraded, 0 newly installed, 2 to remove and 2 not upgraded.
58 not fully installed or removed.
After this operation, 168 kB disk space will be freed.
dpkg: error processing package devterm-thermal-printer (--remove):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting a removal
dpkg: too many errors, stopping
Errors were encountered while processing:
 devterm-thermal-printer
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

Hey all — sorry for the (partial) necrobump. I have the same issue.

Currently on Devterm with CM4 4GB and 32GB SD card (the one that came with the package). Any ideas?

1 Like

Wow never seen that message, try:

sudo dpkg --remove --force-remove-reinstreq devterm-thermal-printer
sudo apt-get install devterm-thermal-printer
1 Like

Two updates.

First, I found a workaround that allows to install the update if one gets stuck in the state that @0xKruzr describes.

I touched the files that the log says are missing (i.e., /usr/local/bin/devterm_socat.sh, /etc/systemd/system/devterm-printer.service and /etc/systemd/system/devterm-socat.service), and then removed the two systemd files, since the installer script was (rightfully) pointing out that they couldn’t be automatically removed since they had been overridden manually.

This makes me think that there is probably a bug in the uninstall script, where it gets stuck if it doesn’t detect the files above.

Second: Installing the printer driver updates broke my wifi card. After issuing a reboot, while powering off, the TTY was flooded with these errors:

brcmfmac: brcmf_sdio_htclk: HT Avail request error: -110

After reboot, WLAN was no longer working. If I ran sudo ip l set wlan0 up the terminal hanged for a few second, then responded RTNETLINK answers: Input/output error.

I reflashed the OS, and, with a clean install, WLAN was back, and I was able to update the printer driver by running

sudo apt update
sudo apt remove devterm-thermal-printer-cups  devterm-thermal-printer -y
sudo apt install -y devterm-thermal-printer-cups  devterm-thermal-printer 
sudo reboot

As suggested by @Petrakis.

However, again, after updating the printer driver I got those brcmfmac errors when shutting down the system, and lost WLAN after rebooting. The printer also stopped working after the driver upgrade/reboot.

I’m currently re-flashing the clean OS image, and will probably just blacklist the driver updates while the issue gets sorted out :]

Let me know if I can help with the troubleshooting!

2 Likes

This did the trick for me.

Please don’t touch the missing files. This breaks the Wi-Fi and causes all sorts of problems.

Hey jan-peter!

I’m happy things worked out for you :]

In my case, the WiFi broke even when I simply updated the two packages on a clean installation where I didn’t edit those files, so it’s unlikely the two things are related.

Admittedly though, as of today I still haven’t inspected the packages or their install scripts, so I haven’t pinpointed the exact cause of the WiFi failure either.

So far, blacklisting the printer driver packages from apt upgrade has been easier, since the printer works okay anyway.

If you’ve successfully updated your drivers, could you give a bit more details about your experience? What was your starting point? Clean image, fully updated system (as of when?), partially updated system…?

Thanks!

Certainly.

I updated the whole system (apt upgrade) and used the mentioned instruction.

But I didn’t test the printer yet. Paper is on its way.

fwiw, this didn’t do anything:

❯ sudo dpkg --remove --force-remove-reinstreq devterm-thermal-printer
dpkg: warning: overriding problem because --force enabled:
dpkg: warning: package is in a very bad inconsistent state; you should
 reinstall it before attempting a removal
(Reading database ... 128373 files and directories currently installed.)
Removing devterm-thermal-printer (0.37) ...
Failed to stop devterm-printer.service: Unit devterm-printer.service not loaded.
Failed to stop devterm-socat.service: Unit devterm-socat.service not loaded.
Failed to disable unit: Unit file devterm-printer.service does not exist.
Failed to disable unit: Unit file devterm-socat.service does not exist.
dpkg: error processing package devterm-thermal-printer (--remove):
 installed devterm-thermal-printer package pre-removal script subprocess returned error exit status 1
Failed to enable unit: Unit file devterm-socat.service does not exist.
Failed to start devterm-socat.service: Unit devterm-socat.service not found.
Failed to enable unit: Unit file devterm-printer.service does not exist.
Failed to start devterm-printer.service: Unit devterm-printer.service not found.
chmod: cannot access '/usr/local/bin/devterm_socat.sh': No such file or directory
dpkg: error while cleaning up:
 installed devterm-thermal-printer package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 devterm-thermal-printer

I also have been having a nightmare of a time with this.

Printer stops working after updates, tried the “remove devterm-thermal-printer-cups devterm-thermal-printer -y” command, and it doesnt work, returning an error.

Try again with a fresh Pi install, this time, running the command before updating anything. It works, now i dont have wifi. Unacceptable. Buy a 20$ USB wifi adapter hoping i could connect wifi again to run an update which would hopefully fix the problem and the usb wifi device wouldn’t be needed beyond that: straight up doesnt see the usb wifi device that is plugged right into it and still wont connect to wifi.

Another fresh Pi Install, this time running the “sudo dpkg --remove --force-remove-reinstreq devterm-thermal-printer” command: and I get the same result:
dpkg: warning: overriding problem because --force enabled:
dpkg: warning: package is in a very bad inconsistent state; you should
reinstall it before attempting a removal
(Reading database … 128373 files and directories currently installed.)
Removing devterm-thermal-printer (0.37) …
Failed to stop devterm-printer.service: Unit devterm-printer.service not loaded.
Failed to stop devterm-socat.service: Unit devterm-socat.service not loaded.
Failed to disable unit: Unit file devterm-printer.service does not exist.
Failed to disable unit: Unit file devterm-socat.service does not exist.
dpkg: error processing package devterm-thermal-printer (–remove):
installed devterm-thermal-printer package pre-removal script subprocess returned error exit status 1
Failed to enable unit: Unit file devterm-socat.service does not exist.
Failed to start devterm-socat.service: Unit devterm-socat.service not found.
Failed to enable unit: Unit file devterm-printer.service does not exist.
Failed to start devterm-printer.service: Unit devterm-printer.service not found.
chmod: cannot access ‘/usr/local/bin/devterm_socat.sh’: No such file or directory
dpkg: error while cleaning up:
installed devterm-thermal-printer package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
devterm-thermal-printer

Why the hell is this such a huge issue? i have found nothing on any other forum as to why this is happening or how to fix it. This seems like the kind of thing that should have been fixed long before anyone should be allowed to purchase this product. :man_shrugging:

Great question! It’s really frustrating. I really wanted to be able to use the printer when I bought this thing.

Which official OS image did you install? I saw elsewhere that people had issues with the 32bit OS, so I installed the 64 bit one. I ran the fix after install and my wifi was never affected. I haven’t yet tested the printer, but I plan to do so soon and I’ll post my result.

But I suspect it may be the 32bit OS that’s broken?

Another difference in my case is that my CM4 has no eMMC. I bought it that way since I didn’t want to buy extra hardware just to flash the device, and because the no eMMC version is the one promoted/sold by ClockworkPi and presumably (?) tested by them.

Also, there’s a wifi antenna fix that must be done when using the 64bit OS. Might be needed on the 32bit OS as well, but I haven’t tested that. Like many useful/critical things, it’s kind of buried in the forum and in github, and easy to miss. It really should be added to the official OS.

I just tried printing and I guess I have the same issue, as after following the steps above to reinstall the driver, I still can’t print. The devterm_printer shows up in the print dialog, but when I select it and print, nothing happens. Also, sending the test print command to the console (echo -en “\x12\x54” > /tmp/DEVTERM_PRINTER_IN) doesn’t do anything either. No errors, but no printing.

Wifi has disappeared, as well.

My printer worked fine with the A06 board, as did the wifi.

Has anyone managed to get the printer and wifi to work on the CM4 64 bit OS? Also, is there a way to restore wifi without reflashing the OS?

Thanks for pointing out the antenna fix! Quite helpful indeed.

FWIW — I’m on the 64bit system, and I’m able to print (though with some minor issues, especially when I try to print black-rich files). I simply didn’t update the driver, and used the default one.

Also, I made a mistake, and I didn’t specify that my CM4 also has no eMMC. I had overlooked the fact that it was mentioned on the title ^_^"

1 Like

I wonder… is there a way to roll back to the original driver? I guess I’d still have the wifi problem though. Sounds like I need to do a fresh install, which won’t hurt too much since I haven’t done a lot of customization yet.

You mentioned you blacklisted the driver to prevent it updating – what command did you use? Thanks!

I actually didn’t try a rollback, now that you mention it! Maybe that could work? Not sure.

Anyway, to prevent the package from upgrading, I ran sudo apt-mark hold devterm-thermal-printer devterm-thermal-printer-cm4 devterm-thermal-printer-cups

1 Like

I haven’t tried rolling it back (wasn’t even sure if that was possible, but I found this which indicates it is and has some example commands to identify version and roll back to a specific version of a package How to downgrade a package via apt-get? - Ask Ubuntu). Once I’m done with the CPU frequency/battery life testing I’ll try it.

Thanks for the info on preventing an update for a package.

Ok, I got my printer working again, after using these commands to get information about what was installed:

apt-cache policy devterm-thermal-printer
apt-cache policy devterm-thermal-printer-cm4
apt-cache policy devterm-thermal-printer-cups

In my case, after updating it only had …-printer and …-printer-cups installed. But …printer-cm4 was NOT installed. When I installed …printer-cm4, it removed …printer. But THAT caused printing to work again!

So apparently with the CM4 based Devterm, we don’t want to have devterm-thermal-printer installed and ONLY want to have devterm-thermal-printer-cm4 and devterm-thermal-printer-cups installed.

Here’s what things look like for my (working) printer now:

cpi@devterm-cm4:~ $ apt-cache policy devterm-thermal-printer
devterm-thermal-printer:
  Installed: (none)
  Candidate: 0.38
  Version table:
     0.38 500
        500 https://raw.githubusercontent.com/clockworkpi/apt/main/debian stable/main arm64 Packages
cpi@devterm-cm4:~ $ apt-cache policy devterm-thermal-printer-cm4
devterm-thermal-printer-cm4:
  Installed: 0.11
  Candidate: 0.11
  Version table:
 *** 0.11 500
        500 https://raw.githubusercontent.com/clockworkpi/apt/main/debian stable/main arm64 Packages
        100 /var/lib/dpkg/status
cpi@devterm-cm4:~ $ apt-cache policy devterm-thermal-printer-cups
devterm-thermal-printer-cups:
  Installed: 0.12.1
  Candidate: 0.12.1
  Version table:
 *** 0.12.1 500
        500 https://raw.githubusercontent.com/clockworkpi/apt/main/debian stable/main arm64 Packages
        100 /var/lib/dpkg/status