Wednesday, May 23rd 2018, 5:37am UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

stephrdev

Beginner

Date of registration: Feb 2nd 2018

Posts: 1

1

Monday, February 5th 2018, 9:59am

[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:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Device name. Default: NRF51822_XXAA >
Target interface. >
Interface speed [kHz]. Default: 4000 kHz >
RTT Control Block address. Default: auto-detection >
RTT Channel name or index. Default: channel 1 > 0
Output file. Default: RTT_<ChannelName>_<Time>.log >

------------------------------------------------------------

Connected to:
J-Link OB-BBC-microbit compiled Mar 24 2017 09:33:30
S/N: 782463927

Searching for RTT Control Block...OK. 1 up-channels found.
RTT Channel description:
Index: 0
Name: Terminal
Size: 128 bytes.

Output file: RTT_Terminal_201802021931.log

Getting RTT data from target. Press any key to quit.
------------------------------------------------------------

Transfer rate: 0 KByte/s Bytes written: 0 Byte



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



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
2
3
4
5
6
type: `rtt::RTTControlBlock`: 72 bytes, alignment: 4 bytes
field `.name`: 16 bytes
field `.max_up_buffers`: 4 bytes
field `.max_down_buffers`: 4 bytes
field `.up_buffers`: 24 bytes
field `.down_buffers`: 24 bytes


Source code

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



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

Thanks a lot!

SEGGER - Nino

Super Moderator

Date of registration: Jan 2nd 2017

Posts: 1,048

2

Tuesday, February 13th 2018, 9:49am

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: Forum Rules

Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
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 contact us per e-mail.
The following contact form can be used for this: https://www.segger.com/about-us/contact-us/