cancel
Showing results for 
Search instead for 
Did you mean: 

zephyr stm32u073 usb

pokitoz
Associate II

Hello,

I am trying to get the USB HID working on STM32U073 with ZephyrOS.

I took the sample code from https://github.com/zephyrproject-rtos/zephyr/tree/v4.2.0/samples/subsys/usb/hid-mouse
And tried both the NEXT and legacy USB stack. 

However, when I boot, I always get the USB Not recognised popup along with the following logs:

 

00> [00:00:00.003,000] <dbg> usb_device: usb_enable: lock usb_enable_lock mutex
00> [00:00:00.011,000] <dbg> usb_descriptor: usb_get_device_descriptor: __usb_descriptor_start 0x20000594
00> [00:00:00.021,000] <dbg> usb_descriptor: usb_get_device_descriptor: __usb_descriptor_end 0x2000062e
00> [00:00:00.031,000] <dbg> usb_descriptor: usb_fix_descriptor: Device descriptor 0x20000594
00> [00:00:00.040,000] <dbg> usb_dc_stm32: usb_dc_ep_check_cap: ep 0, mps 64, type 0
00> [00:00:00.049,000] <dbg> usb_descriptor: usb_desc_update_mps0: Set bMaxPacketSize0 64
00> [00:00:00.057,000] <dbg> usb_descriptor: usb_fix_descriptor: Configuration descriptor 0x200005a6
00> [00:00:00.067,000] <dbg> usb_descriptor: usb_fix_descriptor: Interface descriptor 0x200005af
00> [00:00:00.077,000] <dbg> usb_descriptor: usb_fix_descriptor: Endpoint descriptor 0x200005c1
00> [00:00:00.086,000] <dbg> usb_dc_stm32: usb_dc_ep_check_cap: ep 81, mps 16, type 3
00> [00:00:00.094,000] <dbg> usb_descriptor: usb_validate_ep_cfg_data: Fixing EP address 80 -> 81
00> [00:00:00.104,000] <dbg> usb_descriptor: usb_validate_ep_cfg_data: endpoint 0x81
00> [00:00:00.112,000] <dbg> usb_descriptor: usb_fix_descriptor: Now the wTotalLength is 34
00> [00:00:00.121,000] <dbg> usb_descriptor: ascii7_to_utf16le: idx_max 11, ascii_idx_max 5, buf 0x200005ce
00> [00:00:00.131,000] <dbg> usb_descriptor: ascii7_to_utf16le: char R : 52, idx 5 -> 11
00> [00:00:00.140,000] <dbg> usb_descriptor: ascii7_to_utf16le: char Y : 59, idx 4 -> 9
00> [00:00:00.149,000] <dbg> usb_descriptor: ascii7_to_utf16le: char H : 48, idx 3 -> 7
00> [00:00:00.157,000] <dbg> usb_descriptor: ascii7_to_utf16le: char P : 50, idx 2 -> 5
00> [00:00:00.166,000] <dbg> usb_descriptor: ascii7_to_utf16le: char E : 45, idx 1 -> 3
00> [00:00:00.174,000] <dbg> usb_descriptor: ascii7_to_utf16le: char Z : 5a, idx 0 -> 1
00> [00:00:00.183,000] <dbg> usb_descriptor: ascii7_to_utf16le: idx_max 45, ascii_idx_max 22, buf 0x200005dc
00> [00:00:00.194,000] <dbg> usb_descriptor: ascii7_to_utf16le: char e : 65, idx 22 -> 45
00> [00:00:00.202,000] <dbg> usb_descriptor: ascii7_to_utf16le: char l : 6c, idx 21 -> 43
00> [00:00:00.211,000] <dbg> usb_descriptor: ascii7_to_utf16le: char p : 70, idx 20 -> 41
00> [00:00:00.220,000] <dbg> usb_descriptor: ascii7_to_utf16le: char m : 6d, idx 19 -> 39
00> [00:00:00.229,000] <dbg> usb_descriptor: ascii7_to_utf16le: char a : 61, idx 18 -> 37
00> [00:00:00.238,000] <dbg> usb_descriptor: ascii7_to_utf16le: char s : 73, idx 17 -> 35
00> [00:00:00.246,000] <dbg> usb_descriptor: ascii7_to_utf16le: char   : 20, idx 16 -> 33
00> [00:00:00.255,000] <dbg> usb_descriptor: ascii7_to_utf16le: char e : 65, idx 15 -> 31
00> [00:00:00.264,000] <dbg> usb_descriptor: ascii7_to_utf16le: char s : 73, idx 14 -> 29
00> [00:00:00.273,000] <dbg> usb_descriptor: ascii7_to_utf16le: char u : 75, idx 13 -> 27
00> [00:00:00.282,000] <dbg> usb_descriptor: ascii7_to_utf16le: char o : 6f, idx 12 -> 25
00> [00:00:00.290,000] <dbg> usb_descriptor: ascii7_to_utf16le: char m : 6d, idx 11 -> 23
00> [00:00:00.299,000] <dbg> usb_descriptor: ascii7_to_utf16le: char   : 20, idx 10 -> 21
00> [00:00:00.308,000] <dbg> usb_descriptor: ascii7_to_utf16le: char D : 44, idx 9 -> 19
00> [00:00:00.317,000] <dbg> usb_descriptor: ascii7_to_utf16le: char I : 49, idx 8 -> 17
00> [00:00:00.325,000] <dbg> usb_descriptor: ascii7_to_utf16le: char H : 48, idx 7 -> 15
00> [00:00:00.334,000] <dbg> usb_descriptor: ascii7_to_utf16le: char   : 20, idx 6 -> 13
00> [00:00:00.343,000] <dbg> usb_descriptor: ascii7_to_utf16le: char r : 72, idx 5 -> 11
00> [00:00:00.351,000] <dbg> usb_descriptor: ascii7_to_utf16le: char y : 79, idx 4 -> 9
00> [00:00:00.360,000] <dbg> usb_descriptor: ascii7_to_utf16le: char h : 68, idx 3 -> 7
00> [00:00:00.369,000] <dbg> usb_descriptor: ascii7_to_utf16le: char p : 70, idx 2 -> 5
00> [00:00:00.377,000] <dbg> usb_descriptor: ascii7_to_utf16le: char e : 65, idx 1 -> 3
00> [00:00:00.386,000] <dbg> usb_descriptor: ascii7_to_utf16le: char Z : 5a, idx 0 -> 1
00> [00:00:00.395,000] <dbg> usb_descriptor: usb_update_sn_string_descriptor: Serial Number
00>                                          32 34 50 09 00 28 00 3b                          |24P..(.;         
00> [00:00:00.414,000] <dbg> usb_descriptor: ascii7_to_utf16le: idx_max 31, ascii_idx_max 15, buf 0x2000060c
00> [00:00:00.425,000] <dbg> usb_descriptor: ascii7_to_utf16le: char B : 42, idx 15 -> 31
00> [00:00:00.433,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 3 : 33, idx 14 -> 29
00> [00:00:00.442,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 0 : 30, idx 13 -> 27
00> [00:00:00.451,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 0 : 30, idx 12 -> 25
00> [00:00:00.460,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 8 : 38, idx 11 -> 23
00> [00:00:00.469,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 2 : 32, idx 10 -> 21
00> [00:00:00.477,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 0 : 30, idx 9 -> 19
00> [00:00:00.486,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 0 : 30, idx 8 -> 17
00> [00:00:00.495,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 9 : 39, idx 7 -> 15
00> [00:00:00.504,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 0 : 30, idx 6 -> 13
00> [00:00:00.512,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 0 : 30, idx 5 -> 11
00> [00:00:00.521,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 5 : 35, idx 4 -> 9
00> [00:00:00.530,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 4 : 34, idx 3 -> 7
00> [00:00:00.538,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 3 : 33, idx 2 -> 5
00> [00:00:00.547,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 2 : 32, idx 1 -> 3
00> [00:00:00.555,000] <dbg> usb_descriptor: ascii7_to_utf16le: char 3 : 33, idx 0 -> 1
00> [00:00:00.564,000] <dbg> usb_dc_stm32: usb_dc_set_status_callback: 
00> [00:00:00.571,000] <dbg> usb_dc_stm32: usb_dc_attach: 
00> [00:00:00.577,000] <dbg> usb_dc_stm32: usb_dc_stm32_init: Pinctrl signals configuration
00> [00:00:00.586,000] <dbg> usb_dc_stm32: usb_dc_stm32_init: HAL_PCD_Init
00> [00:00:00.593,000] <dbg> usb_dc_stm32: usb_dc_stm32_init: HAL_PCD_Stop
00> [00:00:00.600,000] <dbg> usb_dc_stm32: usb_dc_stm32_init: HAL_PCD_Start
00> [00:00:00.608,000] <dbg> usb_dc_stm32: usb_dc_ep_configure: ep 0x00, previous ep_mps 64, ep_mps 64, ep_type 0
00> [00:00:00.619,000] <dbg> usb_dc_stm32: usb_dc_ep_configure: ep 0x80, previous ep_mps 64, ep_mps 64, ep_type 0
00> [00:00:00.630,000] <dbg> usb_dc_stm32: usb_dc_ep_set_callback: ep 0x00
00> [00:00:00.637,000] <dbg> usb_dc_stm32: usb_dc_ep_set_callback: ep 0x80
00> [00:00:00.645,000] <dbg> usb_dc_stm32: HAL_PCD_SuspendCallback: 
00> [00:00:00.651,000] <inf> usb_hid: Device suspended
00> [00:00:00.657,000] <dbg> usb_device: composite_setup_ep_cb: set cb, ep: 0x81
00> [00:00:00.665,000] <dbg> usb_dc_stm32: usb_dc_ep_set_callback: ep 0x81
00> [00:00:00.672,000] <dbg> usb_dc_stm32: usb_dc_ep_enable: ep 0x00
00> [00:00:00.679,000] <dbg> usb_dc_stm32: usb_dc_ep_enable: HAL_PCD_EP_Open(0x00, 64, 0)
00> [00:00:00.688,000] <dbg> usb_dc_stm32: usb_dc_ep_enable: ep 0x80
00> [00:00:00.695,000] <dbg> usb_dc_stm32: usb_dc_ep_enable: HAL_PCD_EP_Open(0x80, 64, 0)
00> [00:00:00.704,000] <dbg> usb_device: usb_enable: unlock usb_enable_lock mutex
00> [00:00:00.820,000] <dbg> usb_dc_stm32: HAL_PCD_ResumeCallback: 
00> [00:00:00.826,000] <inf> usb_hid: Device resumed
00> [00:00:00.832,000] <inf> usb_hid: from suspend
00> [00:00:00.873,000] <dbg> usb_dc_stm32: HAL_PCD_ResetCallback: 
00> [00:00:00.880,000] <inf> usb_hid: Device reset detected
00> [00:00:01.552,000] <dbg> usb_dc_stm32: HAL_PCD_ResetCallback: 
00> [00:00:01.558,000] <inf> usb_hid: Device reset detected
00> [00:00:02.230,000] <dbg> usb_dc_stm32: HAL_PCD_ResetCallback: 
00> [00:00:02.236,000] <inf> usb_hid: Device reset detected
00> [00:00:02.908,000] <dbg> usb_dc_stm32: HAL_PCD_ResetCallback: 
00> [00:00:02.915,000] <inf> usb_hid: Device reset detected
00> [00:00:03.041,000] <dbg> usb_dc_stm32: HAL_PCD_SuspendCallback: 
00> [00:00:03.048,000] <inf> usb_hid: Device suspended

 

I guess that I might have missconfigured the clocks in the DTS:

#include <st/u0/stm32u073Xc.dtsi>
#include <st/u0/stm32u073rctx-pinctrl.dtsi>
 

 

	hid_dev_0: hid_dev_0 {
		compatible = "zephyr,hid-device";
		label = "HID0";
		protocol-code = "none";
		in-polling-period-us = <1000>;
		in-report-size = <64>;
	};


...

&clk_hsi {
	status = "okay";
};

&clk_hsi48 {
	status = "okay";
};

&clk_lse {
	status = "okay";
};

&clk_lsi {
	status = "okay";
};

&pll {
	div-m = <1>;
	mul-n = <6>;
	div-p = <2>;
	div-q = <2>;
	div-r = <2>;
	clocks = <&clk_hsi>;
	status = "okay";
};

&rcc {
	clocks = <&pll>;
	clock-frequency = <DT_FREQ_M(48)>;
	ahb-prescaler = <1>;
	apb1-prescaler = <1>;
};

zephyr_udc0: &usb {
	clocks = <&rcc STM32_CLOCK(APB1, 13)>,
		 <&rcc STM32_SRC_HSI48 CLK48_SEL(1)>;
	pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>;
	pinctrl-names = "default";
	status = "okay";
};

&rtc {
	clocks = <&rcc STM32_CLOCK(APB1, 10)>,
		 <&rcc STM32_SRC_LSE RTC_SEL(1)>;
	status = "okay";
};

&clk_hsi48 {
    #clock-cells = <0>;
    compatible = "st,stm32-hsi48-clock";
    clock-frequency = <DT_FREQ_M(48)>;
    status = "okay";
};

 

Is the current zephyr code working on the U073 board?

Am I missing something in the DTS?

 

Thanks a lot

0 REPLIES 0