-
Notifications
You must be signed in to change notification settings - Fork 541
Split debug menu and add Segger RTT as option for logging output #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1. separate debug level from systemview enable/disable This allows enabling systemview without also setting really high debug level. High debug level caused lots of serial output, which slowed things down and added Heisenbugs. 2. Add option to redirect output via Segger RTT instead of serial output. Updates to Segger RTT v6.60d. Boards.txt / platform.txt are used to allow UI to show the new options, which causes the following to be defined during build: * CFG_DEBUG := As before, from 0 (disabled) to 3 (very verbose) * CFG_LOGGER := Where to output logs / printf; either 1 (serial) or 2 (RTT) * CFG_SYSVIEW := Enables SysView APIs if set to non-zero value
Add additional functions to Segger_RTT_Stream_t, so callers do not need to change code if they are expecting a serial port. Per Arduino web page, serialEvent() is not supported on all boards. RTT also has no interrupt-based notification when the host writes data, so for now, not implementing a serialEvent workaround (e.g., timer or loop-based manual check for available data).
This function is identical to SEGGER_RTT_TerminalOut(), except that it sends the caller-specified arbitrary bytes to the terminal. This makes it much easier to use the multiple terminals as a replacement for STDERR, STDOUT, etc., because the function handles all the edges cases, and just needs the formatted string to be provided.
Added distinct header and implementation files. Also redirected _write() to RTT when logging to RTT.
If RTT mode is set to `SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL`, then the program will halt when the buffer fills unless a JLink is connected and draining the buffer. Fix by setting to `SEGGER_RTT_MODE_NO_BLOCK_SKIP`. Always define `Adalog_Default_Logger`, even when CFG_DEBUG is not defined.
In case later have a logger that requires begin(). Also makes conversion from Serial easier, as don't need to special-case calls to begin().
Compile-time assertions are awesome, whether via static_assert() or #if blocks, as they can show when assumptions are false, and they catch new changes that make prior assumptions no longer true.
for Adalog_Default_Logger.
|
Thanks @henrygab your reason is all valid, however, I don't prefer to have 2 extra menu options just to deal with this. Especially there is only 5% of people will ever use it. This Arduino repo still primarily target beginner, most don't ever have a jlink to begin with. To sum up, I think we should still keep the menu as it is with a simple modification to automatically enabled CFG_SYSVIEW when CFG_DEBUG=3, else you could just modify the source to manually enable CFG_SYSVIEW alone while keeping debug level = 0. Same with logger with SYSVIEW, please add CFG_SYSVIEW_LOG somewhere in the source where you could just toggle 0/1 when needed. I am really like your work, unfortunately, this PR will be only used by a very small users and could cause confusion to the vast majority. |
|
Hi @hathach , and welcome back. I hope your time off was excellent. Based on your review, I am removing the menu options as requested. I also updated In this way, if desiring to use the Segger RTT and/or Segger SysView, it is now easily done using either |
hathach
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the original RTT sources files, we will only use it as it is.
Thank you very much, it is indeed excellent, except for the Coronavirus ~ . ~
I don't really like this approach either, but it is doable. I would expect advanced user modify the source file directly without the help of IDE e.g |
|
I will have to think about how to meet all the changes you would like. |
hathach
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not being clear. I mean we should leave the Segger RTT source code untouched.
Per Hathach request, using the files provided under SysView rather than provided with JLink.
Do not use Assembly version.
Hathach requested not to modify any SEGGER-provided files. However, it is not possible to avoid some type of modification. This is the closest without some type of modification.
This hack is brought to you by letters 'Q' and 'Z', and by the numbers '0' and '1'.
|
Please see new PR #431. It is a squashed merge from this branch, and thus will provide a cleaner history. |
[EDIT: Please see new PR #431.]
Resolves #416
At its core, this PR does three things, but does _ not_ change the default build behavior (CFG_DEBUG=0).
Separates the concept of CFG_DEBUG (debug level in UI) from whether or not SysView is enabled. As noted in Split debug menu and add Segger RTT as option for logging output #416, only enabling SysView with CFG_DEBUG set to 3+ can prevent SysView from being used to find Heisenbugs. Now, SysView can be enabled even when CFG_DEBUG is set to zero.
Exposes a "default" logger that derives from the Stream class. This default logger is used for all built-in board logging output, and is exposed for use by libraries if they choose to use it. By default, this is still Serial, and thus has no appreciable effect when using default build configuration.
Add support for Segger RTT as the default data log, helping to track Heisenbugs that otherwise would be hidden when logging levels are increased. Serial remains the default, and a new menu option is provided to select the use of RTT for board-level logging.
Tested on nRF52840 Feather Express hardware with various option combinations, and RTT tested both with and without JLink attached.
NOTE:
Serial.begin()is no-op. Why does main.cpp call it (around line 50)?[edit: not a no-op on nrf52832, which uses hardware uart]
[edit Also tested building using
arduino-builder.exe… made life so much easier!]