Skip to content
Permalink
Browse files

ext: segger: update to SystemView v2.52h

Update the external Segger RTT and SystemView libraries to version
2.52h.

This fixes #14082.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
  • Loading branch information...
henrikbrixandersen authored and nashif committed Apr 21, 2019
1 parent bcb9141 commit ccbfd553d5d4419d21a8c32be318929142eabe3b
@@ -3,13 +3,13 @@
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2018 SEGGER Microcontroller GmbH *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER RTT * Real Time Transfer for embedded targets *
* SEGGER SystemView * Real-time application analysis *
* *
**********************************************************************
* *
@@ -52,15 +52,15 @@
* *
**********************************************************************
* *
* RTT version: 6.32d *
* SystemView version: V2.52h *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
File : SEGGER_RTT.c
Purpose : Implementation of SEGGER real-time transfer (RTT) which
allows real-time communication on targets which support
debugger memory accesses while the CPU is running.
Revision: $Rev: 10887 $
Revision: $Rev: 13375 $
Additional information:
Type "int" is assumed to be 32-bits in size
@@ -738,136 +738,75 @@ void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuff
* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal").
* pBuffer Pointer to character array. Does not need to point to a \0 terminated string.
* NumBytes Number of bytes to be stored in the SEGGER RTT control block.
* MUST be > 0!!!
* This is done for performance reasons, so no initial check has do be done.
*
* Return value
* Number of bytes which have been stored in the "Up"-buffer.
* 1: Data has been copied
* 0: No space, data has not been copied
*
* Notes
* (1) If there is not enough space in the "Up"-buffer, all data is dropped.
* (2) For performance reasons this function does not call Init()
* and may only be called after RTT has been initialized.
* Either by calling SEGGER_RTT_Init() or calling another RTT API function first.
*/
#if (RTT_USE_ASM == 0)
unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) {
const char* pData;
SEGGER_RTT_BUFFER_UP* pRing;
unsigned Avail;
unsigned RdOff;
unsigned WrOff;
unsigned Rem;
#if SEGGER_RTT_MEMCPY_USE_BYTELOOP
char* pDst;
#endif

pData = (const char *)pBuffer;
//
// Get "to-host" ring buffer and copy some elements into local variables.
// Cases:
// 1) RdOff <= WrOff => Space until wrap-around is sufficient
// 2) RdOff <= WrOff => Space after wrap-around needed (copy in 2 chunks)
// 3) RdOff < WrOff => No space in buf
// 4) RdOff > WrOff => Space is sufficient
// 5) RdOff > WrOff => No space in buf
//
// 1) is the most common case for large buffers and assuming that J-Link reads the data fast enough
//
pData = (const char *)pBuffer;
pRing = &_SEGGER_RTT.aUp[BufferIndex];
RdOff = pRing->RdOff;
WrOff = pRing->WrOff;
//
// Handle the most common cases fastest.
// Which is:
// RdOff <= WrOff -> Space until wrap around is free.
// AND
// WrOff + NumBytes < SizeOfBuffer -> No Wrap around necessary.
//
// OR
//
// RdOff > WrOff -> Space until RdOff - 1 is free.
// AND
// WrOff + NumBytes < RdOff -> Data fits into buffer
//
if (RdOff <= WrOff) {
//
// Get space until WrOff will be at wrap around.
//
Avail = pRing->SizeOfBuffer - 1u - WrOff ;
if (Avail >= NumBytes) {
#if SEGGER_RTT_MEMCPY_USE_BYTELOOP
pDst = pRing->pBuffer + WrOff;
WrOff += NumBytes;
while (NumBytes--) {
*pDst++ = *pData++;
};
pRing->WrOff = WrOff;
#else
SEGGER_RTT_MEMCPY(pRing->pBuffer + WrOff, pData, NumBytes);
if (RdOff <= WrOff) { // Case 1), 2) or 3)
Avail = pRing->SizeOfBuffer - WrOff - 1u; // Space until wrap-around (assume 1 byte not usable for case that RdOff == 0)
if (Avail >= NumBytes) { // Case 1)?
CopyStraight:
memcpy(pRing->pBuffer + WrOff, pData, NumBytes);
pRing->WrOff = WrOff + NumBytes;
#endif
return 1;
}
//
// If data did not fit into space until wrap around calculate complete space in buffer.
//
Avail += RdOff;
//
// If there is still no space for the whole of this output, don't bother.
//
if (Avail >= NumBytes) {
Avail += RdOff; // Space incl. wrap-around
if (Avail >= NumBytes) { // Case 2? => If not, we have case 3) (does not fit)
Rem = pRing->SizeOfBuffer - WrOff; // Space until end of buffer
memcpy(pRing->pBuffer + WrOff, pData, Rem); // Copy 1st chunk
NumBytes -= Rem;
//
// OK, we have enough space in buffer. Copy in one or 2 chunks
// Special case: First check that assumed RdOff == 0 calculated that last element before wrap-around could not be used
// But 2nd check (considering space until wrap-around and until RdOff) revealed that RdOff is not 0, so we can use the last element
// In this case, we may use a copy straight until buffer end anyway without needing to copy 2 chunks
// Therefore, check if 2nd memcpy is necessary at all
//
Rem = pRing->SizeOfBuffer - WrOff; // Space until end of buffer
if (Rem > NumBytes) {
#if SEGGER_RTT_MEMCPY_USE_BYTELOOP
pDst = pRing->pBuffer + WrOff;
WrOff += NumBytes;
while (NumBytes--) {
*pDst++ = *pData++;
};
pRing->WrOff = WrOff;
#else
SEGGER_RTT_MEMCPY(pRing->pBuffer + WrOff, pData, NumBytes);
pRing->WrOff = WrOff + NumBytes;
#endif
} else {
//
// We reach the end of the buffer, so need to wrap around
//
#if SEGGER_RTT_MEMCPY_USE_BYTELOOP
pDst = pRing->pBuffer + WrOff;
NumBytes -= Rem;
WrOff = NumBytes;
do {
*pDst++ = *pData++;
} while (--Rem);
pDst = pRing->pBuffer;
while (NumBytes--) {
*pDst++ = *pData++;
};
pRing->WrOff = WrOff;
#else
SEGGER_RTT_MEMCPY(pRing->pBuffer + WrOff, pData, Rem);
SEGGER_RTT_MEMCPY(pRing->pBuffer, pData + Rem, NumBytes - Rem);
pRing->WrOff = NumBytes - Rem;
#endif
if (NumBytes) {
memcpy(pRing->pBuffer, pData + Rem, NumBytes);
}
pRing->WrOff = NumBytes;
return 1;
}
} else {
} else { // Potential case 4)
Avail = RdOff - WrOff - 1u;
if (Avail >= NumBytes) {
#if SEGGER_RTT_MEMCPY_USE_BYTELOOP
pDst = pRing->pBuffer + WrOff;
WrOff += NumBytes;
while (NumBytes--) {
*pDst++ = *pData++;
};
pRing->WrOff = WrOff;
#else
SEGGER_RTT_MEMCPY(pRing->pBuffer + WrOff, pData, NumBytes);
pRing->WrOff = WrOff + NumBytes;
#endif
return 1;
if (Avail >= NumBytes) { // Case 4)? => If not, we have case 5) (does not fit)
goto CopyStraight;
}
}
//
// If we reach this point no data has been written
//
return 0;
return 0; // No space in buffer
}
#endif

/*********************************************************************
*
@@ -3,13 +3,13 @@
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2018 SEGGER Microcontroller GmbH *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER RTT * Real Time Transfer for embedded targets *
* SEGGER SystemView * Real-time application analysis *
* *
**********************************************************************
* *
@@ -52,22 +52,42 @@
* *
**********************************************************************
* *
* RTT version: 6.32d *
* SystemView version: V2.52h *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
File : SEGGER_RTT.h
Purpose : Implementation of SEGGER real-time transfer which allows
real-time communication on targets which support debugger
memory accesses while the CPU is running.
Revision: $Rev: 10533 $
Revision: $Rev: 13430 $
----------------------------------------------------------------------
*/

#ifndef SEGGER_RTT_H
#define SEGGER_RTT_H

#include <SEGGER_RTT_Conf.h>
#include "SEGGER_RTT_Conf.h"



/*********************************************************************
*
* Defines, defaults
*
**********************************************************************
*/
#ifndef RTT_USE_ASM
#if ((defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__) || (defined __clang__)) && (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__))
#define RTT_USE_ASM (1)
#else
#define RTT_USE_ASM (0)
#endif
#endif

#ifndef SEGGER_RTT_ASM // defined when SEGGER_RTT.h is included from assembly file
#include <stdlib.h>
#include <stdarg.h>

/*********************************************************************
*
@@ -158,6 +178,7 @@ int SEGGER_RTT_WaitKey (void);
unsigned SEGGER_RTT_Write (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_ASM_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s);
void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_PutChar (unsigned BufferIndex, char c);
@@ -168,6 +189,10 @@ unsigned SEGGER_RTT_PutCharSkipNoLock (unsigned BufferIndex, char c);
//
#define SEGGER_RTT_HASDATA(n) (_SEGGER_RTT.aDown[n].WrOff - _SEGGER_RTT.aDown[n].RdOff)

#if RTT_USE_ASM
#define SEGGER_RTT_WriteSkipNoLock SEGGER_RTT_ASM_WriteSkipNoLock
#endif

/*********************************************************************
*
* RTT "Terminal" API functions
@@ -184,10 +209,14 @@ int SEGGER_RTT_TerminalOut (char TerminalId, const char* s);
**********************************************************************
*/
int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...);
int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList);

#ifdef __cplusplus
}
#endif

#endif // ifndef(SEGGER_RTT_ASM)

/*********************************************************************
*
* Defines
@@ -198,53 +227,53 @@ int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...);
//
// Operating modes. Define behavior if buffer is full (not enough space for entire message)
//
#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0U) // Skip. Do not block, output nothing. (Default)
#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1U) // Trim: Do not block, output as much as fits.
#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (2U) // Block: Wait until there is space in the buffer.
#define SEGGER_RTT_MODE_MASK (3U)
#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0) // Skip. Do not block, output nothing. (Default)
#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1) // Trim: Do not block, output as much as fits.
#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (2) // Block: Wait until there is space in the buffer.
#define SEGGER_RTT_MODE_MASK (3)

//
// Control sequences, based on ANSI.
// Can be used to control color, and clear the screen
//
#define RTT_CTRL_RESET "[0m" // Reset to default colors
#define RTT_CTRL_CLEAR "[2J" // Clear screen, reposition cursor to top left

#define RTT_CTRL_TEXT_BLACK "[2;30m"
#define RTT_CTRL_TEXT_RED "[2;31m"
#define RTT_CTRL_TEXT_GREEN "[2;32m"
#define RTT_CTRL_TEXT_YELLOW "[2;33m"
#define RTT_CTRL_TEXT_BLUE "[2;34m"
#define RTT_CTRL_TEXT_MAGENTA "[2;35m"
#define RTT_CTRL_TEXT_CYAN "[2;36m"
#define RTT_CTRL_TEXT_WHITE "[2;37m"

#define RTT_CTRL_TEXT_BRIGHT_BLACK "[1;30m"
#define RTT_CTRL_TEXT_BRIGHT_RED "[1;31m"
#define RTT_CTRL_TEXT_BRIGHT_GREEN "[1;32m"
#define RTT_CTRL_TEXT_BRIGHT_YELLOW "[1;33m"
#define RTT_CTRL_TEXT_BRIGHT_BLUE "[1;34m"
#define RTT_CTRL_TEXT_BRIGHT_MAGENTA "[1;35m"
#define RTT_CTRL_TEXT_BRIGHT_CYAN "[1;36m"
#define RTT_CTRL_TEXT_BRIGHT_WHITE "[1;37m"

#define RTT_CTRL_BG_BLACK "[24;40m"
#define RTT_CTRL_BG_RED "[24;41m"
#define RTT_CTRL_BG_GREEN "[24;42m"
#define RTT_CTRL_BG_YELLOW "[24;43m"
#define RTT_CTRL_BG_BLUE "[24;44m"
#define RTT_CTRL_BG_MAGENTA "[24;45m"
#define RTT_CTRL_BG_CYAN "[24;46m"
#define RTT_CTRL_BG_WHITE "[24;47m"

#define RTT_CTRL_BG_BRIGHT_BLACK "[4;40m"
#define RTT_CTRL_BG_BRIGHT_RED "[4;41m"
#define RTT_CTRL_BG_BRIGHT_GREEN "[4;42m"
#define RTT_CTRL_BG_BRIGHT_YELLOW "[4;43m"
#define RTT_CTRL_BG_BRIGHT_BLUE "[4;44m"
#define RTT_CTRL_BG_BRIGHT_MAGENTA "[4;45m"
#define RTT_CTRL_BG_BRIGHT_CYAN "[4;46m"
#define RTT_CTRL_BG_BRIGHT_WHITE "[4;47m"
#define RTT_CTRL_RESET "\x1B[0m" // Reset to default colors
#define RTT_CTRL_CLEAR "\x1B[2J" // Clear screen, reposition cursor to top left

#define RTT_CTRL_TEXT_BLACK "\x1B[2;30m"
#define RTT_CTRL_TEXT_RED "\x1B[2;31m"
#define RTT_CTRL_TEXT_GREEN "\x1B[2;32m"
#define RTT_CTRL_TEXT_YELLOW "\x1B[2;33m"
#define RTT_CTRL_TEXT_BLUE "\x1B[2;34m"
#define RTT_CTRL_TEXT_MAGENTA "\x1B[2;35m"
#define RTT_CTRL_TEXT_CYAN "\x1B[2;36m"
#define RTT_CTRL_TEXT_WHITE "\x1B[2;37m"

#define RTT_CTRL_TEXT_BRIGHT_BLACK "\x1B[1;30m"
#define RTT_CTRL_TEXT_BRIGHT_RED "\x1B[1;31m"
#define RTT_CTRL_TEXT_BRIGHT_GREEN "\x1B[1;32m"
#define RTT_CTRL_TEXT_BRIGHT_YELLOW "\x1B[1;33m"
#define RTT_CTRL_TEXT_BRIGHT_BLUE "\x1B[1;34m"
#define RTT_CTRL_TEXT_BRIGHT_MAGENTA "\x1B[1;35m"
#define RTT_CTRL_TEXT_BRIGHT_CYAN "\x1B[1;36m"
#define RTT_CTRL_TEXT_BRIGHT_WHITE "\x1B[1;37m"

#define RTT_CTRL_BG_BLACK "\x1B[24;40m"
#define RTT_CTRL_BG_RED "\x1B[24;41m"
#define RTT_CTRL_BG_GREEN "\x1B[24;42m"
#define RTT_CTRL_BG_YELLOW "\x1B[24;43m"
#define RTT_CTRL_BG_BLUE "\x1B[24;44m"
#define RTT_CTRL_BG_MAGENTA "\x1B[24;45m"
#define RTT_CTRL_BG_CYAN "\x1B[24;46m"
#define RTT_CTRL_BG_WHITE "\x1B[24;47m"

#define RTT_CTRL_BG_BRIGHT_BLACK "\x1B[4;40m"
#define RTT_CTRL_BG_BRIGHT_RED "\x1B[4;41m"
#define RTT_CTRL_BG_BRIGHT_GREEN "\x1B[4;42m"
#define RTT_CTRL_BG_BRIGHT_YELLOW "\x1B[4;43m"
#define RTT_CTRL_BG_BRIGHT_BLUE "\x1B[4;44m"
#define RTT_CTRL_BG_BRIGHT_MAGENTA "\x1B[4;45m"
#define RTT_CTRL_BG_BRIGHT_CYAN "\x1B[4;46m"
#define RTT_CTRL_BG_BRIGHT_WHITE "\x1B[4;47m"


#endif

0 comments on commit ccbfd55

Please sign in to comment.
You can’t perform that action at this time.