Why don't environment variables work when I create a kernel?

We would like to use ‘./nvbuild.sh’ to build the Orin Nano kernel. (jetpack 5.1.2, ubuntu 18.04)

sudo ./nvbuild.sh -o $PWD/kernel_out

However, if you want to proceed with the build, an error occurs as follows.

Error: env variable CROSS_COMPILE_AARCH64_PATH is not set!!

We already specified the path of ‘CROSS_COMPILE_AARCH64_PATH’.
When checked with the echo command, it is as follows.

echo $CROSS_COMPILE_AARCH64_PATH
/home/jetson-master/workspace/Jetpack_5.1.2/l4t-gcc

I’m not sure why it says PATH is not sure. Is there a solution?

Thanks.

Hi,

are you sure the script is running in the same terminal window/tab where you set the environment variable?
Please check it first.

yes. i do

I will attach the log of my terminal so that you can check it.

log.txt (4.7 KB)

Hi,

you have to set both CROSS_COMPILE_AARCH64 and CROSS_COMPILE_AARCH64_PATH.
Did you do that?

We also added the CROSS_COMPILE_AARCH64 path.

Attach the log again.

The symptoms are the same.

log.txt (8.2 KB)

Hi,

I just tried steps on the document and did not encounter the same error as you did.
So I can only suggest something like deleting the BSP and starting over again, or maybe looking for another host PC.

All right.

I’ll try reinstalling the OS again.

We reinstalled ubuntu on Host, tried changing the Host PC, but the symptoms were not resolved at all.

The same is true even though we tested the ubuntu version with two versions, 18.04 and 20.04.

Are you using Bash or other shell programs?
I tested on Bash and I’m sure it was fine.

I’ll suggest making sure there is no error via:
${CROSS_COMPILE_AARCH64_PATH}gcc --version

If that passes, then what do you see from “echo $ARCH”? If the ARCH is wrong, then it would want a different path.

I carried out what you requested.

${CROSS_COMPILE_AARCH64_PATH}gcc --version
bash: /home/jetson-master/workspace/tools/l4t-gcc/gcc: No such file or directory

echo $ARCH

Nothing is output when “echo $ARCH” is entered.

Leave the terminal log that I ran.

log.txt (5.8 KB)

Thanks.

Hello.

Attempted by adding ‘export’ syntax to .bashrc.

export CROSS_COMPILE=~/workspace/tools/l4t-gcc/bin/aarch64-buildroot-linux-gnu-
export CROSS_COMPILE_AARCH64_PATH=~/workspace/tools/l4t-gcc
export LOCALVERSION=-tegra
export LANG=C

But it still hasn’t been solved.

Other than that, we are not using a separate shell program.

Hi,

can you try writing a shell script to echo the variable in the script and see if it works?
If you still cannot get it done, then I’d suggest hard-coding path to the toolchain:
(inside nvcommon_build.sh)

	if [ "${IS_CROSS_COMPILATION}" -eq 1 ]; then
		check_vars "CROSS_COMPILE_AARCH64_PATH"
		CROSS_COMPILE_AARCH64="${CROSS_COMPILE_AARCH64:-${CROSS_COMPILE_AARCH64_PATH}/bin/aarch64-buildroot-linux-gnu-}"
		if [ ! -f "${CROSS_COMPILE_AARCH64}gcc" ]; then
			echo "Error: Path ${CROSS_COMPILE_AARCH64}gcc does not exist."
			exit 1
		fi
	fi

I made a Shell script as requested.
(env.sh)

env.sh (343 Bytes)

And the results below are the results of the execution.

bash ./env.sh
./env.sh: line 3: [: : integer expression expected

thanks.

NO.
I mean you just write a dummy script and see if you can echo the variable inside it.

If that still does not work, then skip the function for checking envs,
and just hard-code CROSS_COMPILE_AARCH64 inside the script:

	"${MAKE_BIN}" -C "${source_dir}" ARCH=arm64 \
		LOCALVERSION="-tegra" \
		CROSS_COMPILE="${CROSS_COMPILE_AARCH64}" \
		"${O_OPT[@]}" -j"${NPROC}" \
		--output-sync=target Image

Is that clear?

Do you mean to check by putting the dummy code above in ‘nvcommon_build.sh’?

Also, does hard-code mean that the path should be entered directly into ‘${CROSS_COMPILE_AARCH64}’ in the code above?

YES.
See if you can do this in the script:

echo $CROSS_COMPILE_AARCH64

YES.
Replace the variable with the absolute path on your host PC.

First, I modified and ran ‘nvcommon_build.sh’.

function check_vars {
	# shellcheck disable=SC2124
	variables=${@}
	for variable in ${variables} ; do
		if [ -z "${!variable}" ]; then
++			echo $CROSS_COMPILE_AARCH64
			echo "Error: Env variable ${variable} is not set!!"
			exit 1
		fi
	done
}

And the results are as follows.

echo $CROSS_COMPILE_AARCH64
/home/jetson-master/workspace/tools/l4t-gcc/bin/aarch64-buildroot-linux-gnu-

sudo ./nvbuild.sh -o $PWD/kernel_out
(space)
Error: Env variable CROSS_COMPILE_AARCH64_PATH is not set!!

I don’t know why the ‘CROSS_COMPILE_AARCH64’ environment variable hasn’t changed.

I will modify the hard code and test it.

So it still does not work?

Have you tried this?

Hi.

I changed the hard-code.

# Function to check build environment
function check_env_common {
	if [ "${IS_CROSS_COMPILATION}" -eq 1 ]; then
		check_vars "CROSS_COMPILE_AARCH64_PATH"
--		CROSS_COMPILE_AARCH64="${CROSS_COMPILE_AARCH64:-${CROSS_COMPILE_AARCH64_PATH}/bin/aarch64-buildroot-linux-gnu-}"
++		CROSS_COMPILE_AARCH64="${CROSS_COMPILE_AARCH64:-~/workspace/tools/l4t-gcc/bin/aarch64-buildroot-linux-gnu-}"
		if [ ! -f "${CROSS_COMPILE_AARCH64}gcc" ]; then
			echo "Error: Path ${CROSS_COMPILE_AARCH64}gcc does not exist."
			exit 1
		fi
	fi

The results of the execution are as follows.

sudo ./nvbuild.sh -o $PWD/kernel_out
Error: Env variable CROSS_COMPILE_AARCH64_PATH is not set!!

The environment variable still does not seem to change.

thanks.