Timeout on VBUS detect when powered by usb

nRF54LM20A

NCS 3.4.0

Our device is powered by a usb-c connection.  When it is connected to a PC usb port, we want the usb to serve as the console.  We are using the cdc_asm example to test it.  It works fine on the DK, but not on our custom board.

I can view the log output using the RTT Viewer and see this error:

udc_dwc2: Quirk pre enable failed -116

Using the debugger, usbhs_enable_core() times out waiting for VBUS ready. Here:

if (!k_event_wait(events, NRF_USBHS_VBUS_READY, false, timeout)) {
				return -ETIMEDOUT;
			}

Obviously, VBUS is present, since that is what is powering the board.  It will not see the transition on the VBUS line.  How can I make the driver 'see' that the VBUS is already at 5V?

prj.conf

CONFIG_USB_DEVICE_STACK_NEXT=y

CONFIG_STDOUT_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_UART_LINE_CTRL=y
CONFIG_USBD_CDC_ACM_CLASS=y

CONFIG_LOG=y
CONFIG_USBD_LOG_LEVEL_ERR=y
CONFIG_UDC_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USBD_CDC_ACM_LOG_LEVEL_ERR=y

#CONFIG_SAMPLE_USBD_PID=0x0001
#CONFIG_SAMPLE_USBD_PRODUCT="USBD CDC ACM sample"

# TV
CONFIG_CDC_ACM_SERIAL_INITIALIZE_AT_BOOT=y

# Zero waits forever inside the USB init that runs before main. A missing
# VBUS sense then never reaches the status LED or the rest of the app.
CONFIG_UDC_DWC2_USBHS_VBUS_READY_TIMEOUT=1000
CONFIG_CDC_ACM_SERIAL_MANUFACTURER_STRING="MyCompany"
CONFIG_CDC_ACM_SERIAL_PRODUCT_STRING="MyProduct"
CONFIG_CDC_ACM_SERIAL_VID=0x1915
CONFIG_CDC_ACM_SERIAL_PID=0x0001

# MDF
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_USE_SEGGER_RTT=y

overlay

/ {
	chosen {
		nordic,pm-ext-flash = &mx25r64;
		zephyr,console = &cdc_acm_uart0;
		zephyr,shell-uart = &cdc_acm_uart0;
	};

	aliases {
		spi-flash0 = &mx25r64;
	};

	wz_cs_out {
		compatible = "gpio-leds";
		wzcs: wzcs_0 {
			gpios = <&gpio1 19 GPIO_ACTIVE_LOW>;
			label = "W5500 CS";
		};
	};
};

&wdt31 {
	status = "okay";
};

&zephyr_udc0 {
	cdc_acm_uart0: cdc_acm_uart0 {
		compatible = "zephyr,cdc-acm-uart";
	};
};

/* USBHS wrapper takes a device handle to VREGUSB. The parent block is
 * disabled in the SoC dts, which keeps the child from existing as a device.
 */
&regulators {
	status = "okay";
};

&vregusb {
	status = "okay";
};

Thanks,

Mary

Parents
  • VBUS is present, since that is what is powering the board.

    That does not mean it made it all the way to the VBUS pin on the MCU. There should be a series resistor where you can check the voltage at the MCU pin. Its value is 2R2 (2.2 Ohms) on the reference circuit in the datasheet.

  • We are using a third party module from Fanstel.  They have tested the usb port successfully.

    I measured the voltage the the VBUS input t the module.  It is 5.1V.

    Mary

  • Also, found this code in regulator_nrf_vregusg.c

    /* Undocumented STATUS register offset and VBUS detected bit for nRF54LM20.
     * The STATUS register is not part of the NRF_VREGUSB_Type struct in the MDK,
     * but is present in hardware at offset 0x400 from the peripheral base.
     */
    #define VREGUSB_STATUS_OFFSET	0x400
    #define VREGUSB_STATUS_VBUSDET	BIT(2)
    
    static int vregusb_enable(const struct device *const dev)
    {
    	const struct vregusb_config *const config = dev->config;
    	struct vregusb_data *const data = dev->data;
    	NRF_VREGUSB_Type *const base = config->base;
    
    	/* Clear stale events from a previous boot to prevent spurious ISR
    	 * firing with wrong or overwritten event type.
    	 */
    	nrf_vregusb_event_clear(base, NRF_VREGUSB_EVENT_VBUS_DETECTED);
    	nrf_vregusb_event_clear(base, NRF_VREGUSB_EVENT_VBUS_REMOVED);
    
    	nrf_vregusb_int_enable(base, NRF_VREGUSB_INT_VBUS_DETECTED_MASK |
    				     NRF_VREGUSB_INT_VBUS_REMOVED_MASK);
    
    	nrf_vregusb_task_trigger(base, NRF_VREGUSB_TASK_START);
    
    	/* If VBUS is already detected (e.g. after a warm reboot with the cable
    	 * connected), no VBUS_DETECTED edge interrupt will fire.  Synthesize
    	 * the callback so the upper layers learn about the present VBUS.
    	 */
    	if (sys_read32((mem_addr_t)base + VREGUSB_STATUS_OFFSET) & VREGUSB_STATUS_VBUSDET) {
    		LOG_DBG("VBUS already detected at enable");
    		if (data->cb != NULL) {
    			struct regulator_event event = {
    				.type = REGULATOR_VOLTAGE_DETECTED,
    			};
    
    			data->cb(dev, &event, data->user_data);
    		}
    	}
    
    	config->irq_enable_func(dev);
    
    	return 0;
    }

    the 'if(sys_read32())' condition fails here, so the event is not generated.

    Are there any versions of the LM20 that do not have this undocumented register?

Reply
  • Also, found this code in regulator_nrf_vregusg.c

    /* Undocumented STATUS register offset and VBUS detected bit for nRF54LM20.
     * The STATUS register is not part of the NRF_VREGUSB_Type struct in the MDK,
     * but is present in hardware at offset 0x400 from the peripheral base.
     */
    #define VREGUSB_STATUS_OFFSET	0x400
    #define VREGUSB_STATUS_VBUSDET	BIT(2)
    
    static int vregusb_enable(const struct device *const dev)
    {
    	const struct vregusb_config *const config = dev->config;
    	struct vregusb_data *const data = dev->data;
    	NRF_VREGUSB_Type *const base = config->base;
    
    	/* Clear stale events from a previous boot to prevent spurious ISR
    	 * firing with wrong or overwritten event type.
    	 */
    	nrf_vregusb_event_clear(base, NRF_VREGUSB_EVENT_VBUS_DETECTED);
    	nrf_vregusb_event_clear(base, NRF_VREGUSB_EVENT_VBUS_REMOVED);
    
    	nrf_vregusb_int_enable(base, NRF_VREGUSB_INT_VBUS_DETECTED_MASK |
    				     NRF_VREGUSB_INT_VBUS_REMOVED_MASK);
    
    	nrf_vregusb_task_trigger(base, NRF_VREGUSB_TASK_START);
    
    	/* If VBUS is already detected (e.g. after a warm reboot with the cable
    	 * connected), no VBUS_DETECTED edge interrupt will fire.  Synthesize
    	 * the callback so the upper layers learn about the present VBUS.
    	 */
    	if (sys_read32((mem_addr_t)base + VREGUSB_STATUS_OFFSET) & VREGUSB_STATUS_VBUSDET) {
    		LOG_DBG("VBUS already detected at enable");
    		if (data->cb != NULL) {
    			struct regulator_event event = {
    				.type = REGULATOR_VOLTAGE_DETECTED,
    			};
    
    			data->cb(dev, &event, data->user_data);
    		}
    	}
    
    	config->irq_enable_func(dev);
    
    	return 0;
    }

    the 'if(sys_read32())' condition fails here, so the event is not generated.

    Are there any versions of the LM20 that do not have this undocumented register?

Children
No Data
Related