mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-12 17:49:31 +00:00
Add HackRF Pro (PRALINE) Board Detection and Info Display (#3006)
This commit is contained in:
@@ -46,11 +46,10 @@ bool valid_firmware_file(std::filesystem::path::string_type path) {
|
|||||||
auto result = firmware_file.open(path.c_str());
|
auto result = firmware_file.open(path.c_str());
|
||||||
if (!result.is_valid()) {
|
if (!result.is_valid()) {
|
||||||
uint64_t file_size = firmware_file.size();
|
uint64_t file_size = firmware_file.size();
|
||||||
if (portapack::device_type == portapack::DeviceType::DEV_PORTAPACK && file_size > 1 * 1024 * 1024) {
|
if (file_size > FLASH_ROM_SIZE) {
|
||||||
// Portapack firmware files must not be larger than 1MB
|
// Firmware file is larger than the flash size for this device
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// May need to add a check to portarf and portarf pro too.
|
|
||||||
checksum = 0;
|
checksum = 0;
|
||||||
for (uint64_t offset = 0; offset < FLASH_ROM_SIZE && offset < file_size; offset += sizeof(read_buffer)) {
|
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));
|
auto readResult = firmware_file.read(&read_buffer, sizeof(read_buffer));
|
||||||
|
|||||||
@@ -56,11 +56,9 @@ using asahi_kasei::ak4951::AK4951;
|
|||||||
#include "i2cdevmanager.hpp"
|
#include "i2cdevmanager.hpp"
|
||||||
#include "battery.hpp"
|
#include "battery.hpp"
|
||||||
|
|
||||||
#ifndef PRALINE
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "platform_detect.h"
|
#include "platform_detect.h"
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace portapack {
|
namespace portapack {
|
||||||
|
|
||||||
@@ -555,12 +553,10 @@ init_status_t init() {
|
|||||||
|
|
||||||
chThdSleepMilliseconds(100);
|
chThdSleepMilliseconds(100);
|
||||||
|
|
||||||
#ifndef PRALINE
|
|
||||||
detect_hardware_platform();
|
detect_hardware_platform();
|
||||||
finalize_detect_hardware_platform();
|
finalize_detect_hardware_platform();
|
||||||
|
|
||||||
chThdSleepMilliseconds(100);
|
chThdSleepMilliseconds(100);
|
||||||
#endif
|
|
||||||
|
|
||||||
configure_pins_portapack();
|
configure_pins_portapack();
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include "shell.hpp"
|
#include "shell.hpp"
|
||||||
#include "chprintf.h"
|
#include "chprintf.h"
|
||||||
#include "portapack.hpp"
|
#include "portapack.hpp"
|
||||||
|
#include "../flashsize.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "platform_detect.h"
|
#include "platform_detect.h"
|
||||||
@@ -93,6 +94,22 @@ static const char* get_board_revision_string(board_rev_t rev) {
|
|||||||
return "GSG HackRF R9";
|
return "GSG HackRF R9";
|
||||||
case BOARD_REV_GSG_HACKRF1_R10:
|
case BOARD_REV_GSG_HACKRF1_R10:
|
||||||
return "GSG HackRF 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:
|
case BOARD_REV_UNRECOGNIZED:
|
||||||
return "Unrecognized";
|
return "Unrecognized";
|
||||||
case BOARD_REV_UNDETECTED:
|
case BOARD_REV_UNDETECTED:
|
||||||
@@ -134,6 +151,36 @@ static void cmd_info(BaseSequentialStream* chp, int argc, char* argv[]) {
|
|||||||
board_rev_t revision = detected_revision();
|
board_rev_t revision = detected_revision();
|
||||||
const char* revision_string = get_board_revision_string(revision);
|
const char* revision_string = get_board_revision_string(revision);
|
||||||
chprintf(chp, "HackRF Board Rev: %s\r\n", revision_string);
|
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 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());
|
chprintf(chp, "Reference Freq: %s\r\n", portapack::clock_manager.get_freq().c_str());
|
||||||
#ifdef __DATE__
|
#ifdef __DATE__
|
||||||
|
|||||||
@@ -1386,18 +1386,34 @@ static void cmd_getres(BaseSequentialStream* chp, int argc, char* argv[]) {
|
|||||||
static void cmd_getflash(BaseSequentialStream* chp, int argc, char* argv[]) {
|
static void cmd_getflash(BaseSequentialStream* chp, int argc, char* argv[]) {
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(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) {
|
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());
|
chprintf(chp, res.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_getdevtype(BaseSequentialStream* chp, int argc, char* argv[]) {
|
static void cmd_getdevtype(BaseSequentialStream* chp, int argc, char* argv[]) {
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(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";
|
res += "\r\nok\r\n";
|
||||||
chprintf(chp, res.c_str());
|
chprintf(chp, res.c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
Submodule hackrf updated: 8a416fc913...f56e711b6b
Reference in New Issue
Block a user