2016-03-22 01:15:40 +01:00
{ stdenv , fetchurl , fetchFromGitHub , cmake , pkgconfig
, python , pythonPackages , orc , libusb1 , boost } :
2013-05-02 15:27:11 +02:00
# You need these udev rules to not have to run as root (copied from
# ${uhd}/share/uhd/utils/uhd-usrp.rules):
#
# SUBSYSTEMS=="usb", ATTRS{idVendor}=="fffe", ATTRS{idProduct}=="0002", MODE:="0666"
# SUBSYSTEMS=="usb", ATTRS{idVendor}=="2500", ATTRS{idProduct}=="0002", MODE:="0666"
2018-02-01 20:43:40 +01:00
let
2018-03-29 03:14:08 +02:00
uhdVer = " v " + version ;
2013-05-02 15:27:11 +02:00
# UHD seems to use three different version number styles: x.y.z, xxx_yyy_zzz
2018-03-29 03:14:08 +02:00
# and xxx.yyy.zzz. Hrmpf... style keeps changing
2019-01-05 19:52:55 +01:00
version = " 3 . 1 3 . 0 . 1 " ;
2018-02-01 20:43:40 +01:00
2018-06-26 23:47:22 +02:00
# Firmware images are downloaded (pre-built) from the respective release on Github
2018-02-01 20:43:40 +01:00
uhdImagesSrc = fetchurl {
2018-06-26 23:47:22 +02:00
url = " h t t p s : / / g i t h u b . c o m / E t t u s R e s e a r c h / u h d / r e l e a s e s / d o w n l o a d / ${ uhdVer } / u h d - i m a g e s _ ${ version } . t a r . x z " ;
2019-01-05 19:52:55 +01:00
sha256 = " 0 y 9 i 9 3 z 1 8 8 c h 0 h d l k v v 0 k 9 m 0 k 7 v n s 7 r b x a q s n k 3 5 x n l q l x x g q d v j " ;
2018-02-01 20:43:40 +01:00
} ;
in stdenv . mkDerivation {
name = " u h d - ${ version } " ;
2013-05-02 15:27:11 +02:00
2016-03-22 01:15:40 +01:00
src = fetchFromGitHub {
owner = " E t t u s R e s e a r c h " ;
repo = " u h d " ;
2018-03-29 03:14:08 +02:00
rev = " ${ uhdVer } " ;
2019-01-05 19:52:55 +01:00
sha256 = " 0 s i 4 9 q k 9 6 z h p a n m c r z l r 3 i g c 5 s 1 y 3 0 x 4 p 0 z 9 7 3 q 6 0 d x 9 f h q s b b 6 k " ;
2013-05-02 15:27:11 +02:00
} ;
2016-03-22 01:15:40 +01:00
enableParallelBuilding = true ;
2018-03-29 03:14:08 +02:00
# ABI differences GCC 7.1
# /nix/store/wd6r25miqbk9ia53pp669gn4wrg9n9cj-gcc-7.3.0/include/c++/7.3.0/bits/vector.tcc:394:7: note: parameter passing for argument of type 'std::vector<uhd::range_t>::iterator {aka __gnu_cxx::__normal_iterator<uhd::range_t*, std::vector<uhd::range_t> >}' changed in GCC 7.1
cmakeFlags = [ " - D L I B U S B _ I N C L U D E _ D I R S = ${ libusb1 . dev } / i n c l u d e / l i b u s b - 1 . 0 " ] ++
treewide: isArm -> isAarch32
Following legacy packing conventions, `isArm` was defined just for
32-bit ARM instruction set. This is confusing to non packagers though,
because Aarch64 is an ARM instruction set.
The official ARM overview for ARMv8[1] is surprisingly not confusing,
given the overall state of affairs for ARM naming conventions, and
offers us a solution. It divides the nomenclature into three levels:
```
ISA: ARMv8 {-A, -R, -M}
/ \
Mode: Aarch32 Aarch64
| / \
Encoding: A64 A32 T32
```
At the top is the overall v8 instruction set archicture. Second are the
two modes, defined by bitwidth but differing in other semantics too, and
buttom are the encodings, (hopefully?) isomorphic if they encode the
same mode.
The 32 bit encodings are mostly backwards compatible with previous
non-Thumb and Thumb encodings, and if so we can pun the mode names to
instead mean "sets of compatable or isomorphic encodings", and then
voilà we have nice names for 32-bit and 64-bit arm instruction sets
which do not use the word ARM so as to not confused either laymen or
experienced ARM packages.
[1]: https://developer.arm.com/products/architecture/a-profile
2018-03-20 03:41:06 +01:00
[ ( stdenv . lib . optionalString stdenv . isAarch32 " - D C M A K E _ C X X _ F L A G S = - W n o - p s a b i " ) ] ;
2013-05-02 15:27:11 +02:00
2016-03-22 01:15:40 +01:00
nativeBuildInputs = [ cmake pkgconfig ] ;
buildInputs = [ python pythonPackages . pyramid_mako orc libusb1 boost ] ;
2013-05-02 15:27:11 +02:00
# Build only the host software
preConfigure = " c d h o s t " ;
treewide: isArm -> isAarch32
Following legacy packing conventions, `isArm` was defined just for
32-bit ARM instruction set. This is confusing to non packagers though,
because Aarch64 is an ARM instruction set.
The official ARM overview for ARMv8[1] is surprisingly not confusing,
given the overall state of affairs for ARM naming conventions, and
offers us a solution. It divides the nomenclature into three levels:
```
ISA: ARMv8 {-A, -R, -M}
/ \
Mode: Aarch32 Aarch64
| / \
Encoding: A64 A32 T32
```
At the top is the overall v8 instruction set archicture. Second are the
two modes, defined by bitwidth but differing in other semantics too, and
buttom are the encodings, (hopefully?) isomorphic if they encode the
same mode.
The 32 bit encodings are mostly backwards compatible with previous
non-Thumb and Thumb encodings, and if so we can pun the mode names to
instead mean "sets of compatable or isomorphic encodings", and then
voilà we have nice names for 32-bit and 64-bit arm instruction sets
which do not use the word ARM so as to not confused either laymen or
experienced ARM packages.
[1]: https://developer.arm.com/products/architecture/a-profile
2018-03-20 03:41:06 +01:00
patches = if stdenv . isAarch32 then ./neon.patch else null ;
2013-05-02 15:27:11 +02:00
postPhases = [ " i n s t a l l F i r m w a r e " ] ;
2018-06-26 23:47:22 +02:00
# UHD expects images in `$CMAKE_INSTALL_PREFIX/share/uhd/images`
2013-05-02 15:27:11 +02:00
installFirmware = ''
2018-06-26 23:47:22 +02:00
mkdir - p " $ o u t / s h a r e / u h d / i m a g e s "
tar - - strip-components = 1 - xvf " ${ uhdImagesSrc } " - C " $ o u t / s h a r e / u h d / i m a g e s "
2013-05-02 15:27:11 +02:00
'' ;
meta = with stdenv . lib ; {
description = " U S R P H a r d w a r e D r i v e r ( f o r S o f t w a r e D e f i n e d R a d i o ) " ;
longDescription = ''
The USRP Hardware Driver ( UHD ) software is the hardware driver for all
USRP ( Universal Software Radio Peripheral ) devices .
USRP devices are designed and sold by Ettus Research , LLC and its parent
company , National Instruments .
'' ;
2017-06-20 03:26:14 +02:00
homepage = https://uhd.ettus.com/ ;
2013-05-02 15:27:11 +02:00
license = licenses . gpl3Plus ;
2017-05-26 05:15:15 +02:00
platforms = platforms . linux ++ platforms . darwin ;
2018-03-29 03:14:08 +02:00
maintainers = with maintainers ; [ bjornfor fpletz tomberek ] ;
2013-05-02 15:27:11 +02:00
} ;
}