[bladeRF-flash] Initial version

This commit is contained in:
Keith Rothman 2013-09-11 05:19:35 +00:00
commit 1da070aca4
4 changed files with 145 additions and 0 deletions

View file

@ -1,2 +1,3 @@
cmake_minimum_required(VERSION 2.8)
add_subdirectory(bladeRF-cli)
add_subdirectory(bladeRF-flash)

View file

@ -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}")

View file

@ -0,0 +1,29 @@
/*
* bladeRF flashing utility
*/
#include <stdlib.h>
#include <stdio.h>
#include <getopt.h>
#include <stdbool.h>
#include <errno.h>
#include <string.h>
#include <libbladeRF.h>
#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;
}

View file

@ -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