Zephyr/nrf52 - how to override UART speed?

I have an nrf52 zephyr program that prints using printk to the default uart uart0 at 115200 baud. How can I increase the baud rate, for example to 230400?

I found in the documentation reference to DTC_OVERLAY_FILE that can be used to override uart0 configuration using an overlay file in my project but could make it to work nor could I find an actual example.

The default uart0 configuration in nrf52dk_nrf52832.dts:

arduino_serial: &uart0 {
	status = "okay";
	compatible = "nordic,nrf-uarte";
	current-speed = <115200>;
	tx-pin = <6>;
	rx-pin = <8>;
	rts-pin = <5>;
	cts-pin = <7>;
};

My platformio.ini:

[env:nrf52_dk]
platform = nordicnrf52
board = nrf52_dk
framework = zephyr
debug_tool = jlink
monitor_speed = 115200

Answering my own question. Added a file zephyr/nrf52dk_nrf52832.overlay with the content below. This is a device tree overlay for the underlying zephyr nrf52dk_nrf52832
board.

&uart0 {
	status = "okay";
	compatible = "nordic,nrf-uarte";
	current-speed = <230400>;
	tx-pin = <6>;
	rx-pin = <8>;
};
1 Like