|
| 1 | +--- SEGGER_RTT.h 2024-08-28 15:41:15.273606346 +0200 |
| 2 | ++++ SEGGER_RTT_custom.h 2024-08-08 17:02:06.286067463 +0200 |
| 3 | +@@ -53,7 +53,9 @@ |
| 4 | + #ifndef SEGGER_RTT_H |
| 5 | + #define SEGGER_RTT_H |
| 6 | + |
| 7 | ++#ifndef CUSTOM_RTT |
| 8 | + #include "SEGGER_RTT_Conf.h" |
| 9 | ++#endif |
| 10 | + |
| 11 | + /********************************************************************* |
| 12 | + * |
| 13 | +@@ -413,6 +415,7 @@ |
| 14 | + |
| 15 | + #define SEGGER_RTT_HASDATA_UP(n) (((SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[n] + SEGGER_RTT_UNCACHED_OFF))->WrOff - ((SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[n] + SEGGER_RTT_UNCACHED_OFF))->RdOff) // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly |
| 16 | + |
| 17 | ++#ifndef CUSTOM_RTT |
| 18 | + /********************************************************************* |
| 19 | + * |
| 20 | + * RTT "Terminal" API functions |
| 21 | +@@ -430,7 +433,7 @@ |
| 22 | + */ |
| 23 | + int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...); |
| 24 | + int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList); |
| 25 | +- |
| 26 | ++#endif // CUSTOM_RTT |
| 27 | + #ifdef __cplusplus |
| 28 | + } |
| 29 | + #endif |
| 30 | +--- SEGGER_RTT.c 2024-08-28 15:41:12.163607554 +0200 |
| 31 | ++++ SEGGER_RTT_custom.c 2024-08-08 17:02:06.286067463 +0200 |
| 32 | +@@ -1,3 +1,18 @@ |
| 33 | ++/* |
| 34 | ++ customized and cut down (=#ifdef-ed out) minimal version of SEGGER RTT |
| 35 | ++ Version V7.94a (2023-12-06) |
| 36 | ++ https://github.com/adfernandes/segger-rtt/tree/0022265202e4f6e7a44cf0e15e447d75b573c371 |
| 37 | ++ |
| 38 | ++ - no default allocation of channel 0 with name "Terminal" |
| 39 | ++ - customizable "SEGGER RTT" header in memory (to possibly coexist with full version) |
| 40 | ++ - removed some Terminal static deslarations + related Terminal methods |
| 41 | ++ - INIT() macro used in most calls is empty, now needs SEGGER_RTT_Init() to work |
| 42 | ++ - no extra _Conf.h header included |
| 43 | ++*/ |
| 44 | ++#define CUSTOM_RTT // used for ifdefs with changes |
| 45 | ++#ifndef CUSTOM_RTT_HEADER_BACKWARDS |
| 46 | ++#define CUSTOM_RTT_HEADER_BACKWARDS "TTR REGGES" |
| 47 | ++#endif |
| 48 | + /********************************************************************* |
| 49 | + * SEGGER Microcontroller GmbH * |
| 50 | + * The Embedded Experts * |
| 51 | +@@ -68,9 +83,11 @@ |
| 52 | + |
| 53 | + ---------------------------------------------------------------------- |
| 54 | + */ |
| 55 | +- |
| 56 | ++#ifdef CUSTOM_RTT |
| 57 | ++#include "SEGGER_RTT_custom.h" |
| 58 | ++#else |
| 59 | + #include "SEGGER_RTT.h" |
| 60 | +- |
| 61 | ++#endif |
| 62 | + #include <string.h> // for memcpy |
| 63 | + |
| 64 | + /********************************************************************* |
| 65 | +@@ -244,7 +261,10 @@ |
| 66 | + ********************************************************************** |
| 67 | + */ |
| 68 | + |
| 69 | ++#ifndef CUSTOM_RTT |
| 70 | + static const unsigned char _aTerminalId[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; |
| 71 | ++#endif |
| 72 | ++ |
| 73 | + |
| 74 | + /********************************************************************* |
| 75 | + * |
| 76 | +@@ -259,11 +279,22 @@ |
| 77 | + #if SEGGER_RTT_CPU_CACHE_LINE_SIZE |
| 78 | + #if ((defined __GNUC__) || (defined __clang__)) |
| 79 | + SEGGER_RTT_CB _SEGGER_RTT __attribute__ ((aligned (SEGGER_RTT_CPU_CACHE_LINE_SIZE))); |
| 80 | +- static char _acUpBuffer [SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(BUFFER_SIZE_UP)] __attribute__ ((aligned (SEGGER_RTT_CPU_CACHE_LINE_SIZE))); |
| 81 | +- static char _acDownBuffer[SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(BUFFER_SIZE_DOWN)] __attribute__ ((aligned (SEGGER_RTT_CPU_CACHE_LINE_SIZE))); |
| 82 | + #elif (defined __ICCARM__) |
| 83 | + #pragma data_alignment=SEGGER_RTT_CPU_CACHE_LINE_SIZE |
| 84 | + SEGGER_RTT_CB _SEGGER_RTT; |
| 85 | ++ #else |
| 86 | ++ #error "Don't know how to place _SEGGER_RTT, _acUpBuffer, _acDownBuffer cache-line aligned" |
| 87 | ++ #endif |
| 88 | ++#else |
| 89 | ++ SEGGER_RTT_PUT_CB_SECTION(SEGGER_RTT_CB_ALIGN(SEGGER_RTT_CB _SEGGER_RTT)); |
| 90 | ++#endif |
| 91 | ++ |
| 92 | ++#ifndef CUSTOM_RTT |
| 93 | ++#if SEGGER_RTT_CPU_CACHE_LINE_SIZE |
| 94 | ++ #if ((defined __GNUC__) || (defined __clang__)) |
| 95 | ++ static char _acUpBuffer [SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(BUFFER_SIZE_UP)] __attribute__ ((aligned (SEGGER_RTT_CPU_CACHE_LINE_SIZE))); |
| 96 | ++ static char _acDownBuffer[SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(BUFFER_SIZE_DOWN)] __attribute__ ((aligned (SEGGER_RTT_CPU_CACHE_LINE_SIZE))); |
| 97 | ++ #elif (defined __ICCARM__) |
| 98 | + #pragma data_alignment=SEGGER_RTT_CPU_CACHE_LINE_SIZE |
| 99 | + static char _acUpBuffer [SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(BUFFER_SIZE_UP)]; |
| 100 | + #pragma data_alignment=SEGGER_RTT_CPU_CACHE_LINE_SIZE |
| 101 | +@@ -272,13 +303,12 @@ |
| 102 | + #error "Don't know how to place _SEGGER_RTT, _acUpBuffer, _acDownBuffer cache-line aligned" |
| 103 | + #endif |
| 104 | + #else |
| 105 | +- SEGGER_RTT_PUT_CB_SECTION(SEGGER_RTT_CB_ALIGN(SEGGER_RTT_CB _SEGGER_RTT)); |
| 106 | + SEGGER_RTT_PUT_BUFFER_SECTION(SEGGER_RTT_BUFFER_ALIGN(static char _acUpBuffer [BUFFER_SIZE_UP])); |
| 107 | + SEGGER_RTT_PUT_BUFFER_SECTION(SEGGER_RTT_BUFFER_ALIGN(static char _acDownBuffer[BUFFER_SIZE_DOWN])); |
| 108 | + #endif |
| 109 | + |
| 110 | + static unsigned char _ActiveTerminal; |
| 111 | +- |
| 112 | ++#endif |
| 113 | + /********************************************************************* |
| 114 | + * |
| 115 | + * Static functions |
| 116 | +@@ -297,6 +327,9 @@ |
| 117 | + * (1) May only be called via INIT() to avoid overriding settings. |
| 118 | + * The only exception is SEGGER_RTT_Init(), to make an intentional override possible. |
| 119 | + */ |
| 120 | ++#ifdef CUSTOM_RTT |
| 121 | ++#define INIT() |
| 122 | ++#else |
| 123 | + #define INIT() \ |
| 124 | + do { \ |
| 125 | + volatile SEGGER_RTT_CB* pRTTCBInit; \ |
| 126 | +@@ -305,10 +338,11 @@ |
| 127 | + _DoInit(); \ |
| 128 | + } \ |
| 129 | + } while (0) |
| 130 | ++#endif |
| 131 | + |
| 132 | + static void _DoInit(void) { |
| 133 | + volatile SEGGER_RTT_CB* p; // Volatile to make sure that compiler cannot change the order of accesses to the control block |
| 134 | +- static const char _aInitStr[] = "\0\0\0\0\0\0TTR REGGES"; // Init complete ID string to make sure that things also work if RTT is linked to a no-init memory area |
| 135 | ++ static const char _aInitStr[] = "\0\0\0\0\0\0"CUSTOM_RTT_HEADER_BACKWARDS; // Init complete ID string to make sure that things also work if RTT is linked to a no-init memory area |
| 136 | + unsigned i; |
| 137 | + // |
| 138 | + // Initialize control block |
| 139 | +@@ -317,6 +351,7 @@ |
| 140 | + memset((SEGGER_RTT_CB*)p, 0, sizeof(_SEGGER_RTT)); // Make sure that the RTT CB is always zero initialized. |
| 141 | + p->MaxNumUpBuffers = SEGGER_RTT_MAX_NUM_UP_BUFFERS; |
| 142 | + p->MaxNumDownBuffers = SEGGER_RTT_MAX_NUM_DOWN_BUFFERS; |
| 143 | ++#ifndef CUSTOM_RTT |
| 144 | + // |
| 145 | + // Initialize up buffer 0 |
| 146 | + // |
| 147 | +@@ -335,6 +370,7 @@ |
| 148 | + p->aDown[0].RdOff = 0u; |
| 149 | + p->aDown[0].WrOff = 0u; |
| 150 | + p->aDown[0].Flags = SEGGER_RTT_MODE_DEFAULT; |
| 151 | ++#endif |
| 152 | + // |
| 153 | + // Finish initialization of the control block. |
| 154 | + // Copy Id string backwards to make sure that "SEGGER RTT" is not found in initializer memory (usually flash), |
| 155 | +@@ -483,6 +519,7 @@ |
| 156 | + } |
| 157 | + } |
| 158 | + |
| 159 | ++#ifndef CUSTOM_RTT |
| 160 | + /********************************************************************* |
| 161 | + * |
| 162 | + * _PostTerminalSwitch() |
| 163 | +@@ -503,6 +540,7 @@ |
| 164 | + ac[1] = _aTerminalId[TerminalId]; // Caller made already sure that TerminalId does not exceed our terminal limit |
| 165 | + _WriteBlocking(pRing, (const char*)ac, 2u); |
| 166 | + } |
| 167 | ++#endif |
| 168 | + |
| 169 | + /********************************************************************* |
| 170 | + * |
| 171 | +@@ -1672,7 +1710,11 @@ |
| 172 | + if (BufferIndex < SEGGER_RTT_MAX_NUM_UP_BUFFERS) { |
| 173 | + SEGGER_RTT_LOCK(); |
| 174 | + pUp = &pRTTCB->aUp[BufferIndex]; |
| 175 | ++#ifdef CUSTOM_RTT |
| 176 | ++ if (1) { |
| 177 | ++#else |
| 178 | + if (BufferIndex) { |
| 179 | ++#endif |
| 180 | + pUp->sName = sName; |
| 181 | + pUp->pBuffer = (char*)pBuffer; |
| 182 | + pUp->SizeOfBuffer = BufferSize; |
| 183 | +@@ -1724,7 +1766,11 @@ |
| 184 | + if (BufferIndex < SEGGER_RTT_MAX_NUM_DOWN_BUFFERS) { |
| 185 | + SEGGER_RTT_LOCK(); |
| 186 | + pDown = &pRTTCB->aDown[BufferIndex]; |
| 187 | ++#ifdef CUSTOM_RTT |
| 188 | ++ if (1) { |
| 189 | ++#else |
| 190 | + if (BufferIndex) { |
| 191 | ++#endif |
| 192 | + pDown->sName = sName; |
| 193 | + pDown->pBuffer = (char*)pBuffer; |
| 194 | + pDown->SizeOfBuffer = BufferSize; |
| 195 | +@@ -1896,6 +1942,7 @@ |
| 196 | + _DoInit(); |
| 197 | + } |
| 198 | + |
| 199 | ++#ifndef CUSTOM_RTT |
| 200 | + /********************************************************************* |
| 201 | + * |
| 202 | + * SEGGER_RTT_SetTerminal |
| 203 | +@@ -2036,6 +2083,7 @@ |
| 204 | + } |
| 205 | + return Status; |
| 206 | + } |
| 207 | ++#endif // CUSTOM_RTT |
| 208 | + |
| 209 | + /********************************************************************* |
| 210 | + * |
0 commit comments