How to integrated work SPE-fw and CUDA?

Hello All,

I installed SPE-fw in jetson tx2. You know. SPE-fw works on Cortex-R5 ,
I want to process image with cuda on real time. How could I communicate with SPE-fw(FreeRTOS) and Cuda Cores? Is this possible?

Hello, hamzaygrtc:
SPE, generally, is a sensor processing engine, and I don’t think it will processing data like image.
It runs FreeRTOS and can do some real-time tasks but not heavy computation.

Anyway, in current FW, SPE can communicate with CCPLEX (Linux) through data_channel and then send to CUDA kernel.

br
Chenjian

Thanks Chenjian.

How could SPE and Linux kernel communicate each other , do you have document for that ? I’ve never done yet like this .

Hello, hamzaygrtc:
you can check doc/devicetree-ivc.md and there’s a sysfs node xxx/data_channel which you can echo/cat to send/rcv messages between CCPLEX and SPE firmware. Please check the code for detail.

br
ChenJian

Hello jachen,

I checked devicetree-ivc.md. But tegra186-aon.dtsi is not found. Which linux kernel? Where do I find source code ?

aon_echo {
		compatible = "nvidia,tegra186-aon-ivc-echo";
		mboxes = <&aon 0>;
		status = "okay";
	};

CCPLEX means that jetson tx2 has kernel of ubuntu ? I want to image processing with ubuntu of tx2 then if I find object send a message to freertos then blink a led. Is it possible like this communucation?

hi jachen could you help for above question?

Hello, hamzaygrtc:
You need add that content in corresponding DTSI file.
Yes, CCPLEX means the CPUs running Linux. You can send message from CCPLEX to SPE to control something as you desire, but you have to add some code.

you can check “rt-aux-cpu-demo/app/ivc-echo-task.c” for details.

br
Chenjian

hi jachen,
I couldnt find tegra186-aon.dtsi file. If update tegra186-aon.dtsi. I will re-flash full device again?

By the way, I add this code for init ivc in main.

#if defined(ENABLE_IVC_CCPLEX)
   ivc_echo_task_init(&ivc_echo_task_id);
#endif

I add target_specific.mk ENABLE_IVC_CCPLEX

Hello,
that file is in kernel source: ./hardware/nvidia/soc/t18x/kernel-dts/tegra186-soc/tegra186-aon.dtsi
you need re-compile the kernel, update kernel DTB and re-flash the device.
With correct change, /sys/devices/aon_echo/data_channel will appear in Linux side.

You need not add ivc_echo_task_init. That will be called in main.c - late_init.

br
ChenJian

Hi jachen,

I run ./source_sync.sh script in Linux_for_Tegra. But /hardware/nvidia/soc/t18x/ directory is empty.
I received lots of file but every directories are empty.

Hello, hamzaygrtc:
You can get source package from https://developer.nvidia.com/embedded/downloads#?search=L4T%20sources.
Kernel source is inside that package.

br
Chenjian

jachen, I copied all source file to Linux_for_Tegra directory. Then I updated tegra186-aon.dtsi
file like following:

/*
 * Copyright (c) 2017, NVIDIA CORPORATION.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */
/ {
	aon: aon@c160000 {
		compatible = "nvidia,tegra186-aon";
		status = "disabled";
		reg = <0x0 0x0c1a0000 0x0 0x40000>; /* AON shared semaphore */
		#mbox-cells = <1>;
		iommus = <&smmu TEGRA_SID_AON>;
		nvidia,hsp-shared-mailbox = <&aon_hsp 2>;
		nvidia,hsp-shared-mailbox-names = "ivc-pair";
		nvidia,ivc-carveout-base-ss = <0>;
		nvidia,ivc-carveout-size-ss = <1>;
		nvidia,ivc-rx-ss = <2>;
		nvidia,ivc-tx-ss = <3>;
		nvidia,ivc-dbg-enable-ss = <0>;

		ivc-channels@80000000 {
			#address-cells = <1>;
			#size-cells = <0>;

			ivc_aon_echo@0 {
				reg = <0x0000>, <0x10000>;
				reg-names = "rx", "tx";
				nvidia,frame-count = <16>;
				nvidia,frame-size = <64>;
			};
			ivc_aon_aondbg@480 {
				reg = <0x0480>, <0x10480>;
				reg-names = "rx", "tx";
				nvidia,frame-count = <2>;
				nvidia,frame-size = <128>;
			};
			ivc_aon_spi@600 {
				reg = <0x0600>, <0x10600>;
				reg-names = "rx", "tx";
				nvidia,frame-count = <2>;
				nvidia,frame-size = <24704>;
			};
			ivc_can0@c780 {
				reg = <0xc780>, <0x1c780>;
				reg-names = "rx", "tx";
				nvidia,frame-count = <16>;
				nvidia,frame-size = <128>;
			};
			ivc_can1@d000 {
				reg = <0xd000>, <0x1d000>;
				reg-names = "rx", "tx";
				nvidia,frame-count = <16>;
				nvidia,frame-size = <128>;
			};
			ivc_aon_shub@d880 {
				reg = <0xd880>, <0x1d880>;
				reg-names = "rx", "tx";
				nvidia,frame-count = <4>;
				nvidia,frame-size = <256>;
			};
		};
	};

	aondbg {
		compatible = "nvidia,tegra186-aondbg";
		mboxes = <&aon 1>;
	};

	mttcan0-ivc {
		compatible = "bosch,mttcan-ivc";
		mboxes = <&aon 3>;
		status = "disabled";
	};

	mttcan1-ivc {
		compatible = "bosch,mttcan-ivc";
		mboxes = <&aon 4>;
		status = "disabled";
	};

	aon_shub {
		status = "disabled";
		compatible = "nvidia,tegra186_aon_shub";
		mboxes = <&aon 5>;
	};
	aon_echo {
    		compatible = "nvidia,tegra186-aon-ivc-echo";
    		mboxes = <&aon 0>;
    		status = "okay";
	};

};

I must re-flash full device ? If I did. How could I test this data_channel between spe-fw and linuxside?

Hello, hamzaygrtc:
Yes, it’s better to fully re-flash the device.

  1. Change the DTSI file as you pasted.
  2. Recompile the kernel and DTB.
  3. Replace the DTB file in Linux_for_Tegra/xxx
  4. Re-flash the device.

If everything’s OK, you can find sysFS node data_channel, as doc described.
then you can echo/cat to/from that node to send-to/get-from message between CCPLEX and SPE R5.

br
ChenJian

jachen, how could I recompile for kernel and dtb?

/home/nvidia/Desktop/Linux_for_Tegra/sources/kernel/kernel-4.9/scripts/Makefile

I tried with make command but nothing happened.

Hello, hamzaygrtc:
please go to Jetson download center and search for L4T doc. You can find useful information.

br
ChenJian

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fkernel_custom.html%23wwpID0E0QD0HA

I tried this documention part. But not clear.

1.Set the shell variable with the command:
$ TEGRA_KERNEL_OUT=
Where:
• is the desired destination for the compiled kernel.
Where is compiled kernel ? I havent done any compiled kernel
Which directory is ?

make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j6
following error:

make[1]: Entering directory '/home/nvidia/Desktop/Linux_for_Tegra/kernel'
/home/nvidia/Desktop/gcc-linaro-7.3.1-2018.05-i686_aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/7.3.1/cc1: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
/home/nvidia/Desktop/gcc-linaro-7.3.1-2018.05-i686_aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/7.3.1/cc1: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
  GEN     ./Makefile
scripts/kconfig/conf  --silentoldconfig Kconfig
/home/nvidia/Desktop/gcc-linaro-7.3.1-2018.05-i686_aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/7.3.1/cc1: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
/home/nvidia/Desktop/gcc-linaro-7.3.1-2018.05-i686_aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/7.3.1/cc1: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
  CHK     include/config/kernel.release
  GEN     ./Makefile
  UPD     include/config/kernel.release
  WRAP    arch/arm64/include/generated/asm/bugs.h
  WRAP    arch/arm64/include/generated/asm/clkdev.h
  WRAP    arch/arm64/include/generated/asm/cputime.h
  WRAP    arch/arm64/include/generated/asm/delay.h
  WRAP    arch/arm64/include/generated/asm/div64.h
  WRAP    arch/arm64/include/generated/asm/dma.h
  WRAP    arch/arm64/include/generated/asm/dma-contiguous.h
  WRAP    arch/arm64/include/generated/asm/early_ioremap.h
  WRAP    arch/arm64/include/generated/asm/emergency-restart.h
  WRAP    arch/arm64/include/generated/asm/errno.h
  WRAP    arch/arm64/include/generated/asm/ioctl.h
  WRAP    arch/arm64/include/generated/asm/ioctls.h
  WRAP    arch/arm64/include/generated/asm/hw_irq.h
  WRAP    arch/arm64/include/generated/asm/irq_regs.h
  WRAP    arch/arm64/include/generated/asm/ipcbuf.h
  WRAP    arch/arm64/include/generated/asm/kdebug.h
  WRAP    arch/arm64/include/generated/asm/kvm_para.h
  WRAP    arch/arm64/include/generated/asm/kmap_types.h
  WRAP    arch/arm64/include/generated/asm/local.h
  WRAP    arch/arm64/include/generated/asm/local64.h
  CHK     include/generated/uapi/linux/version.h
  WRAP    arch/arm64/include/generated/asm/mcs_spinlock.h
  WRAP    arch/arm64/include/generated/asm/mm-arch-hooks.h
  WRAP    arch/arm64/include/generated/asm/mman.h
  WRAP    arch/arm64/include/generated/asm/msgbuf.h
  UPD     include/generated/uapi/linux/version.h
  WRAP    arch/arm64/include/generated/asm/poll.h
  WRAP    arch/arm64/include/generated/asm/msi.h
  WRAP    arch/arm64/include/generated/asm/preempt.h
  WRAP    arch/arm64/include/generated/asm/mutex.h
  WRAP    arch/arm64/include/generated/asm/resource.h
  WRAP    arch/arm64/include/generated/asm/segment.h
  WRAP    arch/arm64/include/generated/asm/rwsem.h
  WRAP    arch/arm64/include/generated/asm/serial.h
  WRAP    arch/arm64/include/generated/asm/sembuf.h
  WRAP    arch/arm64/include/generated/asm/simd.h
  WRAP    arch/arm64/include/generated/asm/shmbuf.h
  WRAP    arch/arm64/include/generated/asm/socket.h
  WRAP    arch/arm64/include/generated/asm/sizes.h
  WRAP    arch/arm64/include/generated/asm/sockios.h
  WRAP    arch/arm64/include/generated/asm/swab.h
  WRAP    arch/arm64/include/generated/asm/switch_to.h
  WRAP    arch/arm64/include/generated/asm/termios.h
  WRAP    arch/arm64/include/generated/asm/trace_clock.h
  WRAP    arch/arm64/include/generated/asm/types.h
  WRAP    arch/arm64/include/generated/asm/termbits.h
  WRAP    arch/arm64/include/generated/asm/user.h
  WRAP    arch/arm64/include/generated/asm/vga.h
  WRAP    arch/arm64/include/generated/asm/unaligned.h
  WRAP    arch/arm64/include/generated/asm/xor.h
  CHK     include/generated/utsrelease.h
  WRAP    arch/arm64/include/generated/uapi/asm/kvm_para.h
  UPD     include/generated/utsrelease.h
  HOSTCC  scripts/basic/bin2c
  Using /home/nvidia/Desktop/Linux_for_Tegra/sources/kernel/kernel-4.9 as source for kernel
  /home/nvidia/Desktop/Linux_for_Tegra/sources/kernel/kernel-4.9 is not clean, please run 'make mrproper'
  in the '/home/nvidia/Desktop/Linux_for_Tegra/sources/kernel/kernel-4.9' directory.
/home/nvidia/Desktop/Linux_for_Tegra/sources/kernel/kernel-4.9/Makefile:1129: recipe for target 'prepare3' failed
make[1]: *** [prepare3] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/nvidia/Desktop/Linux_for_Tegra/kernel'
Makefile:171: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2

Hello, hamzaygrtc:
Kernel must be cross-compiled in host PC.
From your log, it seems that cross-compiler does not work:
/home/nvidia/Desktop/gcc-linaro-7.3.1-2018.05-i686_aarch64-linux-gnu/bin/…/libexec/gcc/aarch64-linux-gnu/7.3.1/cc1: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
You need setup your building environment correctly first.

Paste the script I used for kernel building for your reference:

export KERNEL_SRC_DIR=/home/Work/jetson_customer/32.1/public_sources/kernel_src/kernel/kernel-4.9
export CROSS_COMPILE=/home/tools/linux/linaro/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
export TEGRA_KERNEL_OUT=/home/Work/jetson_customer/32.1/public_sources/kernel-build
export ARCH=arm64
make -C $KERNEL_SRC_DIR ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig   #kernel configuration
make -C $KERNEL_SRC_DIR ARCH=arm64 O=$TEGRA_KERNEL_OUT -j8               #kernel building

br
ChenJian

I compiled kernel to kernel-build how to communicate each other

I did just compilation. Where is dtb and where I copy?

hello,
you can mkdir that directory for kernel building output.

br
ChenJian