Building & Running C++/CMake Projects on DriveOS Orin using SDK headers/shared libs

Please provide the following info (tick the boxes after creating this topic):
Software Version
DRIVE OS 6.0.6
DRIVE OS 6.0.5
DRIVE OS 6.0.4 (rev. 1)

Target Operating System

Hardware Platform
DRIVE AGX Orin Developer Kit (940-63710-0010-300)
DRIVE AGX Orin Developer Kit (940-63710-0010-200)
DRIVE AGX Orin Developer Kit (940-63710-0010-100)
DRIVE AGX Orin Developer Kit (940-63710-0010-D00)
DRIVE AGX Orin Developer Kit (940-63710-0010-C00)
DRIVE AGX Orin Developer Kit (not sure its number)

SDK Manager Version

Host Machine Version
native Ubuntu Linux 20.04 Host installed with SDK Manager
native Ubuntu Linux 20.04 Host installed with DRIVE OS Docker Containers
native Ubuntu Linux 18.04 Host installed with DRIVE OS Docker Containers

Throughout the Drive OS SDK Dev Guide there are references to various header files like for example the IOCTL structure definitions (from this page TSN API)

Data structure heater files are in the drive-linux/include folder.

and then within various forum Topics, moderators post C/C++ snippets like the NVPPS IOCTL functions posted here in this Topic.

I’ve found the original source header files in the correct locations when browsing the SDK source code within the DRIVE OS Docker container before I flash to the Orin, but I am confused on how I am supposed to include these header files within say a cmake project that I am trying to build & run on the already flashed Orin.

For example, I have this program I am trying to run that uses IOCTL to check NVPPS but I don’t know what header files or shared libs I am supposed to be including in my project.

Any help would be greatly appreciated as I am pretty confused and I feel like having to build this cmake project within the Drive OS Docker and then reflashing the Orin everytime I build, just to run the program on the Orin, is not the intended method.

#include <iostream>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <cstdio>

static int64_t tsc_2_ptp_delta(int64_t tsc, int64_t ptp)
	static int64_t	tsc_prev = 0;
	static int64_t	ptp_prev = 0;
	int64_t		ptp_delta, tsc_delta;

	ptp_delta = ptp - ptp_prev;
	tsc_delta = tsc - tsc_prev;
	/* remember the previous value */
	tsc_prev = tsc;
	ptp_prev = ptp;
	return tsc_delta - ptp_delta;

int main() {
    	std::cout << "Hello, C++ Project!" << std::endl;
	int fd = open("/dev/nvpps0", O_RDWR);
	if (fd < 0) {
		fprintf(stderr, "Failed to open nvpps file descriptor");
		return 1;

	if (ioctl(fd, NVPPS_GETEVENT, &ts) != 0) {
    		fprintf(stderr, "ioctl failed for NVPPS_GETEVENT err %s\n");
    		return 1;
	} else {
    		fprintf(stdout, "evt, %d, tsc, %llu, phc, %llu, sec_phc %llu, delta, %lld, latency %llu, ptp_offset %lld, tsc_res_ns, %llu, evt_mode, %d, tsc_mode, %d\n", ts.evt_nb, ts.tsc, ts.ptp, ts.secondary_ptp, tsc_2_ptp_delta((int64_t)ts.tsc, (int64_t)ts.ptp), ts.irq_latency, (int64_t)(ts.secondary_ptp - ts.ptp), ts.tsc_res_ns, ts.evt_mode, ts.tsc_mode);
	close(fd);  // close out dev port descriptor

    	return 0;

It seems that your colleague has successfully built and run such a program, as mentioned in External PPS not triggering fsync generator. You may discuss this with them regarding their experience.

Thanks for all the help

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.