Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions fx3_firmware/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ option(ENABLE_BLADERF_FIRMWARE
"Build firmware for the bladeRF 1.0"
ON
)
if(BLADERF_OS_ANDROID)
set(ENABLE_BLADERF_FIRMWARE OFF)
endif()

################################################################################
# Build Configuration
Expand Down
21 changes: 19 additions & 2 deletions host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ option(BUILD_DOCUMENTATION
"Enable build and install of manpages and other documentation."
OFF)

option(BUILD_BLADERF_UTILITIES
"Build bladeRF utilities (e.g. bladeRF-cli)."
ON)

if(BLADERF_OS_ANDROID)
set(BUILD_BLADERF_UTILITIES OFF)
endif()

option(TREAT_WARNINGS_AS_ERRORS
"Treat compiler warnings as errors."
ON)
Expand Down Expand Up @@ -86,7 +94,9 @@ option(BUILD_AD936X_DEBUG
OFF)
# We do this prior to the rest of host/common, as the compile options are
# going to be different.
add_subdirectory(common/thirdparty/ad936x)
if(BUILD_AD936X)
add_subdirectory(common/thirdparty/ad936x)
endif(BUILD_AD936X)

################################################################################
# Compiler configuration
Expand Down Expand Up @@ -161,6 +171,9 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR CYGWIN)
endif()
endif(NOT CMAKE_CROSSCOMPILING AND NOT CYGWIN)

elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
set(BLADERF_OS_ANDROID 1)

elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(BLADERF_OS_FREEBSD 1)

Expand Down Expand Up @@ -211,7 +224,11 @@ endif()
################################################################################
add_subdirectory(libraries)
add_subdirectory(misc)
add_subdirectory(utilities)

if(BUILD_BLADERF_UTILITIES)
add_subdirectory(utilities)
endif()

add_subdirectory(common)

################################################################################
Expand Down
36 changes: 34 additions & 2 deletions host/common/include/host_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,44 @@
#cmakedefine01 BLADERF_OS_FREEBSD
#cmakedefine01 BLADERF_OS_OSX
#cmakedefine01 BLADERF_OS_WINDOWS
#cmakedefine01 BLADERF_OS_ANDROID
#cmakedefine01 BLADERF_BIG_ENDIAN

#if !(BLADERF_OS_LINUX || BLADERF_OS_OSX || BLADERF_OS_WINDOWS || BLADERF_OS_FREEBSD)

#if !(BLADERF_OS_LINUX || BLADERF_OS_OSX || BLADERF_OS_WINDOWS || BLADERF_OS_FREEBSD || BLADERF_OS_ANDROID)
# error "Build not configured for any supported operating systems"
#endif

#if 1 < (BLADERF_OS_LINUX + BLADERF_OS_OSX + BLADERF_OS_WINDOWS + BLADERF_OS_FREEBSD)
#error "Build configured for multiple operating systems"
#endif

#ifdef BLADERF_OS_ANDROID
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
#include <pwd.h>
#include <time.h>
#include <errno.h>

static inline struct passwd *bladerf_android_getpwuid_stub(uid_t uid)
{
static struct passwd pwd;
static char fallback_dir[] = "/";
const char *home;

(void)uid;

home = getenv("HOME");
pwd.pw_dir = (char *)(home != NULL ? home : fallback_dir);

return &pwd;
}

#define getpwuid(uid) bladerf_android_getpwuid_stub(uid)

#endif

#cmakedefine01 HAVE_CLOCK_GETTIME

/*******************************************************************************
Expand All @@ -61,7 +89,7 @@
/*-----------------------
* Linux
*---------------------*/
#if BLADERF_OS_LINUX
#if BLADERF_OS_LINUX || BLADERF_OS_ANDROID
#include <endian.h>

#define HOST_TO_LE16(val) htole16(val)
Expand Down Expand Up @@ -153,6 +181,10 @@
#error "Encountered an OS that we do not have endian wrappers for?"
#endif

#if BLADERF_OS_ANDROID
#define pthread_cancel(val) pthread_kill(val, SIGTERM)
#endif

/*******************************************************************************
* Endianness conversions for constants
*
Expand Down
4 changes: 4 additions & 0 deletions host/libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ add_subdirectory(libbladeRF)

# Conditionally add the test directory
option(TEST_LIBBLADERF "Enables libbladeRF test output" ON)
if(BLADERF_OS_ANDROID)
set(TEST_LIBBLADERF OFF)
endif()

if(TEST_LIBBLADERF)
message(STATUS "libbladeRF_test: enabled")
add_subdirectory(libbladeRF_test)
Expand Down
5 changes: 3 additions & 2 deletions host/libraries/libbladeRF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ if(ENABLE_BACKEND_LIBUSB)
else()
message(WARNING "Not checking libbladeRF/libusb compatibility because LIBUSB_VERSION is not defined.")
endif()
set(LIBBLADERF_INCLUDES ${LIBBLADERF_INCLUDES} ${LIBUSB_INCLUDE_DIRS})
set(LIBBLADERF_INCLUDES ${LIBBLADERF_INCLUDES} ${LIBUSB_INCLUDE_DIRS} "${LIBUSB_INCLUDE_DIR}")
endif(NOT LIBUSB_FOUND)
endif(ENABLE_BACKEND_LIBUSB)

Expand All @@ -290,7 +290,8 @@ if(BUILD_AD936X)
set(LIBBLADERF_LIBS ${LIBBLADERF_LIBS} ad936x)
endif(BUILD_AD936X)

include_directories(${LIBBLADERF_INCLUDES})
message(STATUS "libbladeRF includes: ${LIBBLADERF_INCLUDES}")
include_directories(${LIBBLADERF_INCLUDES} )


################################################################################
Expand Down
4 changes: 4 additions & 0 deletions host/libraries/libbladeRF/src/device_calibration.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@

#include <string.h>
#include <stdio.h>
#ifndef BLADERF_OS_ANDROID
#include "common.h"
#else
#include <ad9361.h>
#endif
#include "libbladeRF.h"
#include "board/board.h"
#include "helpers/version.h"
Expand Down
4 changes: 2 additions & 2 deletions host/libraries/libbladeRF/src/helpers/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static size_t strip_last_path_entry(char *buf, char dir_delim)
return len;
}

#if BLADERF_OS_LINUX || BLADERF_OS_OSX || BLADERF_OS_FREEBSD
#if BLADERF_OS_LINUX || BLADERF_OS_OSX || BLADERF_OS_FREEBSD || BLADERF_OS_ANDROID
#define ACCESS_FILE_EXISTS F_OK
#define DIR_DELIMETER '/'

Expand Down Expand Up @@ -229,7 +229,7 @@ static inline size_t get_install_dir(char *buf, size_t max_len)
return 0;
}

#if BLADERF_OS_LINUX
#if BLADERF_OS_LINUX || BLADERF_OS_ANDROID
static inline size_t get_binary_dir(char *buf, size_t max_len)
{
ssize_t result = readlink("/proc/self/exe", buf, max_len);
Expand Down