From 77f747aab27822d5129bc7d3f9326f058af5e5d1 Mon Sep 17 00:00:00 2001 From: jLynx <4393979+jLynx@users.noreply.github.com> Date: Thu, 19 Feb 2026 07:56:22 +0000 Subject: [PATCH] Add HackRF Pro (PRALINE) Board Detection and Info Display (#3006) --- .../application/apps/ui_flash_utility.cpp | 5 +- firmware/application/portapack.cpp | 4 -- firmware/application/shell.cpp | 47 +++++++++++++++++++ firmware/application/usb_serial_shell.cpp | 24 ++++++++-- hackrf | 2 +- 5 files changed, 70 insertions(+), 12 deletions(-) diff --git a/firmware/application/apps/ui_flash_utility.cpp b/firmware/application/apps/ui_flash_utility.cpp index fcaf160f5..c9ff3f081 100644 --- a/firmware/application/apps/ui_flash_utility.cpp +++ b/firmware/application/apps/ui_flash_utility.cpp @@ -46,11 +46,10 @@ bool valid_firmware_file(std::filesystem::path::string_type path) { auto result = firmware_file.open(path.c_str()); if (!result.is_valid()) { uint64_t file_size = firmware_file.size(); - if (portapack::device_type == portapack::DeviceType::DEV_PORTAPACK && file_size > 1 * 1024 * 1024) { - // Portapack firmware files must not be larger than 1MB + if (file_size > FLASH_ROM_SIZE) { + // Firmware file is larger than the flash size for this device return false; } - // May need to add a check to portarf and portarf pro too. checksum = 0; for (uint64_t offset = 0; offset < FLASH_ROM_SIZE && offset < file_size; offset += sizeof(read_buffer)) { auto readResult = firmware_file.read(&read_buffer, sizeof(read_buffer)); diff --git a/firmware/application/portapack.cpp b/firmware/application/portapack.cpp index aa8bf100d..0ad489bd1 100644 --- a/firmware/application/portapack.cpp +++ b/firmware/application/portapack.cpp @@ -56,11 +56,9 @@ using asahi_kasei::ak4951::AK4951; #include "i2cdevmanager.hpp" #include "battery.hpp" -#ifndef PRALINE extern "C" { #include "platform_detect.h" } -#endif namespace portapack { @@ -555,12 +553,10 @@ init_status_t init() { chThdSleepMilliseconds(100); -#ifndef PRALINE detect_hardware_platform(); finalize_detect_hardware_platform(); chThdSleepMilliseconds(100); -#endif configure_pins_portapack(); diff --git a/firmware/application/shell.cpp b/firmware/application/shell.cpp index 6ba4887b8..398e386d9 100644 --- a/firmware/application/shell.cpp +++ b/firmware/application/shell.cpp @@ -31,6 +31,7 @@ #include "shell.hpp" #include "chprintf.h" #include "portapack.hpp" +#include "../flashsize.h" extern "C" { #include "platform_detect.h" @@ -93,6 +94,22 @@ static const char* get_board_revision_string(board_rev_t rev) { return "GSG HackRF R9"; case BOARD_REV_GSG_HACKRF1_R10: return "GSG HackRF R10"; + case BOARD_REV_PRALINE_R0_1: + case BOARD_REV_PRALINE_R0_2: + case BOARD_REV_PRALINE_R0_3: + return "HackRF Pro R0"; + case BOARD_REV_PRALINE_R1_0: + case BOARD_REV_PRALINE_R1_1: + case BOARD_REV_PRALINE_R1_2: + return "HackRF Pro R1"; + case BOARD_REV_GSG_PRALINE_R0_1: + case BOARD_REV_GSG_PRALINE_R0_2: + case BOARD_REV_GSG_PRALINE_R0_3: + return "GSG HackRF Pro R0"; + case BOARD_REV_GSG_PRALINE_R1_0: + case BOARD_REV_GSG_PRALINE_R1_1: + case BOARD_REV_GSG_PRALINE_R1_2: + return "GSG HackRF Pro R1"; case BOARD_REV_UNRECOGNIZED: return "Unrecognized"; case BOARD_REV_UNDETECTED: @@ -134,6 +151,36 @@ static void cmd_info(BaseSequentialStream* chp, int argc, char* argv[]) { board_rev_t revision = detected_revision(); const char* revision_string = get_board_revision_string(revision); chprintf(chp, "HackRF Board Rev: %s\r\n", revision_string); + + // Determine device type string + const char* device_str; +#ifdef PRALINE + device_str = "HackRF Pro"; +#else + if (portapack::device_type == portapack::DEV_PORTARF) { + device_str = "PortaRF"; + } else { + device_str = "HackRF One"; + } +#endif + chprintf(chp, "Device: %s\r\n", device_str); + + // Flash info: build-time allowed MB, runtime-detected limit, current firmware size + // Use explicit uint32_t cast: FLASH_SIZE_LIMIT_MB may be a float (e.g. 3.5 for HPro) + uint8_t flash_allowrun; +#ifdef PRALINE + flash_allowrun = 4; // HackRF Pro +#else + if (portapack::device_type == portapack::DeviceType::DEV_PORTAPACK) { + flash_allowrun = 1; // PortaPack classic + } else { + flash_allowrun = FLASH_SIZE_MB; // PortaRF + } +#endif + chprintf(chp, "Flash Allowed: %dMB\r\n", (uint32_t)FLASH_SIZE_MB); + chprintf(chp, "Flash Runtime: %dMB\r\n", (uint32_t)flash_allowrun); + chprintf(chp, "Flash Current: %dMB\r\n", (uint32_t)FLASH_SIZE_LIMIT_MB); + chprintf(chp, "Reference Source: %s\r\n", portapack::clock_manager.get_source().c_str()); chprintf(chp, "Reference Freq: %s\r\n", portapack::clock_manager.get_freq().c_str()); #ifdef __DATE__ diff --git a/firmware/application/usb_serial_shell.cpp b/firmware/application/usb_serial_shell.cpp index 610b452c7..e1e0bd4f4 100644 --- a/firmware/application/usb_serial_shell.cpp +++ b/firmware/application/usb_serial_shell.cpp @@ -1386,18 +1386,34 @@ static void cmd_getres(BaseSequentialStream* chp, int argc, char* argv[]) { static void cmd_getflash(BaseSequentialStream* chp, int argc, char* argv[]) { (void)argc; (void)argv; - uint8_t allowrun = FLASH_SIZE_MB; + // FLASH_SIZE_LIMIT_MB may be a float (e.g. 3.5 for HPro), always cast explicitly. + uint8_t allowrun; +#ifdef PRALINE + allowrun = 4; // HackRF Pro +#else if (portapack::device_type == portapack::DeviceType::DEV_PORTAPACK) { - allowrun = 1; + allowrun = 1; // PortaPack classic + } else { + allowrun = FLASH_SIZE_MB; // PortaRF } - std::string res = "ALLOWEDFW:" + to_string_dec_uint(FLASH_SIZE_MB) + "\r\nALLOWEDRUNTIME:" + to_string_dec_uint(allowrun) + "\r\nCURRENT:" + to_string_dec_uint(FLASH_SIZE_LIMIT_MB) + "\r\nok\r\n"; +#endif + std::string res = "ALLOWEDFW:" + to_string_dec_uint((uint32_t)FLASH_SIZE_MB) + "\r\nALLOWEDRUNTIME:" + to_string_dec_uint((uint32_t)allowrun) + "\r\nCURRENT:" + to_string_dec_uint((uint32_t)FLASH_SIZE_LIMIT_MB) + "\r\nok\r\n"; chprintf(chp, res.c_str()); } static void cmd_getdevtype(BaseSequentialStream* chp, int argc, char* argv[]) { (void)argc; (void)argv; - std::string res = portapack::device_type == portapack::DeviceType::DEV_PORTARF ? "PORTARF" : "PORTAPACK"; + std::string res; +#ifdef PRALINE + res = "HPRO"; +#else + if (portapack::device_type == portapack::DeviceType::DEV_PORTARF) { + res = "PORTARF"; + } else { + res = "PORTAPACK"; + } +#endif res += "\r\nok\r\n"; chprintf(chp, res.c_str()); } diff --git a/hackrf b/hackrf index 8a416fc91..f56e711b6 160000 --- a/hackrf +++ b/hackrf @@ -1 +1 @@ -Subproject commit 8a416fc9135147b803d1851d9f5fc4c202fbcf95 +Subproject commit f56e711b6bc254a8ea5d25e90133b508de93bd56