Commit 74dc4811 authored by Cedric Roux's avatar Cedric Roux

bladeRF: have it functional with libbladerf 2.0

Not much has been changed in the driver (that used libbladerf 1.0).
Some bugs have been fixed. Documentation has been added. A configuration
file has been added too, put in the directory ./configuration/bladeRF.

To use a bladeRF device, see documentation in targets/ARCH/BLADERF/README.

Only the BladeRF x40 has been tested.

Performance is not too bad at 5MHz, a bit worse at 10MHz and on the test
machine I used I face realtime problems at 20MHz when I push downlink
throughput.

So, there is still some work to do to have a good support of bladeRF.
parent 47437903
This diff is collapsed.
BladeRF documentation
=====================
As of 2018-11-06, the bladeRF support is not fully automatic and requires
some manual settings before use. This documentation is the ultimate source
of information. If something described in this file does not work or does
not correspond to the reality, then contact us so we can fix the problems
and update this documentation.
1. Install bladeRF 2.0 libraries.
As of now, it's better to install from source.
So, do not run: ./build_oai -I -w BLADERF
(That is: do not include '-w BLADERF'.)
Instead, follow the instructions at: https://github.com/Nuand/bladeRF
If you already had some bladeRF software installed using automatic
methods, first remove it by hand ('apt-get purge bladeRF' or something
similar, you can get the list of installed bladeRF packages by running
'dpkg -l|grep -i blade', remove them all).
2. Update the device.
Download the latest FX3 firmware and FPGA images from Nuand's website.
As of writing, this is:
https://github.com/Nuand/bladeRF/wiki
That points to the following pages.
For FX3:
http://www.nuand.com/fx3_images/
For FPGA:
http://www.nuand.com/fpga_images/
Install FX3 firmware:
sudo bladeRF-cli -f bladeRF_fw_latest.img
Install FPGA image (this is for BladeRF x40):
sudo bladeRF-cli -L hostedx40-latest.rbf
Retrieve calibration information:
sudo bladeRF-cli -i
info
That outputs the serial number of your device.
Go to:
https://www.nuand.com/calibration
And enter your serial number.
The website tells you to run something like:
sudo bladeRF-cli -i
flash_init_cal 40 0x9271
Actual values depend on your device and serial number.
3. Calibrate the bladeRF device.
We will work with band 7 on 2.68GHz with a bandwidth of 5 MHz (25 RBs).
Plug the bladeRF device, then run:
sudo bladeRF-cli -i
set frequency tx 2680000000
set frequency rx 2560000000
set gain rx 60
set gain tx 60
set bandwidth 5000000
set samplerate 7680000
cal lms
cal lms
cal lms
cal dc rxtx
cal dc rxtx
cal dc rxtx
4. Tune the RX gain using the enb tracer.
Run the softmodem and the 'enb' tracer. For instructions, see:
https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/T/basic
In the enb window, check the 'input signal'. You should see some blue
signal as seen at:
https://gitlab.eurecom.fr/oai/openairinterface5g/wikis/T/enb
(the 'Time signal power' plot).
The level should be around 30.
If it's not around 30 then edit your configuration file and modify
the value 'max_rxgain' in the section 'RUs'.
The configuration file to use is:
configuration/bladeRF/enb-band7-5mhz.conf
In the configuration file, you also need to set the correct values for:
- tracking_area_code
- plmn_list: mcc, mnc, mnc_length
- mme_ip_address: this is the IP address used by the computer running
the softmodem to connect to the EPC
- NETWORK_INTERFACES: all the ENB*ADDRESS* variables have to point
to the IP address of the EPC machine
5. You're good to go.
You can now connect a UE and pass some traffic. If everything is well
configured you can expect more than 16 Mb/s of throughput in the downlink
using iperf and more than 8 Mb/s in the uplink. Looking at the logs, you
should find lines containing 'PHR 40' and 'CQI 15'. If your values are
lower then your setup may need some adjustments.
6. In case of problems.
If the performance of the softmodem is very bad, you can stop it and
run the calibration again, without setting the parameters (frequencies,
gains, etc.). Just run:
sudo bladeRF-cli -i
cal lms
cal dc rxtx
That may help.
Be sure to use proper radio equipment (duplexer, antennas, clean
environment without interferences).
...@@ -116,15 +116,6 @@ int trx_brf_start(openair0_device *device) { ...@@ -116,15 +116,6 @@ int trx_brf_start(openair0_device *device) {
abort(); abort();
} }
if ((status=bladerf_calibrate_dc(brf->dev, BLADERF_MODULE_TX)) != 0) {
fprintf(stderr,"Failed to calibrate TX DC: %s\n", bladerf_strerror(status));
abort();
}
if ((status=bladerf_calibrate_dc(brf->dev, BLADERF_MODULE_RX)) != 0) {
fprintf(stderr,"Failed to calibrate RX DC: %s\n", bladerf_strerror(status));
abort();
}
return 0; return 0;
} }
...@@ -235,8 +226,6 @@ static int trx_brf_read(openair0_device *device, openair0_timestamp *ptimestamp, ...@@ -235,8 +226,6 @@ static int trx_brf_read(openair0_device *device, openair0_timestamp *ptimestamp,
* \param device the hardware to use * \param device the hardware to use
*/ */
void trx_brf_end(openair0_device *device) { void trx_brf_end(openair0_device *device) {
abort();
int status; int status;
brf_state_t *brf = (brf_state_t*)device->priv; brf_state_t *brf = (brf_state_t*)device->priv;
// Disable RX module, shutting down our underlying RX stream // Disable RX module, shutting down our underlying RX stream
...@@ -247,6 +236,7 @@ abort(); ...@@ -247,6 +236,7 @@ abort();
fprintf(stderr, "Failed to disable TX module: %s\n", bladerf_strerror(status)); fprintf(stderr, "Failed to disable TX module: %s\n", bladerf_strerror(status));
} }
bladerf_close(brf->dev); bladerf_close(brf->dev);
exit(1);
} }
/*! \brief print the BladeRF statistics /*! \brief print the BladeRF statistics
...@@ -362,6 +352,8 @@ void set_rx_gain_offset(openair0_config_t *openair0_cfg, int chain_index) { ...@@ -362,6 +352,8 @@ void set_rx_gain_offset(openair0_config_t *openair0_cfg, int chain_index) {
*/ */
void calibrate_rf(openair0_device *device) { void calibrate_rf(openair0_device *device) {
/* TODO: this function does not seem to work. Disabled until fixed. */
return;
brf_state_t *brf = (brf_state_t *)device->priv; brf_state_t *brf = (brf_state_t *)device->priv;
openair0_timestamp ptimestamp; openair0_timestamp ptimestamp;
...@@ -1005,6 +997,12 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { ...@@ -1005,6 +997,12 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
// RX // RX
// Example of CLI output: RX Frequency: 2539999999Hz // Example of CLI output: RX Frequency: 2539999999Hz
if ((status=bladerf_set_gain_mode(brf->dev, BLADERF_MODULE_RX, BLADERF_GAIN_MGC))) {
fprintf(stderr, "[BRF] Failed to disable AGC\n");
brf_error(status);
}
if ((status=bladerf_set_frequency(brf->dev, BLADERF_MODULE_RX, (unsigned int) openair0_cfg->rx_freq[0])) != 0){ if ((status=bladerf_set_frequency(brf->dev, BLADERF_MODULE_RX, (unsigned int) openair0_cfg->rx_freq[0])) != 0){
fprintf(stderr,"Failed to set RX frequency: %s\n",bladerf_strerror(status)); fprintf(stderr,"Failed to set RX frequency: %s\n",bladerf_strerror(status));
brf_error(status); brf_error(status);
...@@ -1096,17 +1094,14 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { ...@@ -1096,17 +1094,14 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
// calibrate // calibrate
if ((status=bladerf_calibrate_dc(brf->dev, BLADERF_MODULE_TX)) != 0) { if ((status=bladerf_calibrate_dc(brf->dev, BLADERF_DC_CAL_LPF_TUNING)) != 0 ||
fprintf(stderr,"Failed to calibrate TX DC: %s\n", bladerf_strerror(status)); (status=bladerf_calibrate_dc(brf->dev, BLADERF_DC_CAL_TX_LPF)) != 0 ||
(status=bladerf_calibrate_dc(brf->dev, BLADERF_DC_CAL_RX_LPF)) != 0 ||
(status=bladerf_calibrate_dc(brf->dev, BLADERF_DC_CAL_RXVGA2)) != 0) {
fprintf(stderr, "[BRF] error calibrating\n");
brf_error(status); brf_error(status);
} else } else
printf("[BRF] TX module calibrated DC \n"); printf("[BRF] calibration OK\n");
if ((status=bladerf_calibrate_dc(brf->dev, BLADERF_MODULE_RX)) != 0) {
fprintf(stderr,"Failed to calibrate RX DC: %s\n", bladerf_strerror(status));
brf_error(status);
}else
printf("[BRF] RX module calibrated DC \n");
bladerf_log_set_verbosity(get_brf_log_level(openair0_cfg->log_level)); bladerf_log_set_verbosity(get_brf_log_level(openair0_cfg->log_level));
...@@ -1146,8 +1141,8 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) { ...@@ -1146,8 +1141,8 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
* \returns 0 on success * \returns 0 on success
*/ */
int brf_error(int status) { int brf_error(int status) {
fprintf(stderr, "[BRF] brf_error: %s\n", bladerf_strerror(status));
//exit(-1); exit(-1);
return status; // or status error code return status; // or status error code
} }
...@@ -1190,7 +1185,7 @@ struct bladerf * open_bladerf_from_serial(const char *serial) { ...@@ -1190,7 +1185,7 @@ struct bladerf * open_bladerf_from_serial(const char *serial) {
int get_brf_log_level(int log_level){ int get_brf_log_level(int log_level){
int level=BLADERF_LOG_LEVEL_INFO; int level=BLADERF_LOG_LEVEL_INFO;
return BLADERF_LOG_LEVEL_DEBUG; // BLADERF_LOG_LEVEL_VERBOSE;// BLADERF_LOG_LEVEL_DEBUG; // return BLADERF_LOG_LEVEL_INFO;
switch(log_level) { switch(log_level) {
case LOG_DEBUG: case LOG_DEBUG:
level=BLADERF_LOG_LEVEL_DEBUG; level=BLADERF_LOG_LEVEL_DEBUG;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment