- Xavier NX 16GB
- Custom Carrier Board (Seeedstudio A203v2)
- M.2 SSD 1TB formatted as ext4
- JetPack 5.1
Hi all,
we’re currently working with different flight controllers (mostly based on STM32H743VIH6), getting IMU via UART.
On the seeedstudio, the available UART interface is /dev/ttyTHS0, used to exchange MSP messages.
According to the DTB/DTS file, the serial we used is defined as:
serial@3100000 { compatible = "nvidia,tegra186-hsuart"; iommus = <0x02 0x20>; interconnects = <0x03 0x16>; interconnect-names = "dma-mem"; dma-coherent; reg = <0x00 0x3100000 0x00 0x10000>; reg-shift = <0x02>; interrupts = <0x00 0x70 0x04>; nvidia,memory-clients = <0x0e>; dmas = <0x1b 0x08 0x1b 0x08>; dma-names = "rx\0tx"; clocks = <0x04 0x9b 0x04 0x66>; clock-names = "serial\0parent"; assigned-clocks = <0x04 0x9b>; assigned-clock-parents = <0x04 0x66>; resets = <0x04 0x64>; reset-names = "serial"; nvidia,adjust-baud-rates = <0x1c200 0x1c200 0x64>; status = "okay"; phandle = <0x2b3>;
};
So the default baudrate shall be 115200.
nvidia@ubuntu:~$ sudo dmesg | grep serial
[ 5.383542] serial-tegra 3100000.serial: Adding to iommu group 2
[ 5.389609] 3100000.serial: ttyTHS0 at MMIO 0x3100000 (irq = 31, base_baud = 0) is a TEGRA_UART
[ 5.398908] serial-tegra 3110000.serial: Adding to iommu group 2
[ 5.404779] 3110000.serial: ttyTHS1 at MMIO 0x3110000 (irq = 32, base_baud = 0) is a TEGRA_UART
[ 5.413567] serial-tegra 3140000.serial: Adding to iommu group 2
[ 5.419576] 3140000.serial: ttyTHS4 at MMIO 0x3140000 (irq = 33, base_baud = 0) is a TEGRA_UART
[ 7.483604] systemd[1]: Created slice system-serial\x2dgetty.slice.
The interface is assigned to dialout, since nvgetty is disabled.
nvidia@ubuntu:~$ ls -la /dev/ttyTH*
crw-rw---- 1 root dialout 238, 0 Apr 7 16:56 /dev/ttyTHS0
crw-rw---- 1 root dialout 238, 1 Apr 7 16:56 /dev/ttyTHS1
crw-rw---- 1 root dialout 238, 4 Apr 7 16:56 /dev/ttyTHS4
In our MSP C++ Client we initiate the sender using asio and baudrate is 1000000.
bool Client::connectPort(const std::string& device, const size_t baudrate) { port.open(device); port.set_option(asio::serial_port::baud_rate(uint(baudrate))); port.set_option( asio::serial_port::parity(asio::serial_port::parity::none)); port.set_option(asio::serial_port::character_size( asio::serial_port::character_size(8))); port.set_option( asio::serial_port::stop_bits(asio::serial_port::stop_bits::one)); return isConnected(); }
We set our FC serial baudrate to 1000000 too, but the NX doesn’t seem to keep pace with such high frequency (500Hz instead of 1600Hz) and we are wondering if we’re missing something here.
CPU shall run at maximum (nvpmodel -m 8
&& jetson_clocks
).
Browsing the forum I saw this procedure is often recommended: How to make Nano's uart work at about 8Mbps baudrate? - #7 by spatra
Then I coded in C
uart.c (1.4 KB)
I have a question though:
Why setting termios2 c_ospeed/c_ispeed is required if we already set baudrate to 1M in our C++ application?
Do you have any other hints on this problem?
Thank you