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
[Bug] Corrupted console output with large buffers. #1697
Comments
Let's confirm that the same behavior does not exist on a board with a "normal" UART (e.g. Hail or imix). So we can triangulate that this is probably specific to the Segger RTT stack (which is pretty different). |
Yes if someone could check on a traditional UART that would be very helpful. |
on nrf52840dk with kernel on master no changes:
on hail, again on master:
|
I ported the app to c and it runs fine on hail and nrf52840dk using uart. On the nrf52840dk with RTT it gets corrupted:
|
Your kernel loads apps from 0x20004000 whereas the app's layout expects to start from 0x20006000. As mentioned in #1696 (comment), this is because with
Same thing. With libtock-rs the app must currently be compiled with a (board-dependent) fixed start address, because relocating libtock-rs apps currently doesn't work (tock/libtock-rs#28). |
Gotcha. We really need to improve the tooling around all of this. |
What happens would be a bit clearer with Lines 37 to 42 in 527afb4
|
libtock-rs tooling issues aside, this implies that the problem is likely in the Segger-RTT driver, right? |
I think so |
In that case, unless someone else is willing to debug this, I'd label this issue as "blocked" until #1651 is resolved. I don't want to scratch my head on the Segger RTT while the basics it depends on (virtual alarms) are not working properly. Fixing the alarms may even turn out to be sufficient to fix this corrupted output. |
1960: Increase delay in Segger RTT debugging (fix #1697). r=brghena a=gendx ### Pull Request Overview This pull request fixes #1697 by increasing the delay in Segger RTT debugging. I tried various parameters, and 1ms of delay seems reliable enough, even for large buffers (tested up to 1500 bytes). Somehow, when I originally filed #1697, I don't recall that increasing this delay would work, but it seems to fix it in the current kernel. ### Testing Strategy This pull request was tested on a nRF52840-DK board with the "console triangle" test mentioned in #1697 and located on https://github.com/gendx/libtock-rs/blob/console-check/examples/console_triangle.rs. I also tested increasing the "width" of the triangle up to 1500 bytes, and the output works properly. I had a look at https://www.segger.com/downloads/jlink but couldn't find a reliable source of ground truth on the acceptable frequency to refresh the RTT buffers... ### TODO or Help Wanted This change makes the console slower, especially if one only uses very small buffers. However, reliability is likely preferable over premature optimization. Better start from a working code and optimize from there than the opposite. ### Documentation Updated - [x] Updated the relevant files in `/docs`, or no updates are required. ### Formatting - [x] Ran `make prepush`. Co-authored-by: Guillaume Endignoux <guillaumee@google.com> Co-authored-by: gendx <gendx@users.noreply.github.com>
System specifications
USB_DEBUGGING
enabled on the board'ssrc/main.rs
Commands run
On Tock repository.
cd boards/nordic/nrf52840dk make flash
On libtock-rs at my console-check branch.
Expected behavior
The
console_triangle
example from myconsole-check
branch onlibtock-rs
is using the console driver with buffers of increasing size (hence the "triangle") https://github.com/gendx/libtock-rs/blob/console-check/examples/console_triangle.rs.The output is supposed to look like this:
Observed behavior
With a maximum buffer size of 128 bytes, I observe corrupted console output such as the following:
When the maximum buffer size is 64 bytes however, there's no such corrupted output.
Analysis
Incidentally, the console driver has buffers of 64 bytes, which leads me to believe that the bug could come from there.
tock/capsules/src/console.rs
Lines 59 to 60 in 527afb4
It could also be another side-effect of alarms not working properly (see #1651).
Help wanted
I can currently only test on nRF52840-DK via Segger RTT output, so it would be helpful to know if anyone can reproduce on another board and/or on UART output.
The text was updated successfully, but these errors were encountered: