HackRF Pro (praline) arch-port initial PR (#2958)

* Initial commit and pr for HackRF Pro (praline) arch-port to mayhem-firmware. Please see https://github.com/portapack-mayhem/mayhem-firmware/issues/2957. Added flash specifics for -DBOARD=PRALINE. This firmware only builds with toolchain v9.2.1 if hackrf codebase has -B arm in firmware/hackrf_usb/CMakeLists.txt.

* Updated CMakeLists.txt per coordination with @HtoToo. For -DBOARD=PRALINE FLASH_MB_SIZE and FLASH_MB_LIMIT_SIZE are now 4. Removed praline specific variable for FLASH limits.

* Updated chibios-portapack's board.cpp to support initialization of the HachRF-Pro (praline) FPGA. Added append_fpga_bitstream.py tool to ensure that praline_fgpa.bin bitstream can be appended to -DBOARD=PRALINE produced firmware. In order to ensure successful execution of append_fpga_bitstream.py to append the fpga bitstream we should expect that the bistsream will be located at 0x180000 in flash. This requires that FLASH_MB_LIMIT_SIZE must be 1.5, and FLASH_BYTES_LIMIT_SIZE must be 1535 * 1024. If we want to allow more or less space for the base firmware image sans the fpga bitstream the location of the bistream must be moved to a location other than 0x180000.

* Updated location of praline_fpga.bin bitstream to 0x380000 to allow more room for firmware. Firmware now has 3.5MB, or 2MB more available than before as coordinated with @HTotoo.

* Expanded #ifndef PRALINE to include og and r9 gpio and pin setup as coordinated with @HTotoo.

* Added note for PRALINE FLASH_MB_LIMIT_SIZE and FLASH_BYTES_LIMIT_SIZE to explain why we are using the 3.5 and 3584 values respectively as coordinated with @HTotoo.

* Next round of modifications derived heavily, if not entirely  from work done by @banandana at https://github.com/Banandana/mayhem-firmware. This commit should power on the HackRF Pro (praline) display, power on the fpga, and enable gpio, and provide debug utilties. There is still a lot of work to be done to fully enable the new praline board with this build and firmware architectural porting effort. However, hackrf-one boards do not seem to be adversely impacted by the #ifdef PRALINE statements, and CMakeLists updates, as far as I have been able to test.

* Ran format-code.sh. Updates for this commit are only due to formatting. Tested builds and they seem to work as exptected.

* Addressed fixes in firmware/application and firmware/baseband. Stream now flows to capture and looking glass. Issues were related to thread management. Issues were originally addressed by @banandana.

* Ran format-code.sh to allow for consistency with autoamted clang checks.

* Update hackrf ref repo to mayhem-portapack-hackrf next from https://github.com/portapack-mayhem/hackrf

* Addressed format edits necessary to pass clang-format check.

* Starting addressing Si5351 Clocks for radio sampling. These updates correctly set the Si5351 clock at start up. There appears to be an issue during runtime when testing with RX Test Init, Capture and Looking glass.

* Updated clock_manager.cpp to restore correct function introduced by @banandana when testing with Rx Test Init.

* Switched to using decimation for setting the sample rate without changing the Si5351 clock. This assumes that for the praline board Si5351 CLK0 runs at fixed 8 MHz (constant) and the FPGA decimates to get the desired sample rate. For example, for a 1 MHz sample rate -> Si5351 outputs 8 MHz, FPGA decimates by 8. There is still more work needed here, and potential verification that this is the correct way to operate with this new archteitecture.

* After deliberating on hackrf_usb hackrf_core.c and radio.c, and reviewing firmware/application/hw/si5351.cpp the original approach of using the aproach detailed in hackrf_core.c sample_rate_frac_set() lines 580-582, via the implementation in firmware/application/hw/si5351.cpp seems like the best place to continue testing efforts.

* Tested at ~2.4GHz (2.3 - 2.5) with lookgin glass and was able to receive signals. Added a Signal Path debug app to test gains, and readio mode (receive/transmit).

* Added two debug apps for the RFFC507x. Status View and Tuning View. This helped debug some of the potential issues with tuning.

* update submodule

* format code

* Small touch up merging latest next and ensuring build for HackRF One.

* Reverted edits to re: firmware/baseband/sd_over_usb/scsi.c and firmware/application/portapack.cpp. Source now builds, had to pull latest hackrf submodule.

* Skipped detect hardware for praline board to avoid backscreen in HackRF Pro praline board.

---------

Co-authored-by: gullradriel <gullradriel@users.noreply.github.com>
This commit is contained in:
stafur
2026-02-11 03:15:11 -05:00
committed by GitHub
parent cd30022b61
commit 39424632bb
50 changed files with 4822 additions and 48 deletions
+9 -2
View File
@@ -213,7 +213,11 @@ set(CPPWARN "-Wall -Wextra")
# List all default C defines here, like -D_DEBUG=1
# TODO: Switch -DCRT0_INIT_DATA depending on load from RAM or SPIFI?
# NOTE: _RANDOM_TCC to kill a GCC 4.9.3 error with std::max argument types
set(DDEFS "-DLPC43XX -DLPC43XX_M4 -D__NEWLIB__ -DHACKRF_ONE -DTOOLCHAIN_GCC -DTOOLCHAIN_GCC_ARM -D_RANDOM_TCC=0 -D'VERSION_STRING=\"${VERSION}\"'")
# Use BOARD variable if set, otherwise default to HACKRF_ONE
if(NOT DEFINED BOARD)
set(BOARD "HACKRF_ONE")
endif()
set(DDEFS "-DLPC43XX -DLPC43XX_M4 -D__NEWLIB__ -D${BOARD} -DTOOLCHAIN_GCC -DTOOLCHAIN_GCC_ARM -D_RANDOM_TCC=0 -D'VERSION_STRING=\"${VERSION}\"'")
# List all default ASM defines here, like -D_DEBUG=1
set(DADEFS)
@@ -621,7 +625,7 @@ DeclareTargets(PADT adsbtx)
### Binary Timed stream TX
set(MODE_CPPSRC
proc_bint_stream_tx.cpp
proc_bint_stream_tx.cpp
)
DeclareTargets(POSK bintstream)
@@ -725,7 +729,10 @@ set(MODE_CPPSRC
${HACKRF_PATH}/firmware/libopencm3/lib/lpc43xx/timer.c
${HACKRF_PATH}/firmware/libopencm3/lib/lpc43xx/i2c.c
)
# sd_over_usb has type conflicts with PRALINE (HackRF Pro) - disable for now
if(NOT BOARD STREQUAL "PRALINE")
DeclareTargets(PUSB sd_over_usb)
endif()
### HackRF "factory" firmware
+7
View File
@@ -110,6 +110,9 @@ volatile uint32_t buffer_handled = 0;
static void transfer_complete() {
const auto next_lli_index = gpdma_channel_sgpio.next_lli() - &lli_loop[0];
buffer_transfered++;
#ifdef PRALINE
shared_memory.m4_dma_xfr_count++; // Phase 0 instrumentation
#endif
thread_wait.wake_from_interrupt(next_lli_index);
}
@@ -161,6 +164,10 @@ void disable() {
}
baseband::buffer_t wait_for_buffer() {
#ifdef PRALINE
shared_memory.m4_dma_wait_count++; // Phase 0 instrumentation
#endif
const auto next_index = thread_wait.sleep();
buffer_handled++;
+7
View File
@@ -87,8 +87,15 @@ void BasebandThread::run() {
baseband_sgpio.configure(direction());
baseband::dma::enable(direction());
baseband_sgpio.streaming_enable();
#ifdef PRALINE
shared_memory.m4_streaming_marker = 0xAA; // Phase 0 instrumentation
#endif
while (!chThdShouldTerminate()) {
#ifdef PRALINE
shared_memory.m4_baseband_loops++; // Phase 0 instrumentation
#endif
// TODO: Place correct sampling rate into buffer returned here:
const auto buffer_tmp = baseband::dma::wait_for_buffer();
if (buffer_tmp) {
+3
View File
@@ -99,6 +99,9 @@ void EventDispatcher::on_message(const Message* const message) {
switch (message->id) {
case Message::ID::Shutdown:
on_message_shutdown(*reinterpret_cast<const ShutdownMessage*>(message));
#ifdef PRALINE
shared_memory.baseband_message = nullptr; // Must clear before M4 exits!
#endif
break;
default:
+6
View File
@@ -46,7 +46,13 @@ class EventDispatcher {
}
static inline void events_flag_isr(const eventmask_t events) {
#ifdef PRALINE
if (thread_event_loop) {
chEvtSignalI(thread_event_loop, events);
}
#else
chEvtSignalI(thread_event_loop, events);
#endif
}
private:
+10
View File
@@ -29,6 +29,16 @@
#include <array>
#include "dsp_hilbert.hpp"
// Phase 2: Constructor to start threads AFTER object is fully initialized
NarrowbandAMAudio::NarrowbandAMAudio() {
// Initialize members that threads might access
channel_spectrum.set_decimation_factor(1);
// Start threads AFTER everything initialized
baseband_thread.start();
rssi_thread.start();
}
void NarrowbandAMAudio::execute(const buffer_c8_t& buffer) {
if (!configured) {
return;
+8
View File
@@ -37,6 +37,8 @@
class NarrowbandAMAudio : public BasebandProcessor {
public:
NarrowbandAMAudio(); // Phase 2: Explicit constructor for manual thread start
void execute(const buffer_c8_t& buffer) override;
void on_message(const Message* const message) override;
@@ -74,8 +76,14 @@ class NarrowbandAMAudio : public BasebandProcessor {
SpectrumCollector channel_spectrum{};
/* NB: Threads should be the last members in the class definition. */
#ifndef PRALINE
BasebandThread baseband_thread{baseband_fs, this, baseband::Direction::Receive};
RSSIThread rssi_thread{};
#else
BasebandThread baseband_thread{baseband_fs, this, baseband::Direction::Receive,
/*auto_start*/ false}; // Phase 2: Manual start
RSSIThread rssi_thread{/*auto_start*/ false}; // Phase 2: Manual start
#endif
void configure(const AMConfigureMessage& message);
void capture_config(const CaptureConfigMessage& message);
+12
View File
@@ -31,6 +31,18 @@
#include <cstdint>
#include <cstddef>
#ifdef PRALINE
// Phase 2: Constructor to start threads AFTER object is fully initialized
NarrowbandFMAudio::NarrowbandFMAudio() {
// Initialize members that threads might access
channel_spectrum.set_decimation_factor(1);
// Start threads AFTER everything initialized
baseband_thread.start();
rssi_thread.start();
}
#endif
void NarrowbandFMAudio::execute(const buffer_c8_t& buffer) {
// bool new_state;
+10
View File
@@ -41,6 +41,10 @@
class NarrowbandFMAudio : public BasebandProcessor {
public:
#ifdef PRALINE
NarrowbandFMAudio(); // Phase 2: Explicit constructor for manual thread start
#endif
void execute(const buffer_c8_t& buffer) override;
void on_message(const Message* const message) override;
@@ -97,8 +101,14 @@ class NarrowbandFMAudio : public BasebandProcessor {
CodedSquelchMessage ctcss_message{0};
/* NB: Threads should be the last members in the class definition. */
#ifdef PRALINE
BasebandThread baseband_thread{baseband_fs, this, baseband::Direction::Receive,
/*auto_start*/ false}; // Phase 2: Manual start
RSSIThread rssi_thread{/*auto_start*/ false}; // Phase 2: Manual start
#else
BasebandThread baseband_thread{baseband_fs, this, baseband::Direction::Receive};
RSSIThread rssi_thread{};
#endif
void pitch_rssi_config(const PitchRSSIConfigureMessage& message);
void configure(const NBFMConfigureMessage& message);