Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 1 addition & 5 deletions host/libhackrf/src/hackrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdbool.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -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;
}

Expand Down