Hantek 6022BL logic analyzer working with sigrok - all 16 channels - Page 1
Forum section: electronics / testgear

author: grob6k
author_rank: Newbie
timestamp: October 08, 2021, 03:30:47 am
content: 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:Use OpenHantek6022 software (https://github.com/OpenHantek/OpenHantek6022).Do the AC coupling modification (https://github.com/OpenHantek/OpenHantek6022/blob/main/docs/HANTEK6022_AC_Modification.pdf). Note that for the B/L, the control wires can connect to R40/R41 as per the bottom of the article.Calibrate it (it saves the values to the device, so it's a one-time thing) (https://github.com/Ho-Ro/Hantek6022API/blob/main/README.md#create-calibration-values-for-openhantek).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-firmwareFor pulseview it is something like:C:\Program Files\sigrok\PulseView\share\sigrok-firmwareIf 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.

author: dugpatrick
author_rank: Newbie
timestamp: July 05, 2022, 11:23:16 pm
content: 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-firmwareI 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.fwAfter unplugging/re-plugging the 6022BL, Pulseview now shows all 16 channels. :-)Thank you for the pointers!

author: mklivoslov
author_rank: Newbie
timestamp: December 03, 2022, 01:06:34 pm
content: 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 outCode:VID_0925&PID_3881(P mode).There are two options:Option 1: Program EEPROM directlyYou need:The EEPROM programmer;The programming clip (you don't want to remove the EEPROM, eh?);The programmer's softwareSteps: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:C0 25 09 81 38 00 00 00;5. Leave the clip on that EEPROM, replace that 8 bytes withCode: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 withCode:VID_1D50&PID_608D, then it is good;8. Reassemble your Hantek.Option 2: Use CyConsoleYou need:An old enough Windows that does not care what driver it's installing;A HEX file editorSuiteUSB 3.4fromhttps://www.infineon.com/cms/en/product/universal-serial-bus-usb-power-delivery-controller/peripheral-controllers/ez-usb-fx2lp/?tab=~%27development_tools#!designsupport(login to download) for CyConsole tool;(Optional)EZ-USB_devtools_version_261700.zipfromhttps://web.archive.org/web/20110516031006/http://www.cypress.com/?rID=14319(it's old!) for theVend_Axfirmware;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 asCode:VID_0925&PID_3881;3. Remove any drivers that is currently loaded for your Hantek;4. OpenCode:cyusb.infin your SuiteUSB 3.4 installation,Code:Driver\binsubfolder (select your approriate system) in Notepad;5. AddCode:"Hantek6022BL 0925:3881"=CyUsb, USB\VID_0925&PID_3881under sectionCode:; save the file;6. Install all the files in the folder containing your modifiedCode:cyusb.infas driver for your Hantek;7. Open your favourite HEX editor and create a new file ending with .iic with the 8 bytes:Code:C0 50 1D 8D 60 00 00 00;8. Open CyConsole, verify that your Hantek is there, navigate toOptions/EZ-USB Interface;9. Select your Hantek, pressS EEPROMbutton and navigate to your created .iic file;10. (Optional) To verify, pressDownloadsand navigate toC:\Cypress\USB\Examples\FX2\Vend_ax\Vend_Ax.hex(assuming you've installed EZ-USB_devtools_version_261700 there). Then enterCode:0xA2intoReq,Code:0x0000intoValue,Code:8intoLength, selectCode:1 INin Dir and pressVend Req. If the console shows the string similar toCode:C0 50 1D 8D 60 00 00 00then 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 withCode: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:https://sigrok.org/wiki/Fx2grok: Relating to the firmware and the relevant USB IDhttps://sigrok.org/wiki/Fx2lafw#Cypress_FX2_vs._FX2LP: The firmware source code, SDK and stuff relating to CY7C68013A and how PulseView interact with the chiphttps://community.infineon.com/t5/Knowledge-Base-Articles/CY7C68013A-Serial-EEPROM-Read/ta-p/258552: How to read EEPROM using CyConsoleMauriceP.S. Sorry for my terrible formatting

author: netboy3
author_rank: Newbie
timestamp: December 07, 2022, 02:48:19 pm
content: 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:--- 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.