2016-06-30 15:02:43 -04:00
|
|
|
# Copyright 2016 Jared Boone <jared@sharebrained.com>
|
|
|
|
#
|
|
|
|
# This file is part of PortaPack.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
# any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; see the file COPYING. If not, write to
|
|
|
|
# the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
# Boston, MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
|
2016-07-03 21:32:50 -04:00
|
|
|
project(firmware)
|
2016-06-30 15:02:43 -04:00
|
|
|
|
|
|
|
set(COMMON ${PROJECT_SOURCE_DIR}/common)
|
|
|
|
set(CHIBIOS ${PROJECT_SOURCE_DIR}/chibios)
|
|
|
|
set(CHIBIOS_PORTAPACK ${PROJECT_SOURCE_DIR}/chibios-portapack)
|
|
|
|
|
|
|
|
set(HACKRF_FIRMWARE_FILENAME hackrf_one_usb_ram.dfu)
|
|
|
|
set(HACKRF_FIRMWARE_IMAGE ${PROJECT_SOURCE_DIR}/${HACKRF_FIRMWARE_FILENAME})
|
2016-07-17 18:50:36 -04:00
|
|
|
|
|
|
|
set(HACKRF_CPLD_SVF_FILENAME hackrf_cpld_default.svf)
|
|
|
|
set(HACKRF_CPLD_SVF_PATH ${PROJECT_SOURCE_DIR}/${HACKRF_CPLD_SVF_FILENAME})
|
|
|
|
|
2016-07-05 15:34:38 -04:00
|
|
|
set(EXTRACT_CPLD_DATA ${PROJECT_SOURCE_DIR}/tools/extract_cpld_data.py)
|
2016-07-17 18:50:36 -04:00
|
|
|
set(EXTRACT_SVF_DATA_XC2C64A ${PROJECT_SOURCE_DIR}/tools/extract_svf_data_xc2c64a.py)
|
2016-06-30 22:37:05 -04:00
|
|
|
set(STRIP_DFU ${PROJECT_SOURCE_DIR}/tools/strip_dfu.py)
|
2016-06-30 15:02:43 -04:00
|
|
|
set(MAKE_SPI_IMAGE ${PROJECT_SOURCE_DIR}/tools/make_spi_image.py)
|
2016-06-30 19:45:41 -04:00
|
|
|
set(MAKE_IMAGE_CHUNK ${PROJECT_SOURCE_DIR}/tools/make_image_chunk.py)
|
2016-06-30 15:02:43 -04:00
|
|
|
|
2016-08-23 05:27:10 -04:00
|
|
|
set(FIRMWARE_NAME portapack-h1-havoc)
|
2016-07-03 21:32:50 -04:00
|
|
|
set(FIRMWARE_FILENAME ${FIRMWARE_NAME}.bin)
|
|
|
|
|
2016-06-30 15:02:43 -04:00
|
|
|
add_subdirectory(application)
|
|
|
|
add_subdirectory(baseband)
|
|
|
|
add_subdirectory(bootstrap)
|
|
|
|
|
2016-07-03 21:32:50 -04:00
|
|
|
# NOTE: Dependencies break if the .bin files aren't included in DEPENDS. WTF, CMake?
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${FIRMWARE_FILENAME}
|
|
|
|
COMMAND ${MAKE_SPI_IMAGE} ${bootstrap_BINARY_DIR}/bootstrap.bin ${baseband_BINARY_DIR}/baseband.img ${application_BINARY_DIR}/application.bin ${FIRMWARE_FILENAME}
|
|
|
|
DEPENDS bootstrap baseband application ${MAKE_SPI_IMAGE}
|
|
|
|
${bootstrap_BINARY_DIR}/bootstrap.bin ${baseband_BINARY_DIR}/baseband.img ${application_BINARY_DIR}/application.bin
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
|
2016-06-30 15:02:43 -04:00
|
|
|
add_custom_target(
|
2016-07-03 21:32:50 -04:00
|
|
|
firmware
|
|
|
|
DEPENDS ${FIRMWARE_FILENAME}
|
2016-06-30 15:02:43 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(
|
|
|
|
program
|
|
|
|
COMMAND dfu-util --device 1fc9:000c --download ${HACKRF_FIRMWARE_IMAGE} --reset
|
|
|
|
COMMAND sleep 1s
|
2016-07-03 21:32:50 -04:00
|
|
|
COMMAND hackrf_spiflash -w ${FIRMWARE_FILENAME}
|
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${FIRMWARE_FILENAME}
|
2016-06-30 15:02:43 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
# TODO: Bad hack to fix location of LICENSE file for tar.
|
2016-07-03 21:32:50 -04:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${FIRMWARE_NAME}-${GIT_REVISION}.tar.bz2 ${FIRMWARE_NAME}-${GIT_REVISION}.zip
|
2016-06-30 15:02:43 -04:00
|
|
|
COMMAND cp ${LICENSE_PATH} LICENSE
|
|
|
|
COMMAND cp ${HACKRF_FIRMWARE_IMAGE} ${HACKRF_FIRMWARE_FILENAME}
|
2016-07-03 21:32:50 -04:00
|
|
|
COMMAND tar -c -j -f ${FIRMWARE_NAME}-${GIT_REVISION}.tar.bz2 ${FIRMWARE_FILENAME} ${HACKRF_FIRMWARE_FILENAME} LICENSE
|
|
|
|
COMMAND zip -9 -q ${FIRMWARE_NAME}-${GIT_REVISION}.zip ${FIRMWARE_FILENAME} ${HACKRF_FIRMWARE_FILENAME} LICENSE
|
2016-06-30 15:02:43 -04:00
|
|
|
COMMAND rm -f LICENSE ${HACKRF_FIRMWARE_FILENAME}
|
2016-07-03 21:32:50 -04:00
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${FIRMWARE_FILENAME} ${LICENSE_PATH} ${HACKRF_FIRMWARE_IMAGE}
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(
|
|
|
|
release
|
|
|
|
DEPENDS ${FIRMWARE_NAME}-${GIT_REVISION}.tar.bz2 ${FIRMWARE_NAME}-${GIT_REVISION}.zip
|
2016-06-30 15:02:43 -04:00
|
|
|
)
|