Skip to content

Document how to use the HSE clock as the source, and USB on the STM32 Nucleo U5A5ZJ-Q board #79825

@erikarn

Description

@erikarn

Is your enhancement proposal related to a problem? Please describe.

The current nucleo board description (https://docs.zephyrproject.org/latest/boards/st/nucleo_u5a5zj_q/doc/index.html) and support doesn't enable USB-HS. Enabling USB-HS requires that specific components are stuffed including X4, a 16MHz crystal feeding the HSE clock.

However, at least on the board /I/ just bought, they're already stuffed! So it's very possible to enable it by default.
I have some working diffs locally; I need to clean them up and post them.

The TL;DR though is:

  • add the HSE clock source in the device-tree
+/* This board has a 16MHz crystal attached */
+&clk_hse {
+        clock-frequency = <DT_FREQ_M(16)>;
+        status = "okay";
+};
+
  • add a suitable "zephyr_udc0", matching what another u5 part did (just make sure you use the HS pinmux, eg)
+zephyr_udc0: &usbotg_hs {
+        pinctrl-0 = <&usb_otg_hs_dm_pa11 &usb_otg_hs_dp_pa12>;
+        pinctrl-names = "default";
+        status = "okay";
+};
  • add the HSE clock source rather the internal RC source, by changing pll1)
+&pll1 {
+       /* HSE 16MHz source, outputting 160MHz to sysclk and apbclk */
+       div-m = <4>; /* input divisor */
+       mul-n = <80>; /* VCO multiplication factor */
+       div-q = <2>; /* system clock divisor */
+       div-r = <2>; /* peripheral clock divisor */
+       clocks = <&clk_hse>;
+       status = "okay";
+};

And then for the CDC-ACM demo, add this to samples/subsys/usb/cdc_acm/nucleo_u5a5zj_q.overlay:

/*
 * Copyright (c) 2023 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

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

Then it can be built like normal, ie:

`

west build -b nucleo_u5a5zj_q samples/subsys/usb/cdc_acm

`

Describe the solution you'd like

I'm not sure yet. I'm worried that there are versions of the Nucleo board without the HSE crystal (X4) stuffed and jumpered correctly. Is it worth creating a separate board type that assumes it's populated? Or just assume they are and document in the device tree how to flip just to the RC clock source if someone has a board without it?

Describe alternatives you've considered

(n/a)

Additional context

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions