-
-
Notifications
You must be signed in to change notification settings - Fork 118
Description
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:
defmt/firmware/defmt-rtt/src/lib.rs
Lines 250 to 251 in ce8c280
| 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:
defmt/firmware/defmt-rtt/src/channel.rs
Lines 14 to 22 in ce8c280
| 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