Skip to content

RTT structure is incorrect for 64-bit targets #1013

@xobs

Description

@xobs

The in-memory structures currently used by defmt for RTT are incompatible with the reference code when run in 64-bit platforms.

For example, the header uses usize as the datatype when defining the maximum number of up- and down-channels:

max_up_channels: usize,
max_down_channels: usize,

However, the upstream library code uses int, which is equivalent to u32 on all modern platforms: https://github.com/SEGGERMicro/RTT/blob/ad6970d813bb12b8a5e34aa94b3a1999f7bd0b6b/RTT/SEGGER_RTT.h#L353-L354

Additionally, all the fields in Channel are defined as usize or AtomicUsize:

pub size: usize,
/// Written by the target.
pub write: AtomicUsize,
/// Written by the host.
pub read: AtomicUsize,
/// Channel properties.
///
/// Currently, only the lowest 2 bits are used to set the channel mode (see constants below).
pub flags: AtomicUsize,

However, the official implementation uses unsigned as the type, which is also equivalent to a u32 on all tested platforms: https://github.com/SEGGERMicro/RTT/blob/ad6970d813bb12b8a5e34aa94b3a1999f7bd0b6b/RTT/SEGGER_RTT.h#L340-L343

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions