Commit Graph

679 Commits

Author SHA1 Message Date
Pau Espin 3e9179a55e uhd: smpl_buf: Use TIMESTAMP type in str_status
Other related functions use "TIMESTAMP timestamp" so let's use same
stuff in that function.

Change-Id: I016b1a7f8db379caebc1409ca11e5ae8b759d2d4
2019-05-03 13:50:50 +02:00
Pau Espin 87b7d098e5 uhd: smpl_buf: Drop UHD specifics out back to UHDDevice
This way smpl_buf can be re-used later by other non-UHD drivers.

Change-Id: I94061328d46a550d4147121d85baffa29c700c45
2019-05-03 13:50:50 +02:00
Pau Espin 7bef2346c4 cosmetic: uhd: Move smpl_buf out of UHDDevice, move UHDDevice class definition to .h
* move class definition to .h file, like we do for other devices.
* move smpl_buf class to a different file inside uhd/.
* Preparation work to have smpl_buf being used in a generic way for
devices other than UHD (LMS).

Change-Id: Ib4594320da9bb7f6e9f52e7d70d11ecd11106aae
2019-05-03 13:50:47 +02:00
Pau Espin 2876785f50 lms: Catch and log dropped packets by HW during recv
Change-Id: I23554d95b0aff585024610fc12920c9da4f3ba9e
2019-04-25 20:16:10 +02:00
Pau Espin 713b4d81cd lms: Remove unused var m_last_tx_overruns
Change-Id: I2104205b2af7cd6c86075d5cc4f0f36bde5e5311
2019-04-25 20:16:10 +02:00
Pau Espin b96d9ddee3 lms: Remove references to ALERT loglevel
ALERT log level is not Osmocom standard level, it's just a define in
osmo-trx to keep compatibility with old code.

Same goes for one reference to "ERR" intead of "ERROR".

Change-Id: I0e171a8ac8a8bfa804ac97fba3d73efcfa6424b4
2019-04-25 20:16:10 +02:00
Pau Espin 048c3ba300 lms: Log underrun/overrun events
Change-Id: I8c6b1d3e8515153e5d4079cc6620901ef8ce2449
2019-04-25 20:16:10 +02:00
Pau Espin 75cb0b9dd6 Move duplicated thread_enable_cancel to CommonLibs
Change-Id: I1a479b59bdda01233273dfa919bd678edbe34708
2019-04-25 19:33:58 +02:00
Pau Espin bab1583a2c lms: Improve log during flush recv error
Change-Id: Id45d42599738efd6a5d89787c75779838a979330
2019-04-25 19:26:24 +02:00
Pau Espin 541496b65b lms: flush_recv: alloc buf on stack instead of heap
No need to use the heap here since buffer is only used as a temporary
trash. Using the stack is quicker.

Change-Id: Iede8dc0903ee3865a52c8e2fd811bcde444fee33
2019-04-25 19:22:11 +02:00
Joachim Steiger c785fb130a lms: properly call close if set_antennas() fails, add some comments
Change-Id: I9ebe986ee3a15842a15853424ee98e9a2fa6a5df
2019-04-17 18:24:11 +00:00
Joachim Steiger 2875290d95 lms: add device type detection and device specific gains
add device dependant max gain setup - limesdr mini and limenet micro need slightly reduced maximum gains to get a PASS on phase error measurements
rework clock reference setup - external clock needs to be selected before calling LMS_Init(), internal can only be set after.
remove now unused compat_LMS_VCTCXO* functions - we do not set the VCTXCO directly anymore

Change-Id: I3cf905b0a84bc1ec200891762a6646141ee37181
2019-04-17 18:24:11 +00:00
Joachim Steiger 4ce4555d0e lms: move LMS_GetLPFBWRange and LMS_Calibrate calls from open to start
bandwidth, freqency, gain stages need to be set before calibration can be successful

Change-Id: I1090effdf0f43e5183a402e4c1a1ffe5abdefd37
2019-04-17 18:24:11 +00:00
Joachim Steiger 2d130fb15d lms: move LMS_EnableChannel from Start/Stop to Open/Close device
move enable: it is important that channels are actually enabled before applying any configuration (besides external clock)
move disable: move to close, so channels are not disabled and not enabled again while osmotrx is active.

Change-Id: I82878913254ce15a85db8d006e13d5eb639793e9
2019-04-17 18:24:11 +00:00
Joachim Steiger 6c5f4bae46 lms: Remove wrong unused code copied from -uhd
Change-Id: I2bc7fcfa429d1f82c2d8e95d31dfed367f2b3f9d
2019-04-17 18:24:11 +00:00
Harald Welte 71df42550a use BSC_FD_READ and not OSMO_FD_READ
We haven't even released any tagged version of libosmocore yet which
includes support for the renamed OSMO_FD_READ constant.  Let's avoid
any breakage and use the new constants only with considerable delay,
at the very least only when released libosmocore versions provide it.

Change-Id: Idb57077b2a4b2a71dd5d75a24ded8bb5887da188
2019-04-16 17:18:58 +02:00
Tom Tsou d280045884 multi-ARFCN: fix maximum number of carriers limitation
Maximum number of carriers is fixed to 3 channels on a single
physical RF channel in multi-ARFCN mode. For some reason, it
was limited to 5.

Let's fix this, and also follow this limitation in the
following VTY command handlers:

  - cfg_multi_arfcn_cmd,
  - cfg_chan_cmd.

Change-Id: I66a1462f368458afd313ee6f0bc0abc496dde817
2019-04-11 07:33:40 +00:00
Pau Espin 5e6f3e0cad osmo-trx: Check return code of osmo_fd_register
Fixes Coverity CID 197513.
Change-Id: I93fbcb062439a547379aaecba283d107fdc9cb59
2019-04-02 11:45:06 +02:00
Pau Espin 21032b75c0 osmo-trx: Use signalfd to serialize signals in main thread ctx
This should avoid prolematic scenarios where different signal handlers
are running on different thread in parallel. Furthermore, we make sure
those signals are always run by main loop thread.

Change-Id: I9b9d9793be9af11dbe433e0ce09b7ac57a3bdfb5
2019-03-29 19:20:08 +01:00
Pau Espin d01c7b98b6 osmo-trx: Avoid handling signals after shutdown triggered
Recently a blocked osmo-trx process was found after ending SIGTERM to
it.
Apparently one thread was handling SIGTERM and calling fprintf()
(grabbing libc lock) while another thread was handling another signal
and also grabbing similar lock. Both thread looked deadlocked there.
Probably this change doesn't fix the block on its own, but at least
simplifies scenarios inside signal ctx which can go wrong.

Change-Id: If91621913b8b03d8a0f4c863be0b0d479f97e8a1
2019-03-29 18:51:28 +01:00
Vadim Yanitskiy a8b3565246 VTY: add extended (11-bit) RACH detection toggle
Since I838c21db29c54f1924dd478c2b34b46b70aab2cd we have both TS1
and TS2 synch. sequences, in addition to "default" TS0. Let's
finally introduce the VTY configuration parameter, that can
be used to toggle optional detection of both TS1 and TS2.

Note: we keep this optional because of potentially bad impact on
performance. There's no point in paying the performance penalty
unless upper levels (BTS, PCU) actually make use of it.

Change-Id: I1aee998d83b06692d76a83f79748f9129a2547e8
Related: OS#3054
2019-01-24 15:47:48 +01:00
Sylvain Munaut a3934a11a4 convolve: Remove support for step, offset parameters
- Those are not used any where
 - Those are not supported by the sse/neon accelerated versions
 - And I see very little use cases for those.

Change-Id: Ic850269a0ed5d98c0ea68980afd31016ed555b48
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2019-01-21 10:34:51 +01:00
Sylvain Munaut acf804c034 arm/convolve: Fix the vfp4 real convolution for h_len=12
Change-Id: Ic73f0746edd3f1f22bb1d79d4c64aa740691dd48
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2019-01-21 10:34:51 +01:00
Harald Welte 77e18352fb cosmetic: Don't call the SDR "USRP" in error message
Transceiver.cpp is used for all SDR hardware we support, not just USRP.

Change-Id: I9b7ddb0d679f111407704048ef3ddd964db49441
2019-01-11 22:42:29 +01:00
Harald Welte f97d75b355 usrp1: Fix formatting of log message (missing space)
Change-Id: I378a8081a224acda3ee2af9b6aa0d680de884695
2019-01-11 22:42:29 +01:00
Harald Welte a944001873 usrp1: Remove uninitialized skipRx logic
There appears to have been some logic to operate a USRP1 in
transmit-only GSM mode.  This is achieved using the skipRx member
of the transceiver object.  However, there's nobody that ever
initializes it properly, and hence the feature is not possible to
use anyway.

I don't think this has any valid use case, so let's remove it.

Change-Id: I616193f1e9aaefbf4ceb26761657811093f28b6f
2019-01-11 21:46:45 +01:00
Pau Espin 03b11620d9 lms: Fix build against LimeSuite > 18.10
LimeSuite dc124e4e2ed9b549b142410af172f0592f9f0c23 > 18.10 broke API
compatibility.

OS#3729
Change-Id: Idf500a5b39a857233f728c6a4316c00a99374556
2018-12-14 13:30:07 +01:00
Oliver Smith 871713bf6a LMSDevice: make use of dev-args in osmo-trx.cfg
Allow selecting a specific LimeSDR device by setting dev-args in the
config file. Split up the given dev-args address by comma and select
the device where all substrings can be found.

I could not test this with real hardware, but I have added a test case
to make sure this works as expected.

Related: OS#3654
Change-Id: Ib9aaa066a01bf9de3f78234d7ada884d6f28c852
2018-12-13 11:07:02 +01:00
Oliver Smith 8d9a05ce5b osmo-trx.cpp: move comma_delimited_to_vector() to Utils.cpp
Make the "opt" argument const. This function will also be used by
LMSDevice.cpp in a follow-up commit.

Related: OS#3654
Change-Id: If3f0f682ca453c2b0a06175ec9626567932cfce6
2018-12-12 17:26:32 +01:00
Pau Espin fe865f45d7 lms: Do {under,over}run checks even if LMS_RecvStream fails
Under failure, it could still be that stream status is updated, so let's
father that in all cases.

Change-Id: I4e2b8be06d2993db1bab233948a8ee774b8ac4ee
2018-12-07 11:18:32 +01:00
Pau Espin e5b6664419 lms: Move {under,over}run checks into separate method
Change-Id: I7f450aa79f6285d14826c40ecfdd9490d00509ef
2018-12-07 11:18:28 +01:00
Pau Espin 1595ddaa5f transceiver: Log TRXCTRL iface responses towards osmo-bts-trx
Change-Id: I8128c42e63ab1fcd2a58812f3b7cf94435b5bbd8
2018-12-07 11:15:10 +01:00
Pau Espin 441d82add9 Add TRXCTRL log category
This log category is applied to messages related to TRX CTRL socket
interface, and it's printed in yellow, same color used in osmo-bts-trx
for TRX category (so same messages are printed with same color in both
sides).

Change-Id: I98ec5e416272783ad3fbadf70478a4e48ae64983
2018-12-07 11:15:02 +01:00
Pau Espin 2f53ea4cf2 transceiver: log chan on CTRL command received
Change-Id: Ia3b2a35e03a8aaddd6efebc8db2ccca872f51f20
2018-12-05 19:43:46 +00:00
Pau Espin 138caaf09d lms: Improve Set{Rx,Tx}{Gain,Freq} logging
Change-Id: I6713a27c5f74beb7fcfdd712fcf695afccbc3d76
2018-12-05 19:43:46 +00:00
Pau Espin 3fadcad33e lms: Allow setting Tx/RxFreq for lchan!=0
Related: OS#3346
Change-Id: I9dd0bb41d1863111d28947fc0d7c7e7ecfaf5fa8
2018-12-05 19:43:46 +00:00
Pau Espin eaa0144dcb lms: Allow setting Tx/RxGain for chan!=0
Related: OS#3346
Change-Id: I5fae92a7ed5e2d92be12b9dfd33fc56195030c0b
2018-12-05 19:43:46 +00:00
Pau Espin f7331764ac SigProcLib: Improve Vector buffer allocation mess
Original issue: In order to use SSE instructions, 16-byte aligned memory
chunks are needed, and C++ version < C++11 doesn't provide for a native
new/delete store. For that reason, memalign() must be used in the
implementation of convolve_h_alloc() for some buffers.
On the other side, The C++ code relies on C++ "new T[]" operator to
allocate a chunk of memory containing an array of class instances. As
classes are complex types, they cannot be allocated through C structures
(calling malloc). Experimentally can be seen too that it's unreliable
and the process will crash during startup if malloc() is used and then a
Complex<> deferred from it.

Previous implementation allowed for use of convolve_h_alloc or new[]
based on how the (signal)Vector is called, because then the buffer is
not going to be managed internally. But that's unreliable since resize()
calling resize() on it could use "delete" operator on a malloc'ed
buffer, and end up having a new new[] allocated buffer. It was also
found that some of the callers were actually leaking memory through ASan (because the
buffer is not managed by the Vector instance).

IMHO best option would be to rewrite all this code using C structures
and malloc/free exclusively, since it would make all this cod eeasier to
maintain.

But for now, let's extend the Vector class to allow specifying an
external alloc/free function and let the Vector instance take care of
the ownership of the buffer in all scenarios.

Change-Id: Ie484a4762a7f77fe1b105188ea03a6f025730b82
2018-12-05 19:41:34 +00:00
Pau Espin ed361f9912 lms: Close device on LMS_Init failure
Change-Id: I0b307452a9e122a0ea39a46f096423c9a5293d30
2018-12-04 15:57:37 +00:00
Pau Espin 2d085e290b osmo-trx: Change some lines to use libosmocore logging instead of cout
Change-Id: I66e3c37014ba12cd002e5b678bc0a6026f5dfc7e
2018-12-04 15:57:37 +00:00
Pau Espin 5cea18e5cb lms: Make sure LMS_Close is called when Device is torn down
This change fixes lots of memory leaks inside libLimeSuite as
announced by ASan after exiting the osmo-trx process (throgh
CTRL+C for instance).

This way also we make sure libLimeSuite can communicate with the HW and
close whatever subsystems were enabled during LMS_Open time.

Change-Id: I56ffb87079e34aa2d0322fd2ca6429742f9f7640
2018-12-04 15:57:37 +00:00
Pau Espin 39e0bbacca radioInterface: Fix memleak during close()
destructors of pointers created through "new" must be destroyed manually
through "delete".

Change-Id: I10d37579f16bec89cc762f200a8951218305c708
2018-12-03 12:20:07 +01:00
Pau Espin b4ea7b5211 lms: Destroy streams on device stop
They are recreated during start(). Actually, if they are not stopped
here, during start() after stop(), LMS_SetupStream() will fail because
it will detect the streams are already opened.

Change-Id: I70d47c287aabdabc5dc1304a942d130aeb10bdc5
2018-12-03 11:34:25 +01:00
Pau Espin 69869bd58f lms: Fix start after stop of device
Change-Id: I56358a1d1601853bc6dd2e6bb5f80798d0ba84b2
2018-12-03 11:19:52 +01:00
d0gtail ebb37693a5 UHDDevice: log exception information on device open failure
Change-Id: Ia84ddcf50cc83f9326b22bfdfb4f259b4e0bc5f1
2018-12-02 20:01:26 +00:00
Harald Welte 55928f23cb lms: Set Rx gain to midpoint, as comment suggests.
So far, the Rx gain was set to 34 dB, wile the comment stated it
would be set to half-point, which is 73/2=36dB.  Let's adjust the
code to match the comment.

Change-Id: Idc646def53b83faf4e6c011fb595fa436e223b32
2018-11-29 13:26:37 +01:00
Harald Welte 0277b58f6d lms: User correct scale factor for transmit samples
Due to (I believe) a copy+paste mistake from the USRP1 code,
we were using only a scale range of up to 9830 when transmitting
samples, rather than the full 16 bit signed integer range up to
32767.

As a result, we were loosing almost two bits (MSBs) of resolution
as well as a lot of transmit power.

This changes the scale factor to 0.707 (1/sqrt(2)).

Please note that the much higher DAC output level means that the analog
gain should be reduced.  The theoretic range of up to 73dB should not
be used, but Lime Microsystems suggest a value of 61..67 dB.  This can
be achieved by using a "osmotrx tx-attenuation" value of 6..12 inside
the osmo-bts-trx configuration file.

Related: OS#3341
Related: OS#3342
Change-Id: I71702feaa11f53e7614a6938a984dd748405474a
2018-11-29 13:23:08 +01:00
Pau Espin 1e2c0105e2 lms: Apply LMS->OSMO log level conversion
Change-Id: I3a8fbcc7cacebc7038c60175a8ae43b21f713cbb
2018-11-23 14:39:51 +01:00
Pau Espin 32b3c2e4b2 lms: Use LimeSuite.h log level defines instead of hardcoded values
Change-Id: Iee693da1a0fa1db23deafa8d3845c04171e24799
2018-11-23 14:39:06 +01:00
Pau Espin 1c4bbadda6 UHDDevice: setRxGain on chan 0 when using multi-arfcn
When using multi-arfcn feature, several logical channels (arfcn) are multiplxed
into one physical transceiver, as can be seen in
uhd_device::set_channels.

As a result, when multi-arfcn is enabled some properties are actually
shared for those logical channels, and internally mapped to the first
(only existing) channel, and per-channel internal array variables are allocated
accordingly (size() == 1).

When setting RxGain, we need to set the correct existing physical
channel. Same check is done in getRxGain, and then we apply the RxGain correctly and
we avoid outputing an error "Requested non-existent channel" immediatelly after.

Change-Id: I5b02bb1ef6450dc48be7b8058d96a5691847d3cc
2018-11-19 11:47:37 +01:00
Pau Espin 08dfe237c8 ChannelizerBase: Fix ASan alloc-dealloc-mismatch
Fixes following Adress Sanitizer warning:
=================================================================
==27120==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs operator delete) on 0x60c00003d900
    #0 0x7f2f216de421 in operator delete(void*, unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cc:151
    #1 0x561641ce18b7 in ChannelizerBase::~ChannelizerBase() (/build/new/out/bin/osmo-trx-uhd+0x4a8b7)
    #2 0x561641ce1cad in Channelizer::~Channelizer() (/build/new/out/bin/osmo-trx-uhd+0x4acad)
    #3 0x561641cd5160 in RadioInterfaceMulti::close() (/build/new/out/bin/osmo-trx-uhd+0x3e160)
    #4 0x561641cd5047 in RadioInterfaceMulti::~RadioInterfaceMulti() (/build/new/out/bin/osmo-trx-uhd+0x3e047)
    #5 0x561641cd5093 in RadioInterfaceMulti::~RadioInterfaceMulti() (/build/new/out/bin/osmo-trx-uhd+0x3e093)
    #6 0x561641ca3fdd in trx_stop() (/build/new/out/bin/osmo-trx-uhd+0xcfdd)
    #7 0x561641ca4b32 in main (/build/new/out/bin/osmo-trx-uhd+0xdb32)
    #8 0x7f2f1f555222 in __libc_start_main (/usr/lib/libc.so.6+0x24222)
    #9 0x561641ca195d in _start (/build/new/out/bin/osmo-trx-uhd+0xa95d)

0x60c00003d900 is located 0 bytes inside of 128-byte region [0x60c00003d900,0x60c00003d980)
allocated by thread T0 here:
    #0 0x7f2f216dcf19 in operator new[](unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cc:93
    #1 0x561641ce142d in ChannelizerBase::init() (/build/new/out/bin/osmo-trx-uhd+0x4a42d)
    #2 0x561641cd5865 in RadioInterfaceMulti::init(int) (/build/new/out/bin/osmo-trx-uhd+0x3e865)
    #3 0x561641ca1cb7 in makeRadioInterface(trx_ctx*, RadioDevice*, int) (/build/new/out/bin/osmo-trx-uhd+0xacb7)
    #4 0x561641ca44c6 in trx_start(trx_ctx*) (/build/new/out/bin/osmo-trx-uhd+0xd4c6)
    #5 0x561641ca4b05 in main (/build/new/out/bin/osmo-trx-uhd+0xdb05)
    #6 0x7f2f1f555222 in __libc_start_main (/usr/lib/libc.so.6+0x24222)

SUMMARY: AddressSanitizer: alloc-dealloc-mismatch /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cc:151 in operator delete(void*, unsigned long)
==27120==HINT: if you don't care about these errors you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0
==27120==ABORTING

Change-Id: Ib7c98ae478f319573dd86a0d2cb264f676bb3859
2018-11-01 18:23:32 +01:00
Vadim Yanitskiy 444ff34396 sigProcLib: add a CorrType for extended (11-bit) RACH
This is a preparatory change that enables a possibility to choose
the amount of synch. sequences to be used for Access Burst (RACH)
detection. The VTY flag will be introduced in further changes.

There are two correlation types now:

  - RACH (default) - TS0 only;
  - EXT_RACH - all TS0, TS1, and TS2 together.

Change-Id: Ia4f20524350bb8c380d7e10360758eddae8b03e9
Related: OS#3054
2018-10-24 19:28:47 +00:00
Vadim Yanitskiy a79bc70737 sigProcLib: introduce both TS1 and TS2 RACH synch. sequences
According to 3GPP TS 05.02, section 5.2.7, there are three
synch. sequences for Access Bursts:

  - TS0: GSM, GMSK (default),
  - TS1: EGPRS, 8-PSK,
  - TS2: EGPRS, GMSK.

Let's prepare everythyng to be able to detect all TS0-3 synch.
sequences, but keep detection of both TS1 and TS2 disabled
until the corresponding VTY option is introduced.

Change-Id: I838c21db29c54f1924dd478c2b34b46b70aab2cd
Related: OS#3054
2018-10-24 19:28:47 +00:00
Oliver Smith a439fed166 Add long parameters (--help, --version, ...)
Makes osmo-trx-* more consistent with other Osmocom programs, and
allows an unified test for not having "UNKNOWN" in --version.

Related: OS#3578
Change-Id: I90cf01d972aa10b48c59b67a1e7f82a4255ef526
2018-10-23 11:34:43 +00:00
Harald Welte 8fb0c3dce4 trx_validate_config(): Fix validation of rx_sps
Change-Id: I7e932cff59335add09c76caba6f9ac1e7cf69022
Fixes: Coverity CID#188871
2018-10-21 13:48:26 +02:00
Pau Espin 74bcc562a9 Transciever: Log values causing Tx underrun
Change-Id: I68e18075eade55034567d96fc774d00a794afeeb
2018-10-02 17:30:28 +02:00
Pau Espin 5b60c98769 Use pthread_setname_np to name threads
osmo-trx can start a considerable amount of threads that can make
debugging it challenging at least. By using phtread_setname_np, the
system sets a meaningful name to the thread which can be seen while
debugging with gdb or by printing /proc/$pid/task/$tid/comm.

Now we also log system TID when setting the name so we can identify
different tasks in /proc even if pthread_setname_np fails.

Change-Id: I84711739c3e224cb383fd12b6db933785b28209e
2018-09-28 23:17:57 +00:00
Vadim Yanitskiy 92fc186450 device/lms/LMSDevice.cpp: fix compilation warning
The following warning was observed with GCC 4.8.5:

  make[4]: Entering directory `.../osmo-trx/Transceiver52M/device/lms'
    CXX      LMSDevice.lo
  LMSDevice.cpp: In member function 'LMSDevice::writeSamples()':
  LMSDevice.cpp:582:22: warning: 'rc' may be used uninitialized
                        in this function [-Wmaybe-uninitialized]
    samplesWritten += rc;

Let's fix this by zero-initializing 'rc'.

Change-Id: I4b4a061fc12e5fd1db8d1087d8e0c46ff1e23412
2018-09-20 16:17:19 +07:00
Pau Espin 4d179abfd0 cosmetic: Use proper whitespace in several for loops
Change-Id: I82bdeb8a3fa38f3d125e8cbccc3eddbf2b8d8f58
2018-09-13 14:27:48 +00:00
Pau Espin e62555370e Vector: Copy arrays in a sane way for non-trivially copyable types
Avoids this type of compilation warnings:
‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class Complex<float>’; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]

Change-Id: I9724454dfb7b87f74f39074e4004580ac3b5fe5c
2018-09-10 10:33:34 +02:00
Pau Espin 1f15152968 radioInterfaceMulti:pullBuffer: Sanely convert float array to complex array
Fixes this type of compilation warning:
‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class Complex<float>’; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]

Change-Id: Ibb2380a0a335ce798fe87221519fbbebade53054
2018-09-10 10:30:06 +02:00
Pau Espin 21ce05c54f cosmetic: Fix trailing whitespace in several files
Change-Id: Ibf5a69f0a3a309e87814635fd903b114fe68890c
2018-09-10 10:30:06 +02:00
Pau Espin 5e68cde779 SigProcLib: Use available copyTo Vector API instead of memcopy
This change allows to remove some wrong use of code as per compilation
warning:
osmo-trx/Transceiver52M/sigProcLib.cpp:1266:40: error:
‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class Complex<float>’; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]
   midMidamble->size() * sizeof(complex));

Change-Id: Id446711349bec70fa4e7c8efe0f7f9faf7e4f277
2018-09-10 10:30:06 +02:00
Pau Espin 1f4a009c67 UHHDDevice: Replace deprecated header uhd/utils/thread_priority.hpp
Fixes compilation warning:
In file included from osmo-trx/Transceiver52M/device/uhd/UHDDevice.cpp:31:
/usr/include/uhd/utils/thread_priority.hpp:10:17: note: #pragma message: This header is deprecated - please use <uhd/utils/thread.hpp> instead.

Header was moved in uhd.git c33928d2bbdd27688c3475e77fc461e7d16eba5a.

Change-Id: I6299df48a5e14c54eaa07288d166c705eb9ebdbe
2018-09-10 10:30:06 +02:00
Pau Espin 970096932e radioInterface: Fix variable storing integer return value
Change-Id: I0a0a06a6d16a228cfcb7bd746bab2d79f10ce244
2018-09-04 16:35:27 +02:00
Pau Espin db936b9b55 osmo-trx: Add osmo_signal to stop whole transceiver chain correctly on error
Transceiver::stop() can only be called from either CTRL iface thread or
from main thread (running osmocom loop). That's because stop attempts to
cancel and then join all the other threads, which would then lock if
attempting to stop from some of them.
As a result, the best option is to indicate to the user of the
transceiver option (osmo-trx.cpp) to stop it in a correct fashion by
destroying the object from the main thread.

Change-Id: Iac1d2dbe2328e735db2d4b933cb67b1af1babca1
2018-09-04 16:35:23 +02:00
Pau Espin 49ad759072 lms: Return error on device read timeout
If LImeSDR device is unplugged or its fw crashes during operation,
reading from the device will fail and will first receive short reads and
finally 0 byte reads. Let's quickly notify these events to upper layers
instead of trying to process the buffer and checking timestamps for
something we know it's already not useful.

Related: OS#3340
Change-Id: Ib1af8cdd6cdadf581b039882add4049eea45a0f7
2018-09-03 18:53:52 +02:00
Pau Espin 8e498bfd35 radioInterface: forward errors from RadioDevice to Transceiver in recv path
Change-Id: Id7b08b19d6575c79b4d57db656a17ff05bb61ee9
2018-09-03 18:53:52 +02:00
Pau Espin 46444637c6 cosmetic: Fix trailing whitespace
Change-Id: Ia647cfed0acb35adeb9b3b7824170d06c0369ef7
2018-09-03 18:53:41 +02:00
Harald Welte 5cc8858d8f logging: Introduce new "DDEV" category for device-specific code
The DMAIN category got too overloaded.  Let's have the code in
Transceive52M/device/* use the new DDEV category.

Also, in some cases the log levels have been adjusted to ensure
that enabling INFO level should not result in a complete overflow
of messages during normal operation.

Change-Id: I844fe4a75bf277cd3cc5bd8fa06e06ad97b2ea95
2018-08-17 19:57:40 +02:00
Pau Espin 58c89fb8d6 lms: Allow values diff than 34dB to be set by setRxGain()
Until now, setRxGain in LMSDevice did not take into account the setter
parameter and was always using hardcoded 34dB, which was experimentally
found to be a good default value.

Let's force that value during initialization, but still allow the upper
layers (controlled by BTS) to set different values. osmo-bts only sends
a SETRXGAIN command (which calls setRxGain in osmo-trx) if a value is
explicitly set in its VTY config, so we are on the safe side if the user
doesn't explicitly configure a desired dB.

Change-Id: I5684e675281a3f581855dbb56d199a6fe238a712
2018-06-20 07:41:16 +00:00
Pau Espin 16e7e20f85 Add -V param to print version
Change-Id: I9f2d6c4b1a508aceb1ccc0559f0902eedf2ec5af
2018-06-20 07:38:36 +00:00
Harald Welte b229439b31 usrp1: Fail in case of unsupported configuration
There might be some configuration that's not supported by osmo-bts-usrp1,
and we should reject that properly.

Change-Id: Ic7308ce0c57439fe97668bd31801c4bf76b797ad
Closes: OS#3348
2018-06-14 12:38:09 +02:00
Harald Welte ffb3301bd8 lms: Fail in case of unsupported configuration
There might be some configuration that's not supported by osmo-bts-lms,
and we should reject that properly.

Change-Id: I6f82edce589030a4407f6150fb7e8abe6417c1f2
Closes: OS#3347
2018-06-14 12:38:09 +02:00
Harald Welte 62b7900fd7 lms: Fix coding style
In Change-Id Ib2fca81b76d027b08e2891056fa076d071597783 we introduced
some coding style violations.  Let's make newly-added code follows
standard Osmocom coding style.

Change-Id: Ib7ddd275014f03a2eed3cddc02b1356e2b00c0bc
2018-06-14 12:38:09 +02:00
Harald Welte 61707e8b23 radioDevice: better encapsulation in base class
It's not good style to have the derived classes initialize members
inherited from the base class using "this->foo = bar".  Rather, let's
make the base class have a constructor, and call that constructor to
initialize the members of the base class.

While doing this
* rename 'offset' to 'lo_offset' to avoid confusion with timestamp offset
* move 'InterfaceType' into the base class
* move 'chans' into the base class
* move 'rx_sps' into the base class
* mark base class members as 'protected'

Change-Id: Ib885675a7612a392aa7f75fca81269ddcff2f6ab
2018-06-14 12:38:04 +02:00
Harald Welte ce70ba529c radioDevice: Move tx_sps from derived into base class
All three derived classes use a tx_sps member, let's move this into
the base class.

Change-Id: I73b4aa2705c5049561e2d7b21301a0d2b3c96ced
2018-06-13 23:46:27 +02:00
Harald Welte cfb9dac70d lms: Call set_antennas() during open() method
Without this call, the antenna/path configuration is not applied.

Change-Id: I0bca58266b59f1315ec72b6407fe4f4495aff678
2018-06-13 23:46:27 +02:00
Harald Welte 105a61e689 lms: Fix support for rx_paths / tx_paths
Before this patch, any configuration in osmo-trx.cfg regarding the rx
and tx "antenna" (path) would have been completely ignored, as the
radioDevice::make() function would simply drop those arguments to the
floor.

Change-Id: Ie50f854abbc9dcf351cddc052d10206382e1d5d3
2018-06-13 23:46:27 +02:00
Harald Welte 2407314f2e move set_antennas() from UHD to generic radioDevice base class
Change-Id: I806143e9db21f0be4dcc6a376b3a630be7aeb3ba
2018-06-13 23:46:27 +02:00
Zydrunas Tamosevicius ff4418539c lms: Reduce Rx gain from 47 to 34 dB
Initially, Rx gain was hardcoded to be 47. This was too high for our
setup and we were constantly getting "clipping detected" messages.

Reducing Rx gain to 34 solved the issue. However, it looks like gains
should be controlled through configuration files.

Change-Id: I30580f18c4ad630c09f725b1d24c125fc3119809
2018-06-13 21:45:32 +00:00
Zydrunas Tamosevicius 0494d05916 lms: fix LMS_StartStream() handling for multiple channels
LMS_StartStream() (in LMSDevice::start()) was moved to separate loop. It
is because LMS_SetupStream() would fail for second channel if streaming
has already been started (LMS_StartStream()) for single channel
configuration.

Change-Id: I6704bb92864aa81417507c4ae24a22f41dc529c1
2018-06-13 21:45:32 +00:00
Zydrunas Tamosevicius fd268b6f5a lms: Reduce log level of "send buffer of len ..."
Log level of "send buffer of len ..." messages was changed as it was
causing problems on some machines.

Change-Id: I605d50e81966c7bd169b27788d62af6fb54c84e1
2018-06-13 21:45:32 +00:00
Zydrunas Tamosevicius 43f3678b40 lms: Use same timestamp offset like when using LimeSDR via UHD
The tx timestamp offset was not set. We set it to the same value as it
was in UHD interface for LimeSDR

Change-Id: I78bc40cd575097f71a5f82b63467fa81c3f8d837
2018-06-13 21:45:32 +00:00
Pau Espin 6493dc838b lms: Check LPBFW to set is within supported range
As of LimeSuite 618fbb9c3188b36d75ad5785a97b8887dcc468f6, it seems 5e6
is within the returned range, but LMS_SetLPFBW fails anyway.

See for more information: https://github.com/myriadrf/LimeSuite/issues/184

Change-Id: I967e7da7c0e3e8138b76733ee4a0e6311d20b62e
2018-06-13 21:45:32 +00:00
Pau Espin f7905ac548 lms: Makefile.am: Reorder params to fix link issue
It seems the order in which static code and -lfoo is passed to the
linker matters.

This commit is a lms specific follow-up of commit
2a8183bdf0.

Change-Id: I59c20d268ecac4c22689124165c47295bd9176d4
2018-06-13 21:45:32 +00:00
Pau Espin 0c27938d44 LMSDevice: Fix setup failure with LimeSuite > 18.04.1
Fixes: https://github.com/myriadrf/LimeSuite/issues/184

Change-Id: Ia9f37995cd10d19d6820e3e12b8ee8f3efbff5d4
2018-06-13 21:45:32 +00:00
Pau Espin 587916e810 LMSDevice: Set correct values for Max{Tx,Rx}Gain
Change-Id: I3b3a7080a69e15d8d6770186810d922227439099
2018-06-13 21:45:32 +00:00
Harald Welte 79024867de LMSDevice: Reduce Rx logging verbosity: Only log unexpected timestamps
Change-Id: I06b35efb7368616b9f4d348da574cd524ffe3ea6
2018-06-13 21:45:32 +00:00
Harald Welte 4aec1f1cf5 LMS_Device: Set ts_offset to 0.
I'm not quite sure what the ts_offset is for, but by using "0"
we are now receiving exactly the timestamp that we're expecting:

LMSDevice.cpp:486 [tid=140576250332928] chan 0 recv buffer of len 2500 expect 305ed0 got 305ed0 (305ed0) diff=0

Change-Id: I270c94945b1af9662cfc468cfda1ae3af3ac0a27
2018-06-13 21:45:32 +00:00
Harald Welte 68f054169b LMSDevice: Fix initial timestamp offset of 2500
ts_initial must not point to the timestamp of the first sample
in the last "flush" sample buffer, but to the first timestamp we
expect in the next buffer.

Change-Id: I23af62870544d4c6cf5f6e2d6578936603bceb91
2018-06-13 21:45:32 +00:00
Harald Welte ea8be22e50 LMSDevice: Set low-pass filters to smallest possible option
Rx 1.4 MHz, Tx 5MHz.  Both massively too wide for GSM, but there's
no smaller band-width available.

Change-Id: I9723c9a2ea77f65bfa9d796d7c44adc2417e89cf
2018-06-13 21:45:32 +00:00
Harald Welte a5054b398b LMSDevice: Typo fix: s/Internal/External
Change-Id: Icacfe6da90a89c7f00d62c580948fb913998eaa7
2018-06-13 21:45:32 +00:00
Harald Welte a438114173 LMSDevice: Print sample rate range + actual sample rate after setting it
Change-Id: I19c1a5b2d2431b8d39e277244e313f6e559e4d25
2018-06-13 21:45:32 +00:00
Harald Welte 9cb4f27112 LMSDevice: Call LMS_Init() before setting sample rate
LMS_Init() will override basically all device settings with their
default value, including the sample rate.  We hence have to make sure
to call it before any other API function that changes the device config
such as sample rate, frequency, filter bandwidth, ...

Change-Id: I4cdbae8406b5e1e93da491e90f8bad41d4be748b
2018-06-13 21:45:32 +00:00
Pau Espin 1f50fedb5f build: Add support for LimeSuite device backend
Change-Id: I239e1b37263a62b374d84974c9347e3654072e87
2018-06-13 21:45:32 +00:00
Pau Espin c7a0bf1ffc lms: Several improvements and compilation/runtime fixes
Continuation of initial work done on LimeSuite support from Harald.

Change-Id: Ib2fca81b76d027b08e2891056fa076d071597783
2018-06-13 21:45:32 +00:00
Harald Welte 940738e86a Initial work towards direct LimeSuite support in OsmoTRX
This is work in progress towards a direct LimeSuite driver in OsmoTRX,
bypassing the currently rather complex stack of wrappers by going
through UHD, SoapyUHD, SoapySDR and LimeSuite.

Change-Id: Iaef29c4c2585ef8c2f94866c9591919f538c1a2d
2018-06-13 21:45:32 +00:00
Pau Espin 55df1e43e3 UHDDevice: Fix setup failure with LimeSuite > 18.04.1
Fixes: https://github.com/myriadrf/LimeSuite/issues/184

Change-Id: I48ead8b8996981263297b66c0c7d3d0972261316
2018-05-08 20:49:04 +02:00
Harald Welte fad2e09840 osmo-trx: s/GSM Core Address/GSM BTS Address/
The TRX connects to the BTS, not to the "Core".  The Core network
is miles away...

Change-Id: I6de2f708fc7a7df7dea16314b7dfa4ab82f15b2c
2018-04-28 21:43:40 +02:00
Pau Espin 2a8183bdf0 build: More OBS build failure fixes
It seems the order in which static code and -lfoo is passed to the
linker matters.

Change-Id: I3b25be0154053ae8eb5f0a24c39fb9a229130fcf
2018-04-28 01:38:30 +02:00
Pau Espin 478f82f47e build: Fix make distcheck
Change-Id: I1fa5e34b44331cd56408ea7ad4483dcf6443b259
2018-04-27 11:34:11 +02:00
Pau Espin f37b0ad652 Transceiver: log timing info of stale bursts
Change-Id: I043fd8199253bdf3912c7aec2ccf98f8cbe54251
2018-04-25 20:14:55 +02:00
Pau Espin f3d7f443a0 Build one osmo-trx binary for each device support enabled
Same way as we do in osmo-bts. After this commit, osmo-trx no longer
exists. Instead, osmo-trx-uhd and osmo-trx-usrp1 are generated based on
configure flags enabled.

A new flag --with(out)-uhd has been added to enable/disable build of
osmo-trx with UHD backend. It is left enabled by default to keep
compatibility with older build scripts. Binary with USRP1 backend must
still be manually enabled with --with-usrp1 flag.

Change-Id: Iea8c0d7434762713a53440d29bf3ebd84accb262
2018-04-24 19:17:22 +02:00
Pau Espin e564f0fd84 Transceiver: Move device specific code to radioDevice class
Change-Id: Ibcf258d8bf8595e286682e0bc59391b239ea7642
2018-04-24 18:46:48 +02:00
Pau Espin 0fc20d14b3 Move device specific code out of radioInterface
This way code of radioInterface is independent of the device and doesn't
need to be rebuild for each device.

Change-Id: Id104e1edef02f863b6465ced5b4241050dc188f9
2018-04-24 18:46:48 +02:00
Pau Espin a4316ee4c5 Change configure define USRP1 to DEVICE_USRP1
Similar as we do for ARCH_*, it's easier to find those are related to
device support features.

Change-Id: Iba238bff689b8f944af76120402c0fa2e29a70de
2018-04-24 18:46:48 +02:00
Pau Espin 2128a308eb Move device specific files to device subdir
Change-Id: Ib42fef14bf4c7b779f44d99711a35c18b32a4c21
2018-04-24 18:46:48 +02:00
Pau Espin 43fedb656b Move arch specific fiels to arch subdir
Take the chance to update some includes using files available in that
subdir to have them ina more uniform way.

Change-Id: Ibda3c54fd4dc3f6b845cc373f1a1e6b758c1ea82
2018-04-24 15:22:59 +02:00
Pau Espin e1977fcd22 use osmo_init_logging2()
Change-Id: I2c28e6e6e3eb9f587680b34330e03408e32c2b94
2018-04-16 14:50:55 +02:00
Vadim Yanitskiy c0c6d70fe9 Transceiver.cpp: prevent out-of-range array access
There was no a simple range check for both (NO)HANDOVER commands,
so an out-of-range access was possible. For example, a command:

  CMD HANDOVER 0 -3

might enable EDGE at run-time, because:

  a[i] == *(a + i)

Let's fix this.

Change-Id: I24a5f70e8e8097f218d7cbdef8cb10df2c35416f
2018-03-14 21:12:32 +00:00
Vadim Yanitskiy 8c6c5d2bcd Transceiver.cpp: fix incorrect format string for SETTSC
Change-Id: If69a478121a31aa7df945548cc17271c476d6a6b
2018-03-14 21:12:32 +00:00
Vadim Yanitskiy a62fcf786a Transceiver.cpp: use pointer arithmetics for CMD parsing
It looks like the author of control command parsing code was not
familar with simple pointer arithmetics, so excessive amount of
memory and useless memcopying was used to parse a single command.

Let's introduce two pointers, one of which will point to the
beginning of a command, another to the beginning of its arguments.
Also, let's simplify the command matching by using a separate
function called 'MATCH_CMD'.

Change-Id: I226ca0771e63228cf5e04ef9766057d4107fdd11
2018-03-14 21:12:31 +00:00
Vadim Yanitskiy 4d9b59c3ef Transceiver.cpp: properly zero-terminate received commands
Previously it was assumed that a sender should zero-terminate
each command being sent. Otherwise, this could cause to printing
garbage. Let's do this manually, using the length of received
data as a position for '\0'.

Change-Id: I69f413f33156c38a853efc5a8cdc66fbfb0ca6af
2018-03-14 21:12:30 +00:00
Vadim Yanitskiy bd0efb0bea Transceiver.cpp: use a define for the MAX_PACKET_LENGTH
No need to keep this value on stack.

Change-Id: If9ffb03b9e7b642f45732ba5938977bca271f1c7
2018-03-14 21:12:30 +00:00
Pau Espin 8fbbd656c7 Build Transceiver52M/common as an .la lib
Stop picking files from that directory on different places as it causes
dependency issues during make distclean/maintainer-clean.

Fixes: OS#3029

Change-Id: I81bb4251d18fce978d27849b621b20f541caab0b
2018-03-08 14:53:13 +01:00
Pau Espin b35cba613a Makefile.am: Avoid using subdir if arch is not required
There's no need in going a level deeper if we already know nothing's
going to be done. This way we also get cleaner make outputs.

Reference: https://www.gnu.org/software/automake/manual/html_node/Conditional-Subdirectories.html#Conditional-Subdirectories

Related: OS#3029

Change-Id: I3ff57ab14edc575904e8137929a0ef02c95e03af
2018-03-07 19:46:42 +01:00
Pau Espin 8dffadb8da osmo-trx: Re-introduce -l cmd line parameter
Parameter -l to set the terminal logging levle was removed in
3da1f8352e, but afterwards it was decided
to keep the cmd line options for a bit more to easy migration to VTY
cfg.

The command line no longer accepts keywords ("DEBUG", "INFO", etc.) but
log level numbers, due to libosmocore APIs log_parse_level and
log_level_str being marked as deprecated and for internal use only.

Keep in mind the log level is overridden by VTY cfg if any line sets log
levels for log stderr in there.

Explicit cast to unsigned int for loglvel is issued to avoid iostream
printing it as a char.

Change-Id: I91c35ecded177b7976045d9b693855adb9e18f8a
2018-03-06 18:41:29 +01:00
Pau Espin 408f25081e osmo-trx: Use VTY cfg structures while still allowing cmd line options
Existing cmd line options are kept for a while to give people some time
to move to use VTY cfg. All new cfg options should be set only through
VTY. VTY options take preference (override) over cmd line options.
Deprecated options are removed from help message to dissuade users from
keep using them.

Steps to drop cmd line options in the future:
- Drop comma_delimited_to_vector, print_deprecated
- Drop all options in handle_options marked with print_deprecated.
- Set "-c" param to do the same as "-C", to keep compatibility with old
param and still use same naming as all other osmocom projects.
- Remove the hack in main() to set 1 channel implicitly by default.

Change-Id: Ib8de1a5da4b3c0b6a49e00033f616e1d66656adf
2018-03-05 20:12:40 +01:00
Pau Espin a3ab8c263d vty: Implement VTY cfg parsing for current parameters
At this stage, osmo-trx still uses the cmdline parameters top run the
device, but it is already able to parse all the same parameters from a
cfg file through the VTY and filling a trx_ctx structure which will be
later used to drive the device. Device config can be printed in the VTY
with "show trx".

Change-Id: Ie084c1b30b63f91c6e7640832ec1797d9e813832
2018-03-05 19:55:02 +01:00
Pau Espin efac20b6bb Move enums required by VTY to a separate header
This patch is a preparation for next patches, which add full VTY cfg
support.

Change-Id: I3d5b0576aa96869756f1629a40306c0043b6304b
2018-03-05 17:16:05 +01:00
Pau Espin 0bbd8922ea osmo-trx.cpp: Move trx start and stop to helper functions
Make main() smaller, and make it easier to replace cmdline parameters in
following commits.

Change-Id: I10eaaafe38ace2b7bb095a0ad1db70d6c06ee03b
2018-03-05 17:14:32 +01:00
Alexander Huemer 3f52f0e6c5 Fix USRP1 build with support for setting Rx/TxAntenna
The USRP1 build was broken by commit 77ce99ac67.

Commit 77ce99ac67 broke the USRP1 build

Change-Id: I28585947d5662cdd580a814cce54a5d9aa30eeb8
2018-02-27 22:35:37 +01:00
Pau Espin 3da1f8352e Logger: Use libosmocore logging system
We still need an intermediate class Logger due to osmo-trx being
multi-threaded and requiring to have a lock to use libosmocore, which is
not thread safe.

Change-Id: I30baac89f53e927f8699d0586b43cccf88ecd493
2018-02-27 07:11:11 +00:00
Pau Espin 5ea1817dc2 Add initial support for logging, vty, ctrl
Up to this point, the logging system, vty and ctrl are initialized and
can be used fine, though they don't have a lot of use yet.

Depends on libosmocore Change-Id Ib79cdb62d45d8c78445c7b064e58eb7e9faeccf9

Related: OS#2184

Change-Id: I08982c37b4f873966304b3cfb38a10ee86eb3dad
2018-02-27 07:10:50 +00:00
Pau Espin 3a3b220751 osmo-trx: Set up talloc ctx
Change-Id: I67f1980fc615ab74371cbe1c4f83e987381299bc
2018-02-22 20:04:47 +01:00
Pau Espin ab22f4c421 osmo-trx: set up signals using libosmocore helpers
Change-Id: I86e78cd6054d0deff1b1aa061299d9f307e2a352
2018-02-22 20:04:47 +01:00
Pau Espin 8b843e5bed Depend on libosmocore
Change-Id: If345c89293fcd7d1ad4f17214eea339951f25a5d
2018-02-22 20:04:47 +01:00
Pau Espin 11d50d950c Logger: Drop syslog support
This feature is currently not being used, so let's drop it to make it
easier to integrate into libosmocore logging system in the future.

Change-Id: I8282745ef0282d41599eaf94fe460a1d29b18e2a
2018-02-20 20:32:21 +01:00
Pau Espin b7095c7bc5 UHDDevice: Initialize async_event_thrd in constructor
Fixes coverity CID 182757.
It's actually a false warning because "async_event_thrd" member is
protected by other member "started", so in practice it's never going to
be used before being initialized in start().

Change-Id: I5d5739bc9d08fe533e4d44c3992005a14e568a4f
2018-02-09 16:20:39 +01:00
Pau Espin 77ce99ac67 Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.

In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.

Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.

One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW

Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.

One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW

Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-07 13:43:42 +01:00
Pau Espin f58cd8ac83 Fix whitespace
Change-Id: Icda84caa998614ce6c15d5118f8c5c1568ba9a79
2018-02-05 13:04:41 +01:00
Pau Espin 89be118a3b Remove unneeded libdl dependency
Closes: OS#1929

Change-Id: I0caea2a2a8e6bd07432fd73bae72b42b1ce022cd
2018-01-23 18:15:24 +00:00
Alexander Huemer 6fafd33b13 Unbreak `./configure --with-usrp1` build
Change-Id: I49b385594271ae64a48d4d39ee9fe26d7c95bd30
2018-01-20 23:24:20 +01:00
Pau Espin 4a25d6b8f6 arm/convert.c: Add missing convert_init implementation
osmo-trx.cpp calls convert_init, which in case of building using
--with-neon is not implemented and the compiler stops with an error.

Error was introduced in 7e07cf2346.

Related: OS#2720

Change-Id: I9840d374d13b525b97f978ea0c5ed9e8421072a0
2018-01-11 18:45:12 +01:00
Pau Espin 79baee3a8f arm/convert.c: Fix compilation error
Commit fe9769833f aiming at cleaning stuff
introduced a compilation error.

Related: OS#2720

Change-Id: I6ce6e5ec3fdb1e3e8818e2cb674470ad54e38afb
2018-01-11 18:45:12 +01:00
Pau Espin 611212676b Move ARCH_LA to Makefile.common
It will later be used by other directories too (tests/Transceiver52M).

Change-Id: I0ca9b7fc5e1377db971cb7da0b3496ba8d61c716
2018-01-10 12:32:33 +01:00
Pau Espin caf2abc58f Remove Configuration module and libsqlite dependency
Change-Id: I823aea91367d586507bbf352f1b6f25bdd635baa
2018-01-09 15:26:50 +01:00
Pau Espin de1685f6d7 Drop use of ConfigurationTable gConfig
After latest changes, it is not being used anymore.

Change-Id: I43a49aee94e3239194ad9742fb6374324acac0de
2018-01-09 15:26:50 +01:00
Pau Espin 82f83ced73 cosmetic: Remove trailing whitespace
Change-Id: I64c8dbad3fc42bcb8dd4ac9b16bbd9c59a0cf5d5
2018-01-09 15:26:49 +01:00
Max d09843c692 Remove unused headers
Change-Id: Idadb17aeb85b011d114ffc1d81c920544bac1989
2018-01-04 14:31:54 +01:00
Piotr Krysik aa60dda99a UHDDevice.cpp: add USRP B205mini support
The B205mini is similar to the B200mini and runs OsmoTRX just
fine, so let's make OsmoTRX recogonize and support it too.

Change-Id: Iee575121248ea541f7abc49055e49ec2d30904c0
2017-12-04 00:32:33 +07:00
Pau Espin 8c80095017 Add -j option to bind to specific address
Before this patch, the binding of the listening sockets was hardcoded to
a local IP.

Change-Id: I9ba184a1251c823e413a9230943ed263e52142ec
2017-08-16 17:06:54 +02:00
Harald Welte 81486e053c Add '-t' command line option to enable SCHED_RR
SCHED_RR allows us to operate osmo-trx reliable even under exceptionally
high system load, as the realtime scheduler priority will have higher
priority than the other "regular" tasks on the system.

Change-Id: Ia2452b9763960b2be37fbeee9d832554da68a53f
Closes: OS#2344
2017-07-20 18:36:01 +00:00
ignasj 28d8081e25 LimeSDR: Fix sample value range
when "sc16" stream arg is passed to SoapyUHD sample value range is -32768 to 32767

Change-Id: I58b8b6b71648bd9cbc105ddaaa9a7cf0a31b3d47
2017-07-10 11:45:06 +02:00
ignasj 87ed77b937 LimeSDR: change tx window type to TX_WINDOW_FIXED
It seems that TX_WINDOW_USRP1 is for devices that do not support tx
sync to timestamp. LimeSDR supports it. Changing to TX_WINDOW_FIXED
greatly reduces number of "dumping stale buffer" messages

Modified to match current master by Harald Welte.

Change-Id: I8de5b165ccd72a62b0f16655618e24ca740d9637
2017-07-10 09:34:58 +00:00
ignasj f9d996813d LimeSDR: Change device detection to work with USB and PCIe versions
Modified to match current master by Harald Welte.

Change-Id: Ie43610de0b2196d84caf09717ec8c8ca75ab926d
2017-07-10 09:34:32 +00:00
Pau Espin 934da48618 transceiver: Avoid sending clock indications when trx is not powered on
Stop calling writeClockInterface() when receiving commands in Transceiver::driveControl,
otherwise it fools osmo-bts-trx clock skew check because it is always sending a clock
indication with the same fn when it issues any commands during the time in between
CMD POWEROFF and RSP POWERON, because fn is not increased during that period.

Also use mForceClockInterface flag to delay delivery of first IND CLOCK until we start
serving frames, otherwise the first one is sent and only after a long period of time
the next clock indications are sent, when the radio starts to process bursts. That makes
osmo-bts-trx unhappy because it expects to receive an IND CLOCK aprox at least every
400 frames. This way also we send the first IND CLOCK after the RSP POWERON 0 response.

Change-Id: I91b81a4d7627cec39c1814a39ed4be306681b874
2017-07-04 19:15:57 +02:00
Pau Espin 7c405a0c1f cosmetic: transciever: Remove trailing whitespaces
Change-Id: Ib3fbe768048b2a34a75ace9688e306720e67019a
2017-07-04 17:23:30 +02:00
Tom Tsou 4cafb0fa15 LimeSDR: set approximate tx offset value to make GSM work
may be fine-tuned in the future

Modified to match current master by Harald Welte.

Change-Id: Ied215ca9e9d9c346c2a654f96785d1b87b075129
2017-06-29 02:26:07 +02:00
Tom Tsou f611569018 uhd: Always specify samples-per-symbol for device lookup
Fix MCBTS device setup where the map access was failing on the wrong
assumption that all devices support 1-SPS TX-RX operation. Some devices
and/or configurations such as LIMESDR and MCBTS only support running
at 4-SPS.

Even though certain settings (e.g. number of physical channels or the
FPGA clocking rate) are not dependent on the SPS value, we still need to
specify because we use SPS as a parameter for device classification.

Fixes: OS#2341
Change-Id: I56e939285d585cc38efa6c329e30e3acebb734eb
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2017-06-27 11:36:34 -07:00
Tom Tsou 354741326c sigProcLib: Specify standard namespace for isnan()
In commit a3dce85f
"sigProcLib: Use explicit NaN check in sinc table generation"

Use of std::isnan(double) was added without namespace specifier,
which may cause build issues depending on whether the C version
isnan() call is available. Add standard namespace to force C++
call usage and potential build issues.

Change-Id: I49328c43fdd690a4e6a2b2e949411aaf5674ead1
2017-06-22 18:03:29 +00:00
Tom Tsou d2e5c5694e sigProcLib: Replace dynamically allocated resampling buffers
Instead use object allocated STL vectors. This simplifies code,
removes the need to explicitly release buffers, and fixes a
memory leak in destructor deallocation. Also, remove simplified
init and release sub-calls.

Maintain partition filter allocation using memalign() for SIMD
alignment requirements.

Change-Id: Ie836982794c10fb1b6334e40592d44b200454846
2017-06-22 17:39:44 +00:00
Tom Tsou a3dce85ffc sigProcLib: Use explicit NaN check in sinc table generation
Using "x < 0.01" is a crude check for detecting NaN condition, which
occurs in a sinc call when x = 0 due to divide-by-zero. Use stdlib
isnan() call for this purpose. Also, as the table is created only
once during initialization, use double floats for table value
generation.

Change-Id: I3a838fe3139fa977dfe906246020a14451185714
2017-06-19 17:04:04 +00:00
Tom Tsou bb0c68ae61 sigProcLib: Remove trigonometric tables
Trigonometric sin/cos tables are unused after initialization.
There is no benefit to implementing lookup tables for run-once
operations. Also perform initial calculations in double width
because there is no penalty for doing so.

Change-Id: I45bba5daf8610cbba6af95b92c2142f2256491ff
2017-06-19 17:03:11 +00:00
Tom Tsou 7278a87767 sigProcLib: Remove heap based signal vector allocations
The osmo-trx internals rely heavily on dynamic alloction of
I/Q signal vectors. In a number of cases there is no reason
to to use dynamic rather than stack based allocation. Convert
these cases accordingly.

Change-Id: If53da1bf77b5944b6117765fa98ce12e1ccdeede
2017-06-16 17:11:27 +00:00
Tom Tsou 63eef9faf2 sigProcLib: Fix complex/real vector flag in Laurent modulator
The modulator vector to be shaped by Laurent C1 pulse is complex,
but was set as real. The error does not affect behaviour because
we only support complex-complex and complex-real calculations;
real-real convolution is not supported. So in this case the data
vector was already assumed to be complex despite the improper
flag setting.

Change-Id: I03afc6a93a01fde7a9a02e4eb9d201d3ee37d21a
2017-06-16 17:09:09 +00:00
Tom Tsou d67bd603e9 transceiver: Fix POWEROFF crash on USRP2/N200/X300 devices
Upon issuing POWEROFF command to a running transceiver, UHD
interfacing thread state may become undefined if the device
is stopped with I/O threads still active. Bad behavior is
device dependent with only network based USRP devices
affected. USB based device thread behavior stops and shutdowns
as expected. Tested with N200, X300, and B210.

Tested solutions include the following:

  1. Set pthread_setcanceltype() with PTHREAD_CANCEL_ASYNCHRONOUS
  2. Add sleep delay to allow I/O threads to timeout before
     stopping the device
  3. Wait for I/O threads to join after cancellation before stopping
     the device

This patch resolves the issue by with the third approach. Number 1
is not guaranteed to always work with UHD internals as driver code
may explicitly set thread parameters. Using sleep calls to fix
order-of-operation issues is almost never a good idea.

Change-Id: Ib72ab98a27a02084b040319046c92d1c4157ae4c
2017-06-16 17:03:30 +00:00
Tom Tsou 988a464d5d uhd: Fix USRP2/N200/N210 device detection
Commit 1fb0ce67 "uhd: Use map container for for device parameter access"
inadvertently removed the string identifier for the USRP2 and derived
devices (N200/N210).

Add the missing USRP2 string identifier. Also search for partial string
matches in the UHD provided device and mboard stings. This is necessary
to guarantee that strings such as "N200r3" instead of just "N200" are
sucessfully found.

Tested with N200, X310, B200mini and B210 devices.

Change-Id: Ide4e22418e2cc469418cba018970cb0eb9906697
2017-06-16 17:02:27 +00:00
Tom Tsou 1b6ab7d7ee uhd: Fix Tx-RX timing offset setting
Integer timestamp offset was set to zero due to bad cast-operator
precedence.

Change-Id: Ib1f524cc86416699b3c143e5faddb33d61380767
2017-06-15 16:22:44 -07:00
Tom Tsou 980525c8a9 uhd: Add non-UmTRX channel swap support
Previously an UmTRX-only feature.

Change-Id: I4a0e0c1d69e89993158e948535ad33f54e568d2d
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2017-06-14 16:34:46 +00:00
Tom Tsou 70134a01eb sigProcLib: Remove unused functions from public interface
Also remove entirely completely unused calls. Most of these
calls have been around since OpenBTS conception. Nearly a
decade is long enough time for deprecation.

Change-Id: Ifc122aaff23414c363b4b00f99061eed8a6902d0
2017-06-14 16:30:28 +00:00
Tom Tsou 1fb0ce67d8 uhd: Use map container for for device parameter access
OsmoTRX is written in C++ so we might as well use built-in
container types when applicable. Map access allows removal
of significant amounts of special device handling code.

Aggregate device rates and timing offsets into a single
table with access keyed by device/tx-sps/rx-sps tuples.

Change-Id: I8660f75a2b2a13488b913c07637bdd0f5f0f4cf9
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2017-06-12 13:47:14 -07:00
Vadim Yanitskiy 3bd763d2a1 ssedetect: call __builtin_cpu_supports() only if supported
Some compilers don't support the __builtin_cpu_supports built-in,
so let's make them able to compile the project anyway.

Change-Id: I0c90402d8e4c9f196c54b066ff30891c8de3ad2b
2017-06-08 18:32:29 +00:00
Alexander Chemeris 5e65b531e0 sigProcLib: Fix number of tail bits in random Normal Bursts and zero Stealing Bits.
This bug only affects generation of normal bursts filled with random bits which
are used in test mode. It doesn't affect operation of osmo-trx during normal
operation. That's why it has stayed unnoticed for so long.

Each Normal Burst has 3 tail bits, not 4.
Also it's better to set stealing bits to 0 for maximum compatibility. We may want to
introduce a selector for each bit whether to set it to 0, to 1 or to a random number.

Change-Id: I0377029556c8b681b3ba3b635bf19572b34546ea
2017-05-29 15:15:36 +03:00
Tom Tsou d6ae8648ff radioInterface: Remove UmTRX 'diversity' option
The 'diversity' option was an experimental 2 antenna receiver
implementation for UmTRX. The implementation has not been
maintained and current working status is unknown.

In addition to code rot, Coverity is triggering errors in the
associated code sections.

Removal of code cleans up many cases of special handling that
were necessary to accommodate the implementation.

Change-Id: I46752ccf5dbcffbec806081dec03e69a0fbdcdb7
2017-05-19 17:25:44 +00:00
Philipp Maier e51a8f029e cosmetic: Add info about SSE support
The osmo-trx binary outputs no info about its SSE support status.
This commits adds some putput that informs about the SSE of the
binary and also tells which of the SSE levels the CPU supports.

Change-Id: Iacc83fd668c31644e0efb3e18962cf2870ed1daf
2017-05-19 17:23:20 +00:00
Philipp Maier e8ae9fcf38 buildenv: Split up SSE3 and SSE4.1 code
Currently we find SSE3 and SSE4.1 code mixed togehter along with
generic code in one file. This introduces the risk that the
compiler exidantly mixes SSE4.1 instructions into an SSE3, or
even worse into a generic code path.

This commit splits the SSE3 and SSE4.1 code into separate files
and compiles them with the matching target options.

Change-Id: I846e190e92f1258cd412d1b2d79b539e204e04b3
2017-05-19 17:21:45 +00:00
Philipp Maier fe9769833f cosmetic: remove code duplication
The ARM and the X86 implementation of the conversion functions share
the same, non cpu specific implementation in separate files.

This commit removes the code duplication by putting the generic
implementation into a convert_base.c, similar to to convolve_base.c

Change-Id: Ic8d8534a343e27cde79ddc85be4998ebd0cb6e5c
2017-05-19 17:16:37 +00:00
Philipp Maier 7e07cf2346 ssedetect: Add runtime CPU detection
The current implementation can select the SSE support level during
compiletime only.

This commit adds functionality to automatically detect and switch
the SSE support level and automatically switch the Implementation
if the CPU does not support the required SSE level.

Change-Id: Iba74f8a6e4e921ff31e4bd9f0c7c881fe547423a
2017-05-19 17:12:45 +00:00
Philipp Maier 131f82bfac cosmetic: Make parameter lists uniform
The non-sse implementation and the sse implementation of the convert
and convolve functions have different parameter lists. This makes it
difficult to use function pointers in order to select the right
function depending on the SSE-Level and CPU.

This commit uniformizes the parameter lists in preparation for
planned runtime cpu detection support

Change-Id: Ice063b89791537c4b591751f12f5ef5c413a2d27
2017-05-02 17:17:57 +00:00
Philipp Maier 78b5627fa1 buildenv: Turn off native architecture builds
The compiler option -march=native instructs the compiler to auto-optimize
the code for the current build architecture. This is fine for building
and using locally, but contraproductive when generating binary packages.

This commit replaces -march=native with $(SIMD_FLAGS), which contains a
collection of supported SIMD options, so we won't loose the SSE support.

Change-Id: I3df4b8db9692016115edbe2247beeec090715687
2017-05-02 10:21:25 +00:00
Tom Tsou de116e90c0 config: Remove OpenBTS style sqlite configuration
OpenBTS relies on reading in configuration values from the OpenBTS.config
sqlite3 database. This configuration method is not maintained and not
recommended for Osmocom or OpenBTS use. Command line setup is the
recommended approach.

Note that when the osmo-trx logging mechanism is replaced, the sqlite
dependency will be removed.

Change-Id: I95d7b771fde976818bee76f89163e72c3a44ecdd
2017-04-10 06:54:40 +00:00
Tom Tsou 6031734f44 Transceiver: Remove unsigned negative compares
Change-Id: I49f30699786c52736ef334dae61f7bbd65d878d5
Fixes: Coverity CID 149353, 149356
2017-04-03 18:06:48 +00:00
Tom Tsou 5d2a36a113 Resampler: Fix non-array delete for filter taps
Change-Id: I59cdb01809da5940c74aaae9d17f413aefbf04b2
Fixes: Coverity CID 149349
2017-04-03 18:06:48 +00:00
Tom Tsou 2af14407a8 sigProcLib: Fix negative value check on unsigned value
Convert negative value check on unsigned value to zero check
to avoid potential divide-by-zero error condition.

Change-Id: Ib0d7d1bceb5fe66e69345db93a74e3e0773a2257
Fixes: Coverity CID 165059
2017-03-31 21:43:31 +00:00
Tom Tsou 92bdfb86ac sigProcLib: Check return status on downsampling
Improper length values will cause the polyphase resampler
rotation to fail. Check return and return NULL on error.

Change-Id: I3ad22f9fd7a20754f589c04258dcca3770474a9b
Fixes: Coverity CID 165235
2017-03-31 21:41:04 +00:00
Tom Tsou ae91f13ecb sigProcLib: Remove unreachable code and no-effect checks
Unreachable path and negative value inspection on unsigned
types.

Change-Id: If53b4b03550b0a7656c808cfe96806252153eb2f
Fixes: Coverity CID 165239, 165238, 165236
2017-03-31 21:41:03 +00:00
Tom Tsou 9d53ecf666 Resampler: Fix initialization return checking
Greater-than comparison was used on boolean type.

Change-Id: Ia3b71b3a06b34a6fd781bf197ecf9d5cc1711d13
2017-03-31 21:40:23 +00:00
Alexander Chemeris e0c12189d4 sigProcLib: Constify demodulation functions burst argument.
demodCommon() used to scale input vector in place which changed original data.
That's a bad practice and is not really necessary, so I've changed the code to
scale burst after it's copied to a new vector during a delay operation.

Change-Id: Ic45f71b634e48808356d68925bb9f5783e0bf0d3
2017-03-28 14:24:22 +00:00
Alexander Chemeris 1470fcdb5a sigProcLib: constify signalVector arguments for detectBurst() functions.
Change-Id: Ic033371a387353eb12b1827a0eb16c00c07da88a
2017-03-28 14:24:07 +00:00
Alexander Chemeris 6e1dffd486 Move Transceiver::demodulate() to sigProcLib to make it reusable.
Change-Id: I2cad47160e53f65612bd1da8998c83a0a22bce9b
2017-03-28 14:23:56 +00:00
Alexander Chemeris 0229d22d2e sigProcLib.h: Fix whitespaces. No non-whitespace changes.
The file seem to be using "2 spaces" indent, bt some lines are using
tabs which breaks formatting.

Change-Id: I7718cca45c245c9e91250ab2877f5436d4029698
2017-03-28 14:23:44 +00:00
Alexander Chemeris f7717acd0c sigProcLib: Add operator<< to print CorrType to a string.
Change-Id: I3d68cbdab8fb504d7f155029654a576d318a201e
2017-03-28 14:23:35 +00:00
Alexander Chemeris b34e60c105 Move BURST_THRESH from Transceiver.cpp to sigProcLib.h to make it reusable.
Change-Id: I5a888890e26858c0fbb2ddb7ef23cb0fd66a64b4
2017-03-28 14:22:01 +00:00
Alexander Chemeris 4e6c938024 Move Transceiver::detectBurst() to sigProcLib to make it reusable.
Change-Id: I3cbe8e6e4f39dde02c945e6c9086c040e276845c
2017-03-24 14:59:24 -07:00
Alexander Chemeris 4aa548f0c2 sigProcLib: rename signalError type to SignalError.
Change-Id: I1a5ae6e87d4c69945053fdefec185d0fb1a26399
2017-03-24 19:54:04 +00:00
Alexander Chemeris f9e78beea5 Move CorrType type from Transceiver to sigProcLib.
Required to move Transceiver::detectBurst to sigProcLib.

Change-Id: I3e0e74a98bbca4d19657f50a5fb447f078663c9b
2017-03-24 19:54:04 +00:00
Alexander Chemeris e56bf3a0e5 signalVector: Implement segment().
Change-Id: I6fe3aae53fb2fa5bb7637e976de6059eabe08202
2017-03-24 01:22:40 +00:00
Alexander Chemeris b61c610cd9 Call vectorSlicer() right before packing bits for transmission to osmo-bts.
vectorSlicer() converts soft-bits from -1..+1 to 0..1 while we want
to keep SoftVector in -1..+1 mode until the last minute, because at some
point we'll want to transmit -1..+1 to osmo-bts instead of converting it
from 0..1 back to -1..+1 on the osmo-bts side.

Plus it removes code duplication - we call it once instead of twice.

Change-Id: Idd6ddd7ac219afb0df055a692632678b66373764
2017-03-22 18:31:07 +00:00
Alexander Chemeris 132fb247b1 sigProcLib: Slice SoftVector instead of signalVector for GMSK demod.
This makes it similar to 8-PSK demod and also saves a bit of lines ofcode and
should give us a tiny improvement in performance.

Ideally we need to remove vector slicing at all, because in osmo-bts-trx
we convert back to +-1.0 again (actually to +-127, but it doesn't mater).
So we should rather transmit +-1.0 values to avoid double conversion.

Change-Id: If9ed6f0f80fbe88c994b2f9c3cae91d0d57f4442
2017-03-22 18:31:03 +00:00
Alexander Chemeris 1c0b8b355c sigProcLib: Rename demodulateBurst() to demodGmskBurst() for clarity.
Change-Id: Ibcef8d7d4a2c06865bed7e4091ccc8dbbd494d77
2017-03-22 18:30:53 +00:00
Alexander Chemeris 1dd05cf35a sigProcLib: make energyDetect() simpler by returning actual energy.
Change-Id: I9bf97f2dc03fea9bebcf43198dfb05f6e4694e9c
2017-03-22 18:09:00 +00:00
Alexander Chemeris 14d13b67dc sigProcLib: Fix documentation, sync argument names in .cpp and .h files.
Documentation in sigProcLib.h was noticeably out of sync with the actual
implementation - e.g. not all arguments were documented and arguments
which are already removed are still in the documentation. Also argument
names were different between declaration in .h and implementation in .cpp
which was confusing.

I've fixed this for detect*Burst() functions.

Change-Id: I4dfd07125d9a1e9a42a78b79faff539f003deb16
2017-03-20 18:42:32 +00:00
Alexander Chemeris 89bca9b2de radioBuffer: Remove extra ; at the end of inline function definitions.
Change-Id: I8911adf0a0bb1ae828ac9cdf1a76c904639f6c06
2017-03-20 18:41:02 +00:00
Alexander Chemeris 9270a5aa2e sigProcLib: Typo sybols -> symbols
Change-Id: I8cbef852374d0458c4f4ad4be0df0aa998e3796a
2017-03-20 17:36:06 +00:00
Tom Tsou a93f789e50 uhd: Increase MC-BTS FPGA clock rate to 51.2 MHz
Addresses following issues where UHD 3.9 and likely other UHD versions
would report a master clock (FPGA) rate error. Update MC-BTS FPGA clock
for B200 and B210 to 51.2 MHz, which is supported by all UHD versions.
Only B200/B210 is supported for MC-BTS operation.

https://osmocom.org/issues/1963
https://osmocom.org/issues/1648

ALERT UHDDevice.cpp:548:set_master_clk: Failed to set master clock rate
ALERT UHDDevice.cpp:549:set_master_clk: Requested clock rate 3.2e+06
ALERT UHDDevice.cpp:550:set_master_clk: Actual clock rate 5e+06

Change-Id: I78fb2c0959abd0e666628ba39f433162aafb067e
2017-03-07 17:54:06 -08:00
Tom Tsou 72bf762b42 uhd: Add support for UHD-3.11 logging control
The logging API changes in UHD-3.11, which causes build failure if
not properly handled.

Change-Id: I223ebb9fae3f4061e0cb37c05263c1b569e8f628
2017-03-07 14:25:05 -08:00
Max 2dee3e996e Fix building against sqlite3
* Explicitly check for sqlite3 at configure stage, remove old include
  dir, fix header inclusion.
* Use configure results for linking instead of hardcoded linker option
  for sqlite.
* Add dependency on -dev package for .deb

Change-Id: I6d7f697d67651f02ceb77fc4da4317b64fa47f9e
Fixes: OS#1928
2017-01-26 17:06:06 +01:00
Tom Tsou 80cb08071b Revert "uhd: Set minimum supported version to 3.9.0"
This reverts commit 93ca09ea61.

Ettus Research recommends the use of 3.9 series of UHD releases,
but requiring this version has lead to issues with broken OBS and
packaged binaries by Debian, Ubuntu, and other distributions.

Change-Id: Ie6b175ac6d46d091937380c79fdd0125b16ec75f
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2017-01-19 13:48:15 -08:00
Tom Tsou 44c7f41d75 uhd: Add X300 sample timing for 4 SPS
Previously only 4/1 and 1/1 configurations Tx/Tx samples-per-symbol
were supported.

Change-Id: I9153171fe3af95e1cb0d9d35a9287dfde155d184
2017-01-11 13:30:42 -08:00
pierre.baudry 9436fbbf3c transceiver: Fix mismatched allocations and deallocations
The behaviour of a mismatched pair of allocation and deallocation is undefined
Also fixes a memory leak if malloc fails (which stops the application anyway)

Change-Id: I9c8bbade8531e8c9c02dcd43bac38cb954b3c89f
2016-10-26 08:54:13 +02:00
Tom Tsou 93ca09ea61 uhd: Set minimum supported version to 3.9.0
Versions of UHD prior to 3.9.0 are no longer supported.

Rather then backport and ifdef UHD version specific API and
behavioral changes, set minimum support to the current LTS
release, which is 3.9.0.

Change-Id: Id7d15b52cd4e45f1d856a6ef3a84832a28f2dd04
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-10-25 18:48:52 +00:00
Tom Tsou 365bc38bee transceiver: Fix command build warning
Place conditional brackets on handover table reset. Reset table
only on successful start or restart.

Change-Id: I74032b49785bd68835a0a68cb0f14cdaab4fcd26
2016-10-25 18:48:25 +00:00
Tom Tsou 43242efc85 uhd: Add missing B200 sample timing for 4 SPS receive
Only B210 timing was previously set in the timing table.

Change-Id: Idc8d1be8201ad086c57dd9b3d6d72d277306cd2b
2016-10-18 11:30:09 -07:00
Tom Tsou aa15d62a8c sigproc: Match differential GMSK start/end bits to tail bits
Invert the initial and trailing diffential bits in the 4 sps
GMSK modulator to fix power-time mask irregularity at start
and end of burst. GSM tail bits are always zero, so we can
safely use fixed bit values.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-08-11 14:44:57 -07:00
Tom Tsou 8f0ccf618d uhd: Update USRP2/N200/N210 for 4 SPS Rx
Requires changing the radioInterface API to pass in Rx side SPS
value. Update the (deprecated) diversity configuration to match
as well.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-20 16:36:27 -07:00
Tom Tsou 06676ead63 sigproc: Fix missing 8-PSK tail symbols
Agilent E4406A measurement of TSC synchronized RF envelope measurement.
showed failing power levels at the tail end of EDGE bursts. Regression
traced back to following commit.

Commit d2b070369d
"uhd: Correct timing alignment in 8-PSK and GMSK downlink bursts"

In the patch, the EDGE burst was delayed one symbol, but erroneously
truncated at the tail end causing the failing RF envelope measurement.

The missing tail symbol did not appear to affect end-to-end EGPRS tests.
This patch corrects the truncation.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-19 12:56:24 -07:00
Tom Tsou 4609f3285c transceiver: Fix 4 SPS receive TOA value
The time-of-arrival (TOA) value out of sigProc is specified
in symbols or, equivalently, 1 sample per symbol and does
not need to be normalized.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-19 11:30:49 -07:00
Tom Tsou 7c741ec6a6 transceiver: Fix mixed GSMK / 8-PSK transmission
Input burst construction was declared static causing the first
downlink burst from upstream to determine subsequent burst size
and modulation. Consequently, fixed sequence EGPRS tests would
pass, however, switching between 8-PSK and GMSK bursts would
fail with only one modulation type being transmitted.

Internally generated test sequences '-r' option were not affected
because the bursts are not received through the socket interface.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-19 11:26:05 -07:00
Tom Tsou 2f3e60bc1f uhd: Add command line option for GPS reference
Unlike earlier versions of UHD, the current release (3.9.2)
does not automatically select on-board GPSDO as the reference
source. Modify the command line settings to allow explicit
selection of GPS in addition to the external setting.

Simultaneous GPS and external reference settingis disallowed.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-17 19:34:22 -07:00
Alexander Chemeris cbfef6e40a UHD: Initial LimeSDR support.
Only EDGE mode is currently supported. Traditional 1 SPS Rx / 4 SPS Tx
mode requires different sampling rates which is not currently working.

RF performance is also sub-optimal and requires more tuning.
2016-07-12 16:26:51 -07:00
Tom Tsou b577ef014f radioInterface: Fix multi-channel buffer index bug
Discrete RF multi-channel was using hard coded buffer index
on the channel iteration for transmit sample conversion. End
result was segmentation fault on dual RF channel devices with
both channels active (Ettus B210 and UmTRX).

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-12 16:11:13 -07:00
Tom Tsou c37594f3b9 mcbts: Allow out of order channel setup
Previous checks on multi-channel TSC and ARFCN settings would fail
if channels were initialized out of order. Namely, if channel 0
was not configured first, osmo-trx would error on the control
interface leading osmo-bts to fail.

Allow global TSC setting on all channels with added logging notice.
Notify if channel frequency is unexpected - which may happen if
channels are setup out of order - but do no report as error.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-08 14:46:25 -07:00
Tom Tsou ffee30d190 transceiver: Remove HANDOVER warnings
These warnings simply echo the socket command arguments with no
indication of any unexpected or improper operation.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-07 19:39:18 -07:00
Tom Tsou 64464e6c34 egprs: Enable 8-PSK burst detection when EDGE is enabled
The command line EDGE option will enable 8-PSK burst
detection on any slot where a normal burst is expected.
The burst search order is 8-PSK first followed by GMSK.

EDGE will force 4 SPS sampling on Tx and Rx. Along with
twice the search correlation from 8-PSK and GMSK, EDGE
will increase CPU utilization. Whether the increase is
notable or not is dependent on the particular machine.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-01 03:50:02 -07:00
Tom Tsou e88710881b egprs: Enable 8-PSK length vectors on the Tx interface
Allow EGPRS 8-PSK length bit vectors of length 444 (148 * 3)
to pass in through the Tx socket interface. Length is the sole
factor in determining whether to modulate a bit vector using
GMSK or 8-PSK.

Tested with 8-PSK training sequences with random payload
originating from osmo-bts. Output verified with Agilent E4406A.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-01 03:16:03 -07:00
Tom Tsou a84e162672 sigproc: Adjust burst detection threshold criteria
Reduce the burst detection threshold to pass more bursts to upper
layers, but force stricter requirements on the computation itself.
For the latter, we now require at least 5 samples (rather than 2)
to compute a peak-to-average value.

End result is increased burst detection at low SNR conditions with
a small increase in false positive bursts when no signal is present.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-01 03:14:29 -07:00
Tom Tsou 7676427816 mcbts: Add multi-ARFCN radio support
Add new radio interface "radioInterfaceMulti" for multi-carrier
support.

Only USRP B200/B210 devices are supported because of sample
rate requirements (3.2 Msps).

Only 4 SPS operation Tx/RX is supported.

8-PSK is supported.

Other options may be added at a later time

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-01 03:14:15 -07:00
Tom Tsou 35222296fe mcbts: Add multi-ARFCN channelizing filters
Introduce polyphase channelizer (Rx) and synthesis (Tx) filterbanks,
which serve as the signal processing backend for multi-carrier GSM.

Fast Fourier Transform (FFT) is used internally. FFTW is added as
a new build dependency.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-01 03:07:27 -07:00
Tom Tsou 28670fb5da iface: Add inner ring-buffer implementation
Two buffers, inner and outer, are used in the transceiver
implementation. The outer buffer interfaces with the device receive
interface to guarantee timestamp aligned and contiguously allocated
sample buffers. The inner buffer absorbs vector size differences between
GSM bursts (156 or 157 samples) and the resampler interface (typically
fixed multiples of 65).

Reimplement the inner buffer with a ring buffer that allows fixed size
segments on the outer (resampler) portion and variable lengths (GSM
side) on the inner side. Compared to the previous stack-like version,
this implementation removes unnecessary copying of buffer contents.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-01 03:03:11 -07:00
Tom Tsou 05c6feb71d radioInterface: Convert diversity argument to general type
Rather than a simple bool type, convert the diversity switch
to the device interface specifer:

  enum InterfaceType {
    NORMAL,
    RESAMP_64M,
    RESAMP_100M,
    DIVERSITY,
  };

The more general specifier allows passing in special cases
other then selection diversity such as multi-ARFCN support.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-01 03:03:03 -07:00
Tom Tsou 2e4ed10722 transceiver: Add Rx samples-per-symbol option
Previous approach was to enable 4 SPS on the receive path only
for EDGE use, which is not a requirement for 4 SPS operation.
Make the 4 SPS configuration setting directly settable.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-07-01 03:02:56 -07:00
Tom Tsou c8c4eac55e transceiver: Do not report error on SETTSC when radio is on
OsmoTRX does not support the use of multiple TSC settings per
internal TRX instance. There should not be an error to modifiy
the TSC value after POWERON. Setting TSC value on TRX channels
other then 0 is a NOP operation that should only error if the
requested TSC differs from that of TRX channel 0.

Reported-by: Max <msuraev@sysmocom.de>
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-06-28 17:08:34 -07:00
Alexander Chemeris 37c52c79cf transceiver: Add an option to emulate a RACH delay in random filler mode.
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-06-22 15:18:13 -07:00
Alexander Chemeris 58e9591f9e transceiver: Log channel number in DEBUG output of demoded bursts.
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-06-22 14:28:22 -07:00
Alexander Chemeris 19174f581b radioInterface: Initialize power scale with a meaningful default.
Right now if you forget to send "POWER" control command, osmo-trx
will transmitt zeros. This is counter-intuitive and I've spent several
hours debugging this "issue". The issue may happen easily, because
osmo-bts doesn't send "POWER" command if there is no "power" setting
in the configuration file. Given that "POWER" command actually sets
attenuation, it's percieved as optional and in absence of it should
default to "POWER 0" (no attenuation), which translates to power
scale being 1.0.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-06-22 14:28:07 -07:00
Alexander Chemeris 1ba69e7762 uhd: Fix comment.
It's osmo-trx, not OpenBTS anymore.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-06-22 14:27:38 -07:00
Alexander Chemeris f931cf226b radioDevice: GSMRATE macro must have parentheses around its definition.
So we had the following define:
   #define GSMRATE       1625e3/6

Now, I wanted to use it in the following expression:
   3.0/GSMRATE
which turns into:
   3.0/1625e3/6
while what I really wanted is:
   3.0/(1625e3/6) = 3.0/1625e3*6

To avoid this, all macros with calculations must be enclosed in parentheses.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-06-22 14:27:24 -07:00
Alexander Chemeris e476231deb makefile: Fix build from an external path.
When you build from an external path, compiler can't find convert.h
include, because it was specified relative to the current directory.
Change this to specify the include dit relative to the Makefile
location.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-06-22 14:27:00 -07:00
Tom Tsou e90c24c8d5 sigproc: Expand RACH, TSC, and EDGE correlation windows
Slightly widen the search range to accommodate timing jitter
on certain classes of devices. The expanded range minimizes
the possibility of missing bursts that arrive too early or
too late due to timing error.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-06-21 16:19:54 -07:00
Tom Tsou 3b093bb13b uhd: Set minimum UHD version requirement for E3XX
Create runtime version check for minimum supported UHD driver
when using USRP E3XX devices. The minimum version, 3.9.0, matches
supported version on current E3XX release images.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-05-03 19:06:56 -07:00
Tom Tsou 3f4a13f049 uhd: Make device offset check a private method
Removes extra arguments and a static call.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-05-03 19:04:00 -07:00
Tom Tsou 0fe41a583c uhd: Set default Tx sampling to 4 sps
The majority of GSM host platforms are capable of operating with
the 4x oversampled modulator, which justifies the new default
setting. The small number exceptions (e.g. Raspberry Pi) can still
use the lower complexity 1 sps modulator with the '-s 1' command
line option if required.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-05-03 15:17:39 -07:00
Tom Tsou a5e0f1cdba uhd: Update default E3XX settings
Tune timing values after testing on UHD 003.009.002 for E3XX.
Table value for 1 sps was off by 10 samples causing improper
operation. Table value for 4 sps was shifted by 1 sample for
more accurate timing.

Also update E3XX description string detection.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-05-03 15:14:06 -07:00
Tom Tsou 2c650a6895 common: Add mandatory length field to UDP receive calls
Current UDP receive reads up to MAX_UDP_LENGTH bytes into the
passed in buffer, which may lead to buffer overflow if the
write buffer is of insufficient size.

Add mandatory length argument to UDP socket receive calls.

Reported-by: Simone Margaritelli <simone@zimperium.com>
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-05-02 17:37:05 -07:00
Tom Tsou 047956259b EDGE: Fix demodulation slicer input
EDGE 8-PSK soft slicer was receiving input from the output of the
downsampler. Equalization and derotation were missing causing the
soft symbol output to be invalid.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-04-26 21:20:43 -07:00
Tom Tsou d2b070369d uhd: Correct timing alignment in 8-PSK and GMSK downlink bursts
Delay the EDGE downlink bursts by one symbol in order to match GMSK
pulse shaping group delay. The difference in group delay arises from
the dual pulse filter combination of the GMSK Laurent represenation
whereas 8-PSK uses a single pulse linear filter.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-04-26 19:31:14 -07:00
Alexander Chemeris 9664c3a6e7 transceiver: Do not pass transceiver state struct to function where it's not used. 2016-04-26 12:03:20 -07:00
Alexander Chemeris 1ab5e7f7bc osmo-trx: Output Rx SPS as a part of configuration output. 2016-04-26 12:02:51 -07:00
Alexander Chemeris 5efe05021a transceiver: Add an option to generate random Access Bursts. 2016-04-20 13:46:02 -07:00
Alexander Chemeris 78d1fc9a13 transceiver: Properly handle MAXDLY.
Previously MAXDLY value was applied to Normal Bursts, which was nice
when working with sloppy test equipment like CMD57, but useless for
real world usage. At the same time documentation and de facto usage
of MAXDLY in OsmoBTS and OpenBTS assumed that it actually applies to
Access Bursts (RACH). So this patch changes osmo-rx behavior to apply
MAXDLY to RACH bursts and introduces a new command MAXDLYNB for the
old behavior.
2016-04-20 13:45:00 -07:00
Tom Tsou 9bd649ec73 EDGE: Fix USRP B210 device support
Commit 871b8782 "EDGE: Add support for UmTRX" disabled B210 support
using EDGE. Add B210 explicitly to the timing offset table to avoid
this issue.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-03-23 17:20:08 -07:00
Alexander Chemeris 871b87829f EDGE: Add support for UmTRX.
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-03-22 11:01:34 -07:00
Tom Tsou 7fec3030d4 EDGE: Combine shared GMSK and 8-PSK demodulator sections
Timing recovery and single tap channel compensation are identical
in both GMSK and EDGE receivers. This is the section ahead of and
including the optional 4-1 downsampler. GMSK and EDGE specific
sections operate at 1 SPS.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-03-08 17:45:53 -08:00
Tom Tsou af717b2d3c EDGE: Add random burst generator filler option
When EDGE is enabled with the '-e' option, the random burst generator
switches from GMSK normal bursts to 8-PSK EDGE bursts.

  $ ./osmo-trx -e -r 7

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-03-08 17:45:53 -08:00
Tom Tsou 8ee2f38a87 sigproc: Add various GSM burst generators
Setup generators for empty, random, and dummy bursts. This moves error
prone burst length handling out of the Transceiver and into the signal
processing core.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-03-08 17:45:53 -08:00
Tom Tsou 4dfd64aa9e sigproc: Always use 625 sample length bursts with 4 SPS
At 4 samples per symbol, we don't need to maintain the 156/157 sample
slot structure to account for the GSM 156.25 sample burst length.
Set the 4 SPS Laurent modulator to ignore the guard interval setting
and always output 625 sample sized bursts. The EDGE 8-PSK modulator
already has this behavior.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-03-08 17:45:53 -08:00
Tom Tsou b0aefcbf47 EDGE: Add interfaces to enable EDGE transceiver
Create EDGE slot type in the Transceiver. When EDGE mode is enabled
for a particular slot, blind detection will be performed by
correlating against EDGE followed by normal bursts if no EDGE burst
is found.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-03-08 17:44:53 -08:00
Tom Tsou d325343ecc EDGE: Add 8-PSK modulator and demodulator
Setup correlator and detection process similar to the GMSK
receiver chain. Require 4 SPS sampling on both Rx and Tx paths
as 1 SPS sampling adds too much distoration for 8-PSK recovery.
Core receiver operations still run at 1 SPS with the exception
of fractional delay filtering, which runs at the higher rate.

Perform linear equalization to handle the Gaussian pulse
induced ISI. The fixed impulse response used for equalizer tap
calculation consists of combined EDGE pulse shape filter and
effects of the downsampling filter. Note that the non-adaptive
equalizer corrects for modulation induced band limiting and
does not account for or compensate for fading channel effects.

Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-03-06 20:29:27 -08:00