mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-26 20:37:19 +00:00
segger-rtt: allow to configure with SEGGER_RTT_PACKETLOG_* directives
This commit is contained in:
parent
ea1be65587
commit
8cbbcccdda
@ -99,7 +99,7 @@ ENABLE_CC256X_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND | Enable workaround for
|
||||
ENABLE_CYPRESS_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND | Enable workaround for bug in CYW2070x Flow Control during baud rate change, similar to CC256x.
|
||||
ENABLE_TLV_FLASH_EXPLICIT_DELETE_FIELD | Enable use of explicit delete field in TLV Flash implemenation - required when flash value cannot be overwritten with zero
|
||||
ENABLE_CONTROLLER_WARM_BOOT | Enable stack startup without power cycle (if supported/possible)
|
||||
|
||||
ENABLE_SEGGER_RTT | Use SEGGER RTT for console output and packet log, see [additional options](#sec:rttConfiguration)
|
||||
Notes:
|
||||
|
||||
- ENABLE_MICRO_ECC_FOR_LE_SECURE_CONNECTIONS: Only some Bluetooth 4.2+ controllers (e.g., EM9304, ESP32) support the necessary HCI commands for ECC. Other reason to enable the ECC software implementations are if the Host is much faster or if the micro-ecc library is already provided (e.g., ESP32, WICED, or if the ECC HCI Commands are unreliable.
|
||||
@ -187,12 +187,25 @@ If implemented, bonding information is stored in Non-volatile memory. For Classi
|
||||
<!-- a name "lst:nvmDefines"></a-->
|
||||
<!-- -->
|
||||
|
||||
\#define | Description
|
||||
\#define | Description
|
||||
--------------------------|------------
|
||||
NVM_NUM_LINK_KEYS | Max number of Classic Link Keys that can be stored
|
||||
NVM_NUM_DEVICE_DB_ENTRIES | Max number of LE Device DB entries that can be stored
|
||||
NVN_NUM_GATT_SERVER_CCC | Max number of 'Client Characteristic Configuration' values that can be stored by GATT Server
|
||||
|
||||
|
||||
### SEGGER Real Time Transfer (RTT) directives {#sec:rttConfiguration}
|
||||
|
||||
[SEGGER RTT](https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/) replaces use of an UART for debugging with higher throughput and less overhead. In addition, it allows for direct logging in PacketLogger/BlueZ format via the provided JLinkRTTLogger tool.
|
||||
|
||||
When enabled with `ENABLE_SEGGER_RTT` and `hci_dump_open` was called with either `HCI_DUMP_BLUEZ` or `HCI_DUMP_PACKETLOGGER`, the following directives are used to configure the up channel:
|
||||
|
||||
\#define | Default | Description
|
||||
---------------------------------|--------------------------------|------------------------
|
||||
SEGGER_RTT_PACKETLOG_MODE | SEGGER_RTT_MODE_NO_BLOCK_SKIP | SEGGER_RTT_MODE_NO_BLOCK_SKIP to skip messages if buffer is full, or, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL to block
|
||||
SEGGER_RTT_PACKETLOG_CHANNEL | 1 | Channel to use for packet log. Channel 0 is used for terminal
|
||||
SEGGER_RTT_PACKETLOG_BUFFER_SIZE | 1024 | Size of outgoing ring buffer. Increase if you cannot block but get 'message skipped' warnings
|
||||
|
||||
## Source tree structure {#sec:sourceTreeHowTo}
|
||||
|
||||
The source tree has been organized to easily setup new projects.
|
||||
|
@ -70,7 +70,20 @@
|
||||
|
||||
#ifdef ENABLE_SEGGER_RTT
|
||||
#include "SEGGER_RTT.h"
|
||||
static char channel1_out[1024];
|
||||
|
||||
// allow to configure mode, channel, up buffer size in btstack_config.h for binary HCI formats (PacketLogger/BlueZ)
|
||||
|
||||
#ifndef SEGGER_RTT_PACKETLOG_MODE
|
||||
#define SEGGER_RTT_PACKETLOG_MODE SEGGER_RTT_MODE_DEFAULT
|
||||
#endif
|
||||
#ifndef SEGGER_RTT_PACKETLOG_BUFFER_SIZE
|
||||
#define SEGGER_RTT_PACKETLOG_BUFFER_SIZE 1024
|
||||
#endif
|
||||
#ifndef SEGGER_RTT_PACKETLOG_CHANNEL
|
||||
#define SEGGER_RTT_PACKETLOG_CHANNEL 1
|
||||
#endif
|
||||
|
||||
static char segger_rtt_packetlog_buffer[SEGGER_RTT_PACKETLOG_BUFFER_SIZE];
|
||||
#endif
|
||||
|
||||
// BLUEZ hcidump - struct not used directly, but left here as documentation
|
||||
@ -140,12 +153,7 @@ void hci_dump_open(const char *filename, hci_dump_format_t format){
|
||||
switch (dump_format){
|
||||
case HCI_DUMP_PACKETLOGGER:
|
||||
case HCI_DUMP_BLUEZ:
|
||||
// Configure up channel 1, options:
|
||||
// - SEGGER_RTT_MODE_NO_BLOCK_SKIP
|
||||
// - SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
|
||||
// Note: with SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL, firwmware will hang if RTT not supported/debug probe not connected
|
||||
// Note: with SEGGER_RTT_MODE_NO_BLOCK_SKIP, there's a chance for log file corruption if second write (packet) is skipped
|
||||
SEGGER_RTT_ConfigUpBuffer(1, "hci_dump", &channel1_out[0], sizeof(channel1_out), SEGGER_RTT_MODE_NO_BLOCK_SKIP) ;;
|
||||
SEGGER_RTT_ConfigUpBuffer(SEGGER_RTT_PACKETLOG_CHANNEL, "hci_dump", &segger_rtt_packetlog_buffer[0], SEGGER_RTT_PACKETLOG_BUFFER_SIZE, SEGGER_RTT_PACKETLOG_MODE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -298,7 +306,7 @@ void hci_dump_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_SEGGER_RTT
|
||||
#if (SEGGER_RTT_MODE_DEFAULT == SEGGER_RTT_MODE_NO_BLOCK_SKIP)
|
||||
#if (SEGGER_RTT_PACKETLOG_MODE == SEGGER_RTT_MODE_NO_BLOCK_SKIP)
|
||||
static const char rtt_warning[] = "RTT buffer full - packet(s) skipped";
|
||||
static bool rtt_packet_skipped = false;
|
||||
if (rtt_packet_skipped){
|
||||
@ -335,17 +343,17 @@ void hci_dump_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t
|
||||
|
||||
#ifdef ENABLE_SEGGER_RTT
|
||||
|
||||
#if (SEGGER_RTT_MODE_DEFAULT == SEGGER_RTT_MODE_NO_BLOCK_SKIP)
|
||||
#if (SEGGER_RTT_PACKETLOG_MODE == SEGGER_RTT_MODE_NO_BLOCK_SKIP)
|
||||
// check available space in buffer to avoid writing header but not packet
|
||||
unsigned space_free = SEGGER_RTT_GetAvailWriteSpace(1);
|
||||
unsigned space_free = SEGGER_RTT_GetAvailWriteSpace(SEGGER_RTT_PACKETLOG_CHANNEL);
|
||||
if ((header_len + len) > space_free) {
|
||||
rtt_packet_skipped = true;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
SEGGER_RTT_Write(1, &header, header_len);
|
||||
SEGGER_RTT_Write(1, packet, len);
|
||||
SEGGER_RTT_Write(SEGGER_RTT_PACKETLOG_CHANNEL, &header, header_len);
|
||||
SEGGER_RTT_Write(SEGGER_RTT_PACKETLOG_CHANNEL, packet, len);
|
||||
#endif
|
||||
UNUSED(header_len);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user