Skip to content

USB and pwr.vos0 #8

@dlancea

Description

@dlancea

I've been having an issue with setting up USB with this library. Using the usb_device crate the device setup fails about half the time at the final call to build():

#[allow(static_mut_refs)] 
let usb_bus = UsbBus::new(usb, unsafe { EP_MEMORY.assume_init_mut() });

// let mut serial = usbd_serial::SerialPort::new(&usb_bus);
let mut midi_class = UsbMidiClass::new(&usb_bus, 1, 1).unwrap();

let usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x16c0, 0x5e4))
	.device_class(0)
	.device_sub_class(0)
	.strings(&[StringDescriptors::default()
		.manufacturer("Music Company")
		.product("MIDI Device")
		.serial_number("12345678")])
	.unwrap();

let mut usb_dev = usb_dev.build(); // <- Fails here

defmt::info!("Built!");

The problem is this line: https://github.com/stm32-rs/synopsys-usb-otg/blob/master/src/bus.rs#L448 The Soft Reset fails to complete about half the time.

I am ensuring the appropriate timers are set before the call to build():

ccdr.peripheral.kernel_usb_clk_mux(stm32h7xx_hal::rcc::rec::UsbClkSel::Hsi48);
let _ = ccdr.clocks.hsi48_ck().expect("HSI48 must run");
let _ = ccdr.clocks.hse_ck().expect("hse_ck must run");

The problem seems to be tied to the pwr.vos0 power setting and the 480MHz clock. If i change the library to use default power settings and a system clock of 400MHz the problem seems to go away.

Here's a test file I've been using to illustrate the problem: https://gist.github.com/dlancea/0008a8618da3affb934e73ac04a3d35d (this doesn't use this library directly, but uses the same vos0/480MHz setup).

If anyone has advice on how I might get that 80MHz back it would be appreciated!

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