In this blog post we will show installing library simulink-hackrf in MatlabRS2016a. With this library you can using HackRFOne in matlab . HackRFOne is a opensource SDR hardware. This library is Great it is brought for you using HackRFone in matlab for enthusiasts of SDR. In this video you can see installing this library.
1-Install Matlab compiler MinGW64 in Matlab RS2016a
- If you have problem in installing,you should download file seperately and copy to download package matlab: C:\MATLAB\SupportPackages\R2016a\downloads\mingw_download
- I coppied before them for more info search forum matlab this link matlab errror installing mingw
- After installing you should check: mex -setup c
2-Install MinGW64-posix install you should,must install posix MinGW
- I should set path to bin of gcc
- you should installed before cmake
4-Download binary libusb
- I dowloaded libhackrf osmocom before copy libusb to directory libhackrf
- copy libusb.h to include folder of your compiler
- now run cmake
- now i make with mingw32-make
- install in deps directory simulink hackrf library
5-Install with Zadig HackRF One Driver
- For installing HackRF One driver i installed it before with SDRsharp
6-Make in matlab is done
- run matlab make .mfile
We compiled this liibrary according library ReadMe.
Install a compiler and setup MATLAB's
mexcompile script: Here, we will use MinGW64 which is support since MATLAB 2015b. To set it up follow the instructions on the Mathworks page. Next, add the MinGW64 bin directory to your PATH (default is C:\TDM-GCC-64\bin) To double-check, open a MATLAB console:
>> mex -setup C MEX configured to use 'MinGW64 Compiler (C)' for C language compilation. ...
Build the hackrf library (based on libhackrf README):
Start the CMake-GUI and set the source directory to your libhackrf sources, that is subdirectory 'host/libhackrf' in the repo. Create a directory 'build' in there and set it as the binaries directory in the CMake-GUI. Next, hit Configure and select 'MinGW Makefiles' as generator. Set the CMAKE_INSTALL_PREFIX to the 'deps' directory you created above. You will probably have to set the the include and lib settings for libusb manually: LIBUSB_INCLUDE_DIR must be set to the libusb directory, subfolder 'include/libusb-1.0'. LIBUSB_LIBRARIES can point to the static library shipped with the libusb binaries, 'MinGW64/static/libusb-1.0.a'. Finally, press Generate.
Open the MinGW Command Prompt, navigate to the 'libhackrf/build' directory and run
mingw32-maketo build the hackrf library. Next, run
Get Zadig, plug-in your device and run Zadig and install the driver.
Run MATLAB, switch to your Simulink-HackRF directory and start the build process via
If you get errors, create an empty file libhackrf.lib in 'deps/bin/' and rerun. Copy libhackrf.dll from 'deps/bin' into the 'build' folder. Finally, add the build directory to the MATLAB Path.
After a refresh, you will find a new Toolbox named "HackRF" in the Simulink Library Browser. A simple spectrum scope model and a single-tone transmitter model is located in the directory demos. Also, there is MATLAB command
>> hackrf_find_deviceswhich you can use to test your setup.
you can see with more detail in below youtube video: