From 5bd02cd2c08568cb96a58cb33fd4147eb53e3ac6 Mon Sep 17 00:00:00 2001 From: Eisenberger Tamas Date: Fri, 20 Feb 2026 22:51:58 +0100 Subject: [PATCH] remove flashsize schenanigans from the host tools, just allow max 4mb flash size always --- host/CMakeLists.txt | 25 ------------------------- host/libhackrf/src/hackrf.c | 6 +----- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index ce534b196..dec6f8e00 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -5,31 +5,6 @@ project(HackRF C) set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -if(NOT DEFINED FLASH_MB_SIZE) - set(FLASH_MB_SIZE 1) # Default to 1MB if not provided. For PortaRf this should be 2MB passed to cmake with -DFLASH_MB_SIZE=2 -endif() -message("Configuring for FLASH_MB_SIZE=${FLASH_MB_SIZE}MB") -#This is the flash memory size we build. This can be less, so the FW size will be less, so can be flashed with older utils. -if(NOT DEFINED FLASH_MB_LIMIT_SIZE) - set(FLASH_MB_LIMIT_SIZE 1) #TODO: should be ${FLASH_MB_SIZE} remove once we got a stable build for all devices we support with bigger than 1 mb flash -endif() -message("Configuring for FLASH_MB_LIMIT_SIZE=${FLASH_MB_LIMIT_SIZE}MB") - -if(FLASH_MB_SIZE LESS FLASH_MB_LIMIT_SIZE) - message(FATAL_ERROR "Error: The supported flash size is lower than the generated flash file. Build halted.") -endif() - -if(NOT DEFINED FLASH_BYTES_SIZE) - math(EXPR FLASH_BYTES_SIZE "${FLASH_MB_SIZE} * 1024 * 1024") -endif() -if(NOT DEFINED FLASH_BYTES_LIMIT_SIZE) - math(EXPR FLASH_BYTES_LIMIT_SIZE "${FLASH_MB_LIMIT_SIZE} * 1024 * 1024") -endif() - -#generate h file -configure_file(../flashsize.h.in ${CMAKE_CURRENT_SOURCE_DIR}/../flashsize.h) - - set(CMAKE_C_FLAGS "$ENV{CFLAGS}" CACHE STRING "C Flags") diff --git a/host/libhackrf/src/hackrf.c b/host/libhackrf/src/hackrf.c index 701010818..e1bc09c0a 100644 --- a/host/libhackrf/src/hackrf.c +++ b/host/libhackrf/src/hackrf.c @@ -22,7 +22,6 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI */ #include "hackrf.h" -#include "../../../flashsize.h" #include #include #include @@ -1515,10 +1514,7 @@ int ADDCALL hackrf_spiflash_write( { int result; - /* Reject writes that would go past the end of SPI flash (and avoid overflow). */ - const uint32_t flash_size_bytes = FLASH_SIZE_MB * 1024u * 1024u; - - if (address >= flash_size_bytes || length > (flash_size_bytes - address)) { + if ((address + length) > 0x400000) { return HACKRF_ERROR_INVALID_PARAM; }