173 lines
4.7 KiB
Markdown
173 lines
4.7 KiB
Markdown
# Rigol setup.stp Crypter
|
|
|
|
A utility for encrypting, decrypting, and parsing Rigol DG[89]00 Pro Arbitrary Waveform Generator `setup.stp`.
|
|
|
|
HF flatness calibration example in [hfflat_cal.py](./hfflat_cal.py), thanks to zrq from EEVBlog.
|
|
|
|
## Command-Line Options
|
|
|
|
```sh
|
|
usage: rigol_setup_crypter.py [-h] (-e | -d | -p) (-t INPUT_TEXT | -f INPUT_FILE) [-k CPU_SERIAL] [-o FILEPATH]
|
|
|
|
Encrypt or Decrypt Rigol DG[89]00 Pro setup.stp using the CPU SN.
|
|
|
|
options:
|
|
-h, --help show this help message and exit
|
|
-e, --encrypt Encrypt plain text data
|
|
-d, --decrypt Decrypt hex string data
|
|
-p, --parse Parse Rigol CSV data string
|
|
-t, --text INPUT_TEXT
|
|
Input data as text (Plain for Encrypt/Parse, Hex for Decrypt)
|
|
-f, --file INPUT_FILE
|
|
Path to read input data from file
|
|
-k, --key CPU_SERIAL CPU Serial Number (Required for -e/-d modes)
|
|
-o, --output FILEPATH
|
|
Optional path to save output. Console if omitted
|
|
```
|
|
|
|
## Setup and Workflow
|
|
|
|
### Prerequisites
|
|
|
|
1. Install [Python 3](https://www.python.org/downloads/)
|
|
2. Install ADB (Android Debug Bridge) on your system:
|
|
|
|
- **Linux**: `sudo apt install adb` (or equivalent for your distribution)
|
|
- **Windows**: Download and install [Android Platform Tools](https://developer.android.com/studio/releases/platform-tools)
|
|
|
|
3. Connect your Rigol AFG to your local network and note its IP address
|
|
|
|
### Extracting the Setup File
|
|
|
|
1. Connect to your device via ADB:
|
|
|
|
```sh
|
|
$ adb connect IP:55555
|
|
```
|
|
|
|
Replace `IP` with your device's IP address
|
|
|
|
2. Pull the setup file from the device:
|
|
|
|
```sh
|
|
$ adb pull /rigol/data/setup.stp
|
|
```
|
|
|
|
3. Read your CPU serial:
|
|
|
|
```sh
|
|
$ adb shell -- /rigol/shell/get_cpu_serial_num.sh
|
|
```
|
|
|
|
4. **IMPORTANT**: Create a backup of the original file:
|
|
```sh
|
|
$ cp setup.stp setup.stp.backup
|
|
```
|
|
|
|
### Modifying the Setup File
|
|
|
|
For reference, here's what DG922 setup file could look like after correct modification:
|
|
|
|
```sh
|
|
$ ./rigol_setup_crypter.py -p -f ../databackup/data/setup.stp.decrypted
|
|
|
|
CSV header:
|
|
Manufacturer,InstrModel,InstrSN,CalibrationDate,SineMaxFreq,SquareMaxFreq,RampMaxFreq,PulseMaxFreq,ArbMaxFreq,HarmonicMaxFreq,MinFreq,HarmonicMinFreq,ARMSerial,MaxChannels,ArbWaveLenLicense,ArbWaveLenValidTime,DuoChanChannelValidTime
|
|
RIGOL TECHNOLOGIES,DG922 Pro,DG8P123456789,2023-11-11,200000000000000,60000000000000,5000000000000,50000000000000,50000000000000,100000000000000,1,1000,4b97ef24e77c4aeb933b,2,MEM,Forever,Forever
|
|
|
|
Instrument Information:
|
|
Manufacturer: RIGOL TECHNOLOGIES
|
|
Model: DG922 Pro
|
|
Serial Number: DG8P123456789
|
|
Calibration Date: 2023-11-11
|
|
ARM CPU Serial: 4b97ef24e77c4aeb933b
|
|
Max Channels: 2
|
|
|
|
Frequency Specifications:
|
|
Sine Max Frequency: 200000000000000 (200.000000 MHz)
|
|
Square Max Frequency: 60000000000000 (60.000000 MHz)
|
|
Ramp Max Frequency: 5000000000000 (5.000000 MHz)
|
|
Pulse Max Frequency: 50000000000000 (50.000000 MHz)
|
|
Arb Max Frequency: 50000000000000 (50.000000 MHz)
|
|
Harmonic Max Frequency: 100000000000000 (100.000000 MHz)
|
|
Min Frequency: 1 (1.000000e-12 MHz)
|
|
Harmonic Min Frequency: 1000 (1.000000e-09 MHz)
|
|
|
|
Licensing Information:
|
|
Arb Wavelength License: MEM (Memory Depth License)
|
|
Arb Wavelength Valid Time: Forever (Active (No Expiration))
|
|
Duo Channel Valid Time: Forever (Active (No Expiration))
|
|
```
|
|
|
|
1. Decrypt the setup file:
|
|
|
|
```sh
|
|
$ python rigol_setup_crypter.py -d -f setup.stp -k YOUR_CPU_SERIAL -o setup.csv
|
|
```
|
|
|
|
Replace `YOUR_CPU_SERIAL` with your device's CPU serial number
|
|
|
|
2. Parse the file to better understand its structure:
|
|
|
|
```sh
|
|
$ python rigol_setup_crypter.py -p -f setup.csv
|
|
```
|
|
|
|
3. Edit the CSV file using a text editor of your choice
|
|
|
|
4. Verify your changes by parsing again:
|
|
|
|
```sh
|
|
$ python rigol_setup_crypter.py -p -f setup.csv
|
|
```
|
|
|
|
5. Encrypt the modified file:
|
|
```sh
|
|
$ python rigol_setup_crypter.py -e -f setup.csv -k YOUR_CPU_SERIAL -o setup.stp.new
|
|
```
|
|
|
|
### Uploading the Modified File
|
|
|
|
1. Push the modified file back to the device:
|
|
|
|
```sh
|
|
$ adb push setup.stp.new /rigol/data/setup.stp
|
|
```
|
|
|
|
2. Restart your device to apply the changes
|
|
|
|
```sh
|
|
$ adb shell -- reboot
|
|
```
|
|
|
|
## Examples
|
|
|
|
### Decrypt a setup file
|
|
|
|
```sh
|
|
$ python rigol_setup_crypter.py -d -f setup.stp -k d95ebe35672e20c2fc08 -o decrypted.csv
|
|
```
|
|
|
|
### Decrypt a text string and output to console
|
|
|
|
```sh
|
|
$ python rigol_setup_crypter.py -d -t "FBC6BDDB0E..." -k d95ebe35672e20c2fc08
|
|
```
|
|
|
|
### Parse a decrypted CSV
|
|
|
|
```sh
|
|
$ python rigol_setup_crypter.py -p -f decrypted.csv
|
|
```
|
|
|
|
### Encrypt a modified CSV
|
|
|
|
````sh
|
|
$ python rigol_setup_crypter.py -e -f modified.csv -k d95ebe35672e20c2fc08 -o new_setup.stp
|
|
```
|
|
|
|
## Warning
|
|
|
|
Keep a backup of the original `setup.csv`.
|
|
````
|