From c9b921f6ce1ae5f2c3dc281df6b972763e5e09f5 Mon Sep 17 00:00:00 2001 From: DrZlo13 Date: Thu, 29 Oct 2020 08:41:44 +0300 Subject: [PATCH] added openocd support (#211) openocd needs a visible uxTopUsedPriority symbol for freertos, but freertos is discarding it in v7, so I add the helper file manually --- firmware/targets/f2/Src/freertos-openocd.c | 21 +++++++++++++++++++++ make/toolchain.mk | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 firmware/targets/f2/Src/freertos-openocd.c diff --git a/firmware/targets/f2/Src/freertos-openocd.c b/firmware/targets/f2/Src/freertos-openocd.c new file mode 100644 index 00000000..abde4411 --- /dev/null +++ b/firmware/targets/f2/Src/freertos-openocd.c @@ -0,0 +1,21 @@ + +/* + * Since at least FreeRTOS V7.5.3 uxTopUsedPriority is no longer + * present in the kernel, so it has to be supplied by other means for + * OpenOCD's threads awareness. + * + * Add this file to your project, and, if you're using --gc-sections, + * ``--undefined=uxTopUsedPriority'' (or + * ``-Wl,--undefined=uxTopUsedPriority'' when using gcc for final + * linking) to your LDFLAGS; same with all the other symbols you need. + */ + +#include "FreeRTOS.h" + +#ifdef __GNUC__ +#define USED __attribute__((used)) +#else +#define USED +#endif + +const int USED uxTopUsedPriority = configMAX_PRIORITIES - 1; \ No newline at end of file diff --git a/make/toolchain.mk b/make/toolchain.mk index ad43c369..ef660c0e 100644 --- a/make/toolchain.mk +++ b/make/toolchain.mk @@ -23,4 +23,4 @@ endif CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" CPPFLAGS = -fno-threadsafe-statics -LDFLAGS += -Wl,-Map=$(OBJ_DIR)/$(PROJECT).map,--cref -Wl,--gc-sections +LDFLAGS += -Wl,-Map=$(OBJ_DIR)/$(PROJECT).map,--cref -Wl,--gc-sections -Wl,--undefined=uxTopUsedPriority