Commit de3ba76b authored by Florian Kaltenberger's avatar Florian Kaltenberger
Browse files

first steps of SoDeRa configuration

parent 191e93cc
......@@ -438,16 +438,18 @@ elseif (${RF_BOARD} STREQUAL "OAI_BLADERF")
#set(LOWLATENCY False)
elseif (${RF_BOARD} STREQUAL "OAI_SODERA")
include_directories("${OPENAIR_TARGETS}/ARCH/SODERA/USERSPACE/LIB/")
include_directories("${OPENAIR_TARGETS}/ARCH/SODERA/USERSPACE/LIB/SoDeRaV1_distro_01v/lms7suite_source_code/src/lms7002m")
include_directories("${OPENAIR_TARGETS}/ARCH/SODERA/USERSPACE/LIB/SoDeRaV1_distro_01v/lms7suite_source_code/src/Si5351C")
include_directories("${OPENAIR_TARGETS}/ARCH/SODERA/USERSPACE/LIB")
include_directories("${OPENAIR_TARGETS}/ARCH/SODERA/USERSPACE/LIB/lms7suite/src/lms7002m")
include_directories("${OPENAIR_TARGETS}/ARCH/SODERA/USERSPACE/LIB/lms7suite/src/Si5351C")
set(HW_SOURCE ${HW_SOURCE}
${OPENAIR_TARGETS}/ARCH/SODERA/USERSPACE/LIB/sodera_lib.cpp
)
LINK_DIRECTORIES("${OPENAIR_TARGETS}/ARCH/SODERA/USERSPACE/LIB/SoDeRaV1_distro_01v/lms7suite_source_code/build/lms7002m")
LINK_DIRECTORIES("${OPENAIR_TARGETS}/ARCH/SODERA/USERSPACE/LIB/lms7suite/src/lms7002m")
LINK_DIRECTORIES("${OPENAIR_TARGETS}/ARCH/SODERA/USERSPACE/LIB/lms7suite/src/Si5351C")
LINK_DIRECTORIES("/usr/lib/x86_64-linux-gnu")
set(option_HW_lib "usb-1.0")
set(LMS7002_LIB "libLMS7002M.a")
set(Si5351C_LIB "libSi5351C.a")
#set(LOWLATENCY False)
elseif (${RF_BOARD} STREQUAL "ETHERNET")
......@@ -1447,7 +1449,7 @@ add_executable(lte-softmodem
target_link_libraries (lte-softmodem
-Wl,--start-group
RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS L2 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${MIH_LIB} ${LMS7002_LIB}
RRC_LIB S1AP_LIB S1AP_ENB GTPV1U SECU_CN SECU_OSA UTIL HASHTABLE SCTP_CLIENT UDP SCHED_LIB PHY LFDS L2 ${MSC_LIB} ${RAL_LIB} ${NAS_UE_LIB} ${ITTI_LIB} ${MIH_LIB} ${LMS7002_LIB} ${Si5351C_LIB}
-Wl,--end-group )
......
......@@ -59,11 +59,16 @@ int openair0_device_init(openair0_device *device, openair0_config_t *openair0_cf
return(openair0_dev_init_usrp(device, openair0_cfg));
#elif OAI_BLADERF
device->type=BLADERF_IF;
printf(" openair0_dev_init_bladerf ...\n");
printf("openair0_dev_init_bladerf ...\n");
return(openair0_dev_init_bladerf(device, openair0_cfg));
#elif OAI_SODERA
device->type=OAI_SODERA;
printf(" openair0_dev_init_sodera ...\n");
printf("openair0_dev_init_sodera ...\n");
if (openair0_cfg[0].configFilename==NULL) {
printf("Please provide a configuration file for SoDeRa\n");
exit(-1);
}
return(openair0_dev_init_sodera(device, openair0_cfg));
#endif
......
......@@ -133,7 +133,8 @@ typedef struct {
char *my_ip;
//! my port number for Ethernet interface (eNB/BBU, UE)
int my_port;
//! Configuration file for LMS7002M
char *configFilename;
} openair0_config_t;
typedef struct {
......
......@@ -31,8 +31,9 @@
*
* Author: Raymond Knopp
*/
#include <vector>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
......@@ -49,6 +50,7 @@
#include "common_lib.h"
#include "lmsComms.h"
#include "LMS7002M.h"
#include "Si5351C.h"
#ifdef __SSE4_1__
# include <smmintrin.h>
......@@ -58,6 +60,8 @@
# include <immintrin.h>
#endif
using namespace std;
int num_devices=0;
/*These items configure the underlying asynch stream used by the the sync interface.
*/
......@@ -84,8 +88,8 @@ typedef struct
uhd::async_metadata_t async_md;
*/
LMScomms mDataPort;
LMScomms Port;
Si5351C Si;
double sample_rate;
// time offset between transmiter timestamp and receiver timestamp;
double tdiff;
......@@ -103,6 +107,7 @@ typedef struct
} sodera_state_t;
sodera_state_t sodera_state;
static int trx_sodera_start(openair0_device *device)
{
......@@ -308,62 +313,99 @@ int trx_sodera_reset_stats(openair0_device* device) {
int openair0_dev_init_sodera(openair0_device* device, openair0_config_t *openair0_cfg)
{
sodera_state_t *s = (sodera_state_t*)malloc(sizeof(sodera_state_t));
sodera_state_t *s=&sodera_state;
size_t i;
memset(s, 0, sizeof(sodera_state_t));
// Initialize SODERA device
if (!s->mDataPort.Open(0)) {
printf("Cannot open SoDeRa\n");
exit(-1);
}
s->Port.RefreshDeviceList();
vector<string> deviceNames=s->Port.GetDeviceList();
int vers=0,subvers=0,subsubvers=0;
int bw_gain_adjust=0;
if (deviceNames.size() == 1) {
if (s->Port.Open(0) != IConnection::SUCCESS) {
printf("Cannot open SoDeRa\n");
exit(-1);
}
LMSinfo devInfo = s->Port.GetInfo();
printf("Device %s, HW: %d, FW: %d, Protocol %d\n",
GetDeviceName(devInfo.device),
(int)devInfo.hardware,
(int)devInfo.firmware,
(int)devInfo.protocol);
LMS7002M lmsControl(&s->Port);
printf("Configuring Si5351C\n");
s->Si.Initialize(&s->Port);
s->Si.SetPLL(0, 25000000, 0);
s->Si.SetPLL(1, 25000000, 0);
s->Si.SetClock(0, 27000000, true, false);
s->Si.SetClock(1, 27000000, true, false);
for (int i = 2; i < 8; ++i)
s->Si.SetClock(i, 27000000, false, false);
Si5351C::Status status = s->Si.ConfigureClocks();
if (status != Si5351C::SUCCESS)
{
printf("Failed to configure Si5351C");
exit(-1);
}
status = s->Si.UploadConfiguration();
if (status != Si5351C::SUCCESS)
printf("Failed to upload Si5351C configuration");
printf("Configuring LMS7002\n");
int bw_gain_adjust=0;
openair0_cfg[0].rx_gain_calib_table = calib_table_sodera;
switch ((int)openair0_cfg[0].sample_rate) {
case 30720000:
// from usrp_time_offset
openair0_cfg[0].samples_per_packet = 2048;
openair0_cfg[0].tx_sample_advance = 15;
openair0_cfg[0].tx_bw = 20e6;
openair0_cfg[0].rx_bw = 20e6;
openair0_cfg[0].tx_scheduling_advance = 8*openair0_cfg[0].samples_per_packet;
break;
case 15360000:
openair0_cfg[0].samples_per_packet = 2048;
openair0_cfg[0].tx_sample_advance = 45;
openair0_cfg[0].tx_bw = 10e6;
openair0_cfg[0].rx_bw = 10e6;
openair0_cfg[0].tx_scheduling_advance = 5*openair0_cfg[0].samples_per_packet;
break;
case 7680000:
openair0_cfg[0].samples_per_packet = 1024;
openair0_cfg[0].tx_sample_advance = 50;
openair0_cfg[0].tx_bw = 5e6;
openair0_cfg[0].rx_bw = 5e6;
openair0_cfg[0].tx_scheduling_advance = 5*openair0_cfg[0].samples_per_packet;
break;
case 1920000:
openair0_cfg[0].samples_per_packet = 256;
openair0_cfg[0].tx_sample_advance = 50;
openair0_cfg[0].tx_bw = 1.25e6;
openair0_cfg[0].rx_bw = 1.25e6;
openair0_cfg[0].tx_scheduling_advance = 8*openair0_cfg[0].samples_per_packet;
break;
default:
printf("Error: unknown sampling rate %f\n",openair0_cfg[0].sample_rate);
exit(-1);
break;
}
/*
for(i=0;i<s->usrp->get_rx_num_channels();i++) {
if (i<openair0_cfg[0].rx_num_channels) {
openair0_cfg[0].rx_gain_calib_table = calib_table_sodera;
switch ((int)openair0_cfg[0].sample_rate) {
case 30720000:
// from usrp_time_offset
openair0_cfg[0].samples_per_packet = 2048;
openair0_cfg[0].tx_sample_advance = 15;
openair0_cfg[0].tx_bw = 20e6;
openair0_cfg[0].rx_bw = 20e6;
openair0_cfg[0].tx_scheduling_advance = 8*openair0_cfg[0].samples_per_packet;
break;
case 15360000:
openair0_cfg[0].samples_per_packet = 2048;
openair0_cfg[0].tx_sample_advance = 45;
openair0_cfg[0].tx_bw = 10e6;
openair0_cfg[0].rx_bw = 10e6;
openair0_cfg[0].tx_scheduling_advance = 5*openair0_cfg[0].samples_per_packet;
break;
case 7680000:
openair0_cfg[0].samples_per_packet = 1024;
openair0_cfg[0].tx_sample_advance = 50;
openair0_cfg[0].tx_bw = 5e6;
openair0_cfg[0].rx_bw = 5e6;
openair0_cfg[0].tx_scheduling_advance = 5*openair0_cfg[0].samples_per_packet;
break;
case 1920000:
openair0_cfg[0].samples_per_packet = 256;
openair0_cfg[0].tx_sample_advance = 50;
openair0_cfg[0].tx_bw = 1.25e6;
openair0_cfg[0].rx_bw = 1.25e6;
openair0_cfg[0].tx_scheduling_advance = 8*openair0_cfg[0].samples_per_packet;
break;
default:
printf("Error: unknown sampling rate %f\n",openair0_cfg[0].sample_rate);
exit(-1);
break;
}
liblms7_status opStatus;
lmsControl.ResetChip();
opStatus = lmsControl.LoadConfig(openair0_cfg[0].configFilename);
if (opStatus != LIBLMS7_SUCCESS) {
printf("Failed to load configuration file %s\n",openair0_cfg[0].configFilename);
exit(-1);
}
/*
for(i=0;i<openair0_cfg[0].rx_num_channels;i++) {
s->usrp->set_rx_rate(openair0_cfg[0].sample_rate,i);
s->usrp->set_rx_bandwidth(openair0_cfg[0].rx_bw,i);
printf("Setting rx freq/gain on channel %lu/%lu : BW %f (readback %f)\n",i,s->usrp->get_rx_num_channels(),openair0_cfg[0].rx_bw/1e6,s->usrp->get_rx_bandwidth(i)/1e6);
......@@ -420,9 +462,12 @@ int openair0_dev_init_sodera(openair0_device* device, openair0_config_t *openair
std::cout << boost::format("Actual TX bandwidth: %fM...") % (s->usrp->get_tx_bandwidth(i)/1e6) << std::endl;
std::cout << boost::format("Actual TX antenna: %s...") % (s->usrp->get_tx_antenna(i)) << std::endl;
}
}
*/
}
else {
printf("Please connect SoDeRa\n");
exit(-1);
}
device->priv = s;
device->trx_start_func = trx_sodera_start;
......
[file_info]
type=lms7002m_minimal_config
version=1
[lms7002_registers_a]
0x0020=0xFFFD
0x0021=0x0E9F
0x0022=0x07FF
0x0023=0x5550
0x0024=0xE4E4
0x0025=0x0101
0x0026=0x0101
0x0027=0xB1E4
0x0028=0x0101
0x0029=0x0101
0x002A=0x0086
0x002B=0x0038
0x002C=0x0000
0x002D=0xFFFF
0x002E=0x0000
0x002F=0x3840
0x0081=0x0000
0x0082=0x8001
0x0084=0x0400
0x0085=0x0001
0x0086=0x4101
0x0087=0xB13B
0x0088=0x0303
0x0089=0x1078
0x008A=0x0514
0x008B=0x2182
0x008C=0x267B
0x0092=0x0001
0x0093=0x0000
0x0094=0x0000
0x0095=0x0000
0x0096=0x0000
0x0097=0x0000
0x0098=0x0000
0x0099=0x6565
0x009A=0x658C
0x009B=0x6565
0x009C=0x658C
0x009D=0x6565
0x009E=0x658C
0x009F=0x658C
0x00A0=0x6565
0x00A1=0x6565
0x00A2=0x6565
0x00A3=0x6565
0x00A4=0x6565
0x00A5=0x6565
0x00A6=0x0001
0x00A7=0x6565
0x00A8=0x0000
0x00A9=0x8000
0x00AA=0x0000
0x00AB=0x0040
0x00AC=0x2000
0x00AD=0x03FF
0x00AE=0x0000
0x0100=0x7409
0x0101=0x7800
0x0102=0x3180
0x0103=0x0A12
0x0104=0x0088
0x0105=0x0007
0x0106=0x3182
0x0107=0x318C
0x0108=0x3042
0x0109=0x61C1
0x010A=0x104C
0x010C=0x8865
0x010D=0x019D
0x010E=0x2040
0x010F=0x3042
0x0110=0x0BF4
0x0111=0x0083
0x0112=0xC0E6
0x0113=0x03C3
0x0114=0x008D
0x0115=0x0009
0x0116=0x8180
0x0117=0x280C
0x0118=0x018C
0x0119=0x18CB
0x011A=0x2E02
0x011C=0xA941
0x011D=0x4EC4
0x011E=0x048C
0x011F=0x3640
0x0120=0xB9FF
0x0121=0x3158
0x0122=0x033F
0x0123=0x267B
0x0124=0x0000
0x0200=0x0081
0x0201=0x07B0
0x0202=0x06F2
0x0203=0x0FC2
0x0204=0xD51F
0x0205=0x0000
0x0206=0x0000
0x0207=0x0000
0x0208=0x0170
0x0209=0x0000
0x020A=0x0080
0x020B=0x4000
0x020C=0x7FFF
0x0240=0x0020
0x0241=0x0000
0x0242=0x0000
0x0243=0x0000
0x0244=0x0000
0x0245=0x0000
0x0246=0x0000
0x0247=0x0000
0x0248=0x0000
0x0249=0x0000
0x024A=0x0000
0x024B=0x0000
0x024C=0x0000
0x024D=0x0000
0x024E=0x0000
0x024F=0x0000
0x0250=0x0000
0x0251=0x0000
0x0252=0x0000
0x0253=0x0000
0x0254=0x0000
0x0255=0x0000
0x0256=0x0000
0x0257=0x0000
0x0258=0x0000
0x0259=0x0000
0x025A=0x0000
0x025B=0x0000
0x025C=0x0000
0x025D=0x0000
0x025E=0x0000
0x025F=0x0000
0x0260=0x0000
0x0261=0x0000
0x0280=0x0000
0x0281=0x0000
0x0282=0x0000
0x0283=0x0000
0x0284=0x0000
0x0285=0x0000
0x0286=0x0000
0x0287=0x0000
0x0288=0x0000
0x0289=0x0000
0x028A=0x0000
0x028B=0x0000
0x028C=0x0000
0x028D=0x0000
0x028E=0x0000
0x028F=0x0000
0x0290=0x0000
0x0291=0x0000
0x0292=0x0000
0x0293=0x0000
0x0294=0x0000
0x0295=0x0000
0x0296=0x0000
0x0297=0x0000
0x0298=0x0000
0x0299=0x0000
0x029A=0x0000
0x029B=0x0000
0x029C=0x0000
0x029D=0x0000
0x029E=0x0000
0x029F=0x0000
0x02A0=0x0000
0x02A1=0x0000
0x02A2=0x0000
0x02A3=0x0000
0x02A4=0x0000
0x02A5=0x0000
0x02A6=0x0000
0x02A7=0x0000
0x02C0=0x0000
0x02C1=0x0000
0x02C2=0x0000
0x02C3=0x0000
0x02C4=0x0000
0x02C5=0x0000
0x02C6=0x0000
0x02C7=0x0000
0x02C8=0x0000
0x02C9=0x0000
0x02CA=0x0000
0x02CB=0x0000
0x02CC=0x0000
0x02CD=0x0000
0x02CE=0x0000
0x02CF=0x0000
0x02D0=0x0000
0x02D1=0x0000
0x02D2=0x0000
0x02D3=0x0000
0x02D4=0x0000
0x02D5=0x0000
0x02D6=0x0000
0x02D7=0x0000
0x02D8=0x0000
0x02D9=0x0000
0x02DA=0x0000
0x02DB=0x0000
0x02DC=0x0000
0x02DD=0x0000
0x02DE=0x0000
0x02DF=0x0000
0x02E0=0x0000
0x02E1=0x0000
0x02E2=0x0000
0x02E3=0x0000
0x02E4=0x0000
0x02E5=0x0000
0x02E6=0x0000
0x02E7=0x0000
0x0300=0x0000
0x0301=0x0000
0x0302=0x0000
0x0303=0x0000
0x0304=0x0000
0x0305=0x0000
0x0306=0x0000
0x0307=0x0000
0x0308=0x0000
0x0309=0x0000
0x030A=0x0000
0x030B=0x0000
0x030C=0x0000
0x030D=0x0000
0x030E=0x0000
0x030F=0x0000
0x0310=0x0000
0x0311=0x0000
0x0312=0x0000
0x0313=0x0000
0x0314=0x0000
0x0315=0x0000
0x0316=0x0000
0x0317=0x0000
0x0318=0x0000
0x0319=0x0000
0x031A=0x0000
0x031B=0x0000
0x031C=0x0000
0x031D=0x0000
0x031E=0x0000
0x031F=0x0000
0x0320=0x0000
0x0321=0x0000
0x0322=0x0000
0x0323=0x0000
0x0324=0x0000
0x0325=0x0000
0x0326=0x0000
0x0327=0x0000
0x0340=0x0000
0x0341=0x0000
0x0342=0x0000
0x0343=0x0000
0x0344=0x0000
0x0345=0x0000
0x0346=0x0000
0x0347=0x0000
0x0348=0x0000
0x0349=0x0000
0x034A=0x0000
0x034B=0x0000
0x034C=0x0000
0x034D=0x0000
0x034E=0x0000
0x034F=0x0000
0x0350=0x0000
0x0351=0x0000
0x0352=0x0000
0x0353=0x0000
0x0354=0x0000
0x0355=0x0000
0x0356=0x0000
0x0357=0x0000
0x0358=0x0000
0x0359=0x0000
0x035A=0x0000
0x035B=0x0000
0x035C=0x0000
0x035D=0x0000
0x035E=0x0000
0x035F=0x0000
0x0360=0x0000
0x0361=0x0000
0x0362=0x0000
0x0363=0x0000
0x0364=0x0000
0x0365=0x0000
0x0366=0x0000
0x0367=0x0000
0x0380=0x0000
0x0381=0x0000
0x0382=0x0000
0x0383=0x0000
0x0384=0x0000
0x0385=0x0000
0x0386=0x0000
0x0387=0x0000
0x0388=0x0000
0x0389=0x0000
0x038A=0x0000
0x038B=0x0000
0x038C=0x0000
0x038D=0x0000
0x038E=0x0000
0x038F=0x0000
0x0390=0x0000
0x0391=0x0000
0x0392=0x0000
0x0393=0x0000
0x0394=0x0000
0x0395=0x0000
0x0396=0x0000
0x0397=0x0000
0x0398=0x0000
0x0399=0x0000
0x039A=0x0000
0x039B=0x0000
0x039C=0x0000
0x039D=0x0000
0x039E=0x0000
0x039F=0x0000
0x03A0=0x0000
0x03A1=0x0000
0x03A2=0x0000
0x03A3=0x0000
0x03A4=0x0000
0x03A5=0x0000