From 1da070aca4d9380dfb95cb7a00f94d9e9dcb2bc4 Mon Sep 17 00:00:00 2001 From: Keith Rothman Date: Wed, 11 Sep 2013 05:19:35 +0000 Subject: [PATCH] [bladeRF-flash] Initial version --- host/utilities/CMakeLists.txt | 1 + host/utilities/bladeRF-flash/CMakeLists.txt | 105 ++++++++++++++++++ host/utilities/bladeRF-flash/src/main.c | 29 +++++ host/utilities/bladeRF-flash/src/version.h.in | 10 ++ 4 files changed, 145 insertions(+) create mode 100644 host/utilities/bladeRF-flash/CMakeLists.txt create mode 100644 host/utilities/bladeRF-flash/src/main.c create mode 100644 host/utilities/bladeRF-flash/src/version.h.in diff --git a/host/utilities/CMakeLists.txt b/host/utilities/CMakeLists.txt index a1129250..ddfe6964 100644 --- a/host/utilities/CMakeLists.txt +++ b/host/utilities/CMakeLists.txt @@ -1,2 +1,3 @@ cmake_minimum_required(VERSION 2.8) add_subdirectory(bladeRF-cli) +add_subdirectory(bladeRF-flash) diff --git a/host/utilities/bladeRF-flash/CMakeLists.txt b/host/utilities/bladeRF-flash/CMakeLists.txt new file mode 100644 index 00000000..7d36daf8 --- /dev/null +++ b/host/utilities/bladeRF-flash/CMakeLists.txt @@ -0,0 +1,105 @@ +# Copyright 2013 Nuand, LLC. +# +# This file is part of the bladeRF project +# +# TODO license text here (see top-level COPYING for time being) +cmake_minimum_required(VERSION 2.8) +project(bladeRF-flash C) + +################################################################################ +# Version information +################################################################################ + +set(VERSION_INFO_MAJOR 0) +set(VERSION_INFO_MINOR 4) +set(VERSION_INFO_PATCH 0) +set(VERSION_INFO_EXTRA "git") +include(Version) + +set(VERSION "${VERSION_INFO}") + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in + ${CMAKE_CURRENT_BINARY_DIR}/src/version.h + @ONLY +) + +################################################################################ +# Build dependencies +################################################################################ +if(ENABLE_BACKEND_LIBUSB) + find_package(LibUSB) + if(NOT LIBUSB_FOUND) + message(FATAL_ERROR "libusb-1.0 required to use for libusb backend") + else(NOT LIBUSB_FOUND) + set(LIBBLADERF_INCLUDES ${LIBBLADERF_INCLUDES} ${LIBUSB_INCLUDE_DIRS}) + endif(NOT LIBUSB_FOUND) +else() + return() +endif(ENABLE_BACKEND_LIBUSB) + +################################################################################ +# Include paths +################################################################################ +set(FLASH_INCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_BINARY_DIR}/src + ${BLADERF_HOST_COMMON_INCLUDE_DIRS} + ${libbladeRF_SOURCE_DIR}/include + ${BLADERF_FW_COMMON_INCLUDE_DIR} + ${LIBUSB_INCLUDE_DIRS}) + +include_directories(${FLASH_INCLUDE_DIRS}) + +################################################################################ +# Configure source files +################################################################################ +set(BLADERF_FLASH_SOURCE + src/main.c + ${BLADERF_HOST_COMMON_SOURCE_DIR}/conversions.c + ${BLADERF_HOST_COMMON_SOURCE_DIR}/log.c +) + +if(MSVC) + set(BLADERF_FLASH_SOURCE ${BLADERF_FLASH_SOURCE} + ${BLADERF_HOST_COMMON_SOURCE_DIR}/windows/getopt.c + ${BLADERF_HOST_COMMON_SOURCE_DIR}/windows/getopt_long.c + ) +endif() + +add_executable(bladeRF-flash ${BLADERF_FLASH_SOURCE}) + +################################################################################ +# Build configuration +################################################################################ +set(FLASH_LINK_LIBRARIES + libbladerf_shared + ${CMAKE_THREAD_LIBS_INIT} +) + +target_link_libraries(bladeRF-flash ${FLASH_LINK_LIBRARIES}) + +################################################################################ +# Installation +################################################################################ +if(NOT DEFINED BIN_INSTALL_DIR) + set(BIN_INSTALL_DIR bin) +endif() + +install(TARGETS bladeRF-flash DESTINATION ${BIN_INSTALL_DIR}) + +if(MSVC) + add_custom_command(TARGET bladeRF-flash POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_BINARY_DIR}/libraries/libbladeRF/$(Configuration)/libusb-1.0.dll" + "${CMAKE_BINARY_DIR}/utilities/bladeRF-flash/$(Configuration)/") + add_custom_command(TARGET bladeRF-flash POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_BINARY_DIR}/libraries/libbladeRF/$(Configuration)/bladeRF.dll" + "${CMAKE_BINARY_DIR}/utilities/bladeRF-flash/$(Configuration)/") +endif(MSVC) + +################################################################################ +# Informational output +################################################################################ +message(STATUS "Configured to build bladeRF-flash version: ${VERSION_INFO}") diff --git a/host/utilities/bladeRF-flash/src/main.c b/host/utilities/bladeRF-flash/src/main.c new file mode 100644 index 00000000..0cc474b4 --- /dev/null +++ b/host/utilities/bladeRF-flash/src/main.c @@ -0,0 +1,29 @@ +/* + * bladeRF flashing utility + */ +#include +#include +#include +#include +#include +#include +#include +#include "version.h" + + +int main(int argc, char *argv[]) +{ + /* Arguments: + * - Firmware image + * - Device string (optional) + * - Load RAM only (option) + * - Issue RESET before JUMP_TO_BOOTLOADER (option) + */ + + /* Get initial device or scan */ + /* If normal bladeRF, perform protocol to get to FX3 bootloader */ + /* Perform RAM bootloader */ + /* Optionally flash new image to SPI flash */ + + return 0; +} diff --git a/host/utilities/bladeRF-flash/src/version.h.in b/host/utilities/bladeRF-flash/src/version.h.in new file mode 100644 index 00000000..87cb20da --- /dev/null +++ b/host/utilities/bladeRF-flash/src/version.h.in @@ -0,0 +1,10 @@ +#ifndef BLADERF_FLASH_VERSION_H__ +#define BLADERF_FLASH_VERSION_H__ + +#define BLADERF_FLASH_VERSION "@VERSION@" + +#define BLADERF_FLASH_VERSION_MAJOR @VERSION_INFO_MAJOR@ +#define BLADERF_FLASH_VERSION_MINOR @VERSION_INFO_MINOR@ +#define BLADERF_FLASH_VERSION_PATCH @VERSION_INFO_PATCH@ + +#endif