diff --git a/bao1x-boot/boot1/src/main.rs b/bao1x-boot/boot1/src/main.rs index e4896f588..0401e3be3 100644 --- a/bao1x-boot/boot1/src/main.rs +++ b/bao1x-boot/boot1/src/main.rs @@ -93,7 +93,6 @@ pub unsafe extern "C" fn rust_entry() -> ! { // value, and provide feedback on the CPU operation by flashing the RGB LEDs. let mut repl = crate::repl::Repl::new(); let mut new_key: Option; - crate::println!("connect status {:?}", USB_CONNECTED.load(Ordering::SeqCst)); loop { let (new_usb_state, new_portsc) = glue::usb_status(); @@ -121,27 +120,25 @@ pub unsafe extern "C" fn rust_entry() -> ! { // repl handling; USB is entirely interrupt driven, so there is no loop to handle it if USB_CONNECTED.load(Ordering::SeqCst) { - if last_usb_state == UsbDeviceState::Configured { - // fetch characters from the Rx buffer - critical_section::with(|cs| { - let mut queue = USB_RX.borrow(cs).borrow_mut(); - while let Some(byte) = queue.pop_front() { - repl.rx_char(byte); - } - }); + // fetch characters from the Rx buffer + critical_section::with(|cs| { + let mut queue = USB_RX.borrow(cs).borrow_mut(); + while let Some(byte) = queue.pop_front() { + repl.rx_char(byte); + } + }); - // Process any command line requests - match repl.process() { - Err(e) => { - if let Some(m) = e.message { - crate::println!("{}", m); - repl.abort_cmd(); - } + // Process any command line requests + match repl.process() { + Err(e) => { + if let Some(m) = e.message { + crate::println!("{}", m); + repl.abort_cmd(); } - _ => (), - }; - glue::flush_tx(); - } + } + _ => (), + }; + glue::flush_tx(); } else { // Handle keyboard events. critical_section::with(|cs| { diff --git a/bao1x-boot/boot1/src/platform/bao1x/bao1x.rs b/bao1x-boot/boot1/src/platform/bao1x/bao1x.rs index a3b0342bc..75d4f4681 100644 --- a/bao1x-boot/boot1/src/platform/bao1x/bao1x.rs +++ b/bao1x-boot/boot1/src/platform/bao1x/bao1x.rs @@ -13,7 +13,6 @@ static ALLOCATOR: linked_list_allocator::LockedHeap = linked_list_allocator::Loc pub const RAM_SIZE: usize = utralib::generated::HW_SRAM_MEM_LEN; pub const RAM_BASE: usize = utralib::generated::HW_SRAM_MEM; -pub const FLASH_BASE: usize = utralib::generated::HW_RERAM_MEM; pub const SIGBLOCK_LEN: usize = 768; // this is adjusted inside builder.rs, in the sign-image invocation const DATA_SIZE_BYTES: usize = 0x6000; @@ -179,7 +178,7 @@ pub fn early_init(mut board_type: bao1x_api::BoardTypeCoding) -> bao1x_api::Boar // Now that SRAM trims are setup, initialize all the statics by writing to memory. // For baremetal, the statics structure is just at the flash base. - const STATICS_LOC: usize = FLASH_BASE + SIGBLOCK_LEN; + const STATICS_LOC: usize = bao1x_api::BOOT1_START + SIGBLOCK_LEN; // safety: this data structure is pre-loaded by the image loader and is guaranteed to // only have representable, valid values that are aligned according to the repr(C) spec diff --git a/bao1x-boot/boot1/src/platform/bao1x/debug.rs b/bao1x-boot/boot1/src/platform/bao1x/debug.rs index 23015e824..274cea1fa 100644 --- a/bao1x-boot/boot1/src/platform/bao1x/debug.rs +++ b/bao1x-boot/boot1/src/platform/bao1x/debug.rs @@ -149,3 +149,56 @@ pub fn setup_console( udma_uart } + +// ==== DUART-only debug print ==== -> this is used for USB feedback to avoid Tx loops on USB +/// Placeholder for debug +pub struct Duart {} + +impl Duart { + /// Print a character + pub fn putc(&self, c: u8) { + let base = utra::duart::HW_DUART_BASE as *mut u32; + let mut uart = CSR::new(base); + if uart.rf(utra::duart::SFR_CR_SFR_CR) == 0 { + uart.wfo(utra::duart::SFR_CR_SFR_CR, 1); + } + while uart.r(utra::duart::SFR_SR) != 0 {} + uart.wo(utra::duart::SFR_TXD, c as u32); + } +} + +impl Write for Duart { + fn write_str(&mut self, s: &str) -> Result<(), Error> { + for c in s.bytes() { + self.putc(c); + } + Ok(()) + } +} + +#[macro_use] +/// Hardware debug print module +pub mod debug_print_duart { + #[macro_export] + macro_rules! print_d + { + ($($args:tt)+) => ({ + use core::fmt::Write; + let _ = write!(crate::debug::Duart {}, $($args)+); + }); + } +} + +#[macro_export] +macro_rules! println_d +{ + () => ({ + $crate::print_d!("\r\n") + }); + ($fmt:expr) => ({ + $crate::print_d!(concat!($fmt, "\r\n")) + }); + ($fmt:expr, $($args:tt)+) => ({ + $crate::print_d!(concat!($fmt, "\r\n"), $($args)+) + }); +} diff --git a/bao1x-boot/boot1/src/platform/bao1x/usb/driver.rs b/bao1x-boot/boot1/src/platform/bao1x/usb/driver.rs index cd125bdb3..06ecba28f 100644 --- a/bao1x-boot/boot1/src/platform/bao1x/usb/driver.rs +++ b/bao1x-boot/boot1/src/platform/bao1x/usb/driver.rs @@ -83,78 +83,6 @@ pub unsafe fn init_usb() { } } -#[allow(dead_code)] -pub unsafe fn test_usb() { - if let Some(ref mut usb_ref) = USB { - let usb = &mut *core::ptr::addr_of_mut!(*usb_ref); - usb.reset(); - let mut poweron = 0; - loop { - usb.udc_handle_interrupt(); - if usb.pp() { - poweron += 1; // .pp() is a sham. MPW has no way to tell if power is applied. This needs to be fixed for bao1x. - } - delay(100); - if poweron >= 4 { - break; - } - } - usb.reset(); - usb.init(); - usb.start(); - usb.update_current_speed(); - // IRQ enable must happen without dependency on the hardware lock - usb.irq_csr.wo(utralib::utra::irqarray1::EV_PENDING, 0xffff_ffff); // blanket clear - usb.irq_csr.wfo(utralib::utra::irqarray1::EV_ENABLE_USBC_DUPE, 1); - - crate::println!("hw started..."); - /* - let mut vbus_on = false; - let mut vbus_on_count = 0; - let mut in_u0 = false; - loop { - if vbus_on == false && vbus_on_count == 4 { - crate::println!("vbus on"); - usb.init(); - usb.start(); - vbus_on = true; - in_u0 = false; - } else if usb.pp() == true && vbus_on == false { - vbus_on_count += 1; - delay(100); - } else if usb.pp() == false && vbus_on == true { - crate::println!("20230802 vbus off during while"); - usb.stop(); - usb.reset(); - vbus_on_count = 0; - vbus_on = false; - in_u0 = false; - } else if in_u0 == true && vbus_on == true { - crate::println!("USB stack started"); - break; - // crate::println!("Would be uvc_bulk_thread()"); - // uvc_bulk_thread(); - } else if usb.ccs() == true && vbus_on == true { - crate::println!("enter U0"); - in_u0 = true; - } - } - */ - let mut i = 0; - loop { - // wait for interrupt handler to do something - crate::println!("{}", i); - i += 1; - delay(10_000); - // for testing interrupt handler - let mut irqarray19 = utralib::CSR::new(utralib::utra::irqarray19::HW_IRQARRAY19_BASE as *mut u32); - irqarray19.wfo(utralib::utra::irqarray19::EV_SOFT_TRIGGER, 0x80); - } - } else { - crate::println!("USB core not allocated, skipping USB test"); - } -} - fn delay(quantum: usize) { use utralib::{CSR, utra}; // abuse the d11ctime timer to create some time-out like thing @@ -211,7 +139,7 @@ fn get_status_request(this: &mut CorigineUsb, request_type: u8, index: u16) { } fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { - // crate::println!("handle_event: {:x?}", event_trb); + // crate::println_d!("handle_event: {:x?}", event_trb); let pei = event_trb.get_endpoint_id(); let ep_num = pei >> 1; let udc_ep = &mut this.udc_ep[pei as usize]; @@ -223,14 +151,14 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { // this.print_status(portsc_val); let portsc = PortSc(portsc_val); - // crate::println!("{:?}", portsc); + // crate::println_d!("{:?}", portsc); if portsc.prc() && !portsc.pr() { - crate::println!("update_current_speed() - reset done"); + crate::println_d!("update_current_speed() - reset done"); this.update_current_speed(); } if portsc.csc() && portsc.ppc() && portsc.pp() && portsc.ccs() { - crate::println!("update_current_speed() - cable connect"); + crate::println_d!("update_current_speed() - cable connect"); this.update_current_speed(); } @@ -241,7 +169,7 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { CompletionCode::try_from(event_trb.dw2.compl_code()).expect("Invalid completion code"); #[cfg(feature = "verbose-debug")] - crate::println!( + crate::println_d!( "e_trb {:x} {:x} {:x} {:x}", event_trb.dw0, event_trb.dw1, @@ -250,7 +178,7 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { ); let residual_length = event_trb.dw2.trb_tran_len() as u16; // update the dequeue pointer - // crate::println!("event_transfer {:x?}", event_trb); + // crate::println_d!("event_transfer {:x?}", event_trb); let deq_pt = unsafe { (event_trb.dw0 as *mut TransferTrbS).add(1).as_mut().expect("Couldn't deref ptr") }; if deq_pt.get_trb_type() == TrbType::Link { @@ -258,7 +186,7 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { } else { udc_ep.deq_pt = AtomicPtr::new(deq_pt as *mut TransferTrbS); } - // crate::println!("EventTransfer: comp_code {:?}, PEI {}", comp_code, pei); + // crate::println_d!("EventTransfer: comp_code {:?}, PEI {}", comp_code, pei); let dir = (pei & 1) != 0; if pei == 0 { @@ -270,19 +198,19 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { ret = CrgEvent::Data(1, 0, 0); // FIXME: this ordering contradicts the `dir` bit, but seems necessary to trigger the next packet send } } else { - crate::println!("EP0 unhandled comp_code: {:?}", comp_code); + crate::println_d!("EP0 unhandled comp_code: {:?}", comp_code); ret = CrgEvent::None; } } else if pei >= 2 { if comp_code == CompletionCode::Success || comp_code == CompletionCode::ShortPacket { - // crate::println!("EP{} xfer event, dir {}", ep_num, if dir { "OUT" } else { "IN" }); + // crate::println_d!("EP{} xfer event, dir {}", ep_num, if dir { "OUT" } else { "IN" }); // xfer_complete if let Some(f) = this.udc_ep[pei as usize].completion_handler { // so unsafe. so unsafe. We're counting on the hardware to hand us a raw pointer // that isn't corrupted. let p_trb = unsafe { &*(event_trb.dw0 as *const TransferTrbS) }; #[cfg(feature = "verbose-debug")] - crate::println!( + crate::println_d!( "p_trb {:x} {:x} {:x} {:x}", p_trb.dphi, p_trb.dplo, @@ -292,9 +220,9 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { f(this, p_trb.dplo as usize, p_trb.dw2.0, 0, residual_length); } } else if comp_code == CompletionCode::MissedServiceError { - crate::println!("MissedServiceError"); + crate::println_d!("MissedServiceError"); } else { - crate::println!("EventTransfer {:?} event not handled", comp_code); + crate::println_d!("EventTransfer {:?} event not handled", comp_code); } } } @@ -312,7 +240,7 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { let w_length = setup_pkt.w_length; /* - crate::println!( + crate::println_d!( " b_request={:x}, b_request_type={:x}, w_value={:04x}, w_index=0x{:x}, w_length={}", setup_pkt.b_request, setup_pkt.b_request_type, @@ -325,20 +253,20 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { if (setup_pkt.b_request_type & USB_TYPE_MASK) == USB_TYPE_STANDARD { match setup_pkt.b_request { USB_REQ_GET_STATUS => { - crate::println!("USB_REQ_GET_STATUS"); + crate::println_d!("USB_REQ_GET_STATUS"); get_status_request(this, setup_pkt.b_request_type, w_index); } USB_REQ_SET_ADDRESS => { - crate::println!("USB_REQ_SET_ADDRESS: {}, tag: {}", w_value, this.setup_tag); + crate::println_d!("USB_REQ_SET_ADDRESS: {}, tag: {}", w_value, this.setup_tag); this.set_addr(w_value as u8, CRG_INT_TARGET); - // crate::println!(" ******* set address done {}", w_value & 0xff); + // crate::println_d!(" ******* set address done {}", w_value & 0xff); } USB_REQ_SET_SEL => { - crate::println!("USB_REQ_SET_SEL"); + crate::println_d!("USB_REQ_SET_SEL"); this.ep0_receive(this.ep0_buf.load(Ordering::SeqCst) as usize, w_length as usize, 0); delay(100); /* do set sel */ - crate::println!("SEL_VALUE NOT HANDLED"); + crate::println_d!("SEL_VALUE NOT HANDLED"); /* crg_udc->sel_value.u1_sel_value = *ep0_buf; crg_udc->sel_value.u1_pel_value = *(ep0_buf+1); @@ -347,19 +275,19 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { */ } USB_REQ_SET_ISOCH_DELAY => { - crate::println!("USB_REQ_SET_ISOCH_DELAY"); + crate::println_d!("USB_REQ_SET_ISOCH_DELAY"); /* do set isoch delay */ this.ep0_send(0, 0, 0); } USB_REQ_CLEAR_FEATURE => { - crate::println!("USB_REQ_CLEAR_FEATURE"); - crate::println!("*** UNSUPPORTED ***"); + crate::println_d!("USB_REQ_CLEAR_FEATURE"); + crate::println_d!("*** UNSUPPORTED ***"); /* do clear feature */ // clear_feature_request(setup_pkt.b_request_type, w_index, w_value); } USB_REQ_SET_FEATURE => { - crate::println!("USB_REQ_SET_FEATURE\r\n"); - crate::println!("*** UNSUPPORTED ***"); + crate::println_d!("USB_REQ_SET_FEATURE\r\n"); + crate::println_d!("*** UNSUPPORTED ***"); /* do set feature */ /* if crg_udc_get_device_state() == USB_STATE_CONFIGURED { @@ -402,11 +330,11 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { } } USB_REQ_GET_DESCRIPTOR => { - crate::println!("USB_REQ_GET_DESCRIPTOR"); + crate::println_d!("USB_REQ_GET_DESCRIPTOR"); get_descriptor_request(this, w_value, w_index as usize, w_length as usize); } USB_REQ_GET_CONFIGURATION => { - crate::println!("USB_REQ_GET_CONFIGURATION"); + crate::println_d!("USB_REQ_GET_CONFIGURATION"); let ep0_buf = unsafe { core::slice::from_raw_parts_mut( this.ep0_buf.load(Ordering::SeqCst) as *mut u8, @@ -421,13 +349,13 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { this.ep0_send(ep0_buf.as_ptr() as usize, 1, 0); } USB_REQ_SET_INTERFACE => { - crate::println!("USB_REQ_SET_INTERFACE"); + crate::println_d!("USB_REQ_SET_INTERFACE"); this.cur_interface_num = (w_value & 0xF) as u8; - crate::println!("USB_REQ_SET_INTERFACE altsetting {}", this.cur_interface_num); + crate::println_d!("USB_REQ_SET_INTERFACE altsetting {}", this.cur_interface_num); this.ep0_send(0, 0, 0); } USB_REQ_GET_INTERFACE => { - crate::println!("USB_REQ_GET_INTERFACE"); + crate::println_d!("USB_REQ_GET_INTERFACE"); let ep0_buf = unsafe { core::slice::from_raw_parts_mut( this.ep0_buf.load(Ordering::SeqCst) as *mut u8, @@ -438,7 +366,7 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { this.ep0_send(ep0_buf.as_ptr() as usize, 1, 0); } _ => { - crate::println!( + crate::println_d!( "USB_REQ default b_request=0x{:x}, b_request_type=0x{:x}", setup_pkt.b_request, setup_pkt.b_request_type @@ -449,7 +377,7 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { } else if (setup_pkt.b_request_type & USB_TYPE_MASK) == USB_TYPE_CLASS { match setup_pkt.b_request { 0xff => { - crate::println!("Mass Storage Reset\r\n"); + // crate::println_d!("Mass Storage Reset\r\n"); if (0 == w_value) && (InterfaceDescriptor::default_mass_storage().b_interface_number == w_index as u8) @@ -467,7 +395,7 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { } } 0xfe => { - crate::println!("Get Max LUN"); + // crate::println_d!("Get Max LUN"); if w_index != 0 || w_value != 0 || w_length != 1 { this.ep_halt(0, USB_RECV); } else { @@ -483,7 +411,7 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { } 0x20 => { // SET_LINE_CODING (host -> device, 7 bytes) - crate::println!("CDC SET_LINE_CODING"); + // crate::println_d!("CDC SET_LINE_CODING"); let length = w_length as usize; if length == 7 { // queue EP0 OUT to receive the line coding structure @@ -495,7 +423,7 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { } 0x21 => { // GET_LINE_CODING (device -> host, 7 bytes) - crate::println!("CDC GET_LINE_CODING"); + // crate::println_d!("CDC GET_LINE_CODING"); let ep0_buf = unsafe { core::slice::from_raw_parts_mut( this.ep0_buf.load(Ordering::SeqCst) as *mut u8, @@ -511,14 +439,14 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { } 0x22 => { // SET_CONTROL_LINE_STATE (host -> device, 0 length) - crate::println!("CDC SET_CONTROL_LINE_STATE, DTR/RTS = {:x}", w_value); + // crate::println_d!("CDC SET_CONTROL_LINE_STATE, DTR/RTS = {:x}", w_value); // wValue bit0 = DTR, bit1 = RTS // You can ignore since no real UART this.ep0_send(0, 0, 0); } _ => { - crate::println!("Unhandled class request bRequest=0x{:x}", setup_pkt.b_request); + crate::println_d!("Unhandled class request bRequest=0x{:x}", setup_pkt.b_request); this.ep_halt(0, USB_RECV); } } @@ -532,7 +460,7 @@ fn handle_event(this: &mut CorigineUsb, event_trb: &mut EventTrbS) -> CrgEvent { panic!("data stage needs handling"); } _ => { - crate::println!("Unexpected trb_type {:?}", event_trb.get_trb_type()); + crate::println_d!("Unexpected trb_type {:?}", event_trb.get_trb_type()); } } ret diff --git a/bao1x-boot/boot1/src/platform/bao1x/usb/glue.rs b/bao1x-boot/boot1/src/platform/bao1x/usb/glue.rs index 2cdb39052..6ac129dd6 100644 --- a/bao1x-boot/boot1/src/platform/bao1x/usb/glue.rs +++ b/bao1x-boot/boot1/src/platform/bao1x/usb/glue.rs @@ -25,7 +25,6 @@ pub fn setup() -> (UsbDeviceState, u32) { // Below is all unsafe because USB is global mutable state unsafe { if let Some(ref mut usb_ref) = crate::platform::bao1x::usb::USB { - crate::println!("inside update"); let usb = &mut *core::ptr::addr_of_mut!(*usb_ref); usb.reset(); let mut poweron = 0; diff --git a/bao1x-boot/boot1/src/platform/bao1x/usb/handlers.rs b/bao1x-boot/boot1/src/platform/bao1x/usb/handlers.rs index 48214fdd4..49038eacb 100644 --- a/bao1x-boot/boot1/src/platform/bao1x/usb/handlers.rs +++ b/bao1x-boot/boot1/src/platform/bao1x/usb/handlers.rs @@ -238,18 +238,18 @@ pub fn usb_ep1_bulk_out_complete( process_mass_storage_command(this, cbw); // invalid_cbw = 0; } else { - crate::println!("Invalid CBW, HALT"); + crate::println_d!("Invalid CBW, HALT"); this.ep_halt(1, USB_SEND); this.ep_halt(1, USB_RECV); // invalid_cbw = 1; } } else if UmsState::CommandPhase == this.ms_state && (length != 31) { - crate::println!("invalid command"); + crate::println_d!("invalid command"); this.ep_halt(1, USB_SEND); this.ep_halt(1, USB_RECV); // invalid_cbw = 1; } else if UmsState::DataPhase == this.ms_state { - crate::println!("data"); + crate::println_d!("data"); //DATA if let Some((write_offset, len)) = this.callback_wr.take() { let app_buf = conjure_app_buf(); @@ -266,10 +266,10 @@ pub fn usb_ep1_bulk_out_complete( csw.send(this); } } else { - crate::println!("Data completion reached without destination for data copy! data dropped."); + crate::println_d!("Data completion reached without destination for data copy! data dropped."); } } else { - crate::println!("uhhh wtf"); + crate::println_d!("uhhh wtf"); } } @@ -280,7 +280,7 @@ pub fn usb_ep1_bulk_in_complete( _error: u8, _residual: u16, ) { - // crate::println!("bulk IN handler"); + // crate::println_d!("bulk IN handler"); let length = info & 0xFFFF; if UmsState::DataPhase == this.ms_state { //DATA @@ -308,7 +308,7 @@ pub fn usb_ep3_bulk_out_complete( _error: u8, residual: u16, ) { - // crate::println!("EP3 OUT: {:x} {:x}", info, _error); + // crate::println_d!("EP3 OUT: {:x} {:x}", info, _error); let actual = CRG_UDC_APP_BUF_LEN - residual as usize; @@ -320,7 +320,7 @@ pub fn usb_ep3_bulk_out_complete( let buf = unsafe { core::slice::from_raw_parts(buf_addr as *const u8, actual as usize) }; // For now: just print, or push into a ring buffer for your "virtual terminal" - // crate::println!("CDC OUT received {} bytes: {:?}", actual, &buf); + // crate::println_d!("CDC OUT received {} bytes: {:?}", actual, &buf); critical_section::with(|cs| { let mut queue = crate::USB_RX.borrow(cs).borrow_mut(); @@ -386,9 +386,9 @@ pub fn usb_ep3_bulk_in_complete( _error: u8, _residual: u16, ) { - // crate::println!("EP3 IN"); - // let length = CRG_UDC_APP_BUF_LEN - residual as usize; - // crate::println!("CDC IN transfer complete, {} bytes sent", length); + // crate::println_d!("EP3 IN"); + // let length = CRG_UDC_APP_BUF_LEN - _residual as usize; + // crate::println_d!("CDC IN transfer complete, {} bytes sent", length); // signal that more stuff can be put into the pipe TX_IDLE.store(true, Ordering::SeqCst); @@ -405,9 +405,9 @@ pub fn usb_ep2_int_in_complete( _error: u8, _residual: u16, ) { - // crate::println!("EP2 INT"); + // crate::println_d!("EP2 INT"); // let length = CRG_UDC_APP_BUF_LEN - residual as usize; - // crate::println!("CDC notification sent, {} bytes", length); + // crate::println_d!("CDC notification sent, {} bytes", length); // Typically sends SERIAL_STATE bitmap (carrier detect etc). // Ignoring - this is a virtual terminal @@ -489,7 +489,7 @@ fn process_request_sense(this: &mut CorigineUsb, cbw: Cbw) { csw.residue = 0; csw.status = 0; csw.send(this); - // crate::println!("UMS_STATE_STATUS_PHASE\r\n"); + // crate::println_d!("UMS_STATE_STATUS_PHASE\r\n"); } else if cbw.flags & 0x80 != 0 { if cbw.data_transfer_length < 18 { let ep1_in = unsafe { core::slice::from_raw_parts_mut(EP1_IN_BUF as *mut u8, EP1_IN_BUF_LEN) }; @@ -559,7 +559,7 @@ fn process_prevent_allow_medium_removal(this: &mut CorigineUsb, _cbw: Cbw) { } fn process_report_capacity(this: &mut CorigineUsb, cbw: Cbw) { - crate::println!("REPORT CAPACITY"); + crate::println_d!("REPORT CAPACITY"); let mut csw = Csw::derive(); let rc_lba = RAMDISK_LEN / SECTOR_SIZE as usize - 1; let rc_bl: u32 = SECTOR_SIZE as u32; @@ -633,7 +633,7 @@ fn process_read_command(this: &mut CorigineUsb, cbw: Cbw) { this.ms_state = UmsState::DataPhase; return; } - crate::println!( + crate::println_d!( "DISK READ address = 0x{:x}, length = 0x{:x}", RAMDISK_ADDRESS + lba as usize * SECTOR_SIZE as usize, length @@ -685,7 +685,7 @@ fn process_write_command(this: &mut CorigineUsb, cbw: Cbw) { return; } - crate::println!( + crate::println_d!( "Write address = 0x{:x}, length = 0x{:x}", RAMDISK_ADDRESS + lba as usize * SECTOR_SIZE as usize, length @@ -734,7 +734,7 @@ fn process_write12_command(this: &mut CorigineUsb, cbw: Cbw) { length |= (cbw.cdb[9] as u32) << 0; length *= SECTOR_SIZE as u32; - crate::println!("write12 of {} bytes", length); + crate::println_d!("write12 of {} bytes", length); if cbw.flags & 0x80 != 0 { csw.residue = cbw.data_transfer_length;