From 07c3699225bb8b092e6c6aedc564625a19096015 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Tue, 1 Dec 2020 14:39:06 +0100 Subject: [PATCH] version.h: Remove from platform.h files - Consolidate ident string generation - Recompile only needed files --- libopencm3 | 2 +- src/platforms/common/cdcacm.c | 4 ++++ src/platforms/f4discovery/platform.h | 5 +---- src/platforms/hosted/ftdi_bmp.c | 1 - src/platforms/hydrabus/platform.h | 5 +---- src/platforms/launchpad-icdi/platform.h | 6 +----- src/platforms/native/platform.h | 5 +---- src/platforms/stlink/platform.h | 5 +---- src/platforms/stm32/dfucore.c | 5 ++++- src/platforms/swlink/platform.h | 5 +---- src/remote.c | 7 ++++--- 11 files changed, 19 insertions(+), 31 deletions(-) diff --git a/libopencm3 b/libopencm3 index 89074d6..505ac65 160000 --- a/libopencm3 +++ b/libopencm3 @@ -1 +1 @@ -Subproject commit 89074d6a13ed7febba04d3c421ce7bf2b7972156 +Subproject commit 505ac65c05b776af031dac3c15b69573b5709850 diff --git a/src/platforms/common/cdcacm.c b/src/platforms/common/cdcacm.c index 3516336..36d3bd2 100644 --- a/src/platforms/common/cdcacm.c +++ b/src/platforms/common/cdcacm.c @@ -34,6 +34,7 @@ #endif #include "usbuart.h" #include "serialno.h" +#include "version.h" #include #include @@ -400,6 +401,9 @@ static char serial_no[13]; static char serial_no[9]; #endif +#define BOARD_IDENT "Black Magic Probe" PLATFORM_IDENT FIRMWARE_VERSION +#define DFU_IDENT "Black Magic Firmware Upgrade" PLATFORM_IDENT FIRMWARE_VERSION + static const char *usb_strings[] = { "Black Sphere Technologies", BOARD_IDENT, diff --git a/src/platforms/f4discovery/platform.h b/src/platforms/f4discovery/platform.h index 29e2b86..8f05909 100644 --- a/src/platforms/f4discovery/platform.h +++ b/src/platforms/f4discovery/platform.h @@ -27,14 +27,11 @@ #include "gpio.h" #include "timing.h" #include "timing_stm32.h" -#include "version.h" #include #define PLATFORM_HAS_TRACESWO -#define BOARD_IDENT "Black Magic Probe (F4Discovery), (Firmware " FIRMWARE_VERSION ")" -#define BOARD_IDENT_DFU "Black Magic Firmware Upgrade (F4Discovery)" -#define DFU_IDENT "Black Magic Firmware Upgrade (F4Discovery)" +#define PLATFORM_IDENT "(F4Discovery) " /* Important pin mappings for STM32 implementation: * diff --git a/src/platforms/hosted/ftdi_bmp.c b/src/platforms/hosted/ftdi_bmp.c index acf9ed4..306e025 100644 --- a/src/platforms/hosted/ftdi_bmp.c +++ b/src/platforms/hosted/ftdi_bmp.c @@ -20,7 +20,6 @@ */ #include "general.h" #include "gdb_if.h" -#include "version.h" #include "platform.h" #include "target.h" diff --git a/src/platforms/hydrabus/platform.h b/src/platforms/hydrabus/platform.h index f8c5a09..c2c8533 100644 --- a/src/platforms/hydrabus/platform.h +++ b/src/platforms/hydrabus/platform.h @@ -28,14 +28,11 @@ #include "gpio.h" #include "timing.h" #include "timing_stm32.h" -#include "version.h" #include #define PLATFORM_HAS_TRACESWO -#define BOARD_IDENT "Black Magic Probe (HydraBus), (Firmware " FIRMWARE_VERSION ")" -#define BOARD_IDENT_DFU "Black Magic (Upgrade) for HydraBus, (Firmware " FIRMWARE_VERSION ")" -#define DFU_IDENT "Black Magic Firmware Upgrade (HydraBus)" +#define PLATFORM_IDENT " (HydraBus))" /* Important pin mappings for STM32 implementation: * diff --git a/src/platforms/launchpad-icdi/platform.h b/src/platforms/launchpad-icdi/platform.h index d05f61c..7ed9636 100644 --- a/src/platforms/launchpad-icdi/platform.h +++ b/src/platforms/launchpad-icdi/platform.h @@ -21,12 +21,8 @@ #include #include "timing.h" -#include "version.h" -#define BOARD_IDENT "Black Magic Probe (Launchpad ICDI), (Firmware " FIRMWARE_VERSION ")" -#define BOARD_IDENT_DFU "Black Magic (Upgrade) for Launchpad, (Firmware " FIRMWARE_VERSION ")" -#define DFU_IDENT "Black Magic Firmware Upgrade (Launchpad)" -#define DFU_IFACE_STRING "lolwut" +#define PLATFORM_IDENT "(Launchpad ICDI) " extern uint8_t running_status; diff --git a/src/platforms/native/platform.h b/src/platforms/native/platform.h index 451d308..0ef4178 100644 --- a/src/platforms/native/platform.h +++ b/src/platforms/native/platform.h @@ -38,10 +38,7 @@ extern bool debug_bmp; int usbuart_debug_write(const char *buf, size_t len); #endif -#define BOARD_IDENT "Black Magic Probe" -#define BOARD_IDENT_DFU "Black Magic Probe (Upgrade)" -#define BOARD_IDENT_UPD "Black Magic Probe (DFU Upgrade)" -#define DFU_IDENT "Black Magic Firmware Upgrade" +#define PLATFORM_IDENT " " #define UPD_IFACE_STRING "@Internal Flash /0x08000000/8*001Kg" /* Important pin mappings for STM32 implementation: diff --git a/src/platforms/stlink/platform.h b/src/platforms/stlink/platform.h index ee776f6..97c219d 100644 --- a/src/platforms/stlink/platform.h +++ b/src/platforms/stlink/platform.h @@ -27,7 +27,6 @@ #include "gpio.h" #include "timing.h" #include "timing_stm32.h" -#include "version.h" #include #include @@ -40,9 +39,7 @@ extern bool debug_bmp; int usbuart_debug_write(const char *buf, size_t len); #endif -#define BOARD_IDENT "Black Magic Probe (STLINK), (Firmware " FIRMWARE_VERSION ")" -#define BOARD_IDENT_DFU "Black Magic (Upgrade) for STLink/Discovery, (Firmware " FIRMWARE_VERSION ")" -#define DFU_IDENT "Black Magic Firmware Upgrade (STLINK)" +#define PLATFORM_IDENT "(STLINK/V2) " /* Hardware definitions... */ #define TDI_PORT GPIOA diff --git a/src/platforms/stm32/dfucore.c b/src/platforms/stm32/dfucore.c index 84e588e..3aceef9 100644 --- a/src/platforms/stm32/dfucore.c +++ b/src/platforms/stm32/dfucore.c @@ -18,6 +18,8 @@ */ #include "general.h" +#include "version.h" + #include #include @@ -124,10 +126,11 @@ const struct usb_config_descriptor config = { static char serial_no[9]; static char if_string[] = DFU_IFACE_STRING; +#define BOARD_IDENT_DFU(BOARD_TYPE) "Black Magic Probe DFU " PLATFORM_IDENT "" FIRMWARE_VERSION static const char *usb_strings[] = { "Black Sphere Technologies", - BOARD_IDENT_DFU, + BOARD_IDENT_DFU(PLATFORM_IDENT), serial_no, /* This string is used by ST Microelectronics' DfuSe utility */ if_string, diff --git a/src/platforms/swlink/platform.h b/src/platforms/swlink/platform.h index c8a9f2e..0eb7f4d 100644 --- a/src/platforms/swlink/platform.h +++ b/src/platforms/swlink/platform.h @@ -28,7 +28,6 @@ #include "gpio.h" #include "timing.h" #include "timing_stm32.h" -#include "version.h" #ifdef ENABLE_DEBUG # define PLATFORM_HAS_DEBUG @@ -37,9 +36,7 @@ extern bool debug_bmp; int usbuart_debug_write(const char *buf, size_t len); #endif -#define BOARD_IDENT "Black Magic Probe (SWLINK), (Firmware " FIRMWARE_VERSION ")" -#define BOARD_IDENT_DFU "Black Magic (Upgrade), SWLINK, (Firmware " FIRMWARE_VERSION ")" -#define DFU_IDENT "Black Magic Firmware Upgrade (SWLINK)" +#define PLATFORM_IDENT "(SWLINK) " /* Hardware definitions... */ #define TMS_PORT GPIOA diff --git a/src/remote.c b/src/remote.c index 445d18e..10fc65e 100644 --- a/src/remote.c +++ b/src/remote.c @@ -24,6 +24,7 @@ #include "swdptap.h" #include "jtagtap.h" #include "gdb_if.h" +#include "platform.h" #include "version.h" #include "exception.h" #include @@ -299,11 +300,11 @@ void remotePacketProcessGEN(uint8_t i, char *packet) #endif break; -#if !defined(BOARD_IDENT) && defined(PLATFORM_IDENT) -# define BOARD_IDENT() PLATFORM_IDENT +#if !defined(BOARD_IDENT) && defined(BOARD_IDENT) +# define PLATFORM_IDENT() BOARD_IDENT #endif case REMOTE_START: - _respondS(REMOTE_RESP_OK, BOARD_IDENT " " FIRMWARE_VERSION); + _respondS(REMOTE_RESP_OK, PLATFORM_IDENT "" FIRMWARE_VERSION); break; default: