bladeRF CLI Tips and Tricks - junaid124/bladeRF GitHub Wiki
Currently, the following information is stored in a user-modifiable "calibration region":
- FPGA size (40 or 115)
- VCTCXO (Voltage-controlled temperature-compensated oscillator) trim DAC value
Unless you're planning to replace the FPGA (not a recommended endeavor), there's no reason to mess with this field. The reason the FPGA size is here rather than in the OTP region is largely historic and pertains to debug usage during early development and testing.
The VCTCXO frequency will drift over time and due to environmental factors. Users will generally want to periodically recalibrate the associated trim DAC value, and write it back to the bladeRF.
From with the bladeRF-cli's interactive mode, the current calibration values can be viewed via the info command:
bladeRF> info Serial #: 00000000000000000000000000000000 VCTCXO DAC calibration: 0xa0a8 FPGA size: 40 KLE FPGA loaded: no USB bus: 4 USB address: 2 USB speed: SuperSpeed Backend: libusb Instance: 0
Note the VCTXCO (trim) DAC calibration value above.
To back up this information to a file, which may later be restored through the bladeRF-cli program, the flash_backup command may be used. Type help flash_backup to see the full help text for this command.
The general usage for saving calibration data is flash_backup <output_file> cal:
bladeRF> flash_backup /home/jon/bladeRF-files/bladerf_cal_2014_03_18.bin cal [INFO] Reading 0x00000100 bytes from address 0x00030000.
This command will store the calibration data, along with some additional metadata, in the specified file. To view the associated metadata stored in the flash image, use the flash_image command. This metadata may prove useful if you've accidentally renamed a file, or forgot which device (via serial number) is associated with the file.
bladeRF> flash_image /home/jon/bladeRF-files/bladerf_cal_2014_03_18.bin Checksum: d3ad936733b841cd10f0cb852d2a133e08cf080a60c4a607cca9908b75bd5e59 Image format version: 0.1.0 Timestamp: 2014-03-18 20:25:37 Serial #: 00000000000000000000000000000000 Image type: Calibration data Address: 0x00030000 Length: 0x00000100
If you've backed up calibration data to a file via the flash_backup command, you can use the flash_restore command to write this data back to the device. Note that the serial number information in the metadata is strictly for informational purposes; it is not used to prevent data from being written to another device.
For more information about the flash_restore command, run help flash_restore.
bladeRF> flash_restore /home/jon/bladeRF-files/bladerf_cal_2014_03_18.bin [INFO] Reading 0x00010000 bytes from address 0x00030000. [INFO] Erasing 0x00010000 bytes starting at address 0x00030000. [INFO] Writing 0x00010000 bytes to address 0x00030000.
Note: A power cycle will be required for this change to take effect.
This approach useful if you'd like to manually specify a VCTCXO trim value to store in the device.
The flash_init_cal command generates a calibration region of flash, and can either write it directly to a device, or to a file (for future use with the flash_restore command).
For more information about this command, run help flash_init_cal from the bladeRF-cli interactive mode.
For a bladeRF with a 40 kLE FPGA and a desired VCTCXO trim DAC value of 0x9015, you can write this information directly to the device via:
bladeRF> flash_init_cal 40 0x9015 [INFO] Reading 0x00010000 bytes from address 0x00030000. [INFO] Erasing 0x00010000 bytes starting at address 0x00030000. [INFO] Writing 0x00010000 bytes to address 0x00030000.
Note: A power cycle will be required for this change to take effect.
Alternatively, to write this data to a file:
bladeRF> flash_init_cal 40 0x9015 /tmp/new_cal_data.bin
If you've managed to wipe your calibration region and do not have the necessary tools to identify an appropriate VCTCXO trim value, email [email protected] with your serial number and a request to look up your factory-calibrated trim value. (Please be patient!)
Samples received via the bladeRF-cli, in either CSV or binary format, can easily be imported into tools such as Octave, MATLAB or baudline.
In the CSV format, samples are stored in rows of: I, Q.
To load these samples and reconstruct the complex signal:
> samples = load("my_file.csv");
> samples_i = samples(:, 1);
> samples_q = samples(:, 2);
> signal = samples_i + j * samples_q;
> % Plot the magnitude of the signal in the time domain
> plot(abs(signal));
Binary data in the SC16Q11 format is little-endian, sign-extended, and right-aligned. To load the samples and reconstruct the complex signal:
> f = fopen("debug_trimmed.bin", "r", "ieee-le");
> samples = fread(f, Inf, "int16");
> samples_i = samples(1:2:end, :);
> samples_q = samples(2:2:end, :);
> % Plot the magnitude of the signal in the time domain
> plot(abs(signal));
Samples must be in a binary format to be used with baudline. This section assumes you've saved them to the binary SC16Q11 format, but other conversions are certainly possible.
- Open baudline
- Right-click and select Input -> Open File
- Change File Format to raw
- Select your file and click Open
- Set the following parameters in the raw parameters dialog:
- Decompression: OFF
- Initial byte offset: 0
- Sample Rate: Sample rate you recorded the samples at
- Channel: 2, quadrature
- Decode Format: 16 bit linear, little endian
If you've built bladeRF-cli with support for libtecla (highly recommended), you'll have a number of great features available to you, including history, tab-completion (for filenames) and handy key bindings (including emacs and vi bindings).
See the tecla man page for detailed information about configuring and using libtelca-based programs.
To use vi or emacs key bindings, create a ~/.teclarc file, and add the relevant line:
edit-mode vior
edit-mode emacs