uart_configure cause Stack overflow

when the code run to "uart_configure" function, the program cause Stack overflow 

	if (mdata.current_serial_speed != MDM_SPEED_WORK)
	{
		if (serial_cfg.baudrate != mdata.current_serial_speed)
		{
			serial_cfg.baudrate = mdata.current_serial_speed;
			// 停止接收数据
			uart_irq_rx_disable(MDM_UART_DEV);

			uart_configure(MDM_UART_DEV, &serial_cfg);
			// 开启接收数据
			uart_irq_rx_enable(MDM_UART_DEV);
		}

		snprintk(buf, sizeof(buf), "AT+IPR=%u", MDM_SPEED_WORK);

		ret = modem_cmd_send(&mctx.iface, &mctx.cmd_handler, NULL, 0U, buf,
							 &mdata.sem_response, K_MSEC(500));
		if (ret < 0)
		{
			LOG_ERR("Failed to send init commands!");
			goto error;
		}
		mdata.current_serial_speed = MDM_SPEED_WORK;
		serial_cfg.baudrate = MDM_SPEED_WORK;


		// 停止接收数据
		uart_irq_rx_disable(MDM_UART_DEV);

		uart_configure(MDM_UART_DEV, &serial_cfg);
		// 开启接收数据
		uart_irq_rx_enable(MDM_UART_DEV);

	}

  • I've also tried increasing the size of the main stack, and I have also tried increasing the size of the workqueue stack, and the same phenomenon still occurs. I think it should not be a problem with the stack, or a stack overflow when changing the baud rate from 115200 to 230400 at runtime, as long as the baud rate is not modified, there is no problem

  • Noted,

    it looks like a stack overflow that occurred on the idle thread.

    Did you increase the stack size of the idle thread?

    or a stack overflow when changing the baud rate from 115200 to 230400 at runtime, as long as the baud rate is not modified, there is no problem

    This sounds strange. Changing the baud rate on runtime should not lead to a stack overflow, unless there is something in Zephyr that also changes when you change the baud rate during runtime such as buffers increasing in size or similar items. Or  that you do additional modifications at the same time that you change the baud rate. I would recommend you to investigate these two items when debugging further

    Kind regards,
    Andreas

Related