1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

fix(core): fix & upgrade systemview target code

[no changelog]
This commit is contained in:
cepetr 2024-10-15 16:43:24 +02:00 committed by cepetr
parent 76891323f6
commit 2589d48c8b
18 changed files with 1135 additions and 421 deletions

View File

@ -225,8 +225,8 @@ if FEATURE_FLAGS["RDI"]:
CPPDEFINES_MOD += ['RDI']
if FEATURE_FLAGS["SYSTEM_VIEW"]:
SOURCE_FIRMWARE += [
'embed/segger/SEGGER/SEGGER_SYSVIEW_Config_NoOS.c',
SOURCE_MOD += [
'embed/segger/Config/SEGGER_SYSVIEW_Config_NoOS.c',
'embed/segger/SEGGER/SEGGER_SYSVIEW.c',
'embed/segger/SEGGER/SEGGER_RTT.c',
'embed/segger/SEGGER/SEGGER_RTT_ASM_ARMv7M.S',

View File

@ -1,101 +1,34 @@
/*
* This file is part of the Trezor project, https://trezor.io/
*
* Copyright (c) SatoshiLabs
*
* 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef SYSTEM_VIEW
#include "systemview.h"
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include "irq.h"
#include "mpconfigport.h"
#include "SEGGER_SYSVIEW.h"
#include "SEGGER_SYSVIEW_Conf.h"
#define SYSTICK ((SYSTICK_REGS *)0xE000E010)
#define SCS ((SCS_REGS *)0xE000ED00)
// for storing DWT CYCCNT from SVC call
volatile uint32_t cyccnt_cycles;
typedef struct {
volatile unsigned int CSR;
volatile unsigned int RVR;
volatile unsigned int CVR;
volatile unsigned int CALIB;
} SYSTICK_REGS;
typedef struct {
volatile unsigned int CPUID; // CPUID Base Register
volatile unsigned int ICSR; // Interrupt Control and State Register
volatile unsigned int VTOR; // Vector Table Offset Register
volatile unsigned int
AIRCR; // Application Interrupt and Reset Control Register
volatile unsigned int SCR; // System Control Register
volatile unsigned int CCR; // Configuration and Control Register
volatile unsigned int SHPR1; // System Handler Priority Register 1
volatile unsigned int SHPR2; // System Handler Priority Register 2
volatile unsigned int SHPR3; // System Handler Priority Register 3
volatile unsigned int SHCSR; // System Handler Control and State Register
volatile unsigned int CFSR; // Configurable Fault Status Register
volatile unsigned int HFSR; // HardFault Status Register
volatile unsigned int DFSR; // Debug Fault Status Register
volatile unsigned int MMFAR; // MemManage Fault Address Register
volatile unsigned int BFAR; // BusFault Address Register
volatile unsigned int AFSR; // Auxiliary Fault Status Register
volatile unsigned int aDummy0[4]; // 0x40-0x4C Reserved
volatile unsigned int aDummy1[4]; // 0x50-0x5C Reserved
volatile unsigned int aDummy2[4]; // 0x60-0x6C Reserved
volatile unsigned int aDummy3[4]; // 0x70-0x7C Reserved
volatile unsigned int aDummy4[2]; // 0x80-0x87 - - - Reserved.
volatile unsigned int CPACR; // Coprocessor Access Control Register
} SCS_REGS;
extern uint32_t SystemCoreClock;
static inline uint32_t is_mode_unprivileged(void) {
uint32_t r0;
__asm__ volatile("mrs %0, control" : "=r"(r0));
return r0 & 1;
}
uint32_t svc_get_dwt_cyccnt() {
if (is_mode_unprivileged()) {
__asm__ __volatile__("svc %0" ::"i"(SVC_GET_DWT_CYCCNT));
} else {
cyccnt_cycles = *DWT_CYCCNT_ADDR;
}
return cyccnt_cycles;
}
U32 SEGGER_SYSVIEW_X_GetInterruptId() {
return ((*(U32 *)(0xE000ED04)) & 0x1FF);
}
void enable_systemview() {
SEGGER_SYSVIEW_Conf();
SEGGER_SYSVIEW_Start();
U32 v;
//
// Configure SysTick and debug monitor interrupt priorities
// Low value means high priority
// A maximum of 8 priority bits and a minimum of 3 bits is implemented per
// interrupt. How many bits are implemented depends on the actual CPU being
// used If less than 8 bits are supported, the lower bits of the priority byte
// are RAZ. In order to make sure that priority of monitor and SysTick always
// differ, please make sure that the difference is visible in the highest 3
// bits
v = SCS->SHPR3;
v |= (0xFFuL << 24); // Lowest prio for SysTick so SystemView does not get
// interrupted by Systick
SCS->SHPR3 = v;
//
// Configure SysTick interrupt
// SysTick is running at CPU speed
// Configure SysTick to fire every ms
//
SYSTICK->RVR = (SystemCoreClock / 1000) - 1; // set reload
SYSTICK->CVR = 0x00; // set counter
SYSTICK->CSR = 0x07; // enable systick
}
#ifdef SYSTEMVIEW_DEST_RTT

View File

@ -1,19 +1,31 @@
/*
* This file is part of the Trezor project, https://trezor.io/
*
* Copyright (c) SatoshiLabs
*
* 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CORE_SYSTEMVIEW_H
#define CORE_SYSTEMVIEW_H
#ifdef SYSTEM_VIEW
#include <stdint.h>
#include "SEGGER_SYSVIEW.h"
#define DWT_CYCCNT_ADDR ((uint32_t*)(0xE0001004));
#define SVC_GET_DWT_CYCCNT 3
extern volatile uint32_t cyccnt_cycles;
void enable_systemview();
uint32_t svc_get_dwt_cyccnt();
void enable_systemview(void);
#else
#define SEGGER_SYSVIEW_RecordEnterISR()

View File

@ -45,6 +45,7 @@
#include "secret.h"
#include "secure_aes.h"
#include "system.h"
#include "systemview.h"
#include "systick.h"
#include "tamper.h"
#include "touch.h"

View File

@ -3,7 +3,7 @@
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
@ -42,7 +42,7 @@
* *
**********************************************************************
* *
* SystemView version: 3.20 *
* SystemView version: 3.58 *
* *
**********************************************************************
----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
@ -42,7 +42,7 @@
* *
**********************************************************************
* *
* SystemView version: 3.20 *
* SystemView version: 3.58 *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
@ -50,7 +50,7 @@ File : SEGGER_RTT_Conf.h
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: 21386 $
Revision: $Rev: 24316 $
*/
@ -169,7 +169,7 @@ Revision: $Rev: 21386 $
: \
); \
}
#elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__))
#elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__) || defined(__ARM_ARCH_8_1M_MAIN__))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
@ -190,7 +190,7 @@ Revision: $Rev: 21386 $
); \
}
#elif defined(__ARM_ARCH_7A__)
#elif (defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__))
#define SEGGER_RTT_LOCK() { \
unsigned int _SEGGER_RTT__LockState; \
__asm volatile ("mrs r1, CPSR \n\t" \

View File

@ -3,7 +3,7 @@
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
@ -42,7 +42,7 @@
* *
**********************************************************************
* *
* SystemView version: 3.20 *
* SystemView version: 3.58 *
* *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
@ -74,10 +74,10 @@ Additional information:
**********************************************************************
*/
/*********************************************************************
* TODO: Add your defines here. *
**********************************************************************
*/
#define SEGGER_SYSVIEW_RTT_BUFFER_SIZE 4096
#define SEGGER_SYSVIEW_MAX_STRING_LEN 1024
#define SEGGER_SYSVIEW_BUFFER_SECTION "CCMRAM"

View File

@ -3,7 +3,7 @@
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
@ -42,7 +42,7 @@
* *
**********************************************************************
* *
* SystemView version: 3.20 *
* SystemView version: 3.58 *
* *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
@ -68,7 +68,7 @@ extern unsigned int SystemCoreClock;
#define SYSVIEW_APP_NAME "Trezor Core"
// The target device name
#define SYSVIEW_DEVICE_NAME "STM32F427VI"
#define SYSVIEW_DEVICE_NAME "Cortex-M"
// Frequency of the timestamp. Must match SEGGER_SYSVIEW_Conf.h
#define SYSVIEW_TIMESTAMP_FREQ (SystemCoreClock)
@ -110,8 +110,9 @@ extern unsigned int SystemCoreClock;
*/
static void _cbSendSystemDesc(void) {
SEGGER_SYSVIEW_SendSysDesc("N="SYSVIEW_APP_NAME",D="SYSVIEW_DEVICE_NAME);
SEGGER_SYSVIEW_SendSysDesc("I#11=SVCall");
SEGGER_SYSVIEW_SendSysDesc("I#14=PendSV");
SEGGER_SYSVIEW_SendSysDesc("I#15=SysTick");
SEGGER_SYSVIEW_SendSysDesc("I#93=USB_HS");
}
/*********************************************************************

View File

@ -3,7 +3,7 @@
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
@ -42,7 +42,7 @@
* *
**********************************************************************
* *
* SystemView version: 3.20 *
* SystemView version: 3.58 *
* *
**********************************************************************
----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
@ -42,7 +42,7 @@
* *
**********************************************************************
* *
* SystemView version: 3.20 *
* SystemView version: 3.58 *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
@ -50,7 +50,7 @@ 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: 20869 $
Revision: $Rev: 29668 $
Additional information:
Type "int" is assumed to be 32-bits in size
@ -174,12 +174,6 @@ Additional information:
#ifndef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
//
// For some environments, NULL may not be defined until certain headers are included
//
#ifndef NULL
#define NULL 0
#endif
/*********************************************************************
*
@ -192,7 +186,7 @@ Additional information:
#endif
#if SEGGER_RTT_ALIGNMENT || SEGGER_RTT_BUFFER_ALIGNMENT
#if (defined __GNUC__)
#if ((defined __GNUC__) || (defined __clang__))
#define SEGGER_RTT_ALIGN(Var, Alignment) Var __attribute__ ((aligned (Alignment)))
#elif (defined __ICCARM__) || (defined __ICCRX__)
#define PRAGMA(A) _Pragma(#A)
@ -208,7 +202,7 @@ Additional information:
#endif
#if defined(SEGGER_RTT_SECTION) || defined (SEGGER_RTT_BUFFER_SECTION)
#if (defined __GNUC__)
#if ((defined __GNUC__) || (defined __clang__))
#define SEGGER_RTT_PUT_SECTION(Var, Section) __attribute__ ((section (Section))) Var
#elif (defined __ICCARM__) || (defined __ICCRX__)
#define SEGGER_RTT_PUT_SECTION(Var, Section) RTT_PRAGMA(location=Section) \
@ -254,7 +248,7 @@ Additional information:
**********************************************************************
*/
static unsigned char _aTerminalId[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
static const unsigned char _aTerminalId[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
/*********************************************************************
*
@ -266,9 +260,26 @@ static unsigned char _aTerminalId[16] = { '0', '1', '2', '3', '4', '5', '6', '7'
//
// RTT Control Block and allocate buffers for channel 0
//
#if SEGGER_RTT_CPU_CACHE_LINE_SIZE
#if ((defined __GNUC__) || (defined __clang__))
SEGGER_RTT_CB _SEGGER_RTT __attribute__ ((aligned (SEGGER_RTT_CPU_CACHE_LINE_SIZE)));
static char _acUpBuffer [SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(BUFFER_SIZE_UP)] __attribute__ ((aligned (SEGGER_RTT_CPU_CACHE_LINE_SIZE)));
static char _acDownBuffer[SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(BUFFER_SIZE_DOWN)] __attribute__ ((aligned (SEGGER_RTT_CPU_CACHE_LINE_SIZE)));
#elif (defined __ICCARM__)
#pragma data_alignment=SEGGER_RTT_CPU_CACHE_LINE_SIZE
SEGGER_RTT_CB _SEGGER_RTT;
#pragma data_alignment=SEGGER_RTT_CPU_CACHE_LINE_SIZE
static char _acUpBuffer [SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(BUFFER_SIZE_UP)];
#pragma data_alignment=SEGGER_RTT_CPU_CACHE_LINE_SIZE
static char _acDownBuffer[SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(BUFFER_SIZE_DOWN)];
#else
#error "Don't know how to place _SEGGER_RTT, _acUpBuffer, _acDownBuffer cache-line aligned"
#endif
#else
SEGGER_RTT_PUT_CB_SECTION(SEGGER_RTT_CB_ALIGN(SEGGER_RTT_CB _SEGGER_RTT));
SEGGER_RTT_PUT_BUFFER_SECTION(SEGGER_RTT_BUFFER_ALIGN(static char _acUpBuffer [SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(BUFFER_SIZE_UP)]));
SEGGER_RTT_PUT_BUFFER_SECTION(SEGGER_RTT_BUFFER_ALIGN(static char _acDownBuffer[SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(BUFFER_SIZE_DOWN)]));
SEGGER_RTT_PUT_BUFFER_SECTION(SEGGER_RTT_BUFFER_ALIGN(static char _acUpBuffer [BUFFER_SIZE_UP]));
SEGGER_RTT_PUT_BUFFER_SECTION(SEGGER_RTT_BUFFER_ALIGN(static char _acDownBuffer[BUFFER_SIZE_DOWN]));
#endif
static unsigned char _ActiveTerminal;
@ -285,25 +296,29 @@ static unsigned char _ActiveTerminal;
*
* Function description
* Initializes the control block an buffers.
* May only be called via INIT() to avoid overriding settings.
*
* Notes
* (1) May only be called via INIT() to avoid overriding settings.
* The only exception is SEGGER_RTT_Init(), to make an intentional override possible.
*/
#define INIT() { \
volatile SEGGER_RTT_CB* pRTTCBInit; \
pRTTCBInit = (volatile SEGGER_RTT_CB*)((char*)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); \
#define INIT() \
do { \
if (pRTTCBInit->acID[0] == '\0') { \
volatile SEGGER_RTT_CB* pRTTCBInit; \
pRTTCBInit = (volatile SEGGER_RTT_CB*)((uintptr_t)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); \
if (pRTTCBInit->acID[0] != 'S') { \
_DoInit(); \
} \
} while (0); \
}
} while (0)
static void _DoInit(void) {
volatile SEGGER_RTT_CB* p; // Volatile to make sure that compiler cannot change the order of accesses to the control block
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
unsigned i;
//
// Initialize control block
//
p = (volatile SEGGER_RTT_CB*)((char*)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access control block uncached so that nothing in the cache ever becomes dirty and all changes are visible in HW directly
p = (volatile SEGGER_RTT_CB*)((uintptr_t)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access control block uncached so that nothing in the cache ever becomes dirty and all changes are visible in HW directly
memset((SEGGER_RTT_CB*)p, 0, sizeof(_SEGGER_RTT)); // Make sure that the RTT CB is always zero initialized.
p->MaxNumUpBuffers = SEGGER_RTT_MAX_NUM_UP_BUFFERS;
p->MaxNumDownBuffers = SEGGER_RTT_MAX_NUM_DOWN_BUFFERS;
//
@ -326,15 +341,14 @@ static void _DoInit(void) {
p->aDown[0].Flags = SEGGER_RTT_MODE_DEFAULT;
//
// Finish initialization of the control block.
// Copy Id string in three steps to make sure "SEGGER RTT" is not found
// in initializer memory (usually flash) by J-Link
// Copy Id string backwards to make sure that "SEGGER RTT" is not found in initializer memory (usually flash),
// as this would cause J-Link to "find" the control block at a wrong address.
//
STRCPY((char*)&p->acID[7], "RTT");
RTT__DMB(); // Force order of memory accessed inside core for cores that allow to change the order
STRCPY((char*)&p->acID[0], "SEGGER");
RTT__DMB(); // Force order of memory accessed inside core for cores that allow to change the order
p->acID[6] = ' ';
RTT__DMB(); // Force order of memory accessed inside core for cores that allow to change the order
RTT__DMB(); // Force order of memory accesses for cores that may perform out-of-order memory accesses
for (i = 0; i < sizeof(_aInitStr) - 1; ++i) {
p->acID[i] = _aInitStr[sizeof(_aInitStr) - 2 - i]; // Skip terminating \0 at the end of the array
}
RTT__DMB(); // Force order of memory accesses for cores that may perform out-of-order memory accesses
}
/*********************************************************************
@ -565,7 +579,7 @@ unsigned SEGGER_RTT_ReadUpBufferNoLock(unsigned BufferIndex, void* pData, unsign
volatile char* pSrc;
INIT();
pRing = (SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pBuffer = (unsigned char*)pData;
RdOff = pRing->RdOff;
WrOff = pRing->WrOff;
@ -657,7 +671,7 @@ unsigned SEGGER_RTT_ReadNoLock(unsigned BufferIndex, void* pData, unsigned Buffe
volatile char* pSrc;
//
INIT();
pRing = (SEGGER_RTT_BUFFER_DOWN*)((char*)&_SEGGER_RTT.aDown[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_DOWN*)((uintptr_t)&_SEGGER_RTT.aDown[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pBuffer = (unsigned char*)pData;
RdOff = pRing->RdOff;
WrOff = pRing->WrOff;
@ -824,7 +838,7 @@ void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuff
// Get "to-host" ring buffer and copy some elements into local variables.
//
pData = (const char *)pBuffer;
pRing = (SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
//
// Check if we will overwrite data and need to adjust the RdOff.
//
@ -935,14 +949,13 @@ unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pBuffer, u
// 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_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
RdOff = pRing->RdOff;
WrOff = pRing->WrOff;
pDst = (pRing->pBuffer + WrOff) + SEGGER_RTT_UNCACHED_OFF;
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:
pDst = (pRing->pBuffer + WrOff) + SEGGER_RTT_UNCACHED_OFF;
memcpy((void*)pDst, pData, NumBytes);
RTT__DMB(); // Force data write to be complete before writing the <WrOff>, in case CPU is allowed to change the order of memory accesses
pRing->WrOff = WrOff + NumBytes;
@ -951,7 +964,6 @@ CopyStraight:
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
pDst = (pRing->pBuffer + WrOff) + SEGGER_RTT_UNCACHED_OFF;
memcpy((void*)pDst, pData, Rem); // Copy 1st chunk
NumBytes -= Rem;
//
@ -971,7 +983,10 @@ CopyStraight:
} else { // Potential case 4)
Avail = RdOff - WrOff - 1u;
if (Avail >= NumBytes) { // Case 4)? => If not, we have case 5) (does not fit)
goto CopyStraight;
memcpy((void*)pDst, pData, NumBytes);
RTT__DMB(); // Force data write to be complete before writing the <WrOff>, in case CPU is allowed to change the order of memory accesses
pRing->WrOff = WrOff + NumBytes;
return 1;
}
}
return 0; // No space in buffer
@ -1016,7 +1031,7 @@ unsigned SEGGER_RTT_WriteDownBufferNoLock(unsigned BufferIndex, const void* pBuf
// It is save to cast that to a "to-host" buffer. Up and Down buffer differ in volatility of offsets that might be modified by J-Link.
//
pData = (const char *)pBuffer;
pRing = (SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aDown[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aDown[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
//
// How we output depends upon the mode...
//
@ -1090,7 +1105,7 @@ unsigned SEGGER_RTT_WriteNoLock(unsigned BufferIndex, const void* pBuffer, unsig
// Get "to-host" ring buffer.
//
pData = (const char *)pBuffer;
pRing = (SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
//
// How we output depends upon the mode...
//
@ -1254,7 +1269,7 @@ unsigned SEGGER_RTT_PutCharSkipNoLock(unsigned BufferIndex, char c) {
//
// Get "to-host" ring buffer.
//
pRing = (SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
//
// Get write position and handle wrap-around if necessary
//
@ -1309,7 +1324,7 @@ unsigned SEGGER_RTT_PutCharSkip(unsigned BufferIndex, char c) {
//
// Get "to-host" ring buffer.
//
pRing = (SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
//
// Get write position and handle wrap-around if necessary
//
@ -1368,7 +1383,7 @@ unsigned SEGGER_RTT_PutChar(unsigned BufferIndex, char c) {
//
// Get "to-host" ring buffer.
//
pRing = (SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
//
// Get write position and handle wrap-around if necessary
//
@ -1475,7 +1490,7 @@ int SEGGER_RTT_HasKey(void) {
int r;
INIT();
pRing = (SEGGER_RTT_BUFFER_DOWN*)((char*)&_SEGGER_RTT.aDown[0] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_DOWN*)((uintptr_t)&_SEGGER_RTT.aDown[0] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
RdOff = pRing->RdOff;
if (RdOff != pRing->WrOff) {
r = 1;
@ -1501,7 +1516,7 @@ unsigned SEGGER_RTT_HasData(unsigned BufferIndex) {
SEGGER_RTT_BUFFER_DOWN* pRing;
unsigned v;
pRing = (SEGGER_RTT_BUFFER_DOWN*)((char*)&_SEGGER_RTT.aDown[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_DOWN*)((uintptr_t)&_SEGGER_RTT.aDown[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
v = pRing->WrOff;
return v - pRing->RdOff;
}
@ -1522,7 +1537,7 @@ unsigned SEGGER_RTT_HasDataUp(unsigned BufferIndex) {
SEGGER_RTT_BUFFER_UP* pRing;
unsigned v;
pRing = (SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
v = pRing->RdOff;
return pRing->WrOff - v;
}
@ -1541,6 +1556,7 @@ unsigned SEGGER_RTT_HasDataUp(unsigned BufferIndex) {
* pBuffer Pointer to a buffer to be used.
* BufferSize Size of the buffer.
* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message).
* Flags[31:24] are used for validity check and must be zero. Flags[23:2] are reserved for future use. Flags[1:0] = RTT operating mode.
*
* Return value
* >= 0 - O.K. Buffer Index
@ -1552,7 +1568,7 @@ int SEGGER_RTT_AllocDownBuffer(const char* sName, void* pBuffer, unsigned Buffer
INIT();
SEGGER_RTT_LOCK();
pRTTCB = (volatile SEGGER_RTT_CB*)((unsigned char*)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRTTCB = (volatile SEGGER_RTT_CB*)((uintptr_t)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
BufferIndex = 0;
do {
if (pRTTCB->aDown[BufferIndex].pBuffer == NULL) {
@ -1589,6 +1605,7 @@ int SEGGER_RTT_AllocDownBuffer(const char* sName, void* pBuffer, unsigned Buffer
* pBuffer Pointer to a buffer to be used.
* BufferSize Size of the buffer.
* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message).
* Flags[31:24] are used for validity check and must be zero. Flags[23:2] are reserved for future use. Flags[1:0] = RTT operating mode.
*
* Return value
* >= 0 - O.K. Buffer Index
@ -1600,7 +1617,7 @@ int SEGGER_RTT_AllocUpBuffer(const char* sName, void* pBuffer, unsigned BufferSi
INIT();
SEGGER_RTT_LOCK();
pRTTCB = (volatile SEGGER_RTT_CB*)((unsigned char*)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRTTCB = (volatile SEGGER_RTT_CB*)((uintptr_t)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
BufferIndex = 0;
do {
if (pRTTCB->aUp[BufferIndex].pBuffer == NULL) {
@ -1638,6 +1655,7 @@ int SEGGER_RTT_AllocUpBuffer(const char* sName, void* pBuffer, unsigned BufferSi
* pBuffer Pointer to a buffer to be used.
* BufferSize Size of the buffer.
* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message).
* Flags[31:24] are used for validity check and must be zero. Flags[23:2] are reserved for future use. Flags[1:0] = RTT operating mode.
*
* Return value
* >= 0 - O.K.
@ -1651,19 +1669,21 @@ int SEGGER_RTT_AllocUpBuffer(const char* sName, void* pBuffer, unsigned BufferSi
int SEGGER_RTT_ConfigUpBuffer(unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) {
int r;
volatile SEGGER_RTT_CB* pRTTCB;
volatile SEGGER_RTT_BUFFER_UP* pUp;
INIT();
pRTTCB = (volatile SEGGER_RTT_CB*)((unsigned char*)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
if (BufferIndex < (unsigned)pRTTCB->MaxNumUpBuffers) {
pRTTCB = (volatile SEGGER_RTT_CB*)((uintptr_t)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
if (BufferIndex < SEGGER_RTT_MAX_NUM_UP_BUFFERS) {
SEGGER_RTT_LOCK();
if (BufferIndex > 0u) {
pRTTCB->aUp[BufferIndex].sName = sName;
pRTTCB->aUp[BufferIndex].pBuffer = (char*)pBuffer;
pRTTCB->aUp[BufferIndex].SizeOfBuffer = BufferSize;
pRTTCB->aUp[BufferIndex].RdOff = 0u;
pRTTCB->aUp[BufferIndex].WrOff = 0u;
pUp = &pRTTCB->aUp[BufferIndex];
if (BufferIndex) {
pUp->sName = sName;
pUp->pBuffer = (char*)pBuffer;
pUp->SizeOfBuffer = BufferSize;
pUp->RdOff = 0u;
pUp->WrOff = 0u;
}
pRTTCB->aUp[BufferIndex].Flags = Flags;
pUp->Flags = Flags;
SEGGER_RTT_UNLOCK();
r = 0;
} else {
@ -1687,6 +1707,7 @@ int SEGGER_RTT_ConfigUpBuffer(unsigned BufferIndex, const char* sName, void* pBu
* pBuffer Pointer to a buffer to be used.
* BufferSize Size of the buffer.
* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message).
* Flags[31:24] are used for validity check and must be zero. Flags[23:2] are reserved for future use. Flags[1:0] = RTT operating mode.
*
* Return value
* >= 0 O.K.
@ -1700,19 +1721,21 @@ int SEGGER_RTT_ConfigUpBuffer(unsigned BufferIndex, const char* sName, void* pBu
int SEGGER_RTT_ConfigDownBuffer(unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) {
int r;
volatile SEGGER_RTT_CB* pRTTCB;
volatile SEGGER_RTT_BUFFER_DOWN* pDown;
INIT();
pRTTCB = (volatile SEGGER_RTT_CB*)((unsigned char*)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
if (BufferIndex < (unsigned)pRTTCB->MaxNumDownBuffers) {
pRTTCB = (volatile SEGGER_RTT_CB*)((uintptr_t)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
if (BufferIndex < SEGGER_RTT_MAX_NUM_DOWN_BUFFERS) {
SEGGER_RTT_LOCK();
if (BufferIndex > 0u) {
pRTTCB->aDown[BufferIndex].sName = sName;
pRTTCB->aDown[BufferIndex].pBuffer = (char*)pBuffer;
pRTTCB->aDown[BufferIndex].SizeOfBuffer = BufferSize;
pRTTCB->aDown[BufferIndex].RdOff = 0u;
pRTTCB->aDown[BufferIndex].WrOff = 0u;
pDown = &pRTTCB->aDown[BufferIndex];
if (BufferIndex) {
pDown->sName = sName;
pDown->pBuffer = (char*)pBuffer;
pDown->SizeOfBuffer = BufferSize;
pDown->RdOff = 0u;
pDown->WrOff = 0u;
}
pRTTCB->aDown[BufferIndex].Flags = Flags;
pDown->Flags = Flags;
RTT__DMB(); // Force data write to be complete before writing the <WrOff>, in case CPU is allowed to change the order of memory accesses
SEGGER_RTT_UNLOCK();
r = 0;
@ -1741,12 +1764,14 @@ int SEGGER_RTT_ConfigDownBuffer(unsigned BufferIndex, const char* sName, void* p
int SEGGER_RTT_SetNameUpBuffer(unsigned BufferIndex, const char* sName) {
int r;
volatile SEGGER_RTT_CB* pRTTCB;
volatile SEGGER_RTT_BUFFER_UP* pUp;
INIT();
pRTTCB = (volatile SEGGER_RTT_CB*)((unsigned char*)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
if (BufferIndex < (unsigned)pRTTCB->MaxNumUpBuffers) {
pRTTCB = (volatile SEGGER_RTT_CB*)((uintptr_t)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
if (BufferIndex < SEGGER_RTT_MAX_NUM_UP_BUFFERS) {
SEGGER_RTT_LOCK();
pRTTCB->aUp[BufferIndex].sName = sName;
pUp = &pRTTCB->aUp[BufferIndex];
pUp->sName = sName;
SEGGER_RTT_UNLOCK();
r = 0;
} else {
@ -1774,12 +1799,14 @@ int SEGGER_RTT_SetNameUpBuffer(unsigned BufferIndex, const char* sName) {
int SEGGER_RTT_SetNameDownBuffer(unsigned BufferIndex, const char* sName) {
int r;
volatile SEGGER_RTT_CB* pRTTCB;
volatile SEGGER_RTT_BUFFER_DOWN* pDown;
INIT();
pRTTCB = (volatile SEGGER_RTT_CB*)((unsigned char*)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
if (BufferIndex < (unsigned)pRTTCB->MaxNumDownBuffers) {
pRTTCB = (volatile SEGGER_RTT_CB*)((uintptr_t)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
if (BufferIndex < SEGGER_RTT_MAX_NUM_DOWN_BUFFERS) {
SEGGER_RTT_LOCK();
pRTTCB->aDown[BufferIndex].sName = sName;
pDown = &pRTTCB->aDown[BufferIndex];
pDown->sName = sName;
SEGGER_RTT_UNLOCK();
r = 0;
} else {
@ -1799,6 +1826,7 @@ int SEGGER_RTT_SetNameDownBuffer(unsigned BufferIndex, const char* sName) {
* Parameters
* BufferIndex Index of the buffer.
* Flags Flags to set for the buffer.
* Flags[31:24] are used for validity check and must be zero. Flags[23:2] are reserved for future use. Flags[1:0] = RTT operating mode.
*
* Return value
* >= 0 O.K.
@ -1807,12 +1835,14 @@ int SEGGER_RTT_SetNameDownBuffer(unsigned BufferIndex, const char* sName) {
int SEGGER_RTT_SetFlagsUpBuffer(unsigned BufferIndex, unsigned Flags) {
int r;
volatile SEGGER_RTT_CB* pRTTCB;
volatile SEGGER_RTT_BUFFER_UP* pUp;
INIT();
pRTTCB = (volatile SEGGER_RTT_CB*)((unsigned char*)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
if (BufferIndex < (unsigned)pRTTCB->MaxNumUpBuffers) {
pRTTCB = (volatile SEGGER_RTT_CB*)((uintptr_t)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
if (BufferIndex < SEGGER_RTT_MAX_NUM_UP_BUFFERS) {
SEGGER_RTT_LOCK();
pRTTCB->aUp[BufferIndex].Flags = Flags;
pUp = &pRTTCB->aUp[BufferIndex];
pUp->Flags = Flags;
SEGGER_RTT_UNLOCK();
r = 0;
} else {
@ -1832,6 +1862,7 @@ int SEGGER_RTT_SetFlagsUpBuffer(unsigned BufferIndex, unsigned Flags) {
* Parameters
* BufferIndex Index of the buffer to renamed.
* Flags Flags to set for the buffer.
* Flags[31:24] are used for validity check and must be zero. Flags[23:2] are reserved for future use. Flags[1:0] = RTT operating mode.
*
* Return value
* >= 0 O.K.
@ -1840,12 +1871,14 @@ int SEGGER_RTT_SetFlagsUpBuffer(unsigned BufferIndex, unsigned Flags) {
int SEGGER_RTT_SetFlagsDownBuffer(unsigned BufferIndex, unsigned Flags) {
int r;
volatile SEGGER_RTT_CB* pRTTCB;
volatile SEGGER_RTT_BUFFER_DOWN* pDown;
INIT();
pRTTCB = (volatile SEGGER_RTT_CB*)((unsigned char*)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
if (BufferIndex < (unsigned)pRTTCB->MaxNumDownBuffers) {
pRTTCB = (volatile SEGGER_RTT_CB*)((uintptr_t)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
if (BufferIndex < SEGGER_RTT_MAX_NUM_DOWN_BUFFERS) {
SEGGER_RTT_LOCK();
pRTTCB->aDown[BufferIndex].Flags = Flags;
pDown = &pRTTCB->aDown[BufferIndex];
pDown->Flags = Flags;
SEGGER_RTT_UNLOCK();
r = 0;
} else {
@ -1895,7 +1928,7 @@ int SEGGER_RTT_SetTerminal (unsigned char TerminalId) {
ac[0] = 0xFFu;
if (TerminalId < sizeof(_aTerminalId)) { // We only support a certain number of channels
ac[1] = _aTerminalId[TerminalId];
pRing = (SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp[0] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[0] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
SEGGER_RTT_LOCK(); // Lock to make sure that no other task is writing into buffer, while we are and number of free bytes in buffer does not change downwards after checking and before writing
if ((pRing->Flags & SEGGER_RTT_MODE_MASK) == SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL) {
_ActiveTerminal = TerminalId;
@ -1947,7 +1980,7 @@ int SEGGER_RTT_TerminalOut (unsigned char TerminalId, const char* s) {
//
// Get "to-host" ring buffer.
//
pRing = (SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp[0] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[0] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
//
// Need to be able to change terminal, write data, change back.
// Compute the fixed and variable sizes.
@ -2024,7 +2057,7 @@ int SEGGER_RTT_TerminalOut (unsigned char TerminalId, const char* s) {
unsigned SEGGER_RTT_GetAvailWriteSpace (unsigned BufferIndex) {
SEGGER_RTT_BUFFER_UP* pRing;
pRing = (SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRing = (SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[BufferIndex] + SEGGER_RTT_UNCACHED_OFF); // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
return _GetAvailWriteSpace(pRing);
}
@ -2051,7 +2084,7 @@ unsigned SEGGER_RTT_GetBytesInBuffer(unsigned BufferIndex) {
// Avoid warnings regarding volatile access order. It's not a problem
// in this case, but dampen compiler enthusiasm.
//
pRTTCB = (volatile SEGGER_RTT_CB*)((unsigned char*)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
pRTTCB = (volatile SEGGER_RTT_CB*)((uintptr_t)&_SEGGER_RTT + SEGGER_RTT_UNCACHED_OFF); // Access RTTCB uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
RdOff = pRTTCB->aUp[BufferIndex].RdOff;
WrOff = pRTTCB->aUp[BufferIndex].WrOff;
if (RdOff <= WrOff) {

View File

@ -3,7 +3,7 @@
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
@ -42,7 +42,7 @@
* *
**********************************************************************
* *
* SystemView version: 3.20 *
* SystemView version: 3.58 *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
@ -50,7 +50,7 @@ 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: 20869 $
Revision: $Rev: 25842 $
----------------------------------------------------------------------
*/
@ -65,65 +65,22 @@ Revision: $Rev: 20869 $
*
**********************************************************************
*/
#ifndef RTT_USE_ASM
#if (defined __SES_ARM) // SEGGER Embedded Studio
#define _CC_HAS_RTT_ASM_SUPPORT 1
#elif (defined __CROSSWORKS_ARM) // Rowley Crossworks
#define _CC_HAS_RTT_ASM_SUPPORT 1
#elif (defined __ARMCC_VERSION) // ARM compiler
#if (__ARMCC_VERSION >= 6000000) // ARM compiler V6.0 and later is clang based
#define _CC_HAS_RTT_ASM_SUPPORT 1
#else
#define _CC_HAS_RTT_ASM_SUPPORT 0
#endif
#elif (defined __GNUC__) // GCC
#define _CC_HAS_RTT_ASM_SUPPORT 1
#elif (defined __clang__) // Clang compiler
#define _CC_HAS_RTT_ASM_SUPPORT 1
#elif ((defined __IASMARM__) || (defined __ICCARM__)) // IAR assembler/compiler
#define _CC_HAS_RTT_ASM_SUPPORT 1
#else
#define _CC_HAS_RTT_ASM_SUPPORT 0
#endif
#if ((defined __IASMARM__) || (defined __ICCARM__)) // IAR assembler/compiler
//
// IAR assembler / compiler
// Some cores support out-of-order memory accesses (reordering of memory accesses in the core)
// For such cores, we need to define a memory barrier to guarantee the order of certain accesses to the RTT ring buffers.
// Needed for:
// Cortex-M7 (ARMv7-M)
// Cortex-M23 (ARM-v8M)
// Cortex-M33 (ARM-v8M)
// Cortex-A/R (ARM-v7A/R)
//
#if (__VER__ < 6300000)
#define VOLATILE
#else
#define VOLATILE volatile
#endif
#if (defined __ARM7M__) // Needed for old versions that do not know the define yet
#if (__CORE__ == __ARM7M__) // Cortex-M3
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#endif
#endif
#if (defined __ARM7EM__) // Needed for old versions that do not know the define yet
#if (__CORE__ == __ARM7EM__) // Cortex-M4/M7
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
#if (defined __ARM8M_BASELINE__) // Needed for old versions that do not know the define yet
#if (__CORE__ == __ARM8M_BASELINE__) // Cortex-M23
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
#if (defined __ARM8M_MAINLINE__) // Needed for old versions that do not know the define yet
#if (__CORE__ == __ARM8M_MAINLINE__) // Cortex-M33
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
#else
//
// GCC / Clang
// We do not explicitly check for "Embedded Studio" as the compiler in use determines what we support.
// You can use an external toolchain like IAR inside ES. So there is no point in checking for "Embedded Studio"
//
#if (defined __CROSSWORKS_ARM) // Rowley Crossworks
#define _CC_HAS_RTT_ASM_SUPPORT 1
#if (defined __ARM_ARCH_7M__) // Cortex-M3
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#elif (defined __ARM_ARCH_7EM__) // Cortex-M4/M7
@ -138,9 +95,143 @@ Revision: $Rev: 20869 $
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined(__ARM_ARCH_8_1M_MAIN__)) // Cortex-M85
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#else
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#endif
#elif (defined __ARMCC_VERSION)
//
// ARM compiler
// ARM compiler V6.0 and later is clang based.
// Our ASM part is compatible to clang.
//
#if (__ARMCC_VERSION >= 6000000)
#define _CC_HAS_RTT_ASM_SUPPORT 1
#else
#define _CC_HAS_RTT_ASM_SUPPORT 0
#endif
#if (defined __ARM_ARCH_6M__) // Cortex-M0 / M1
#define _CORE_HAS_RTT_ASM_SUPPORT 0 // No ASM support for this architecture
#elif (defined __ARM_ARCH_7M__) // Cortex-M3
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#elif (defined __ARM_ARCH_7EM__) // Cortex-M4/M7
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8M_BASE__) // Cortex-M23
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8M_MAIN__) // Cortex-M33
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8_1M_MAIN__) // Cortex-M85
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif ((defined __ARM_ARCH_7A__) || (defined __ARM_ARCH_7R__)) // Cortex-A/R 32-bit ARMv7-A/R
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#else
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#endif
#elif ((defined __GNUC__) || (defined __clang__))
//
// GCC / Clang
//
#define _CC_HAS_RTT_ASM_SUPPORT 1
// ARM 7/9: __ARM_ARCH_5__ / __ARM_ARCH_5E__ / __ARM_ARCH_5T__ / __ARM_ARCH_5T__ / __ARM_ARCH_5TE__
#if (defined __ARM_ARCH_7M__) // Cortex-M3
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#elif (defined __ARM_ARCH_7EM__) // Cortex-M4/M7
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1 // Only Cortex-M7 needs a DMB but we cannot distinguish M4 and M7 here...
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8M_BASE__) // Cortex-M23
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8M_MAIN__) // Cortex-M33
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8_1M_MAIN__) // Cortex-M85
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif ((defined __ARM_ARCH_7A__) || (defined __ARM_ARCH_7R__)) // Cortex-A/R 32-bit ARMv7-A/R
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#else
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#endif
#elif ((defined __IASMARM__) || (defined __ICCARM__))
//
// IAR assembler/compiler
//
#define _CC_HAS_RTT_ASM_SUPPORT 1
#if (__VER__ < 6300000)
#define VOLATILE
#else
#define VOLATILE volatile
#endif
#if (defined __ARM7M__) // Needed for old versions that do not know the define yet
#if (__CORE__ == __ARM7M__) // Cortex-M3
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#endif
#endif
#if (defined __ARM7EM__)
#if (__CORE__ == __ARM7EM__) // Cortex-M4/M7
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
#if (defined __ARM8M_BASELINE__)
#if (__CORE__ == __ARM8M_BASELINE__) // Cortex-M23
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
#if (defined __ARM8M_MAINLINE__)
#if (__CORE__ == __ARM8M_MAINLINE__) // Cortex-M33
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
#if (defined __ARM8EM_MAINLINE__)
#if (__CORE__ == __ARM8EM_MAINLINE__) // Cortex-???
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
#if (defined __ARM7A__)
#if (__CORE__ == __ARM7A__) // Cortex-A 32-bit ARMv7-A
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
#if (defined __ARM7R__)
#if (__CORE__ == __ARM7R__) // Cortex-R 32-bit ARMv7-R
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
// TBD: __ARM8A__ => Cortex-A 64-bit ARMv8-A
// TBD: __ARM8R__ => Cortex-R 64-bit ARMv8-R
#else
//
// Other compilers
//
#define _CC_HAS_RTT_ASM_SUPPORT 0
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#endif
//
// If IDE and core support the ASM version, enable ASM version by default
@ -155,11 +246,6 @@ Revision: $Rev: 20869 $
#endif
#endif
//
// We need to know if a DMB is needed to make sure that on Cortex-M7 etc.
// the order of accesses to the ring buffers is guaranteed
// Needed for: Cortex-M7, Cortex-M23, Cortex-M33
//
#ifndef _CORE_NEEDS_DMB
#define _CORE_NEEDS_DMB 0
#endif
@ -192,6 +278,7 @@ Revision: $Rev: 20869 $
#ifndef SEGGER_RTT_ASM // defined when SEGGER_RTT.h is included from assembly file
#include <stdlib.h>
#include <stdarg.h>
#include <stdint.h>
/*********************************************************************
*
@ -232,7 +319,7 @@ typedef struct {
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
unsigned WrOff; // Position of next item to be written by either target.
volatile unsigned RdOff; // Position of next item to be read by host. Must be volatile since it may be modified by host.
unsigned Flags; // Contains configuration flags
unsigned Flags; // Contains configuration flags. Flags[31:24] are used for validity check and must be zero. Flags[23:2] are reserved for future use. Flags[1:0] = RTT operating mode.
} SEGGER_RTT_BUFFER_UP;
//
@ -245,7 +332,7 @@ typedef struct {
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
volatile unsigned WrOff; // Position of next item to be written by host. Must be volatile since it may be modified by host.
unsigned RdOff; // Position of next item to be read by target (down-buffer).
unsigned Flags; // Contains configuration flags
unsigned Flags; // Contains configuration flags. Flags[31:24] are used for validity check and must be zero. Flags[23:2] are reserved for future use. Flags[1:0] = RTT operating mode.
} SEGGER_RTT_BUFFER_DOWN;
//
@ -311,7 +398,7 @@ unsigned SEGGER_RTT_GetBytesInBuffer (unsigned BufferIndex);
//
// Function macro for performance optimization
//
#define SEGGER_RTT_HASDATA(n) (((SEGGER_RTT_BUFFER_DOWN*)((char*)&_SEGGER_RTT.aDown[n] + SEGGER_RTT_UNCACHED_OFF))->WrOff - ((SEGGER_RTT_BUFFER_DOWN*)((char*)&_SEGGER_RTT.aDown[n] + SEGGER_RTT_UNCACHED_OFF))->RdOff)
#define SEGGER_RTT_HASDATA(n) (((SEGGER_RTT_BUFFER_DOWN*)((uintptr_t)&_SEGGER_RTT.aDown[n] + SEGGER_RTT_UNCACHED_OFF))->WrOff - ((SEGGER_RTT_BUFFER_DOWN*)((uintptr_t)&_SEGGER_RTT.aDown[n] + SEGGER_RTT_UNCACHED_OFF))->RdOff)
#if RTT_USE_ASM
#define SEGGER_RTT_WriteSkipNoLock SEGGER_RTT_ASM_WriteSkipNoLock
@ -328,7 +415,7 @@ unsigned SEGGER_RTT_ReadUpBufferNoLock (unsigned BufferIndex, void* pDa
unsigned SEGGER_RTT_WriteDownBuffer (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteDownBufferNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
#define SEGGER_RTT_HASDATA_UP(n) (((SEGGER_RTT_BUFFER_UP*)((char*)&_SEGGER_RTT.aUp[n] + SEGGER_RTT_UNCACHED_OFF))->WrOff - ((SEGGER_RTT_BUFFER_UP*)((char*)&_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
#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
/*********************************************************************
*
@ -354,6 +441,13 @@ int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pPa
#endif // ifndef(SEGGER_RTT_ASM)
//
// For some environments, NULL may not be defined until certain headers are included
//
#ifndef NULL
#define NULL ((void*)0)
#endif
/*********************************************************************
*
* Defines

View File

@ -3,7 +3,7 @@
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
@ -42,7 +42,7 @@
* *
**********************************************************************
* *
* SystemView version: 3.20 *
* SystemView version: 3.58 *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
@ -423,6 +423,9 @@ int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pPa
case 's':
{
const char * s = va_arg(*pParamList, const char *);
if (s == NULL) {
s = "(NULL)"; // Print (NULL) instead of crashing or breaking, as it is more informative to the user.
}
do {
c = *s;
s++;

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
@ -42,13 +42,13 @@
* *
**********************************************************************
* *
* SystemView version: 3.20 *
* SystemView version: 3.58 *
* *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW.h
Purpose : System visualization API.
Revision: $Rev: 21292 $
Revision: $Rev: 28768 $
*/
#ifndef SEGGER_SYSVIEW_H
@ -77,7 +77,7 @@ extern "C" {
*/
#define SEGGER_SYSVIEW_MAJOR 3
#define SEGGER_SYSVIEW_MINOR 10
#define SEGGER_SYSVIEW_MINOR 32
#define SEGGER_SYSVIEW_REV 0
#define SEGGER_SYSVIEW_VERSION ((SEGGER_SYSVIEW_MAJOR * 10000) + (SEGGER_SYSVIEW_MINOR * 100) + SEGGER_SYSVIEW_REV)
@ -116,7 +116,7 @@ extern "C" {
#define SYSVIEW_EVTID_TIMER_EXIT 20
#define SYSVIEW_EVTID_STACK_INFO 21
#define SYSVIEW_EVTID_MODULEDESC 22
#define SYSVIEW_EVTID_DATA_SAMPLE 23
#define SYSVIEW_EVTID_INIT 24
#define SYSVIEW_EVTID_NAME_RESOURCE 25
#define SYSVIEW_EVTID_PRINT_FORMATTED 26
@ -130,6 +130,11 @@ extern "C" {
//
#define SYSVIEW_EVTID_EX_MARK 0
#define SYSVIEW_EVTID_EX_NAME_MARKER 1
#define SYSVIEW_EVTID_EX_HEAP_DEFINE 2
#define SYSVIEW_EVTID_EX_HEAP_ALLOC 3
#define SYSVIEW_EVTID_EX_HEAP_ALLOC_EX 4
#define SYSVIEW_EVTID_EX_HEAP_FREE 5
#define SYSVIEW_EVTID_EX_REGISTER_DATA 6
//
// Event masks to disable/enable events
//
@ -156,7 +161,7 @@ extern "C" {
#define SYSVIEW_EVTMASK_TIMER_EXIT (1 << SYSVIEW_EVTID_TIMER_EXIT)
#define SYSVIEW_EVTMASK_STACK_INFO (1 << SYSVIEW_EVTID_STACK_INFO)
#define SYSVIEW_EVTMASK_MODULEDESC (1 << SYSVIEW_EVTID_MODULEDESC)
#define SYSVIEW_EVTMASK_DATA_SAMPLE (1 << SYSVIEW_EVTID_DATA_SAMPLE)
#define SYSVIEW_EVTMASK_INIT (1 << SYSVIEW_EVTID_INIT)
#define SYSVIEW_EVTMASK_NAME_RESOURCE (1 << SYSVIEW_EVTID_NAME_RESOURCE)
#define SYSVIEW_EVTMASK_PRINT_FORMATTED (1 << SYSVIEW_EVTID_PRINT_FORMATTED)
@ -191,8 +196,42 @@ typedef struct {
U32 Prio;
U32 StackBase;
U32 StackSize;
U32 StackUsage;
} SEGGER_SYSVIEW_TASKINFO;
typedef struct {
U32 TaskID;
U32 StackBase;
U32 StackSize;
U32 StackUsage;
} SEGGER_SYSVIEW_STACKINFO;
typedef struct {
U32 ID;
union {
U32* pU32;
I32* pI32;
float* pFloat;
} pValue;
} SEGGER_SYSVIEW_DATA_SAMPLE;
typedef enum {
SEGGER_SYSVIEW_TYPE_U32 = 0,
SEGGER_SYSVIEW_TYPE_I32 = 1,
SEGGER_SYSVIEW_TYPE_FLOAT = 2
} SEGGER_SYSVIEW_DATA_TYPE;
typedef struct {
U32 ID;
SEGGER_SYSVIEW_DATA_TYPE DataType;
I32 Offset;
I32 RangeMin;
I32 RangeMax;
float ScalingFactor;
const char* sName;
const char* sUnit;
} SEGGER_SYSVIEW_DATA_REGISTER;
typedef struct SEGGER_SYSVIEW_MODULE_STRUCT SEGGER_SYSVIEW_MODULE;
struct SEGGER_SYSVIEW_MODULE_STRUCT {
@ -251,10 +290,13 @@ void SEGGER_SYSVIEW_Stop (void);
void SEGGER_SYSVIEW_GetSysDesc (void);
void SEGGER_SYSVIEW_SendTaskList (void);
void SEGGER_SYSVIEW_SendTaskInfo (const SEGGER_SYSVIEW_TASKINFO* pInfo);
void SEGGER_SYSVIEW_SendStackInfo (const SEGGER_SYSVIEW_STACKINFO* pInfo);
void SEGGER_SYSVIEW_SendSysDesc (const char* sSysDesc);
int SEGGER_SYSVIEW_IsStarted (void);
int SEGGER_SYSVIEW_GetChannelID (void);
void SEGGER_SYSVIEW_SampleData (const SEGGER_SYSVIEW_DATA_SAMPLE *pInfo);
/*********************************************************************
*
* Event recording functions
@ -292,7 +334,13 @@ void SEGGER_SYSVIEW_MarkStop (unsigned int MarkerId);
void SEGGER_SYSVIEW_Mark (unsigned int MarkerId);
void SEGGER_SYSVIEW_NameMarker (unsigned int MarkerId, const char* sName);
void SEGGER_SYSVIEW_HeapDefine (void* pHeap, void* pBase, unsigned int HeapSize, unsigned int MetadataSize);
void SEGGER_SYSVIEW_HeapAlloc (void* pHeap, void* pUserData, unsigned int UserDataLen);
void SEGGER_SYSVIEW_HeapAllocEx (void* pHeap, void* pUserData, unsigned int UserDataLen, unsigned int Tag);
void SEGGER_SYSVIEW_HeapFree (void* pHeap, void* pUserData);
void SEGGER_SYSVIEW_NameResource (U32 ResourceId, const char* sName);
void SEGGER_SYSVIEW_RegisterData ( SEGGER_SYSVIEW_DATA_REGISTER* pInfo);
int SEGGER_SYSVIEW_SendPacket (U8* pPacket, U8* pPayloadEnd, unsigned int EventId);
@ -323,13 +371,21 @@ void SEGGER_SYSVIEW_SendNumModules (void);
*/
#ifndef SEGGER_SYSVIEW_EXCLUDE_PRINTF // Define in project to avoid warnings about variable parameter list
void SEGGER_SYSVIEW_PrintfHostEx (const char* s, U32 Options, ...);
void SEGGER_SYSVIEW_VPrintfHostEx (const char* s, U32 Options, va_list* pParamList);
void SEGGER_SYSVIEW_PrintfTargetEx (const char* s, U32 Options, ...);
void SEGGER_SYSVIEW_VPrintfTargetEx (const char* s, U32 Options, va_list* pParamList);
void SEGGER_SYSVIEW_PrintfHost (const char* s, ...);
void SEGGER_SYSVIEW_VPrintfHost (const char* s, va_list* pParamList);
void SEGGER_SYSVIEW_PrintfTarget (const char* s, ...);
void SEGGER_SYSVIEW_VPrintfTarget (const char* s, va_list* pParamList);
void SEGGER_SYSVIEW_WarnfHost (const char* s, ...);
void SEGGER_SYSVIEW_VWarnfHost (const char* s, va_list* pParamList);
void SEGGER_SYSVIEW_WarnfTarget (const char* s, ...);
void SEGGER_SYSVIEW_VWarnfTarget (const char* s, va_list* pParamList);
void SEGGER_SYSVIEW_ErrorfHost (const char* s, ...);
void SEGGER_SYSVIEW_VErrorfHost (const char* s, va_list* pParamList);
void SEGGER_SYSVIEW_ErrorfTarget (const char* s, ...);
void SEGGER_SYSVIEW_VErrorfTarget (const char* s, va_list* pParamList);
#endif
void SEGGER_SYSVIEW_Print (const char* s);

View File

@ -3,7 +3,7 @@
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
@ -42,14 +42,14 @@
* *
**********************************************************************
* *
* SystemView version: 3.20 *
* SystemView version: 3.58 *
* *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW_ConfDefaults.h
Purpose : Defines defaults for configurable defines used in
SEGGER SystemView.
Revision: $Rev: 21319 $
Revision: $Rev: 26230 $
*/
#ifndef SEGGER_SYSVIEW_CONFDEFAULTS_H
@ -69,10 +69,6 @@ Revision: $Rev: 21319 $
extern "C" {
#endif
#include <stdint.h>
extern uint32_t svc_get_dwt_cyccnt();
/*********************************************************************
*
* Defines, fixed
@ -216,7 +212,7 @@ extern uint32_t svc_get_dwt_cyccnt();
*/
#ifndef SEGGER_SYSVIEW_GET_TIMESTAMP
#if defined (SEGGER_SYSVIEW_CORE) && (SEGGER_SYSVIEW_CORE == SEGGER_SYSVIEW_CORE_CM3)
#define SEGGER_SYSVIEW_GET_TIMESTAMP() svc_get_dwt_cyccnt() // Retrieve a system timestamp. Cortex-M cycle counter.
#define SEGGER_SYSVIEW_GET_TIMESTAMP() (*(U32 *)(0xE0001004)) // Retrieve a system timestamp. Cortex-M cycle counter.
#else
#define SEGGER_SYSVIEW_GET_TIMESTAMP() SEGGER_SYSVIEW_X_GetTimestamp() // Retrieve a system timestamp via user-defined function
#endif
@ -269,7 +265,7 @@ extern uint32_t svc_get_dwt_cyccnt();
* 1024
*/
#ifndef SEGGER_SYSVIEW_RTT_BUFFER_SIZE
#define SEGGER_SYSVIEW_RTT_BUFFER_SIZE 4096
#define SEGGER_SYSVIEW_RTT_BUFFER_SIZE 1024
#endif
/*********************************************************************
@ -364,7 +360,33 @@ extern uint32_t svc_get_dwt_cyccnt();
* 128
*/
#ifndef SEGGER_SYSVIEW_MAX_STRING_LEN
#define SEGGER_SYSVIEW_MAX_STRING_LEN 1024
#define SEGGER_SYSVIEW_MAX_STRING_LEN 128
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_SUPPORT_LONG_ID
*
* Description
* It set, support enconding Evend Ids longer than 14 bit.
* Default
* 1
*/
#ifndef SEGGER_SYSVIEW_SUPPORT_LONG_ID
#define SEGGER_SYSVIEW_SUPPORT_LONG_ID 1
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_SUPPORT_LONG_DATA
*
* Description
* It set, support enconding event data longer than 14 bit.
* Default
* 0
*/
#ifndef SEGGER_SYSVIEW_SUPPORT_LONG_DATA
#define SEGGER_SYSVIEW_SUPPORT_LONG_DATA 0
#endif
/*********************************************************************

View File

@ -3,7 +3,7 @@
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
@ -42,7 +42,7 @@
* *
**********************************************************************
* *
* SystemView version: 3.20 *
* SystemView version: 3.58 *
* *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------

View File

@ -3,7 +3,7 @@
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2019 SEGGER Microcontroller GmbH *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
@ -42,7 +42,7 @@
* *
**********************************************************************
* *
* SystemView version: 3.20 *
* SystemView version: 3.58 *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
@ -50,7 +50,7 @@ File : SEGGER_RTT_Syscalls_GCC.c
Purpose : Low-level functions for using printf() via RTT in GCC.
To use RTT for printf output, include this file in your
application.
Revision: $Rev: 20755 $
Revision: $Rev: 24316 $
----------------------------------------------------------------------
*/
#if (defined __GNUC__) && !(defined __SES_ARM) && !(defined __CROSSWORKS_ARM) && !(defined __ARMCC_VERSION) && !(defined __CC_ARM)

View File

@ -479,11 +479,6 @@ __attribute__((no_stack_protector, used)) static uint32_t svc_handler(
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
switch (svc_number) {
#ifdef SYSTEM_VIEW
case SVC_GET_DWT_CYCCNT:
cyccnt_cycles = *DWT_CYCCNT_ADDR;
break;
#endif
case SVC_SYSTASK_YIELD:
// Yield to the waiting task
systask_yield();