cancel
Showing results for 
Search instead for 
Did you mean: 

It's possible to make work USB-OTG and USART1 in the same device (STM32MP157CAC)?

areify
Associate II

Hi everyone.

I have an already-designed PCB with an STM32MP157 on it. In order to communicate with an external device, I am using USART1. At the same time, I'm using an USB OTG port to connect my device to my PC.

My problem is that USART1 is working with pins PA10 (AF7: USART1 RX), PA12 (AF7: USART1 DE) and PB6 (AF7: USART1 TX). It seems that PA10 is also set up as OTG HS pin:

usbotg_hs_pins_a: usbotg_hs-0 {
				pins {
					pinmux = <STM32_PINMUX('A', 10, ANALOG)>; /* OTG_ID */
				};
			};

(in stm32mp157-pinctrl.dtsi).

I am not sure at all but I think this pin is not referenced at any device tree file in the whole DTS. However, if I disable usb-otg device, USART1 starts working.

But I don't want to do that.

So after reading the usb-otg driver documentation I discovered the following parameter:

dr_mode: shall be one of "host", "peripheral" and "otg"

So I set up my otg as "peripheral" and now my usb otg works when I connect the external device to my USART1. But USART1 still not works.

What am I missing? I also tried deleting node usbotg_hs_pins_a in pinctrl and property pinctrl-0 in usbotg_hs.

My device tree topology is next: I am using a .dts file which includes stm32mp157a-dk1.dts. And I've redefined usbotg_hs node as:

&usbotg_hs {
        /delete-property/ extcon;
	dr_mode = "peripheral";
};

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

Ecosystem v1.0.0 is really outdated (we are using v3.0.0 as of today). At least you should switch to v1.2.0, this might not break your existing development (anyway v1.2.0 is still no more supported by ST deliveries, so, any community patches not in this version should be added by your own).

For information, wiki archive for ecosystem v1.2.0 is here : https://wiki.st.com/stm32mpu-ecosystem-v1/wiki/Main_Page

I'm not a SW expert, so I can just give you few HW hints on your issue.

Enabling OTG_ID (which sound be the case for you) is using OTG_GCCFG.IDEN bit =1. This enable will take precedence over any GPIO AFMUX setting on PA10 (USART1 RX in your case) which explain why you did not receive UART data.

OTG_ID pin control is disabled with OTG_GCCFG.IDEN=0.

Regards,

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

12 REPLIES 12
PatrickF
ST Employee

Hi,

please see https://wiki.st.com/stm32mpu/wiki/How_to_configure_U-Boot_for_your_board#USB_OTG_node

To disable OTG_ID pin on PA10, at least you miss also the following line:

 	u-boot,force-b-session-valid;

Regards,

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi Patrick

Thank you for your fast reply :)

I've tested that line and it did not worked. Also I tried with

force-b-session-valid;

And USART1 still does not work. Maybe I'm doing something else wrong.

Hi,

any log related to USART1 'does not work' ?

Check if USART1 kernel clock is enabled, see https://wiki.st.com/stm32mpu/wiki/STM32MP15_clock_tree

see also https://wiki.st.com/stm32mpu/wiki/Serial_TTY_device_tree_configuration#Activation_of_a_USART_or_UART_instance

if you are trying to use USART1 from Cortex-M4, please see https://wiki.st.com/stm32mpu/wiki/How_to_assign_an_internal_peripheral_to_a_runtime_context

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi Patrick

While I was with the first steps of development I remember using all the debug tips that are mentioned in ST Wiki for tty. After this stage I achieved my goal: getting a built C code where USART1 was working. I've logs from that C program where I check the frames received. When I say 'is not working' I mean that I am not receiving anything from the USART1. I could share this logs if you want, but I don't see it neccesary because they are not giving more extra info about the USART1 state.

Thank you again for your response. Let me check all those points and I'll come back with more news.

By the way, disabling the whole usbotg node worked fine, so the conflict must be encapsulated in usbotg configuration. About Cortex-M4, all the USART setups are disabled.

One more thing: I've checked the official code commit logs and it looks that I'm working with an old version. I will take a look deeply to this too. Here you have my dts files (if you want to check anything)

2/3

3/3

It seems that my device-tree version does not support usbotg force-b-session instruction.

I prefer not to download the latest version, it could be possible to fix it anyway? Also if I can avoid editing ST files it would be great.

Thank you in advance

Hi,

which STM32MP Ecosystem version are you using ?

As far as I know, "u-boot,force-b-session-valid;" is already supported on v2.1 (Yocto LTS Dunfell, Kernel 5.4 LTS, U-BOOT v2020-01, TF-A 2.2, OP-TEE 3.9).

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Ecosystem v1.0.0 :(