[ABANDONED] Memory layout RTT control block and buffer

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [ABANDONED] Memory layout RTT control block and buffer

    Hi!

    I'm currently trying to implement a Segger RTT library in Rust for - in my case a bbc micro:bit (Cortex M0+) flashed with the JLink OB.

    It looks like it could work because the JLinkRTTLogger automatically finds the RTT control block and also correctly detects the buffer size of the first up buffer:

    Brainfuck Source Code

    1. Device name. Default: NRF51822_XXAA >
    2. Target interface. >
    3. Interface speed [kHz]. Default: 4000 kHz >
    4. RTT Control Block address. Default: auto-detection >
    5. RTT Channel name or index. Default: channel 1 > 0
    6. Output file. Default: RTT_<ChannelName>_<Time>.log >
    7. ------------------------------------------------------------
    8. Connected to:
    9. J-Link OB-BBC-microbit compiled Mar 24 2017 09:33:30
    10. S/N: 782463927
    11. Searching for RTT Control Block...OK. 1 up-channels found.
    12. RTT Channel description:
    13. Index: 0
    14. Name: Terminal
    15. Size: 128 bytes.
    16. Output file: RTT_Terminal_201802021931.log
    17. Getting RTT data from target. Press any key to quit.
    18. ------------------------------------------------------------
    19. Transfer rate: 0 KByte/s Bytes written: 0 Byte
    Display All



    But from this point, nothing happens. No bytes are received after this point.

    I used the gdb to ensure that the buffer is correctly filled with chars and the write offset is updated as expected, this is the printed data structure of the control block:

    Source Code

    1. $4 = {
    2. name = "SEGGER RTT\000\000\000\000\000",
    3. max_up_buffers = 1,
    4. max_down_buffers = 1,
    5. up_buffers = {{
    6. name = 0xae4c <str.0> "Terminal",
    7. buffer = 0x20002018 "34C334C334C334C",
    8. buffer_size = 128,
    9. write_offset = 15,
    10. read_offset = 0,
    11. flags = 0
    12. }},
    13. down_buffers = ...
    14. }
    Display All



    It seems like the JLinkRTTLogger doesn't pick up on the write offset, reads the bytes and updates the read offset.

    Finally, to make sure I ported the RTT C structs correctly, this is the memory layout of both, the control block and the buffer (assuming one up and one down channel):

    Source Code

    1. type: `rtt::RTTControlBlock`: 72 bytes, alignment: 4 bytes
    2. field `.name`: 16 bytes
    3. field `.max_up_buffers`: 4 bytes
    4. field `.max_down_buffers`: 4 bytes
    5. field `.up_buffers`: 24 bytes
    6. field `.down_buffers`: 24 bytes


    Source Code

    1. type: `rtt::RttBuffer`: 24 bytes, alignment: 4 bytes
    2. field `.name`: 4 bytes
    3. field `.buffer`: 4 bytes
    4. field `.buffer_size`: 4 bytes
    5. field `.write_offset`: 4 bytes
    6. field `.read_offset`: 4 bytes
    7. field `.flags`: 4 bytes



    I'm thankful for any hint or help on this topic!

    Thanks a lot!
  • Hello,

    Thank you for your inquiry.
    Generally your implementation looks correct. So it is not clear why it would not work.
    Are you using any low power modes that might alter or disable the debug connection?
    If so try to disable them and retry.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.