Skip to content

Unified Firmware#1657

Draft
antoinevg wants to merge 25 commits intogreatscottgadgets:mainfrom
antoinevg:antoinevg/unified-firmware
Draft

Unified Firmware#1657
antoinevg wants to merge 25 commits intogreatscottgadgets:mainfrom
antoinevg:antoinevg/unified-firmware

Conversation

@antoinevg
Copy link
Copy Markdown
Member

@antoinevg antoinevg commented Jan 27, 2026

This PR introduces a new BOARD target called UNIVERSAL that can be used to compile a combined firmware that supports both HackRF One and HackRF Pro hardware.

Conventions

It introduces a new pattern to the code base for working with board support.

Previously, we used a mix of patterns of the form #ifdef HACKRF_ONE or #ifndef PRALINE in conjunction with platform_detect.detected_platform() to manage board differences.

This PR applies the following new patterns across the codebase:

  • Conditional directives now only serve as guards for what code gets linked into the firmware for a given board.
  • To control code execution always use if (detected_platform() == BOARD_ID_x) or switch (detected_platform())
  • Conditional directives of the form #ifdef SOME_BOARD become #if defined(SOME_BOARD) or #ifndef SOME_BOARD becomes #if !defined(SOME_BOARD). This keeps usage consistent with the next point.
  • Specifically, for HACKRF_ONE and PRALINE always include the UNIVERSAL target to ensure the code will be present in the combined firmware binary. For example: #if defined(PRALINE) || defined(UNIVERSAL)
  • Be careful of #else, this caught me a few times:
#if defined(PRALINE) || defined(UNIVERSAL)`
    ... some code ...
#else
    ... this code now gets left out of UNIVERSAL ...
#endif

Make sure to use this form instead:

#if defined(PRALINE) || defined(UNIVERSAL)`
    ... some code ...
#endif
#if !defined(PRALINE) || defined(UNIVERSAL)`
    ... this code is now also included in UNIVERSAL ...
#endif

Compilation

mkdir firmware/build
cd firmware/build
cmake .. -DBOARD=UNIVERSAL
make

Size impact

Single-board firmware are slightly bigger as a result:

PRALINE:     was: 240288  => now:  243336  difference: 3048
HACKRF_ONE:  was:  45920  => now:   48672  difference: 2752
RAD1O:       was:  75244  => now:   77548  difference: 2304
JAWBREAKER:  was:  38060  => now:   39988  difference: 1928
JELLYBEAN:   was:    n/a  => now:   39204

The size increase is mostly due to:

  • platform_scu: 968 bytes
  • platform_gpio: 1044 bytes

…with the remaining being due to runtime platform detection across the rest of the code-base.

The combined firmware comes to 258376 bytes.

Testing

This PR has been tested with both single-board and combined firmware using hackrf.git/ci-scripts/hackrf-test.py and praline-factory-test.git/bin/hackrf_test.py in the following configurations:

EUT: Hackrf One r4, TESTER: HackRF One r10c Portapack H4M clone from SDRStore

python hackrf_test.py --unattended --ci --eut $EUT --tester $TESTER --rev any -f $FIRMWARE -L /tmp/log

EUT: Hackrf Pro, TESTER: HackRF One r4

python hackrf_test.py --factory -p --eut $EUT --tester $TESTER --rev any -f $FIRMWARE -L /tmp/log --tcxo

Future Work

Now that conditional compilation directives are no longer used to control code execution we have the opportunity to consider whether we should follow the example of firmware/common/rad1o/ and add firmware/common/hackrf_one/ and firmware/common/praline/ directories.


  • Finish up proof of concept for rf_path.c
  • Add max2831 support to max283x
  • Refactor remaining gpio's into platform_gpio.c
  • Refactor remaining scu's into platform_scu.c
  • Figure out how to handle config & drivers that need to setup early
  • Figure out how to handle LED's for platform_detect.c
  • Refactor remaining #ifdefs
  • Get PRALINE binary booting on HACKRF_ONE
  • Test. Test. Test.
  • Clean up #includes
  • Fix MCU LED not lighting up on HackRF Pro
  • Fix supported platforms text in hackrf_info
  • Add platform compilation conditionals back

@antoinevg antoinevg force-pushed the antoinevg/unified-firmware branch 13 times, most recently from 9b27e37 to 40b52af Compare February 3, 2026 14:37
@antoinevg antoinevg force-pushed the antoinevg/unified-firmware branch 8 times, most recently from 8f63bbb to af22ea6 Compare February 5, 2026 16:00
@antoinevg antoinevg force-pushed the antoinevg/unified-firmware branch 7 times, most recently from 1a1911b to 13a82d5 Compare February 13, 2026 07:03
@antoinevg antoinevg force-pushed the antoinevg/unified-firmware branch 2 times, most recently from 2f96cc9 to fd50120 Compare March 2, 2026 09:52
@antoinevg antoinevg force-pushed the antoinevg/unified-firmware branch from fd50120 to 8aba74e Compare March 2, 2026 10:04
@antoinevg antoinevg marked this pull request as draft March 3, 2026 07:40
This was referenced Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants