Solved: Disable UART in AWS_IOT sample

Solved! I had issues with connected sensors. 

Hi, 

I am using the Actinius Icarus board. I want to use the AWS_IOT sample to migrate my application from SDK 2.3 to 2.6. I want do disable UART to reduce the current consumption.

I have created a function:

void uart_set_enable(bool enable)
{
	const struct device *uart0_dev = DEVICE_DT_GET(DT_NODELABEL(uart0));
	const struct device *uart1_dev = DEVICE_DT_GET(DT_NODELABEL(uart1));

	if (device_is_ready(uart0_dev))
	{
		pm_device_action_run(uart0_dev, enable ? PM_DEVICE_ACTION_RESUME : PM_DEVICE_ACTION_SUSPEND);
	}

	if (device_is_ready(uart1_dev))
	{
		pm_device_action_run(uart1_dev, enable ? PM_DEVICE_ACTION_RESUME : PM_DEVICE_ACTION_SUSPEND);
	}

}

and I am calling this function in main 

uart_set_enable(false);

I get an error:

[00:00:00.255,462] <inf> aws_iot_sample: The AWS IoT sample started, version: v1.0.0
16:39:39:590 -> [00:00:00.255,523] <inf> aws_iot_sample: Bringing network interface up and connecting to the network
16:39:39:601 -> [00:00:00.489,929] <inf> nrf_modem_lib_trace: Trace thread ready
16:39:39:606 -> [00:00:00.497,222] <inf> nrf_modem_lib_trace: Trace level override: 2
16:39:39:617 -> [00:00:00.536,956] <inf> aws_iot_sample: Hardware ID: 351901936128515
16:39:39:622 -> ASSERTION FAIL [!data->async->tx_size] @ WEST_TOPDIR/zephyr/drivers/serial/uart_nrfx_uarte.c:1901
16:39:39:627 -> [00:00:00.537,689] <err> os: r0/a1:  0x00000004  r1/a2:  0x0000076d  r2/a3:  0x00000009
16:39:39:638 -> [00:00:00.537,719] <err> os: r3/a4:  0x20011080 r12/ip:  0x00000014 r14/lr:  0x0002628b
16:39:39:649 -> [00:00:00.537,719] <err> os:  xpsr:  0x41000000
16:39:39:654 -> [00:00:00.537,750] <err> os: Faulting instruction address (r15/pc): 0x0003a4f0
16:39:39:659 -> [00:00:00.537,780] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
16:39:39:665 -> [00:00:00.537,811] <err> os: Current thread: 0x200137b0 (unknown)
16:39:39:675 -> [00:00:00.645,904] <err> fatal_error: Resetting system

I guess this is due to the modem trace lib in proj.conf, so I will comment these lines:

# # Modem trace
# CONFIG_NRF_MODEM_LIB_TRACE=y
# CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_UART=y
# CONFIG_NRF_MODEM_LIB_TRACE_BACKEND_UART_ZEPHYR=y
# CONFIG_UART_ASYNC_API=y
# CONFIG_UART_1_ASYNC=y
# CONFIG_UART_1_INTERRUPT_DRIVEN=n

But after this the device is not booting anymore. Serial is not working anymore and power consumption is stable so I guess it is locked in a loop at boot. 

I am wondering if the connection manager is using the modem trace? What would be the best way to turn off the UART to lower the power consumption? 

Thanks

Related