Add firmware_info structure
This commit is contained in:
52
firmware/common/firmware_info.c
Normal file
52
firmware/common/firmware_info.c
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2022 Great Scott Gadgets <info@greatscottgadgets.com>
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "firmware_info.h"
|
||||
#include "platform_detect.h"
|
||||
#include "gpio_lpc.h"
|
||||
#include "hackrf_core.h"
|
||||
|
||||
#include <libopencm3/lpc43xx/scu.h>
|
||||
#include <libopencm3/lpc43xx/adc.h>
|
||||
|
||||
#ifdef JAWBREAKER
|
||||
#define SUPPORTED_PLATFORM PLATFORM_JAWBREAKER
|
||||
#elif HACKRF_ONE
|
||||
#define SUPPORTED_PLATFORM PLATFORM_HACKRF1_OG
|
||||
#elif RAD1O
|
||||
#define SUPPORTED_PLATFORM PLATFORM_RAD1O
|
||||
#else
|
||||
#define SUPPORTED_PLATFORM 0
|
||||
#endif
|
||||
|
||||
#ifdef DFU_MODE
|
||||
#define DFU_MODE_VALUE 1
|
||||
#else
|
||||
#define DFU_MODE_VALUE 0
|
||||
#endif
|
||||
|
||||
__attribute__((section(".firmware_info"))) const struct firmware_info_t firmware_info = {
|
||||
.magic = "HACKRFFW",
|
||||
.struct_version = 1,
|
||||
.dfu_mode = DFU_MODE_VALUE,
|
||||
.supported_platform = SUPPORTED_PLATFORM,
|
||||
.version_string = VERSION_STRING,
|
||||
};
|
37
firmware/common/firmware_info.h
Normal file
37
firmware/common/firmware_info.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2022 Great Scott Gadgets <info@greatscottgadgets.com>
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef FIRMWARE_INFO_H
|
||||
#define FIRMWARE_INFO_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct firmware_info_t {
|
||||
char magic[8];
|
||||
uint16_t struct_version;
|
||||
uint16_t dfu_mode;
|
||||
uint32_t supported_platform;
|
||||
char version_string[32];
|
||||
} __attribute__((packed, aligned(1)));
|
||||
|
||||
extern const struct firmware_info_t firmware_info;
|
||||
|
||||
#endif
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "platform_detect.h"
|
||||
#include "firmware_info.h"
|
||||
#include "gpio_lpc.h"
|
||||
#include "hackrf_core.h"
|
||||
|
||||
@ -218,19 +219,5 @@ board_rev_t detected_revision(void)
|
||||
|
||||
uint32_t supported_platform(void)
|
||||
{
|
||||
uint32_t binary_platform = 0;
|
||||
|
||||
#ifdef JAWBREAKER
|
||||
binary_platform = PLATFORM_JAWBREAKER;
|
||||
#endif
|
||||
|
||||
#ifdef HACKRF_ONE
|
||||
binary_platform = PLATFORM_HACKRF1_OG;
|
||||
#endif
|
||||
|
||||
#ifdef RAD1O
|
||||
binary_platform = PLATFORM_RAD1O;
|
||||
#endif
|
||||
|
||||
return binary_platform;
|
||||
return firmware_info.supported_platform;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ typedef struct usb_endpoint_t usb_endpoint_t;
|
||||
|
||||
struct usb_endpoint_t {
|
||||
usb_setup_t setup;
|
||||
uint8_t buffer[8]; // Buffer for use during IN stage.
|
||||
uint8_t buffer[32]; // Buffer for use during IN stage.
|
||||
const uint_fast8_t address;
|
||||
usb_device_t* const device;
|
||||
usb_endpoint_t* const in;
|
||||
|
@ -184,6 +184,7 @@ macro(DeclareTargets)
|
||||
${PATH_HACKRF_FIRMWARE_COMMON}/gpio_lpc.c
|
||||
${PATH_HACKRF_FIRMWARE_COMMON}/hackrf_ui.c
|
||||
${PATH_HACKRF_FIRMWARE_COMMON}/platform_detect.c
|
||||
${PATH_HACKRF_FIRMWARE_COMMON}/firmware_info.c
|
||||
)
|
||||
|
||||
if(BOARD STREQUAL "RAD1O")
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "usb_api_board_info.h"
|
||||
#include "platform_detect.h"
|
||||
#include "firmware_info.h"
|
||||
|
||||
#include <hackrf_core.h>
|
||||
#include <rom_iap.h>
|
||||
@ -32,8 +33,6 @@
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
char version_string[] = VERSION_STRING;
|
||||
|
||||
usb_request_status_t usb_vendor_request_read_board_id(
|
||||
usb_endpoint_t* const endpoint,
|
||||
const usb_transfer_stage_t stage)
|
||||
@ -58,10 +57,15 @@ usb_request_status_t usb_vendor_request_read_version_string(
|
||||
uint8_t length;
|
||||
|
||||
if (stage == USB_TRANSFER_STAGE_SETUP) {
|
||||
length = (uint8_t) strlen(version_string);
|
||||
length = (uint8_t) strlen(firmware_info.version_string);
|
||||
// The USB peripheral doesn't seem to be able to read directly from flash,
|
||||
// so copy the version string into ram first.
|
||||
memcpy(&endpoint->buffer,
|
||||
firmware_info.version_string,
|
||||
sizeof(firmware_info.version_string));
|
||||
usb_transfer_schedule_block(
|
||||
endpoint->in,
|
||||
version_string,
|
||||
&endpoint->buffer,
|
||||
length,
|
||||
NULL,
|
||||
NULL);
|
||||
|
Submodule firmware/libopencm3 updated: 55021bff2b...cfc2f34514
Reference in New Issue
Block a user