diff --git a/firmware/CMakeLists.txt b/firmware/CMakeLists.txt index 68c1e2e2..b902226a 100644 --- a/firmware/CMakeLists.txt +++ b/firmware/CMakeLists.txt @@ -18,7 +18,7 @@ # Boston, MA 02110-1301, USA. # -project(portapack-h1-firmware) +project(firmware) set(COMMON ${PROJECT_SOURCE_DIR}/common) set(CHIBIOS ${PROJECT_SOURCE_DIR}/chibios) @@ -30,31 +30,48 @@ set(STRIP_DFU ${PROJECT_SOURCE_DIR}/tools/strip_dfu.py) set(MAKE_SPI_IMAGE ${PROJECT_SOURCE_DIR}/tools/make_spi_image.py) set(MAKE_IMAGE_CHUNK ${PROJECT_SOURCE_DIR}/tools/make_image_chunk.py) +set(FIRMWARE_NAME portapack-h1-firmware) +set(FIRMWARE_FILENAME ${FIRMWARE_NAME}.bin) + add_subdirectory(application) add_subdirectory(baseband) add_subdirectory(bootstrap) +# 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 +) + add_custom_target( - ${PROJECT_NAME}.bin - COMMAND ${MAKE_SPI_IMAGE} ${bootstrap_BINARY_DIR}/bootstrap.bin ${baseband_BINARY_DIR}/baseband.img ${application_BINARY_DIR}/application.bin ${PROJECT_NAME}.bin - DEPENDS bootstrap.bin baseband.img application.bin + firmware + DEPENDS ${FIRMWARE_FILENAME} ) add_custom_target( program COMMAND dfu-util --device 1fc9:000c --download ${HACKRF_FIRMWARE_IMAGE} --reset COMMAND sleep 1s - COMMAND hackrf_spiflash -w ${PROJECT_NAME}.bin - DEPENDS ${PROJECT_NAME}.bin + COMMAND hackrf_spiflash -w ${FIRMWARE_FILENAME} + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${FIRMWARE_FILENAME} ) # TODO: Bad hack to fix location of LICENSE file for tar. -add_custom_target( - release +add_custom_command( + OUTPUT ${FIRMWARE_NAME}-${GIT_REVISION}.tar.bz2 ${FIRMWARE_NAME}-${GIT_REVISION}.zip COMMAND cp ${LICENSE_PATH} LICENSE COMMAND cp ${HACKRF_FIRMWARE_IMAGE} ${HACKRF_FIRMWARE_FILENAME} - COMMAND tar -c -j -f ${PROJECT_NAME}-${GIT_REVISION}.tar.bz2 ${PROJECT_NAME}.bin ${HACKRF_FIRMWARE_FILENAME} LICENSE - COMMAND zip -9 -q ${PROJECT_NAME}-${GIT_REVISION}.zip ${PROJECT_NAME}.bin ${HACKRF_FIRMWARE_FILENAME} LICENSE + 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 COMMAND rm -f LICENSE ${HACKRF_FIRMWARE_FILENAME} - DEPENDS ${PROJECT_NAME}.bin + 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 ) diff --git a/firmware/application/CMakeLists.txt b/firmware/application/CMakeLists.txt index f9995934..d0719340 100644 --- a/firmware/application/CMakeLists.txt +++ b/firmware/application/CMakeLists.txt @@ -305,3 +305,8 @@ add_custom_command( COMMAND ${CMAKE_OBJCOPY} -O binary ${PROJECT_NAME}.elf ${PROJECT_NAME}.bin DEPENDS ${PROJECT_NAME}.elf ) + +add_custom_target( + ${PROJECT_NAME} + DEPENDS ${PROJECT_NAME}.bin +) diff --git a/firmware/baseband/CMakeLists.txt b/firmware/baseband/CMakeLists.txt index dfc7d686..6d30a8ec 100644 --- a/firmware/baseband/CMakeLists.txt +++ b/firmware/baseband/CMakeLists.txt @@ -26,7 +26,7 @@ enable_language(C CXX ASM) -project(baseband) +project(baseband_shared) # Compiler options here. set(USE_OPT "-O3 -falign-functions=16 -fno-math-errno --specs=nano.specs") @@ -253,22 +253,18 @@ macro(DeclareTargets chunk_tag name) project("baseband_${name}") include(${RULESPATH}/rules.cmake) - add_executable(${PROJECT_NAME}.elf $ ${MODE_CPPSRC} ${LDSCRIPT}) + add_executable(${PROJECT_NAME}.elf $ ${MODE_CPPSRC} ${LDSCRIPT}) add_definitions(${DEFS}) include_directories(. ${INCDIR}) link_directories(${LLIBDIR}) target_link_libraries(${PROJECT_NAME}.elf ${LIBS}) add_custom_command( - OUTPUT ${PROJECT_NAME}.bin + OUTPUT ${PROJECT_NAME}.bin ${PROJECT_NAME}.img COMMAND ${CMAKE_OBJCOPY} -O binary ${PROJECT_NAME}.elf ${PROJECT_NAME}.bin - DEPENDS ${PROJECT_NAME}.elf - ) - - add_custom_command( - OUTPUT ${PROJECT_NAME}.img COMMAND ${MAKE_IMAGE_CHUNK} ${PROJECT_NAME}.bin ${chunk_tag} ${PROJECT_NAME}.img - DEPENDS ${PROJECT_NAME}.bin ${MAKE_IMAGE_CHUNK} + DEPENDS ${PROJECT_NAME}.elf ${MAKE_IMAGE_CHUNK} + VERBATIM ) set(BASEBAND_IMAGES ${BASEBAND_IMAGES} ${PROJECT_NAME}.img) @@ -333,15 +329,11 @@ DeclareTargets(PSPE wideband_spectrum) ### HackRF "factory" firmware add_custom_command( - OUTPUT hackrf.bin + OUTPUT hackrf.bin hackrf.img COMMAND ${STRIP_DFU} ${HACKRF_FIRMWARE_IMAGE} hackrf.bin - DEPENDS ${HACKRF_FIRMWARE_IMAGE} ${STRIP_DFU} -) - -add_custom_command( - OUTPUT hackrf.img COMMAND ${MAKE_IMAGE_CHUNK} hackrf.bin HRF1 hackrf.img - DEPENDS hackrf.bin ${MAKE_IMAGE_CHUNK} + DEPENDS ${HACKRF_FIRMWARE_IMAGE} ${STRIP_DFU} ${MAKE_IMAGE_CHUNK} + VERBATIM ) set(BASEBAND_IMAGES ${BASEBAND_IMAGES} hackrf.img) @@ -352,12 +344,23 @@ add_custom_command( OUTPUT terminator.img COMMAND ${MAKE_IMAGE_CHUNK} terminator.img DEPENDS ${MAKE_IMAGE_CHUNK} + VERBATIM ) +set(BASEBAND_IMAGES ${BASEBAND_IMAGES} terminator.img) + ####################################################################### -add_custom_target( - baseband.img - COMMAND cat ${BASEBAND_IMAGES} terminator.img >baseband.img - DEPENDS ${BASEBAND_IMAGES} terminator.img +project(baseband) + +add_custom_command( + OUTPUT ${PROJECT_NAME}.img + COMMAND cat ${BASEBAND_IMAGES} > ${PROJECT_NAME}.img + DEPENDS ${BASEBAND_IMAGES} + VERBATIM +) + +add_custom_target( + ${PROJECT_NAME} + DEPENDS ${PROJECT_NAME}.img ) diff --git a/firmware/bootstrap/CMakeLists.txt b/firmware/bootstrap/CMakeLists.txt index 07c8abe1..35af3025 100644 --- a/firmware/bootstrap/CMakeLists.txt +++ b/firmware/bootstrap/CMakeLists.txt @@ -204,3 +204,8 @@ add_custom_command( COMMAND ${CMAKE_OBJCOPY} -O binary ${PROJECT_NAME}.elf ${PROJECT_NAME}.bin DEPENDS ${PROJECT_NAME}.elf ) + +add_custom_target( + bootstrap + DEPENDS ${PROJECT_NAME}.bin +)