Skip to content

Commit

Permalink
update docs; more verbose example program
Browse files Browse the repository at this point in the history
Signed-off-by: Martin <[email protected]>
  • Loading branch information
Ho-Ro committed May 24, 2024
1 parent 9664f5f commit efbffa9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
2024-05-23: do not install system files when building/installing as user (#27) [9664f5f]
2024-05-23: new tool upload_firmware_6022.py (upload to different VID:PID) [c85792d]
2024-05-06: make scopevis.py example program really useful [ea05828]
2024-05-03: upversion 2.10.8; update examples and doc [ac44d00]
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ This means:

- download this repo (as `https://github.com/Ho-Ro/Hantek6022API/archive/refs/heads/main.zip`)
- or execute `git clone https://github.com/Ho-Ro/Hantek6022API.git`
- to enable user access to the device copy (as root) the file `udev/60-hantek6022api.rules`
into `/etc/udev/rules.d`
- go to `examples`
- try e.g. `python3 get_serial_number.py`.

- try e.g. `python3 get_serial_number.py`

## Developer Info

Expand Down
30 changes: 23 additions & 7 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,38 @@ usage: upload_6022_firmware_from_hex.py HEXFILE
Uploads firmware from intel hex file to device

### `upload_6022_firmware.py`
Uploads standard firmware to device - deprecated, will be replaced by ´upload_firmware_6022.py´
Uploads standard firmware to device - deprecated, will be replaced by `upload_firmware_6022.py`

### ´upload_firmware_6022.py´
### `upload_firmware_6022.py`
```
usage: upload_firmware_6022.py [-h] [-V VID] [-P PID] [--be | --bl]
Upload firmware to Hantek6022 devices with different VID:PID
options:
-h, --help show this help message and exit
-V VID, --VID VID
-P PID, --PID PID
--be, --6022be
--bl, --6022bl
-V VID, --VID VID set vendor id (hex)
-P PID, --PID PID set product id (hex)
--be, --6022be use DSO-6022BE firmware
--bl, --6022bl use DSO-6022BL firmware
```

This tool can be used to upload the firmware to devices with
[damaged EEPROM content](https://github.com/Ho-Ro/Hantek6022API/discussions/28).
These devices enumerate as Cypress development kit with VID:PID 04b4:8613.

```
$ lsusb | grep Cypress
Bus 002 Device 021: ID 04b4:8613 Cypress Semiconductor Corp. CY7C68013 EZ-USB FX2 USB 2.0 Development Kit
$ ./upload_firmware_6022.py --VID 04b4 --PID 8613 --6022be
upload DSO-6022BE firmware
FW version 0x210
Serial number CF81BA1F3532
$ lsusb | grep Hantek
Bus 002 Device 022: ID 04b5:6022 ROHM LSI Systems USA, LLC Hantek DSO-6022BE
```

### `reset_eeprom_6022.py`
**Warning:** this program will delete all calibration values from EEPROM - use with care!

21 changes: 14 additions & 7 deletions examples/upload_firmware_6022.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
ap = argparse.ArgumentParser(
prog='upload_firmware_6022.py',
description='Upload firmware to Hantek6022 devices with different VID:PID' )
ap.add_argument( '-V', '--VID', type = lambda x: int(x,16), default = 0 )
ap.add_argument( '-P', '--PID', type = lambda x: int(x,16), default = 0 )
ap.add_argument( '-V', '--VID', type = lambda x: int(x,16), default = 0, help = 'set vendor id (hex)' )
ap.add_argument( '-P', '--PID', type = lambda x: int(x,16), default = 0, help = 'set product id (hex)' )
fw = ap.add_mutually_exclusive_group()
fw.add_argument( '--be', '--6022be', action = 'store_true' )
fw.add_argument( '--bl', '--6022bl', action = 'store_true' )
fw.add_argument( '--be', '--6022be', action = 'store_true', help = 'use DSO-6022BE firmware' )
fw.add_argument( '--bl', '--6022bl', action = 'store_true', help = 'use DSO-6022BL firmware' )

options = ap.parse_args()
print( options.VID, options.PID )

if not options.VID and not options.PID:
scope = Oscilloscope()
elif options.VID and options.PID and ( options.be or options.bl ):
Expand All @@ -30,17 +30,24 @@
print( '--VID and --PID and one of --be or --bl must be provided')
sys.exit()

scope.setup()
if not scope.setup():
print( 'scope setup error - no device?' )
sys.exit( -1 )

if not scope.open_handle():
print( 'No device' )
print( 'scope open error - no device?' )
sys.exit( -1 )

if options.be:
print( 'upload DSO-6022BE firmware' )
scope.flash_firmware( dso6022be_firmware )
elif options.bl:
print( 'upload DSO-6022BL firmware' )
scope.flash_firmware( dso6022bl_firmware )
else:
print( 'upload default firmware' )
scope.flash_firmware()

print( "FW version", hex( scope.get_fw_version() ) )
print( "Serial number", scope.get_serial_number_string() )
scope.close_handle()

0 comments on commit efbffa9

Please sign in to comment.