Skip to content
Closed
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
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
strategy:
matrix:
os: ['macos', 'ubuntu', 'windows']
board: ['HACKRF_ONE', 'JAWBREAKER', 'RAD1O', 'PRALINE']
board: ['HACKRF_ONE', 'JAWBREAKER', 'RAD1O', 'PRALINE', 'UNIVERSAL']
cmake: ['3.10.0', 'latest']
exclude:
- os: 'windows'
Expand All @@ -186,7 +186,7 @@ jobs:

- name: Install dependencies (macOS)
run: |
brew install dfu-util
brew install dfu-util include-what-you-use
python3 -m venv environment && source environment/bin/activate
python3 -m pip install PyYAML
if: matrix.os == 'macos'
Expand All @@ -195,7 +195,7 @@ jobs:
run: |
python3 -m venv environment && source environment/bin/activate
python3 -m pip install PyYAML
sudo apt install dfu-util
sudo apt install dfu-util iwyu
if: matrix.os == 'ubuntu'

- name: Build libopencm3
Expand Down Expand Up @@ -237,6 +237,7 @@ jobs:
mingw-w64-ucrt-x86_64-cmake
mingw-w64-ucrt-x86_64-dfu-util
mingw-w64-ucrt-x86_64-python-yaml
mingw-w64-ucrt-x86_64-include-what-you-use

- name: Build with MSYS (Windows)
if: matrix.os == 'windows'
Expand Down
502 changes: 263 additions & 239 deletions Jenkinsfile

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ci-scripts/build_h1_firmware.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ git submodule init
git submodule update
cd firmware/hackrf_usb
rm -rf build
cmake -DBOARD=HACKRF_ONE -B build
cmake -DBOARD=$1 -B build
cmake --build build
cd ../..
2 changes: 1 addition & 1 deletion ci-scripts/build_hpro_firmware.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ git submodule init
git submodule update
cd firmware/hackrf_usb
rm -rf build
cmake -DBOARD=PRALINE -B build
cmake -DBOARD=$1 -B build
cmake --build build
cd ../..
8 changes: 8 additions & 0 deletions firmware/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
# Top directory CMake project for HackRF firmware

cmake_minimum_required(VERSION 3.10.0)

find_program(IWYU NAMES include-what-you-use)
if(IWYU)
list(APPEND IWYU -Xiwyu --no-fwd-decls -Xiwyu --mapping_file=${CMAKE_SOURCE_DIR}/libopencm3.imp)
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${IWYU})
set(CMAKE_C_INCLUDE_WHAT_YOU_USE ${IWYU})
endif()

set(CMAKE_TOOLCHAIN_FILE toolchain-arm-cortex-m.cmake)

project (hackrf_firmware_all C)
Expand Down
5 changes: 1 addition & 4 deletions firmware/common/adc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@
* Boston, MA 02110-1301, USA.
*/

#ifndef __ADC_H__
#define __ADC_H__
#pragma once

#include <stdint.h>

uint16_t adc_read(uint8_t pin);
void adc_off(void);

#endif // __ADC_H__
5 changes: 1 addition & 4 deletions firmware/common/bitband.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
* Boston, MA 02110-1301, USA.
*/

#ifndef __BITBAND_H__
#define __BITBAND_H__
#pragma once

#include <stdint.h>

Expand All @@ -37,5 +36,3 @@ void peripheral_bitband_clear(
uint32_t peripheral_bitband_get(
volatile void* const peripheral_address,
const uint_fast8_t bit_number);

#endif //__BITBAND_H__
5 changes: 1 addition & 4 deletions firmware/common/clkin.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@
* Boston, MA 02110-1301, USA.
*/

#ifndef __CLKIN_H__
#define __CLKIN_H__
#pragma once

#include <stdint.h>

void clkin_detect_init(void);
uint32_t clkin_frequency(void);

#endif //__CLKIN_H__
81 changes: 58 additions & 23 deletions firmware/common/cpld_jtag.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
#endif

#include "cpld_jtag.h"
#include "platform_detect.h"
#if !defined(PRALINE)
#include "xapp058/micro.h"
#endif

#ifndef PRALINE
#if !defined(PRALINE) || defined(UNIVERSAL)
static refill_buffer_cb refill_buffer;
static uint32_t xsvf_buffer_len, xsvf_pos;
static unsigned char* xsvf_buffer;
Expand All @@ -38,52 +39,86 @@ void cpld_jtag_take(jtag_t* const jtag)
{
const jtag_gpio_t* const gpio = jtag->gpio;

board_id_t board_id = detected_platform();

/* Set initial GPIO state to the voltages of the internal or external pull-ups/downs,
* to avoid any glitches.
*/
#if (defined HACKRF_ONE || defined PRALINE)
gpio_set(gpio->gpio_pp_tms);
switch (board_id) {
case BOARD_ID_HACKRF1_OG:
case BOARD_ID_HACKRF1_R9:
case BOARD_ID_PRALINE:
#if defined(HACKRF_ONE) || defined(PRALINE) || defined(UNIVERSAL)
gpio_set(gpio->gpio_pp_tms);
#endif
break;
default:
break;
}
gpio_clear(gpio->gpio_tck);
#ifndef PRALINE
gpio_set(gpio->gpio_tms);
gpio_set(gpio->gpio_tdi);
if (board_id != BOARD_ID_PRALINE) {
#if !defined(PRALINE) || defined(UNIVERSAL)
gpio_set(gpio->gpio_tms);
gpio_set(gpio->gpio_tdi);
#endif
}

#if (defined HACKRF_ONE || defined PRALINE)
/* Do not drive PortaPack-specific TMS pin initially, just to be cautious. */
gpio_input(gpio->gpio_pp_tms);
gpio_input(gpio->gpio_pp_tdo);
switch (board_id) {
case BOARD_ID_HACKRF1_OG:
case BOARD_ID_HACKRF1_R9:
case BOARD_ID_PRALINE:
#if defined(HACKRF_ONE) || defined(PRALINE) || defined(UNIVERSAL)
/* Do not drive PortaPack-specific TMS pin initially, just to be cautious. */
gpio_input(gpio->gpio_pp_tms);
gpio_input(gpio->gpio_pp_tdo);
#endif
break;
default:
break;
}
gpio_output(gpio->gpio_tck);
#ifndef PRALINE
gpio_output(gpio->gpio_tms);
gpio_output(gpio->gpio_tdi);
gpio_input(gpio->gpio_tdo);
if (board_id != BOARD_ID_PRALINE) {
#if !defined(PRALINE) || defined(UNIVERSAL)
gpio_output(gpio->gpio_tms);
gpio_output(gpio->gpio_tdi);
gpio_input(gpio->gpio_tdo);
#endif
}
}

void cpld_jtag_release(jtag_t* const jtag)
{
const jtag_gpio_t* const gpio = jtag->gpio;

board_id_t board_id = detected_platform();

/* Make all pins inputs when JTAG interface not active.
* Let the pull-ups/downs do the work.
*/
#if (defined HACKRF_ONE || defined PRALINE)
/* Do not drive PortaPack-specific pins, initially, just to be cautious. */
gpio_input(gpio->gpio_pp_tms);
gpio_input(gpio->gpio_pp_tdo);
switch (board_id) {
case BOARD_ID_HACKRF1_OG:
case BOARD_ID_HACKRF1_R9:
case BOARD_ID_PRALINE:
#if defined(HACKRF_ONE) || defined(PRALINE) || defined(UNIVERSAL)
/* Do not drive PortaPack-specific pins, initially, just to be cautious. */
gpio_input(gpio->gpio_pp_tms);
gpio_input(gpio->gpio_pp_tdo);
#endif
break;
default:
break;
}
gpio_input(gpio->gpio_tck);
#ifndef PRALINE
gpio_input(gpio->gpio_tms);
gpio_input(gpio->gpio_tdi);
gpio_input(gpio->gpio_tdo);
if (board_id != BOARD_ID_PRALINE) {
#if !defined(PRALINE) || defined(UNIVERSAL)
gpio_input(gpio->gpio_tms);
gpio_input(gpio->gpio_tdi);
gpio_input(gpio->gpio_tdo);
#endif
}
}

#ifndef PRALINE
#if !defined(PRALINE) || defined(UNIVERSAL)
/* return 0 if success else return error code see xsvfExecute() */
int cpld_jtag_program(
jtag_t* const jtag,
Expand Down
11 changes: 4 additions & 7 deletions firmware/common/cpld_jtag.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@
* Boston, MA 02110-1301, USA.
*/

#ifndef __CPLD_JTAG_H__
#define __CPLD_JTAG_H__
#pragma once

#include <stdint.h>

#include "gpio.h"

typedef struct jtag_gpio_t {
typedef struct {
gpio_t gpio_tck;
#ifndef PRALINE
#if !defined(PRALINE) || defined(UNIVERSAL)
gpio_t gpio_tms;
gpio_t gpio_tdi;
gpio_t gpio_tdo;
#endif
#if (defined HACKRF_ONE || defined PRALINE)
#if defined(HACKRF_ONE) || defined(PRALINE) || defined(UNIVERSAL)
gpio_t gpio_pp_tms;
gpio_t gpio_pp_tdo;
#endif
Expand All @@ -59,5 +58,3 @@ int cpld_jtag_program(
unsigned char* const buffer,
refill_buffer_cb refill);
unsigned char cpld_jtag_get_next_byte(void);

#endif //__CPLD_JTAG_H__
5 changes: 1 addition & 4 deletions firmware/common/cpld_xc2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
* Boston, MA 02110-1301, USA.
*/

#ifndef __CPLD_XC2C_H__
#define __CPLD_XC2C_H__
#pragma once

#include <stdbool.h>
#include <stdint.h>
Expand Down Expand Up @@ -69,5 +68,3 @@ bool cpld_xc2c64a_jtag_sram_verify(
extern const cpld_xc2c64a_program_t cpld_hackrf_program_sram;
extern const cpld_xc2c64a_verify_t cpld_hackrf_verify;
extern const cpld_xc2c64a_row_addresses_t cpld_hackrf_row_addresses;

#endif /*__CPLD_XC2C_H__*/
5 changes: 1 addition & 4 deletions firmware/common/crc.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
* Boston, MA 02110-1301, USA.
*/

#ifndef __CRC_H__
#define __CRC_H__
#pragma once

#include <stddef.h>
#include <stdint.h>
Expand All @@ -35,5 +34,3 @@ typedef struct {
void crc32_init(crc32_t* const crc);
void crc32_update(crc32_t* const crc, const uint8_t* const data, const size_t byte_count);
uint32_t crc32_digest(const crc32_t* const crc);

#endif //__CRC_H__
7 changes: 4 additions & 3 deletions firmware/common/delay.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
* Boston, MA 02110-1301, USA.
*/

#ifndef __DELAY_H
#define __DELAY_H
#pragma once

#ifdef __cplusplus
extern "C" {
Expand All @@ -31,4 +30,6 @@ extern "C" {
void delay(uint32_t duration);
void delay_us_at_mhz(uint32_t us, uint32_t mhz);

#endif /* __DELAY_H */
#ifdef __cplusplus
}
#endif
11 changes: 3 additions & 8 deletions firmware/common/fault_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
* Boston, MA 02110-1301, USA.
*/

#ifndef __FAULT_HANDLER__
#define __FAULT_HANDLER__
#pragma once

#include <stdint.h>

Expand All @@ -30,9 +29,7 @@
// TODO: Move all this to a Cortex-M(?) include file, since these
// structures are supposedly the same between processors (to an
// undetermined extent).
typedef struct armv7m_scb_t armv7m_scb_t;

struct armv7m_scb_t {
typedef struct {
volatile const uint32_t CPUID;
volatile uint32_t ICSR;
volatile uint32_t VTOR;
Expand Down Expand Up @@ -64,12 +61,10 @@ struct armv7m_scb_t {
volatile const uint32_t ID_ISAR4;
volatile const uint32_t __reserved_0x74_0x87[5];
volatile uint32_t CPACR;
} __attribute__((packed));
} __attribute__((packed)) armv7m_scb_t;

static armv7m_scb_t* const SCB = (armv7m_scb_t*) SCB_BASE;

#define SCB_HFSR_DEBUGEVT (1 << 31)
#define SCB_HFSR_FORCED (1 << 30)
#define SCB_HFSR_VECTTBL (1 << 1)

#endif //__FAULT_HANDLER__
3 changes: 3 additions & 0 deletions firmware/common/firmware_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#define SUPPORTED_PLATFORM PLATFORM_RAD1O
#elif PRALINE
#define SUPPORTED_PLATFORM PLATFORM_PRALINE
#elif UNIVERSAL
#define SUPPORTED_PLATFORM \
(PLATFORM_PRALINE | PLATFORM_HACKRF1_OG | PLATFORM_HACKRF1_R9)
#else
#define SUPPORTED_PLATFORM 0
#endif
Expand Down
5 changes: 1 addition & 4 deletions firmware/common/firmware_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
* Boston, MA 02110-1301, USA.
*/

#ifndef FIRMWARE_INFO_H
#define FIRMWARE_INFO_H
#pragma once

#include <stdint.h>

Expand All @@ -33,5 +32,3 @@ struct firmware_info_t {
} __attribute__((packed, aligned(1)));

extern const struct firmware_info_t firmware_info;

#endif
5 changes: 1 addition & 4 deletions firmware/common/fixed_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
* Boston, MA 02110-1301, USA.
*/

#ifndef __FIXED_POINT_H__
#define __FIXED_POINT_H__
#pragma once

#include <stdint.h>

Expand All @@ -32,5 +31,3 @@ typedef uint64_t fp_40_24_t;

/* one in 40.24 fixed-point */
#define FP_ONE_HZ (1 << 24)

#endif /*__FIXED_POINT_H__*/
Loading
Loading