Author Topic: Hantek 6022BL logic analyzer working with sigrok - all 16 channels  (Read 3855 times)

0 Members and 1 Guest are viewing this topic.

Offline grob6kTopic starter

  • Newbie
  • Posts: 1
  • Country: au
Hi All,

Just thought I'd leave this here, as I had terrible trouble finding good info on this and had to learn a lot as I went; hopefully it helps someone else.

I recently bought a Hantek 6022BL for a friend getting into audio and IoT/digital electronics. The combo of scope and logic analyzer for $100AUD was pretty tempting. You should know it can only work as one or the other at one time (you select which with a switch before plugging it in...).

Prior to giving it to them, I realised the Hantek software is all completely unusable, so went about 'fixing' it before sending them down this path of chaos. The findings are:

Oscilloscope mode:


Logic Analyzer mode:

There are a couple of options for software:
1. sigrok/PulseView (https://sigrok.org/wiki/Downloads)
2. Salae Logic (https://www.saleae.com/downloads/) - note that it will only run up to 12MS/sec; it will let you select more than this but will generate errors.

It works 'out of the box' (as per the sigrok wiki) in 8-channel mode, as the device reports itself with the same USB ID as a Salae Logic, which was an 8-channel device. It's kind of a clone in that regard. You can use the Salae Logic software (which is great; even friendlier than PulseView) as long as 8 channels is enough.

However, the device has 16 channels, and I wanted to get them all working. Here's how:

Enabling 16-channels for 6022BL with sigrok:

Basically, the device uses a FX2 chip - for these, there is no flash, firmware is uploaded to it every time it is connected. The initial USB VID/PID is reported from EEPROM on the device; there are two EEPROMs in the 6022BL which are selected by the mode selection switch (H/in=oscilloscope or P/out=logic analyzer). Sigrok comes with a firmware called 'fx2lafw', which is designed to work with lots of logic analyzer devices based on these chips. As the device reports it is a Saleae Logic, sigrok is uploading a firmware configured for this 8ch device when it runs. All we need to do is swap the salae-logic firmware file for a properly configured 16ch firmware file - fortunately, there is one that works provided with sigrok/pulseview already!

Here's how; I'm using windows, but linux people will be able to adapt the below to suit:

(1) Find the 'sigrok-firmware' directory.
For sigrok-cli, this is something like: C:\Program Files\sigrok\sigrok-cli\share\sigrok-firmware
For pulseview it is something like: C:\Program Files\sigrok\PulseView\share\sigrok-firmware
If you want to use either, do steps (2) and (3) for both!

(2) Make a backup of "fx2lafw-saleae-logic.fw" (e.g. change name to ... .fw.bak)

(3) Copy "fx2lafw-sigrok-fx2-16ch.fw", and rename the copy to "fx2laf2-salae-logic.fw".

(4) On the device, set the H/P switch to P (out) for logic analyzer mode, and plug in the USB cable.

Now, if you're using sigrok-cli:

(5a) Scan for fx2lafw devices. Command line: "sigrok-cli --scan". libsigrok will upload the 'wrong' firmware but report a 'Salae Logic with 8 channels'
(6a) If you're using windows, and this is the first time with this device, use Zadig (comes with pulseview, or you can install separately: https://zadig.akeo.ie/) to install the WinUSB driver for the new device that has appeared (name: 'fx2lafw', VID:1D50, PID:608D).
(7a) Now, scan again (sigrok-cli --scan) and device "sigrok FX2 LA (16ch)" will appear and work.

Or if you're using pulseview:

(5b) Start pulseview. During the start-up scan, the 16-ch firmware is uploaded.
(6b) If you're using windows, and this is the first time with this device, use Zadig to install the WinUSB driver for the new device that has appeared (name: 'fx2lafw', VID:1D50, PID:608D).
(7b.i) Manually connect to the device: Click the arrow next to <No Device> and then 'Connect to Device...' from the dropdown, select 'fx2lafw' from the driver list, then 'scan for devices...', and 'sigrok FX2 LA (16ch) with 16 channels' should appear in the device list. Click OK, and ready to work.
-- OR --
(7b.ii) Quit and restart pulseview, which should find and connect the 16ch firmware automatically.

More notes:
  • Obviously if you also use Salae Logic hardware, when you try and connect to this with sigrok or PulseView it will now do the same firmware loading to this device as above. Presumably (I don't have one to test) it will report 16 channels but only 8 will work. Worst case it might not work at all. You'll have to swap back the firmware files to make it work again.
  • You can still use the Salae Logic software with the 6022BL if you like - just plug the device in, DON'T RUN SIGROK OR PULSEVIEW. Salae Logic will identify the device and load it's own firmware, and you can use the first 8 channels.
 
The following users thanked this post: ledtester, dugpatrick

Offline dugpatrick

  • Newbie
  • Posts: 1
  • Country: us
Re: Hantek 6022BL logic analyzer working with sigrok - all 16 channels
« Reply #1 on: July 05, 2022, 11:23:16 pm »
Kudos, and thanks for sharing.

On my Linux system I was able to enable the 16 channel firmware with similar steps:  The location(s) for firmware can be found from "Settings/About" in Pulseview.  On my system I see the following firmware locations:
        Firmware search paths:
        /home/dug/.local/share/sigrok-firmware
        /home/jenkins_slave/sr/share/sigrok-firmware
        /tmp/.mount_PulseVbbFR03/usr/share/sigrok-firmware
        /usr/local/share/sigrok-firmware
        /usr/share/sigrok-firmware

I found the 16 channel firmware in the /tmp location, and so I made a copy (and renamed the file) into my home directory location:
        $ cp /tmp/.mount_PulseVfMGQyx/usr/share/sigrok-firmware/fx2lafw-sigrok-fx2-16ch.fw fx2lafw-saleae-logic.fw

After unplugging/re-plugging the 6022BL, Pulseview now shows all 16 channels. :-)

Thank you for the pointers!
 

Offline mklivoslov

  • Newbie
  • Posts: 2
  • Country: ca
    • Woodruff's Personal Directory
Re: Hantek 6022BL logic analyzer working with sigrok - all 16 channels
« Reply #2 on: December 03, 2022, 01:06:34 pm »
Thanks for your great post!  Since I did consider the side effect of your "hack", I'll propose another one similar in result  :).

This make PulseView detect the Hantek 6022BL as having 16ch and load the 16ch firmware when the switch is left in P mode.
The downside is that you may void the warranty (?).

There are two EEPROMs for USB ID on the Hantek 6022BL for each state of the switch.  I only care about the one that gives out
Code: [Select]
VID_0925&PID_3881 (P mode).

There are two options:

Option 1: Program EEPROM directly
You need:
  • The EEPROM programmer;
  • The programming clip (you don't want to remove the EEPROM, eh?);
  • The programmer's software
Steps:
  1.  Open your Hantek (definitely void the warranty :) );
  2.  Locate the 2 EEPROMs;
  3.  Prepare the programme;
  4.  Read both EEPROMs until you find the one with first 8 bytes:
Code: [Select]
C0 25 09 81 38 00 00 00;
  5.  Leave the clip on that EEPROM, replace that 8 bytes with
Code: [Select]
C0 50 1D 8D 60 00 00 00, then write them;
  6.  Remove the clip; put your Hantek into P mode, and plug it into your PC to test the result;
  7.  If the device appears with
Code: [Select]
VID_1D50&PID_608D, then it is good;
  8.  Reassemble your Hantek.

Option 2: Use CyConsole
You need:
Steps:
  1.  Install SuiteUSB 3.4 and EZ-USB_devtools_version_261700 (if you chose to);
  2.  Put your Hantek into P mode and plug it in; make sure Windows detects it as
Code: [Select]
VID_0925&PID_3881;
  3.  Remove any drivers that is currently loaded for your Hantek;
  4.  Open
Code: [Select]
cyusb.inf in your SuiteUSB 3.4 installation,
Code: [Select]
Driver\bin subfolder (select your approriate system) in Notepad;
  5.  Add
Code: [Select]
"Hantek6022BL 0925:3881"=CyUsb, USB\VID_0925&PID_3881 under section
Code: [Select]
[Device]; save the file;
  6.  Install all the files in the folder containing your modified
Code: [Select]
cyusb.inf as driver for your Hantek;
  7.  Open your favourite HEX editor and create a new file ending with .iic with the 8 bytes:
Code: [Select]
C0 50 1D 8D 60 00 00 00;
  8.  Open CyConsole, verify that your Hantek is there, navigate to Options/EZ-USB Interface;
  9.  Select your Hantek, press S EEPROM button and navigate to your created .iic file;
  10.  (Optional) To verify, press Downloads and navigate to C:\Cypress\USB\Examples\FX2\Vend_ax\Vend_Ax.hex (assuming you've installed EZ-USB_devtools_version_261700 there).  Then enter
Code: [Select]
0xA2 into Req,
Code: [Select]
0x0000 into Value,
Code: [Select]
8 into Length, select
Code: [Select]
1 IN in Dir and press Vend Req.  If the console shows the string similar to
Code: [Select]
C0 50 1D 8D 60 00 00 00 then it is good;
  11.  Close CyConsole, remove the driver (if you want to), unplug and replug your Hantek;
  12.  If the Hantek appears as Unknown Device with
Code: [Select]
VID_1D50&PID_608D, you're done!

The remaining is to open PulseView and use it.  The 16ch firmware will automatically be loaded.

To revert, just follow the same steps and options above, with adjusted USB ID value.

Resources:

Maurice

P.S.  Sorry for my terrible formatting  :palm:
 
The following users thanked this post: TSCOLAN

Offline netboy3

  • Newbie
  • Posts: 1
  • Country: us
Re: Hantek 6022BL logic analyzer working with sigrok - all 16 channels
« Reply #3 on: December 07, 2022, 02:48:19 pm »
Thank you for all the creative solutions offered in this thread. There are two additional points I wanted to make:
  • The 16 channel modification is not really a firmware issue. Almost all FX2 based hardware is using the same chip and thus loaded with similar firmware. The difference is in the channel mapping of the incoming data from the FX2. That mapping is based on different presets in libsigrok which are matched based on the USB ID. Both solutions above achieve the same thing; fooling libsigrok into thinking it's using a different hardware. Instead of a hack, one could simply rebuild libsigrok with the following patch that will enable 16 channel support on any device with USB ID 0925:3881:
Code: [Select]
--- a/src/hardware/fx2lafw/api.c        2019-12-25 15:29:19.000000000 -0500
+++ b/src/hardware/fx2lafw/api.c        2022-12-06 23:15:38.024054544 -0500
@@ -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.:

  • One thing that was never mentioned here is the inherent bandwidth limitation of the FX2 solution. As the 6022BL is a streaming only LA with a USB2 interface, it is critical to have enough bandwidth to pump the packed data in real-time into the PC. Using only 8 channels will just get you by 24MHz samplerate. If you choose to use all 16 channels, you'll be limiting your samplerate to 12MHz. Personally, I prefer a higher samplerate over wider channel count, and in the rare circumstance where I need those 16 channels, I can always hack the firmware file trick to get those. I would avoid using any more permanent solutions.
« Last Edit: December 07, 2022, 03:21:54 pm by netboy3 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf