Both sides previous revision
Previous revision
Next revision
|
Previous revision
Last revision
Both sides next revision
|
howtos:hardware:arm:gcc-9.x_aarch64_cross-compiler [2019/08/01 09:58 (UTC)] exaga |
howtos:hardware:arm:gcc-9.x_aarch64_cross-compiler [2019/08/03 12:46 (UTC)] exaga [Building the gcc aarch64 cross-compiler] missing CFLAG |
=== Building binutils === | === Building binutils === |
| |
First move back into the 'BUILD' directory and then create a build directory for binutils. You'll notice the various build options but as a quick explanation; '--with-sysroot' basically tells binutils to enable 'sysroot' support in the cross-compiler by pointing it to a default empty directory, '--target=aarch64-linux' is the target system type (arm64), and '--disable-multilib' means that we only want binutils to work with the aarch64 instruction set and nothing else. | First move back into the 'BUILD' directory and then create a build directory for binutils. You'll notice the various CFLAGS but as a quick explanation; '--with-sysroot' basically tells binutils to enable 'sysroot' support in the cross-compiler by pointing it to a default empty directory, '--target=aarch64-linux' is the target system type (arm64), and '--disable-multilib' means that we only want binutils to work with the aarch64 instruction set and nothing else. |
| |
<code> | <code> |
mkdir build-binutils | mkdir build-binutils |
cd build-binutils | cd build-binutils |
../binutils-2.32/configure --prefix=/tmp/.gcc-cross --target=aarch64-linux --disable-multilib | ../binutils-2.32/configure --prefix=/tmp/.gcc-cross --target=aarch64-linux --with-sysroot --disable-multilib |
make -j4 | make -j4 |
make install | make install |
==== Building the arm64 kernel, modules, and device tree blob (DTB) ==== | ==== Building the arm64 kernel, modules, and device tree blob (DTB) ==== |
| |
To build the aarch64 kernel, modules and device tree blob(s) is exactly the same method as you would carry it out under normal circumstances. Commands such as 'make bzImage && make modules && make modules_install' may be all too familiar to you. The major difference when cross-compiling is that you'll use certain Makefile options/variables/arguments/switches, commonly known as CFLAGS. In our case, CFLAGS will be used to instruct the gcc cross-compiler to build for the aarch64 (arm64) architecture specifically. | To build the aarch64 kernel, modules and device tree blob(s) is exactly the same method as you would carry it out under normal circumstances. Commands such as 'make bzImage && make modules && make modules_install' may be all too familiar to you. The major difference when cross-compiling is that you'll use certain Makefile variables/arguments/switches, commonly known as //build options//<. In our case, //build options// will be used to instruct the gcc cross-compiler to build for the aarch64 (arm64) architecture specifically. |
| |
=== Creating the arm64 kernel .config === | === Creating the arm64 kernel .config === |
</code> | </code> |
| |
<note important>Make a note here of the CFLAGS which have been specified. They should be self-explanatory by now. Pay special attention to the trailing '-' of 'CROSS_COMPILE=aarch64-linux-' because that's **NOT** a typo. __It needs to be like that!__</note> | <note important>Make a note here of the //build options// [ARCH=arm64 CROSS_COMPILE=aarch64-linux-] which have been specified. They should be self-explanatory by now. Pay special attention to the trailing '-' of 'CROSS_COMPILE=aarch64-linux-' because that's **NOT** a typo. __It needs to be like that!__</note> |
| |
Now that you've created a kernel .config which contains the default settings for your hardware, some settings within need to be checked and possibly modified. The Raspberry Pi 4's "VideoCore VI" GPU is not //64-bit compatible// and the build process will crash each time you attempt to compile the module's source code for ARMv8 architecture. | Now that you've created a kernel .config which contains the default settings for your hardware, some settings within need to be checked and possibly modified. The Raspberry Pi 4's "VideoCore VI" GPU is not //64-bit compatible// and the build process will crash each time you attempt to compile the module's source code for ARMv8 architecture. |
=== Building the arm64 kernel === | === Building the arm64 kernel === |
| |
Next up is building the kernel, based on the .config file you have just created. Again, you'll use the same CFLAGS as before. You can even set a 'LOCALVERSION' here which appends whatever you set to the end of the kernel version (e.g. LOCALVERSION="-aarch64" would eventually give you 5.2.1-v8-aarch64) once the kernel and modules have been built. Just as an example we'll use it here. Run the following command to start building the arm64 Linux kernel: | Next up is building the kernel, based on the .config file you have just created. Again, you'll use the same //build options// as before. You can even set a 'LOCALVERSION' here which appends whatever you set to the end of the kernel version (e.g. LOCALVERSION="-aarch64" would eventually give you 5.2.1-v8-aarch64) once the kernel and modules have been built. Just as an example we'll use it here. Run the following command to start building the arm64 Linux kernel: |
| |
<code> | <code> |
=== Installing the arm64 modules === | === Installing the arm64 modules === |
| |
Once the modules have been built, you have to 'make modules_install'. The process will install your kernel modules to '/tmp/lib/modules/5.2.1-v8-aarch64'. | Once the modules have been built, you have to 'make modules_install'. The process will install your kernel modules to '/lib/modules/5.2.1-v8-aarch64'. |
| |
You could build //out-of-tree// kernel modules but, to keep things simple, you're going to install them to the usual location. Again, you will use the same CFLAGS as before but without any 'LOCALVERSION' set. | You could build //out-of-tree// kernel modules but, to keep things simple, you're going to install them to the usual location. Again, you will use the same //build options// as before but without any 'LOCALVERSION' set. |
| |
First you need become '**root**' user and enter a passwd when prompted. To install the aarch64 modules run the following commands: | First you need become '**root**' user and enter a passwd when prompted. To install the aarch64 modules run the following commands: |
<code> | <code> |
ls -lah rpi-boot/boot/kernel* | ls -lah rpi-boot/boot/kernel* |
ls -lah rpi-boot/boot/bcm*-rpi-3-b.dtb | ls -lah rpi-boot/boot/bcm*-rpi-4-b.dtb |
ls -lah rpi-root/lib/modules/5.2.1-v8* | ls -lah rpi-root/lib/modules/5.2.1-v8* |
</code> | </code> |
<!-- You must remove the tag-word "template" below before saving your new page --> | <!-- You must remove the tag-word "template" below before saving your new page --> |
{{tag>howtos slackware raspberry pi arm aarch64 arm64 armv8 cross-compile author_exaga}} | {{tag>howtos slackware raspberry pi arm aarch64 arm64 armv8 cross-compile author_exaga}} |
| |
| |