Skip to content

zephyr stm32f4 startup freezes at startup in PRINT_BOOT_BANNER() #stm32 #uart #boot #11339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
StefJar opened this issue Nov 13, 2018 · 6 comments
Labels
bug The issue is a bug, or the PR is fixing a bug platform: STM32 ST Micro STM32

Comments

@StefJar
Copy link

StefJar commented Nov 13, 2018

After pulling latest commit(7c290b0), the startup hangs when printing chars to the UART.

Call stack trace:

uart_stm32_poll_out() at uart_stm32.c:59 0x8007dd2	
_impl_uart_poll_out() at uart.h:257 0x8006024	
uart_poll_out() at uart.h:17 0x8006024	
console_out() at uart_console.c:110 0x8006024	
char_out() at printk.c:265 0x8002a72	
_vprintk() at printk.c:103 0x8002e2e	
vprintk() at printk.c:290 0x8002e54	
printk() at printk.c:340 0x8002e6e	
bg_thread_main() at init.c:215 0x8008252	
_thread_entry() at thread_entry.c:29 0x80025c0	
_Cstart() at init.c:485 0x80082b8	
__config_i2c_stm32_1() at 0x8009780	

hang at uart_stm32.c in

static unsigned char uart_stm32_poll_out(struct device *dev,
					unsigned char c)
{
	USART_TypeDef *UartInstance = UART_STRUCT(dev);

	/* Wait for TXE flag to be raised */
>>>	while (!LL_USART_IsActiveFlag_TXE(UartInstance))
		;

	LL_USART_ClearFlag_TC(UartInstance);


this function is called from init.c:

static void bg_thread_main(void *unused1, void *unused2, void *unused3)
{
...
PRINT_BOOT_BANNER();
...

I am using the a slightly different version of the

with following dts changes:

	chosen {
		zephyr,console = &usart1;
		zephyr,sram = &sram0;
		zephyr,flash = &flash0;
	};
	
	soc {
		pinctrl: pin-controller@40020000 {
			usart1_pins_d: usart1_3 {
				rx_tx {
					rx = <STM32_PIN_PA10 (STM32_PINMUX_ALT_FUNC_7 | STM32_PUPDR_NO_PULL)>;
					tx = <STM32_PIN_PA15 (STM32_PINMUX_ALT_FUNC_7 | STM32_PUSHPULL_PULLUP)>;
				};
			};
...

&usart1 {
	current-speed = <115200>;
	pinctrl-0 = <&usart1_pins_d>;
	pinctrl-names = "default";
	status = "ok";
};

@erwango
Copy link
Member

erwango commented Nov 13, 2018

@StefJar

What was your previous sha1?
What board are you using?
Do you mean that banner does not print correctly in eg hello_world?

@StefJar
Copy link
Author

StefJar commented Nov 13, 2018

@sha1 sorry I don't know the exactly one. Guess the last form Friday(09-11-2018).
@board: a custom board. It's comparable to the nucleo_f412zg BUT I redirected the console form uart3 to uart1. these uart1 has a different pin use. That's why I added the usart1_pins_d node to the pin control
@PRINT_BOOT_BANNER(): this prints the boot message of zephyr os like version & hash

@StefJar
Copy link
Author

StefJar commented Nov 13, 2018

Maybe commit : 6d1a31b
or bd73879 breaks the power up sequence

To make it clear. The PRINT_BOOT_BANNER function is called at the starting of the main thread/kernel. It loops now infinite in the uart_stm32_poll_out function

@erwango
Copy link
Member

erwango commented Nov 14, 2018

ok, I think I got the issue.
Looks like a clock configuration issue in dts.
In dts/arm/st/f4/stm32f4.dtsi, can you try the following change:

 		usart1: serial@40011000 {
 			compatible = "st,stm32-usart", "st,stm32-uart";
 			reg = <0x40011000 0x400>;
-			clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00004000>;
+			clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00000010>;
 			interrupts = <37 0>;
 			status = "disabled";
 			label = "UART_1";
 		};

@erwango erwango added platform: STM32 ST Micro STM32 bug The issue is a bug, or the PR is fixing a bug labels Nov 14, 2018
@StefJar
Copy link
Author

StefJar commented Nov 14, 2018

I can confirm that the clock change to
clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00000010>;
solves that issue

@avisconti
Copy link
Collaborator

avisconti commented Nov 14, 2018

Verified the proposed fix also on ArgonKey board.
Thx!

erwango added a commit to erwango/zephyr that referenced this issue Nov 14, 2018
Clock mask was not set correctly for usart1 in stm32f4.dtsi

Fixes zephyrproject-rtos#11339

Signed-off-by: Erwan Gouriou <[email protected]>
nashif pushed a commit that referenced this issue Nov 14, 2018
Clock mask was not set correctly for usart1 in stm32f4.dtsi

Fixes #11339

Signed-off-by: Erwan Gouriou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug platform: STM32 ST Micro STM32
Projects
None yet
Development

No branches or pull requests

3 participants