Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arm64 cross-compiling #81

Open
gorghino opened this issue Mar 29, 2023 · 5 comments
Open

Arm64 cross-compiling #81

gorghino opened this issue Mar 29, 2023 · 5 comments

Comments

@gorghino
Copy link

gorghino commented Mar 29, 2023

Hi! I'm trying to cross-compile your drivers for my Jetson NX (arm64). I cannot directly use neither the install script nor the manual compilation on-board, since I'm testing the RealTime kernel.

On my host (x64 - Ubuntu 20.04.5 - gcc 9.4.0) I downloaded Nvidia's kernel sources and I compiled them.
The jetson NX has Ubuntu 20.04 (Jetpack 5.1) and I used toolchain 2020.08 (9.3.0) to compile the kernel sources in /media/gorgo/PopOS/home/gorgo/NX_5_1_HYAI/Linux_for_Tegra/source/public/kernel_out.

According to the Nvidia's documentation I shall be able to cross compile with

$ cd <path_to_module_source>
$ make ARCH=arm64 –C <kernel_directory> M=$(pwd)

after setting CROSS_COMPILE accordingly.

I tried:

gorgo@razer:~/8821cu-20210118$ make ARCH=arm64 CROSS_COMPILE=~/Downloads/l4t-gcc/bin/aarch64-buildroot-linux-gnu- -C /media/gorgo/PopOS/home/gorgo/NX_5_1_HYAI/Linux_for_Tegra/source/public/kernel_out M=$(pwd)
make: Entering directory '/media/gorgo/PopOS/home/gorgo/NX_5_1_HYAI/Linux_for_Tegra/source/public/kernel_out'
  MODPOST /home/gorgo/8821cu-20210118/Module.symvers
make: Leaving directory '/media/gorgo/PopOS/home/gorgo/NX_5_1_HYAI/Linux_for_Tegra/source/public/kernel_out'

Make stops after creating 4 files only (two are 0B):

-rw-rw-r--   1 gorgo gorgo    0 mar 29 10:07 modules.order
-rw-rw-r--   1 gorgo gorgo  121 mar 29 10:07 .modules.order.cmd
-rw-rw-r--   1 gorgo gorgo  212 mar 29 10:07 .Module.symvers.cmd
-rw-rw-r--   1 gorgo gorgo    0 mar 29 10:07 Module.symvers

In this log I retried the command with -d.
makefile.log

Thank you

@morrownr
Copy link
Owner

morrownr commented Apr 29, 2023

Hi @gorghino

You likely cannot use the installation script but that is no big deal.

For manually compiling, since I have made alterations to autodetect the platform, you will need to turn the autodetection off. Find the below lines in Makefile:

CONFIG_PLATFORM_AUTODETECT = y
CONFIG_PLATFORM_I386_PC = n

Change them to the following:

CONFIG_PLATFORM_AUTODETECT = n
CONFIG_PLATFORM_I386_PC = y

Try what you did again and let me know what happens. I did not test this but I do need to document what to do for cross-compiling so if we can work it out, I will document it.

@gorghino
Copy link
Author

Hi @morrownr
I changed those lines in Makefile but I don't see a different output:

gorgo@razer:~/8821cu-20210916$ make ARCH=arm64 CROSS_COMPILE=~/Downloads/l4t-gcc/bin/aarch64-buildroot-linux-gnu- -C /media/gorgo/PopOS/home/gorgo/ORIN_5_1_1/Linux_for_Tegra/sources/kernel/kernel-5.10/ M=$(pwd)
make: Entering directory '/media/gorgo/PopOS/home/gorgo/ORIN_5_1_1/Linux_for_Tegra/sources/kernel/kernel-5.10'
  MODPOST /home/gorgo/8821cu-20210916/Module.symvers
make: Leaving directory '/media/gorgo/PopOS/home/gorgo/ORIN_5_1_1/Linux_for_Tegra/sources/kernel/kernel-5.10'

This is the same command with V=1

gorgo@razer:~/8821cu-20210916$ make V=1 ARCH=arm64 CROSS_COMPILE=~/Downloads/l4t-gcc/bin/aarch64-buildroot-linux-gnu- -C /media/gorgo/PopOS/home/gorgo/ORIN_5_1_1/Linux_for_Tegra/sources/kernel/kernel-5.10/ M=$(pwd)
make: Entering directory '/media/gorgo/PopOS/home/gorgo/ORIN_5_1_1/Linux_for_Tegra/sources/kernel/kernel-5.10'
test -e include/generated/autoconf.h -a -e include/config/auto.conf || (		\
echo >&2;							\
echo >&2 "  ERROR: Kernel configuration is invalid.";		\
echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";	\
echo >&2 ;							\
/bin/false)
make -f ./scripts/Makefile.build obj=/home/gorgo/8821cu-20210916 \
single-build= \
need-builtin=1 need-modorder=1
  {  :; } | awk '!x[$0]++' - > /home/gorgo/8821cu-20210916/modules.order
make -f ./scripts/Makefile.modpost
  sed 's/ko$/o/' /home/gorgo/8821cu-20210916/modules.order | scripts/mod/modpost -m  -E  -o /home/gorgo/8821cu-20210916/Module.symvers -e -i Module.symvers   -T -
make -f ./scripts/Makefile.modfinal
make: Leaving directory '/media/gorgo/PopOS/home/gorgo/ORIN_5_1_1/Linux_for_Tegra/sources/kernel/kernel-5.10'

The kernel_out folder has changed, but both contains Linux Kernel-5.10 sources

@morrownr
Copy link
Owner

I am going to reach out to another user that cross compiles to see if we can get some guidance. My to-do list is long right now so my time is limited. Will let you know.

@gorghino
Copy link
Author

Tnks, no rush

@morrownr
Copy link
Owner

Here is the reply from @disaster123

I used the following command to cross compile the driver - for sure the pathes need to be adjusted and may be adapted to the environment:

ARCH=arm64 CROSS_COMPILE=/root/BPI-M4-bsp/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- make KVER=4.9.119-BPI-M4 KSRC=/root/BPI-M4-bsp/linux-rtk

If I had time right now, I would make a short guide for those using this and the drivers here. I think it could be specific to host x86 and target arm64. Would either or both of you gents like to work on it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants