From 0fe51fa7e34d414dabd99dee88307731297c2c55 Mon Sep 17 00:00:00 2001 From: "E.T." Date: Sun, 22 Feb 2026 21:21:03 +0100 Subject: [PATCH] Move flashsize.h to build directory to avoid conflicts when switching between different builds (#3021) * Move flashsize.h to build directory to avoid conflicts when switching builds plus small fix in praline image generation * Update hackrf submodule to latest next * fix fpga append comments * Update firmware/CMakeLists.txt Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update firmware/CMakeLists.txt Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * remove ls dependency from build --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: gullradriel --- .gitignore | 2 - CMakeLists.txt | 3 - firmware/CMakeLists.txt | 59 +++++++++++-------- .../application/apps/ui_flash_utility.hpp | 2 - firmware/application/shell.cpp | 1 - firmware/baseband/proc_flash_utility.cpp | 2 - firmware/common/memory_map.hpp | 1 - flashsize.h.in => firmware/flashsize.h.in | 0 8 files changed, 33 insertions(+), 37 deletions(-) rename flashsize.h.in => firmware/flashsize.h.in (100%) diff --git a/.gitignore b/.gitignore index 5dd1a8ef6..dae8329db 100644 --- a/.gitignore +++ b/.gitignore @@ -83,5 +83,3 @@ venv/ # generated bitmap arr file # TODO: generate bitmap during build, since we use python during build anyway, lemme know if this is a bad idea @zxkmm /firmware/tools/bitmap.hpp -# flashsize is generated by cmake -/firmware/flashsize.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e7f2c72af..08bda7fc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,9 +58,6 @@ else() math(EXPR FLASH_BYTES_LIMIT_SIZE "${FLASH_MB_LIMIT_SIZE} * 1024 * 1024") endif() -#generate h files -configure_file(flashsize.h.in ${CMAKE_CURRENT_SOURCE_DIR}/firmware/flashsize.h) - option(USE_CCACHE "Enable ccache, please keep an eye on this because sometimes it's not quite stable and generated unusable binary" OFF) project(portapack-h1) diff --git a/firmware/CMakeLists.txt b/firmware/CMakeLists.txt index 0783692b8..ada583cb6 100644 --- a/firmware/CMakeLists.txt +++ b/firmware/CMakeLists.txt @@ -48,43 +48,50 @@ if(NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_EQUAL ${EXPECTED_GCC_VERSION}) set(GCC_VERSION_MISMATCH 1) endif() +#generate h files +configure_file(flashsize.h.in flashsize.h) +add_compile_options(-include ${CMAKE_CURRENT_BINARY_DIR}/flashsize.h) + add_subdirectory(application) add_subdirectory(baseband) add_subdirectory(standalone) add_subdirectory(test) -# NOTE: Dependencies break if the .bin files aren't included in DEPENDS. WTF, CMake? -add_custom_command( - OUTPUT ${FIRMWARE_FILENAME} - COMMAND ${MAKE_SPI_IMAGE} ${application_BINARY_DIR}/application.bin ${baseband_BINARY_DIR}/baseband.img ${FIRMWARE_FILENAME} ${FLASH_BYTES_LIMIT_SIZE} - DEPENDS baseband application ${MAKE_SPI_IMAGE} - ${baseband_BINARY_DIR}/baseband.img ${application_BINARY_DIR}/application.bin - VERBATIM -) +if(BOARD STREQUAL "PRALINE") + math(EXPR PRALINE_FINAL_SIZE "4 * 1024 * 1024") + set(PRALINE_FPGA_BIN ${CMAKE_CURRENT_SOURCE_DIR}/../hackrf/firmware/fpga/build/praline_fpga.bin) + set(APPEND_FPGA_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/tools/append_fpga_bitstream.py) + + # NOTE: Dependencies break if the .bin files aren't included in DEPENDS. WTF, CMake? + add_custom_command( + OUTPUT ${FIRMWARE_FILENAME} + COMMAND ${MAKE_SPI_IMAGE} ${application_BINARY_DIR}/application.bin ${baseband_BINARY_DIR}/baseband.img ${FIRMWARE_FILENAME} ${FLASH_BYTES_LIMIT_SIZE} + # PRALINE: Append FPGA bitstream to firmware at offset 0x380000 + # The base firmware is 3.5MB, FPGA bitstream gets appended at the end of it, final size is 4MB + COMMAND ${CMAKE_COMMAND} -E echo "Appending PRALINE FPGA bitstream to firmware..." + COMMAND python3 ${APPEND_FPGA_SCRIPT} ${FIRMWARE_FILENAME} ${PRALINE_FPGA_BIN} ${FIRMWARE_FILENAME}.tmp ${PRALINE_FINAL_SIZE} + COMMAND ${CMAKE_COMMAND} -E rename ${FIRMWARE_FILENAME}.tmp ${FIRMWARE_FILENAME} + DEPENDS baseband application ${MAKE_SPI_IMAGE} + ${baseband_BINARY_DIR}/baseband.img ${application_BINARY_DIR}/application.bin + ${PRALINE_FPGA_BIN} ${APPEND_FPGA_SCRIPT} + VERBATIM + ) +else() # Sadly this part had to be duplicated (or at least I couldn't find a better way to do it) + # NOTE: Dependencies break if the .bin files aren't included in DEPENDS. WTF, CMake? + add_custom_command( + OUTPUT ${FIRMWARE_FILENAME} + COMMAND ${MAKE_SPI_IMAGE} ${application_BINARY_DIR}/application.bin ${baseband_BINARY_DIR}/baseband.img ${FIRMWARE_FILENAME} ${FLASH_BYTES_LIMIT_SIZE} + DEPENDS baseband application ${MAKE_SPI_IMAGE} + ${baseband_BINARY_DIR}/baseband.img ${application_BINARY_DIR}/application.bin + VERBATIM + ) +endif() add_custom_target( firmware DEPENDS ${FIRMWARE_FILENAME} ${HACKRF_FIRMWARE_DFU_FILENAME} ${HACKRF_FIRMWARE_FILENAME} ) -# PRALINE: Append FPGA bitstream to firmware at offset 0x180000 -# The base firmware is 1MB, FPGA goes at 1MB offset, final size is 2MB -if(BOARD STREQUAL "PRALINE") - math(EXPR PRALINE_FINAL_SIZE "4 * 1024 * 1024") - set(PRALINE_FPGA_BIN ${CMAKE_CURRENT_SOURCE_DIR}/../hackrf/firmware/fpga/build/praline_fpga.bin) - set(APPEND_FPGA_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/tools/append_fpga_bitstream.py) - add_custom_command( - TARGET firmware POST_BUILD - COMMAND ${CMAKE_COMMAND} -E echo "Appending PRALINE FPGA bitstream to firmware..." - COMMAND python3 ${APPEND_FPGA_SCRIPT} ${FIRMWARE_FILENAME} ${PRALINE_FPGA_BIN} ${FIRMWARE_FILENAME}.tmp ${PRALINE_FINAL_SIZE} - COMMAND ${CMAKE_COMMAND} -E rename ${FIRMWARE_FILENAME}.tmp ${FIRMWARE_FILENAME} - COMMAND ${CMAKE_COMMAND} -E echo "PRALINE firmware with FPGA bitstream created:" - COMMAND ls -la ${FIRMWARE_FILENAME} - COMMENT "Appending PRALINE FPGA bitstream" - VERBATIM - ) -endif() - if(${GCC_VERSION_MISMATCH}) set(COMPILER_MISMATCH_MESSAGE "WARNING: Compiler version mismatch, please use the official compiler version ${EXPECTED_GCC_VERSION} when sharing builds! Current compiler version: ${CMAKE_CXX_COMPILER_VERSION}") message(${COMPILER_MISMATCH_MESSAGE}) diff --git a/firmware/application/apps/ui_flash_utility.hpp b/firmware/application/apps/ui_flash_utility.hpp index bb393e87a..e1a0d82d3 100644 --- a/firmware/application/apps/ui_flash_utility.hpp +++ b/firmware/application/apps/ui_flash_utility.hpp @@ -32,8 +32,6 @@ #include "untar.hpp" #include -#include "../../flashsize.h" - #define FLASH_ROM_SIZE (FLASH_SIZE_MB * 1024 * 1024) #define FLASH_STARTING_ADDRESS 0x00000000 #define FLASH_EXPECTED_CHECKSUM 0x00000000 diff --git a/firmware/application/shell.cpp b/firmware/application/shell.cpp index 398e386d9..67ae90744 100644 --- a/firmware/application/shell.cpp +++ b/firmware/application/shell.cpp @@ -31,7 +31,6 @@ #include "shell.hpp" #include "chprintf.h" #include "portapack.hpp" -#include "../flashsize.h" extern "C" { #include "platform_detect.h" diff --git a/firmware/baseband/proc_flash_utility.cpp b/firmware/baseband/proc_flash_utility.cpp index 85a5587f8..69096f35b 100644 --- a/firmware/baseband/proc_flash_utility.cpp +++ b/firmware/baseband/proc_flash_utility.cpp @@ -28,8 +28,6 @@ #include "debug.hpp" #include "portapack_shared_memory.hpp" -#include "../flashsize.h" - #define PAGE_LEN 256U #define NUM_PAGES (4096U * FLASH_SIZE_MB) diff --git a/firmware/common/memory_map.hpp b/firmware/common/memory_map.hpp index 8a35916be..fd5e10e62 100644 --- a/firmware/common/memory_map.hpp +++ b/firmware/common/memory_map.hpp @@ -29,7 +29,6 @@ using namespace lpc43xx; #include "utility.hpp" -#include "../flashsize.h" namespace portapack { namespace memory { diff --git a/flashsize.h.in b/firmware/flashsize.h.in similarity index 100% rename from flashsize.h.in rename to firmware/flashsize.h.in