Pulseview/Sigrok: Use Hantek 6022bl with 16 channels (Linux/debian)

Hi,

there are several ways to get all 16 channels of a Hantek 6022bl working.

Methode one:
– copy fx2lafw-sigrok-fx2-16ch.fw to fx2lafw-saleae-logic.fw. But for me this is NOT RELIABLE:
This must be done each time you connect the Hantek to the PC!
Backup firmware

  cp /usr/share/sigrok-firmware/fx2lafw-saleae-logic.fw /usr/share/sigrok-firmware/fx2lafw-saleae-logic.fw.bak
  

Copy 16 Channel firmware over fx2lafw-saleae-logic.fw

  cp /usr/share/sigrok-firmware/fx2lafw-sigrok-fx2-16ch.fw /usr/share/sigrok-firmware/fx2lafw-saleae-logic.fw
  

Load firmware to the device

  sigrok-cli --scan
    .....
    fx2lafw:conn=1.15 - Saleae Logic [S/N: Saleae Logic] with 16 channels: D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 D14 D15
  

Then ( I ) have to copy the old firmware back

  cp /usr/share/sigrok-firmware/fx2lafw-saleae-logic.fw.bak /usr/share/sigrok-firmware/fx2lafw-saleae-logic.fw
  

And pulsview can be started. As I said really applicable.
Methode two:
– Changing the eeprom Hantek 6022bl => To difficult, see this link

In my opinion the best way is to build an own package. But be aware that the full speed of 24Mhz is not reachable with 16 channels.

michael@debdev ~ # mkdir fx2lafw-build

Add Source repository to

deb-src http://archive.ubuntu.com/ubuntu noble main restricted universe multiverse

to

/etc/apt/sources.list.d/official-package-repositories.list

Update repository

michael@debdev ~ # sudo apt update
michael@debdev ~ # sudo apt install build-essential fakeroot sigrok-cli sigrok-firmware-fx2lafw pulseview

michael@debdev ~ # cd fx2lafw-build
michael@debdev ~/fx2lafw-build # apt-get source  libsigrok

Install build depedencies

michael@debdev ~/fx2lafw-build # cd libsigrok-0.5.2
michael@debdev ~/fx2lafw-build/libsigrok-0.5.2 # sudo apt-get build-dep libsigrok

Apply the patch to src/hardware/fx2lafw/api.c

michael@debdev ~/fx2lafw-build/libsigrok-0.5.2 #  cp src/hardware/fx2lafw/api.c src/hardware/fx2lafw/api.c.org

Modifing src/hardware/fx2lafw/api.c. Open for edit, go to line 74 and replace

 0, NULL, NULL},

with

 DEV_CAPS_16BIT, NULL, NULL},

To create a patch for further usage use:

michael@debdev ~/fx2lafw-build/libsigrok-0.5.2 #  diff -Nuar  ~/software/fx2lafw-build-org/libsigrok-0.5.2/src/hardware/fx2lafw/api.c src/hardware/fx2lafw/api.c > ~/fx2lafw.patch > ~/hantek-6022bl-16ch.patch

This creates a file like this

--- src/hardware/fx2lafw/api.c  2019-12-25 21:29:19.000000000 +0100
+++ src/hardware/fx2lafw/api.c  2025-03-31 20:30:26.463457393 +0200
@@ -71,7 +71,7 @@
         */
        { 0x0925, 0x3881, "Saleae", "Logic", NULL,
                "fx2lafw-saleae-logic.fw",
-               0, NULL, NULL},
+               DEV_CAPS_16BIT, NULL, NULL},

        /*
         * Default Cypress FX2 without EEPROM, e.g.:

which can be later applied by

michael@debdev ~/fx2lafw-build/libsigrok-0.5.2 # patch -p1 src/hardware/fx2lafw/api.c < ~/hantek-6022bl-16ch.patch

then update the change log

michael@debdev ~/fx2lafw-build/libsigrok-0.5.2 #  dch -i

libsigrok (0.5.2-5.1ubuntu1) UNRELEASED; urgency=medium

  * Build for 16 channel support.

 -- Michael Albert <michael@albert-hetzles.de>  Wed, 19 Mar 2025 21:17:34 +0100

Start build

michael@debdev ~/fx2lafw-build/libsigrok-0.5.2 #  dpkg-source --commit
michael@debdev ~/fx2lafw-build/libsigrok-0.5.2 #  dpkg-buildpackage -us -uc
michael@debdev ~/fx2lafw-build/libsigrok-0.5.2 #  cd ..

Remove sigrok and pulseview

michael@debdev ~/fx2lafw-build # sudo apt autoremove pulseview and sigrok
michael@debdev ~/fx2lafw-build # sudo apt autoremove libsigrok4
michael@debdev ~/fx2lafw-build # sudo apt autoclean
michael@debdev ~/fx2lafw-build # sudo apt autoremove

Install libsigrok4 and libsigrokcxx4, may be you must adjust the version

michael@debdev ~/fx2lafw-build # ls -l *.deb
michael@debdev ~/fx2lafw-build # sudo dpkg -i libsigrok4t64_0.5.2-5.1ubuntu1_amd64.deb 
michael@debdev ~/fx2lafw-build # sudo dpkg -i libsigrokcxx4t64_0.5.2-5.1ubuntu1_amd64.de

And install sigrok again

michael@debdev ~/fx2lafw-build # sudo apt install sigrok-cli sigrok-firmware-fx2lafw pulseview

Be aware that the manual installation of deb package could break some update dependencies. If happens: simply remove libsigrok4, update your system and rebuild and install a new libsigrok4.

Michael