TKE- NV Timer - TMR0 configuration as interrupt

Hi team,

We want to use the NV Timer (preferably TMR0) from the TKE in Jetson Orin Nano, to generate a high priority event for a task that needs to be executed every 1ms.

So, wanted to know whether the support for the timer’s device driver has been added or how can it be accessed?

I’m using - nvidia-jetpack (6.2.1), Operating System: Ubuntu 22.04.5 LTS, Kernel: Linux 5.15.148-tegra

*** Please note that this reply is generated by LLM automatically ***

The Jetson Orin Nano does support the use of timers, including the NV Timer (TMR0) from the TKE (Timer Kernel Extension). However, the support for the timers device driver is not explicitly mentioned in the provided context.

To access the NV Timer, you can use the nv_tmr driver, which is a part of the Linux kernel. This driver provides a character device interface to access the NV Timer.

To use the nv_tmr driver, you will need to:

  1. Ensure that the nv_tmr driver is loaded and enabled in your kernel configuration. You can check this by running the command lsmod | grep nv_tmr.
  2. Use the nv_tmr driver to open the NV Timer device file, typically located at /dev/nv_tmr.
  3. Use the ioctl system call to configure and control the NV Timer.

Here is an example of how you can use the nv_tmr driver to generate a high-priority event every 1ms:

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/nv_tmr.h>

int main() {
    int fd;
    struct nv_tmr_config config;

    // Open the NV Timer device file
    fd = open("/dev/nv_tmr", O_RDWR);
    if (fd < 0) {
        perror("open");
        return 1;
    }

    // Configure the NV Timer to generate an event every 1ms
    config.timer_id = 0; // TMR0
    config.period = 1000; // 1ms
    config.mode = NV_TMR_MODE_PERIODIC;
    config.priority = NV_TMR_PRIORITY_HIGH;

    if (ioctl(fd, NV_TMR_IOCTL_SET_CONFIG, &config) < 0) {
        perror("ioctl");
        return 1;
    }

    // Start the NV Timer
    if (ioctl(fd, NV_TMR_IOCTL_START, NULL) < 0) {
        perror("ioctl");
        return 1;
    }

    // Wait for the event to be generated
    while (1) {
        // Your task code here
    }

    return 0;
}

Note that this is just an example code snippet, and you will need to modify it to suit your specific requirements.

In comparison to other timer drivers, the nv_tmr driver provides a more flexible and high-performance timer solution, especially for applications that require high-priority events.

It’s also worth noting that the nv_tmr driver is specific to the NVIDIA Jetson platform, and may not be available on other Linux-based systems.

As for the kernel version, the nv_tmr driver is available in the Linux kernel version 5.15.148-tegra, which is the kernel version you are using.

*** Please give the thumbs up if you get answers you like. Or provide feedback to help us improve the answer. ***

Current Jetson support GTE only.

Thank you for the response, there exists no file named nv_tmr.h in my “/dev/” or “/usr/src/linux-headers-5.15.148-tegra-ubuntu22.04_aarch64/3rdparty/canonical/linux-jammy/kernel-source/include/uapi/linux/” directory. Would that be found sowhere else or do I need to add it there somehow ?

Check the document for enabling the GTE instead of LLM’s responce.

Thanks