USB disconnection using CDC ACM, OS error 22 on nRF534'

Hello all,


I'm currently developing some test FW for our custom hardware which include a nRF5340 and nRF7002, I made a small program to test the the different power supply via UART command to enable/disable GPIO.


For some reason my UART communication is not stable and failed every ~30 seconds with this error : 

[17:16:06.655] WiFi Buck Power turned ON
[17:16:06.655] uart:~$ [17:16:07.647] [00:00:36.256,958] power_control: WiFi Buck Power turned ON (GPIO0.12)
[17:16:07.647] uart:~$ [00:00:36.256,988] power_control: WiFi Buck Power pin read-back: 0
[17:16:07.647] uart:~$ uart:~$ [17:16:08.287] Serial Error: Device disconnected or communication error: ClearCommError failed (PermissionError(13, 'Le périphérique ne reconnaît pas la commande.', None, 22))


I'm new to the Zephyr stack and was wondering if can be a configuration issue / driver issue, I use nRF connect SDK 3.0.2. 

Here is my proj.conf file and my overlay files :

# Main project configuration
CONFIG_GPIO=y
CONFIG_SERIAL=y
CONFIG_PRINTK=y
CONFIG_UART_CONSOLE=y

# GPIO configuration
CONFIG_GPIO_NRFX=y
# Allow application core to access all GPIO pins
CONFIG_ARM_NONSECURE_PREEMPTIBLE_SECURE_CALLS=n
# Explicitly disable network core and BT to free P1.00
CONFIG_BOARD_ENABLE_CPUNET=n
CONFIG_BT=n
# Disable UART forwarding that might use P1.00
CONFIG_NRF53_UPGRADE_NETWORK_CORE=n

# Configure logging
CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_LOG_MODE_DEFERRED=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_PRINTK=y
CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=1024
CONFIG_LOG_PROCESS_THREAD_STARTUP_DELAY_MS=4000
CONFIG_LOG_BUFFER_SIZE=8192
CONFIG_LOG_FUNC_NAME_PREFIX_DBG=n

# Shell config
CONFIG_SHELL=y
CONFIG_SHELL_LOG_BACKEND=y
CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY=51
CONFIG_SHELL_BACKEND_SERIAL_CHECK_DTR=n
CONFIG_SHELL_VT100_COMMANDS=n
CONFIG_SHELL_VT100_COLORS=n
CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=256
CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE=256

# Enable USB CDC ACM
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_REMOTE_WAKEUP=n
CONFIG_USB_DEVICE_PRODUCT="ROOMZ hardware"
CONFIG_USB_DEVICE_VID=0x1915
CONFIG_USB_DEVICE_PID=0x530D
CONFIG_USB_CDC_ACM=y
CONFIG_USB_CDC_ACM_LOG_LEVEL_ERR=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
CONFIG_UART_LINE_CTRL=n
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
s

# ADC support
CONFIG_ADC=y

/*
 * Power Supply Test Overlay for nRF5340 Application Core
 */

#include <zephyr/dt-bindings/adc/adc.h>
#include <zephyr/dt-bindings/adc/nrf-adc.h>

/ {
	aliases {
		power-test-led0 = &led0;
		power-test-led1 = &led1;
		power-test-sw0 = &button0;
		power-test-sw1 = &button1;
	};

	power_supplies {
		compatible = "gpio-leds";

		/* 3V3 power supply control - P1.12 */
		supply_3v3: supply_3v3 {
			gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>;
			label = "3V3 Power Supply Enable";
		};

		/* WiFi IO power enable - P1.00 */
		wifi_io_power: wifi_io_power {
			gpios = <&gpio1 0 (GPIO_ACTIVE_HIGH | GPIO_PUSH_PULL)>;
			label = "WiFi IO Power Enable";
		};

		/* AN7002Q-P Buck enable - P0.12 */
		wifi_buck_power: wifi_buck_power {
			gpios = <&gpio0 12 (GPIO_ACTIVE_HIGH | GPIO_PUSH_PULL)>;
			label = "WiFi Buck Power Enable";
		};

		/* ITE enable - P0.02 */
		ite_power: ite_power {
			gpios = <&gpio0 2 (GPIO_ACTIVE_HIGH | GPIO_PUSH_PULL)>;
			label = "ITE Power Enable";
		};

		/* NFC enable - P1.05 */
		nfc_power: nfc_power {
			gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
			label = "NFC Power Enable";
		};

		/* ITE Flash output enable - P1.11 */
		ite_flash_oe: ite_flash_oe {
			gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;
			label = "ITE Flash Output Enable";
		};
	};

	power_status {
		compatible = "gpio-keys";

		/* TPS status - P0.28 */
		tps_status: tps_status {
			gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
			label = "TPS Status";
		};

		/* PMIC power good - P1.07 */
		pmic_pwrgood: pmic_pwrgood {
			gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
			label = "PMIC Power Good";
		};

		/* ITE ready status - P0.24 */
		ite_ready: ite_ready {
			gpios = <&gpio0 24 GPIO_ACTIVE_HIGH>;
			label = "ITE Ready Status";
		};
	};

};

/* Enable GPIO ports */
&gpio0 {
	status = "okay";
};

&gpio1 {
	status = "okay";
};

/* ADC configuration for battery voltage monitoring */
&adc {
	status = "okay";
	#address-cells = <1>;
	#size-cells = <0>;

	channel@0 {
		reg = <0>;
		zephyr,gain = "ADC_GAIN_1_6";
		zephyr,reference = "ADC_REF_INTERNAL";
		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
		zephyr,input-positive = <NRF_ADC_AIN0>; /* P0.04 */
		zephyr,resolution = <12>;
	};
};

/ {
	chosen {
		zephyr,console = &cdc_acm_uart0;
		zephyr,shell-uart = &cdc_acm_uart0;
	};
};

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

/* Disable the entire GPIO forwarder to free up P1.00 */
&gpio_fwd {
	status = "disabled";
};


Thank you in advance for your help, maybe it's also a hardware issue since the board is a prototype, but we've follow the design recommendation for the UART part.

Best regards,

Valentin Künti

Parents
  • Hello Valentin,
    Based on the description here and your observations, if there's a failure about 30seconds into the FW every time, it is often related to buffers becoming full or sudden remapping of GPIOs in FW unintentionally. 
    The four lines of uart print, is that all you see across the 30 seconds? Is this as expected for your test? The switching between power supplies you are attempting, is that happening and is it reaching the same place in the FW every time around 30 second mark, e.g. is it failing when a specific configuration is tested?
    Best regards
    Asbjørn
Reply
  • Hello Valentin,
    Based on the description here and your observations, if there's a failure about 30seconds into the FW every time, it is often related to buffers becoming full or sudden remapping of GPIOs in FW unintentionally. 
    The four lines of uart print, is that all you see across the 30 seconds? Is this as expected for your test? The switching between power supplies you are attempting, is that happening and is it reaching the same place in the FW every time around 30 second mark, e.g. is it failing when a specific configuration is tested?
    Best regards
    Asbjørn
Children
Related