Error when building trusty in TX2

Hello,
I get errors when building trusty on Ubuntu 16.04.
According to the Jetson Linux Driver Package Toolchain in the development guide, I downloaded the 64-bit cross-compilation toolchain and put the toolchain in ‘/opt/l4t-gcc’ directory(some parts of the developer guide are really confusing).

  1. I entered ‘echo “export CROSS_COMPILE=/opt/l4t-gcc/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-” >> ~.bashrc’ in the terminal.
  2. according to the atf_and_trusty_README.txt, I entered the command as follow.

make t186 PROJECT=t186 TARGET=t186 BUILDROOT=./t186ref
TOOLCHAIN_PREFIX="{CROSS_COMPILE}" \ ARCH_arm_TOOLCHAIN_PREFIX="{CROSS_COMPILE_ARM}"
ARCH_arm64_TOOLCHAIN_PREFIX="${CROSS_COMPILE}"
DEBUG=0 DEBUG_LVL=0 DEFAULT_OTE_APP_DEBUGLEVEL=1 NOECHO=@
TRUSTY_VARIANT=l4t-public TRUSTY_MULTI_GUEST_CONFIGURATION=
TARGET_SOC=t186

Note, here I replaced CROSS_COMPILE_AARCH64 with CROSS_COMPILE.
But an error was reported:

make t186 PROJECT=t186 TARGET=t186 BUILDROOT=./t186ref \

     TOOLCHAIN_PREFIX="${CROSS_COMPILE}" \
     ARCH_arm_TOOLCHAIN_PREFIX="${CROSS_COMPILE_ARM}" \
     ARCH_arm64_TOOLCHAIN_PREFIX="${CROSS_COMPILE}" \
     DEBUG=0 DEBUG_LVL=0 DEFAULT_OTE_APP_DEBUGLEVEL=1 NOECHO=@ \
     TRUSTY_VARIANT=l4t-public TRUSTY_MULTI_GUEST_CONFIGURATION= \
     TARGET_SOC=t186

make[1]: Entering directory ‘/home/yangfan/trusty_src/trusty’
make[2]: Entering directory ‘/home/yangfan/trusty_src/trusty’
PROJECT = t186
PLATFORM = t18x
TARGET = t186
TOOLCHAIN_PREFIX =
including app dev dev/interrupt/arm_gic dev/timer/arm_generic kernel lib/boot_profiler lib/memlog lib/sm lib/trusty platform target
including kernel/vm lib/debug lib/fixed_point lib/heap lib/libc lib/syscall lib/uthread lib/version
Include Trusty user tasks support
XBIN_TOOLCHAIN_PREFIX =
XBIN_LIBGCC = /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a
including app/trusty lib/libc-trusty
including lib/libc
XBIN_TOOLCHAIN_PREFIX =
XBIN_LIBGCC = /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a
including app/trusty lib/libc-trusty
including lib/libc
XBIN_TOOLCHAIN_PREFIX =
XBIN_LIBGCC = /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a
including app/trusty lib/libc-trusty lib/openssl
including lib/libc lib/openssl-stubs
including lib/rng
including interface/hwrng
LIBGCC = /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a
GLOBAL_COMPILEFLAGS = -g -fno-builtin -finline -include ./t186ref/build-t186/config.h -W -Wall -Wno-multichar -Wno-unused-parameter -Wno-nonnull-compare -ffunction-sections -fdata-sections
GLOBAL_OPTFLAGS = -O2
generating t186ref/build-t186/tegra/public/platform/t18x/module_config.h
generating t186ref/build-t186/config.h
compiling tegra/public/platform/t18x/platform.c
gcc: error: unrecognized command line option ‘-mgeneral-regs-only’
make/compile.mk:41: recipe for target ‘t186ref/build-t186/tegra/public/platform/t18x/platform.o’ failed
make[2]: *** [t186ref/build-t186/tegra/public/platform/t18x/platform.o] Error 1
make[2]: Leaving directory ‘/home/yangfan/trusty_src/trusty’
lk/common/engine.mk:28: recipe for target ‘make-make’ failed
make[1]: *** [make-make] Error 2
make[1]: Leaving directory ‘/home/yangfan/trusty_src/trusty’
makefile:27: recipe for target ‘t186’ failed
make: *** [t186] Error 2

Later, I downloaded the 32-bit toolchain and placed it in the /opt/l4t-gcc-32 directory.

  1. I entered ‘echo “export CROSS32CC=/opt/l4t-gcc-32/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc” >> ~.bashrc’ in the terminal.
  2. enter the command

make t186 PROJECT=t186 TARGET=t186 BUILDROOT=./t186ref
TOOLCHAIN_PREFIX="{CROSS_COMPILE}" \ ARCH_arm_TOOLCHAIN_PREFIX="{CROSS32CC}"
ARCH_arm64_TOOLCHAIN_PREFIX="${CROSS_COMPILE}"
DEBUG=0 DEBUG_LVL=0 DEFAULT_OTE_APP_DEBUGLEVEL=1 NOECHO=@
TRUSTY_VARIANT=l4t-public TRUSTY_MULTI_GUEST_CONFIGURATION=
TARGET_SOC=t186

Note, here I replaced CROSS_COMPILE_ARM with CROSS32CC.
Still, same as the first error.
What should I do?

hello fanyangyf688,

did you build Trusty on Jetson-TX2?
according to How to Implement a New Trusted Application, you should build it on your host machine.
thanks

hello,
I plan to build trusty on the host machine and generate executable files on TX2, and then download to TX2 for execution. The above operating environment is the host machine.
thanks for replying again.

You might find this of use:
https://developer.arm.com/documentation/dui0774/a/compiler-command-line-options/-mgeneral-regs-only

Just a general thought, I’m not sure how much this applies here, but it probably does: Some options from 32-bit ARM are not allowed in 64-bit ARM. It isn’t because 64-bit does not support the option, it is instead because in 64-bit some features are always available, and as a result, no option exists for the feature…the feature is not optional, so why give such an option? Some code from 32-bit days may sometimes work its way into 64-bit. Actual 32-bit instructions are usually supported, but compiler options once required for that feature will not exist. Quite possibly you are running into such a configuration.

There are also cases where a single 64-bit compiler is used, and the 32-bit components are from a compatibility mode, and this is actually a superset of the 32-bit instructions. In other cases it is possible to specify building of mixed 32-bit/64-bit code using two separate compilers. If the code expects to be built from a time when 64-bit was just emerging, then it is likely the build will specify to use a separate 32-bit compiler and not use a 64-bit compiler with 32-bit compatibility mode. When simultaneously using a dedicated 32-bit compiler and a 64-bit compiler the options will apply. Newer code probably uses only one 64-bit compiler, and that compiler supports the ARMv8 32-bit superset of the ARMv7-a, and this compiler would call the same options an error.

hello,
thank you for your reply!
The export environment variable is PATH, which is inconsistent with CROSS_COMPILE_AARCH64 (refer to atf_trusty_README.txt).

export PATH=$PATH:(Path of cross compiler)-----Report an error!
export CROSS_COMPILE_AARCH64=(Path of cross compiler) ------correct!

1 Like