Do any one had successfully cross compile tegra_multimedia_api ?

Hi:
I followed “NVIDIA_Tegra_Linux_MultiMediaAPIReference” step by step,just want to cross compile

tegra_multimedia_api’s samples on host PC(X86,ubuntu16.04).but I get an error:

ml@ml:~/work/tegra_multimedia_api$ make all

Make in samples/00_video_decode
make[1]: Entering directory ‘/home/ml/work/tegra_multimedia_api/samples/00_video_decode’
Linking: video_decode
/opt/toolchain/bin/…/lib/gcc/aarch64-unknown-linux-gnu/4.8.5/…/…/…/…/aarch64-unknown-linux-gnu/bin/ld: cannot find /home/ml/jetson/usr/lib/crt1.o: Permission denied
/opt/toolchain/bin/…/lib/gcc/aarch64-unknown-linux-gnu/4.8.5/…/…/…/…/aarch64-unknown-linux-gnu/bin/ld: cannot find /home/ml/jetson/usr/lib/crti.o: Permission denied
/opt/toolchain/bin/…/lib/gcc/aarch64-unknown-linux-gnu/4.8.5/…/…/…/…/aarch64-unknown-linux-gnu/bin/ld: cannot find /lib/aarch64-linux-gnu/libpthread.so.0 inside /home/ml/jetson
collect2: error: ld returned 1 exit status
Makefile:52: recipe for target ‘video_decode’ failed
make[1]: *** [video_decode] Error 1
make[1]: Leaving directory ‘/home/ml/work/tegra_multimedia_api/samples/00_video_decode’
Makefile:53: recipe for target ‘all’ failed
make: *** [all] Error 1

It seems something wrong with crt1.o’s privilege.and it comfused me some days.

After followed “Build and Running”,now I can compile multimedia_api’samples on tx2 board,but why can’t

cross compile it.

when I read samba’s config file in “Cross-Compile Support”,I found a bug:It should be

“valid users”,not “valid user”. (this bug can be test use “testparm -v”)

the end of /etc/samba/smb.conf on target board is:

[root]
comment = Rootfs for Tegra
path = /
browseable = yes
read only = yes
valid users = root

the end of ~/.bashrc on host PC(X86) is:

export PATH=/opt/toolchain/bin:$PATH
export ARCH=arm64
export CROSS_COMPILE=aarch64-unknown-linux-gnu-
export TEGRA_KERNEL_OUT=/home/ml/kernel-out/kernel
export TARGET_ROOTFS=$HOME/jetson

after “sudo mount -t cifs -o “username=root,password=nvidia” //192.168.0.115/root $HOME/jetson”.

ml@ml:~/jetson/usr/lib$ cat /home/ml/jetson/usr/lib/crt1.o
cat: /home/ml/jetson/usr/lib/crt1.o: Permission denied

ml@ml:~/jetson/usr/lib$ ls -al /home/ml/jetson/usr/lib/crt*
-rwxr-xr-x 1 root root 1672 Jun 17 2017 /home/ml/jetson/usr/lib/crt1.o
-rwxr-xr-x 1 root root 1440 Jun 17 2017 /home/ml/jetson/usr/lib/crti.o
-rwxr-xr-x 1 root root 1016 Jun 17 2017 /home/ml/jetson/usr/lib/crtn.o

Do any one had solve this problem?

I have not tried to set up for this cross compile, but this is user space and not bare metal. This means the software you are building has to talk to libraries and the supporting environment. If working on bare metal (such as a kernel) your environment is simplified. Once you build in user space you need to provide everything to do linking of libraries plus the libraries themselves. The tools for linking could be called the binutils or runtime, the files being linked against (and which are basically a subset of the Jetson’s rootfs) are the sysroot.

You are missing the sysroot (possibly through missing configuration if you have the sysroot of this foreign architecture already installed). The crt* files are the lowest level files for startup of your programs (think of it as the glue between “main()” and the kernel doing the actual work). You can’t use your PC’s crt* files, they’re for the wrong architecture. You can’t use the PC’s native binutils/runtime…nor can you use purely aarch64 binutils/runtime…you’d need the cross version which executes on x86_64, but links to aarch64/arm64/ARMv8-a format libraries.

I suggest actually trying your cross compile on the Jetson. You will find required but missing packages this way. Once you can build on your Jetson you might clone it and use the loopback mounted clone as a source of cross compile sysroot files (you can get sysroot files from Linaro, but this is limited in scope and you might end up building all kinds of things before you can build your desired software…these things would already exist in a properly set up Jetson). Everything else is a foreign architecture tool on the PC.

If you look at Linaro, who provides many ARM tools which run on a PC for cross development, you’ll see a naming convention like this:
https://releases.linaro.org/components/toolchain/binaries/

gcc-linaro-<version>-x86_64_aarch64-linux-gnu

…in the above this is a cross compiler package which runs on x86_64 (a PC) and outputs to aarch64 (a TX2) assembler/binary under Linux with GNU supporting infrastructure (you probably couldn’t use this directly with Android despite having a Linux kernel).

You might see “-none-” in a name…in which case it is bare metal. Typically the “linux-gnu” works for building kernels and boot loaders for Linux, but you could not use the “-none-” with user space applications (or at least “-none-” isn’t intended for that). References to ARMv7 or armhf or eabi are all references to the predecessor 32-bit ARM and do not apply to the TX2 (there is a compatibility mode on a TX2 but you will not want this).

Thanks for your reply.

“TRAGET_ROOTFS” just “sysroot”,we can find it in tegra_multimedia_api/samples/Rules.mk,83 line.

CPPFLAGS += --sysroot=$(TARGET_ROOTFS)

But I accept your advice,I shouldn’t spend too much time on it.

I can compile these samples on tx2 board.

Thanks for mentioned me about sysroot and some knowledges.

You could attempt use the mount point of a cloned rootfs (via loopback) for the path named in “–sysroot=”…but even this would fail if the Jetson the clone came from didn’t have everything needed. So even if you choose to use cross compile later it would still be best to set up for this compile natively on the Jetson first…and only then migrate to cross compile (that way a clone would be a known complete sysroot).

This is not supported on latest r28.2. Thanks.

A good explanation,but if nvidia has updated it to “tegra multimedia api reference”,that will be more

better!

yes,I think so.

Hi,zuoye010
我也遇到了同样的问题,交叉编译失败。同样一开始蒙蔽到不行,cat: /home/ml/jetson/usr/lib/crt1.o: Permission denied,明明用ls命令可以看到root是有权限的,结果就是cat不出来,cat都不行,g++绝对不行~
接下来我发现官方文档里面让我们建了三个符号链接(sudo ln -sf aarch64-linux-gnu/crt1.o crt1.o 和其他两个),我意识到我们访问的不是crt1.o这个文件本身,于是我在TX2上把符号链接删除之后,直接把源文件从/usr/lib/aarch64-linux-gnu/复制到/usr/lib/下面。然后,很神奇,问题解决了~我擦。。。当时就蒙蔽了,符号链接不好使???
但是make依旧通不过,因为还有/opt/toolchain/bin/…/lib/gcc/aarch64-unknown-linux-gnu/4.8.5/…/…/…/…/aarch64-unknown-linux-gnu/bin/ld: cannot find /lib/aarch64-linux-gnu/libpthread.so.0 inside /home/ml/jetson 这个错误。我在/usr/lib/aarch64-linux-gnu/找到了libpthread.so,发现g++是通过它来找到/lib/aarch64-linux-gnu/libpthread.so.0的。而/lib/aarch64-linux-gnu/libpthread.so.0本身也是一个符号链接,指向/lib/aarch64-linux-gnu/libpthread-2.23.so。呵呵,转了一圈又回到了符号链接这个节骨眼上。所以我接下来意识到samba绝壁出问题了!!
google了关键词 samba symbolic links,发现,samba默认不支持跟踪符号链接。。。。。。。:-)。:-)。:-)。https://ubuntuforums.org/showthread.php?t=1439092
然后只需要按照@theLured,讲解的那样,把
follow symlinks = yes
wide links = yes
unix extensions = no
放在/etc/samba/smb.conf的global区域里面就行了。。。。所以结论是:
当按照官方交叉编译的流程走的时候,在/etc/samba/smb.conf除了加上
[root]
comment= Rootfs for Tegra
path = /
browseable = yes
read only = yes
valid user = root
还需要在[global]下面加上
follow symlinks = yes
wide links = yes
unix extensions = no
其他一模一样执行就可以了~
——————————————————————————————————————————————Chinese——————————————————————————————————————————

——————————————————————————————————————————————English——————————————————————————————————————————
Most of the words I say in Chinese explain how I tried to solve the problem, which was stupid. So I don’t wanna repeat them in English。
The solution might be:
When you are following the cross compile guide provided on L4T Multimedia API Reference, and trying to modify /etc/samba/smb.conf , please add 3 more lines at [global] section:

follow symlinks = yes
wide links = yes
unix extensions = no

and do the rest of the actions we’re asked to perform.

The reason is simple: samba does NOT follow symbolic links by default. Since, we create some symbolic links via (sudo ln -sf aarch64-linux-gnu/crt1.o crt1.o), it’s totally not going to work.

And I don’t know whether this will fix your problem, hope this can work.

As of now we still have no plan to support cross compile.

fengxueem:
Thanks for sharing your method,though i can’t corss-compile it now.
Compile it on tx2 board is a easy way.

Hey Zuoye010,

I am currently playing with the multimedia API. Since we cannot cross compile the samples on the host machine, can you let me know what is your current way to debug those samples? Is there any IDE you suggest that can be installed on the target device? Thanks.

Compiling it on the tx2 board(arm),no need to cross-compile on host pc(x86).
I am poor in gstreamer,sorry,no suggestion to you.Gstreamer has a debug method itself,you can google it.
I debug it step by step,if i want to create a pipeline has 5 elements,i will create a pipeline just use 2 elements,test it,and create a pipeline use 3 elements…
I use vim. Someone may be use nsight…
https://blog.csdn.net/qq_38880380/article/details/76849880

Hi

I solved it in the following way.

On the Jetson board

  1. Install and start nfs server with the following commands:
    $ sudo apt-get install nfs-kernel-server

  2. Add the following configurations to /etc/exports
    / (ro,sync)

    ex) => 192.168.0.10
    / 192.168.0.10(ro,sync)

  3. Enter:
    $sudo /etc/init.d/nfs-kernel-server restart

On the host system
$sudo apt-get install nfs-common
$sudo mount -t nfs :/ ~/jetson

ex) => 192.168.0.101
$sudo mount -t nfs 192.168.0.101:/ ~/jetson

Good luck.

Nice! Thanks for sharing!