@@ -238,10 +238,10 @@ impl RttSession {
238
238
239
239
// Send the stop command if we can
240
240
if let RttSessionState :: Run ( rtt_handles) = & self . state {
241
- if ! self . rtt_cfg . disable_control_plane {
241
+ if let Some ( down_ch ) = rtt_handles . down_channel . as_ref ( ) {
242
242
debug ! ( "Sending stop command" ) ;
243
243
let cmd = TrcCommand :: StopTracing . to_wire_bytes ( ) ;
244
- rtt_handles . down_channel . write ( & mut core, & cmd) . ok ( ) ;
244
+ down_ch . write ( & mut core, & cmd) . ok ( ) ;
245
245
}
246
246
}
247
247
@@ -512,24 +512,24 @@ impl RttSession {
512
512
. position ( |ch| ch. number ( ) == self . rtt_cfg . up_channel as usize )
513
513
. ok_or_else ( || Error :: UpChannelInvalid ( self . rtt_cfg . up_channel as _ ) ) ?;
514
514
515
- let down_ch_index = rtt
516
- . down_channels ( )
517
- . iter ( )
518
- . position ( |ch| ch. number ( ) == self . rtt_cfg . down_channel as usize )
519
- . ok_or_else ( || Error :: DownChannelInvalid ( self . rtt_cfg . down_channel as _ ) ) ?;
520
-
521
515
let up_channel = rtt. up_channels . remove ( up_ch_index) ;
522
516
let up_channel_mode = up_channel. mode ( & mut core) ?;
523
517
debug ! ( channel = up_channel. number( ) , mode = ?up_channel_mode, buffer_size = up_channel. buffer_size( ) , "Opened up channel" ) ;
524
518
525
- let down_channel = rtt. down_channels . remove ( down_ch_index) ;
526
- debug ! (
527
- channel = down_channel. number( ) ,
528
- buffer_size = down_channel. buffer_size( ) ,
529
- "Opened down channel"
530
- ) ;
519
+ let down_channel = if !self . rtt_cfg . disable_control_plane {
520
+ let down_ch_index = rtt
521
+ . down_channels ( )
522
+ . iter ( )
523
+ . position ( |ch| ch. number ( ) == self . rtt_cfg . down_channel as usize )
524
+ . ok_or_else ( || Error :: DownChannelInvalid ( self . rtt_cfg . down_channel as _ ) ) ?;
525
+
526
+ let down_channel = rtt. down_channels . remove ( down_ch_index) ;
527
+ debug ! (
528
+ channel = down_channel. number( ) ,
529
+ buffer_size = down_channel. buffer_size( ) ,
530
+ "Opened down channel"
531
+ ) ;
531
532
532
- if !self . rtt_cfg . disable_control_plane {
533
533
if self . rtt_cfg . restart {
534
534
debug ! ( "Sending stop command" ) ;
535
535
let cmd = TrcCommand :: StopTracing . to_wire_bytes ( ) ;
@@ -540,7 +540,11 @@ impl RttSession {
540
540
debug ! ( "Sending start command" ) ;
541
541
let cmd = TrcCommand :: StartTracing . to_wire_bytes ( ) ;
542
542
down_channel. write ( & mut core, & cmd) ?;
543
- }
543
+
544
+ Some ( down_channel)
545
+ } else {
546
+ None
547
+ } ;
544
548
545
549
// Auxilary cores get vector catching enabled after we know they're running
546
550
if !self . target_cfg . bootloader && !self . target_cfg . bootloader_companion_application {
@@ -665,7 +669,7 @@ pub struct RttHandles {
665
669
/// RTT up (target to host) channel
666
670
up_channel : UpChannel ,
667
671
/// RTT down (host to target) channel
668
- down_channel : DownChannel ,
672
+ down_channel : Option < DownChannel > ,
669
673
}
670
674
671
675
#[ derive( Debug ) ]
0 commit comments