[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
howtos:hardware:arm:gcc-9.x_aarch64_cross-compiler [2019/07/25 19:09 (UTC)] – [Sources] text output formatting exagahowtos:hardware:arm:gcc-9.x_aarch64_cross-compiler [2019/08/03 12:38 (UTC)] – [Building the arm64 kernel, modules, and device tree blob (DTB)] rewording exaga
Line 3: Line 3:
 === Preface === === Preface ===
  
-With the recent congruous updates to [[http://arm.slackware.com|Slackware ARM]] [~24 June 2019 - "A MILLION THANKS to MoZes!"] and the surprise arrival of the Raspberry Pi 4, this just had to be done. Creating a gcc-9.1.0 armv8 arm64 aarch64 cross-compiler with the intention of building aarch64-linux binaries from source code and turning them into Slackware packages. +With the recent congruous updates to [[http://arm.slackware.com|Slackware ARM]] [~24 June 2019 - "A MILLION THANKS to MoZes!"] and the surprise arrival of the Raspberry Pi 4, this just had to be done. Creating a 64-bit gcc-9.1.0 arm64 aarch64 cross-compiler with the intention of building aarch64-linux binaries from source code and turning them into Slackware packages. 
  
-Previous [[howtos:hardware:arm:gcc_aarch64_cross-compiler|work in this area]] had already been done in 2016/2017. However, this time we'll be compiling with gcc-9.1.0 and not gcc-5.4.0 and we'll be using a Raspberry Pi 4 Model B and not a Mk3 version. The old build scripts weren't totally useless and some of the code was reused for this project, to save time.+Previous [[howtos:hardware:arm:gcc_aarch64_cross-compiler|work in this area]] had already been done since 2016/2017. However, this time we'll be compiling with gcc-9.1.0 and not gcc-5.4.0 and we'll be using a Raspberry Pi 4 Model B and not a Mk3 version. The old build scripts weren't totally useless and some of the code was reused for this project, to save time.
  
 === Notes === === Notes ===
Line 60: Line 60:
  
 When that's done you should see a message that 'origin/rpi-5.2.y' is the current branch. When that's done you should see a message that 'origin/rpi-5.2.y' is the current branch.
 +
 +<note tip>You can select which kernel source you would like to build instead of rpi-5.2.y branch. Just substitute it in the 'git checkout -f rpi-5.2.y' command for your chosen branch. To see a list of available branches use this command while in your Linux source directory:
 +
 +<code>
 +git branch -a
 +</code></note>
 +
 +
  
 === Downloading required package source === === Downloading required package source ===
Line 65: Line 73:
 Before downloading the package source needed to build the gcc cross-compiler, be aware that more recent package versions may exist than the ones shown here. You may wish to install newer versions. It's always a good idea to check. To keep things simple, you might consider downloading a version of gcc which matches the one you currently have installed. I've read lots of articles about this and most advise to install the //latest and greatest// version of gcc available. However, if you're running Slackware ARM current you'll have gcc-9.1.0 installed and this is adequate for what you need. Before downloading the package source needed to build the gcc cross-compiler, be aware that more recent package versions may exist than the ones shown here. You may wish to install newer versions. It's always a good idea to check. To keep things simple, you might consider downloading a version of gcc which matches the one you currently have installed. I've read lots of articles about this and most advise to install the //latest and greatest// version of gcc available. However, if you're running Slackware ARM current you'll have gcc-9.1.0 installed and this is adequate for what you need.
  
-So, first move back into the 'build-dir' directory and then download the packages below.+So, first move back into the 'BUILD' directory and then download the packages below.
  
 <code> <code>
Line 123: Line 131:
 === Exporting install directory PATH === === Exporting install directory PATH ===
  
-You need to export the installation directory's /bin folder to your user's $PATH. the PATH of your gcc-9.1.0 cross-compiler bin needs to be the FIRST item in the $PATH in order to be successful.+You need to export the installation directory''/binfolder to your user's $PATH. The PATH of your gcc-9.1.0 cross-compiler bin needs to be the __FIRST__ item in the $PATH in order to be successful.
  
 <code> <code>
Line 140: Line 148:
 /tmp/.gcc-cross/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib/kde4/libexec:/usr/lib/qt/bin /tmp/.gcc-cross/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib/kde4/libexec:/usr/lib/qt/bin
 </code> </code>
 +
 +NB: your $PATH may be very different from the one shown above, but that doesn't matter. As long as the PATH to your gcc cross-compiler's '/bin' directory is the first item in the $PATH it's all good.
  
 ==== Building the gcc aarch64 cross-compiler ==== ==== Building the gcc aarch64 cross-compiler ====
Line 147: Line 157:
 === Building binutils === === Building binutils ===
  
-First move back into the 'build-dir' 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 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. 
  
 <code> <code>
Line 169: Line 179:
 === Build gcc C and C++ cross-compilers === === Build gcc C and C++ cross-compilers ===
  
-First move into the 'build-dir' directory and create a build directory for gcc before building it. Notice that only C and C++ have been specified as build languages. That's all you will need here. Incidentally, the available build language options allow just one, or a selection, or all, of the following '--enable-languages=all,ada,c,c++,fortran,go,jit,lto,objc,obj-c++'.+First move into the 'BUILD' directory and create a build directory for gcc before building it. Notice that only C and C++ have been specified as build languages. That's all you will need here. Incidentally, the available build language options allow just one, or a selection, or all, of the following '--enable-languages=all,ada,c,c++,fortran,go,jit,lto,objc,obj-c++'.
  
 <code> <code>
Line 223: Line 233:
 === Build and install glibc === === Build and install glibc ===
  
-First move into the 'build-dir' directory and create a 'build-glibc' directory. Then move into the 'build-glibc' directory before building it. '--build=$MACHTYPE' is a predefined environment variable which describes the Raspberry Pi 4 (in this case) and it's required to compile some additional tools which are utilised during the build process. Notice that you're installing the C library startup files to the installation directory (csu/crt1.o, csu/crti.o, and csu/crtn.o) separately because there doesn’t seem to a 'make' rule that does this without creating other problems.+First move into the 'BUILD' directory and create a 'build-glibc' directory. Then move into the 'build-glibc' directory before building it. '--build=$MACHTYPE' is a predefined environment variable which describes the Raspberry Pi 4 (in this case) and it's required to compile some additional tools which are utilised during the build process. Notice that you're installing the C library startup files to the installation directory (csu/crt1.o, csu/crti.o, and csu/crtn.o) separately because there doesn’t seem to a 'make' rule that does this without creating other problems.
  
 <code> <code>
Line 308: Line 318:
 === Creating the arm64 kernel .config === === Creating the arm64 kernel .config ===
  
-First of all, as always, you need to be in the Raspberry Pi Linux kernel source directory which is in the 'build-dirfolder. Then you need to create a kernel .config file, based on Raspberry Pi 4 parameters. To keep it simple you can generate a default .config (**defconfig**) file. This file holds the Linux kernel configuration for the arm64 kernel you are going to build. To achieve this run the following commands:+First of all, as always, you need to be in the Raspberry Pi Linux kernel source directory which is within your 'BUILDdirectory. Then you need to create a kernel .config file, based on Raspberry Pi 4 parameters. To keep it simple you can generate a default .config (**defconfig**) file. This file holds the Linux kernel configuration for the arm64 kernel you are going to build. To achieve this run the following commands:
  
 <code> <code>
Line 315: Line 325:
 </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.
Line 396: Line 406:
 === 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 CFLAGS as before but without any 'LOCALVERSION' set.
Line 482: Line 492:
 <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>
Line 542: Line 552:
  
 ====== Sources ====== ====== Sources ======
-# If you need to install any of the packages above [* check for updates!]:+# If you need to install any of the software above [* check for updates!]:
  
 [[ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-current/slackware/a/gawk-5.0.1-arm-1.txz]]  # Slackware ARM current - gawk package. \\ [[ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-current/slackware/a/gawk-5.0.1-arm-1.txz]]  # Slackware ARM current - gawk package. \\
Line 548: Line 558:
 [[ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-current/slackware/d/bison-3.4.1-arm-1.txz]]  # Slackware ARM current - bison package. \\ [[ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-current/slackware/d/bison-3.4.1-arm-1.txz]]  # Slackware ARM current - bison package. \\
 [[ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-current/slackware/d/flex-2.6.4-arm-3.txz]] # Slackware ARM current - flex package. \\  [[ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-current/slackware/d/flex-2.6.4-arm-3.txz]] # Slackware ARM current - flex package. \\ 
-[[http://arm.slackware.com/FAQs]] # Slackware ARM Linux Project Frequently Asked Questions. \\ +[[https://www.github.com/raspberrypi/]] # Raspberry Pi Foundation GitHub repository Linux kernel and boot-firmware source. \\ 
 +[[https://ftp.gnu.org/gnu/]] # gcc, binutils, glibc, gmp, mpc, mpfr package source. \\  
 +[[ftp://gcc.gnu.org/pub/gcc/infrastructure]] # cloog, isl package source. 
 + 
 +# Documentation which assisted in this guide: 
 + 
 +[[slackwarearm:faq|http://arm.slackware.com/FAQs]] # Slackware ARM Linux Project Frequently Asked Questions. \\ 
 [[http://wiki.osdev.org/GCC_Cross-Compiler]] # gcc cross-compiler documentation. \\  [[http://wiki.osdev.org/GCC_Cross-Compiler]] # gcc cross-compiler documentation. \\ 
 +[[howtos:hardware:arm:gcc_aarch64_cross-compiler|Slackware ARM GCC aarch64-linux cross-compiler]] for the Raspberry Pi. \\
 [[https://www.raspberrypi.org/documentation/linux/kernel]] # Raspberry Pi Linux kernel documentation. \\  [[https://www.raspberrypi.org/documentation/linux/kernel]] # Raspberry Pi Linux kernel documentation. \\ 
-[[https://www.github.com/raspberrypi/]] # Raspberry Pi Foundation GitHub repository Linux kernel, bootloader/GPU firmware. \\ 
-[[https://ftp.gnu.org/gnu/]] # gcc, binutils, glibc, gmp, mpc, mpfr package source \\  
-[[ftp://gcc.gnu.org/pub/gcc/infrastructure]] # cloog, isl package source 
  
 <!-- If you are copying information from another source, then specify that source --> <!-- If you are copying information from another source, then specify that source -->
Line 565: Line 579:
 <!-- 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}}
 +
  
 howtos:hardware:arm:gcc-9.x_aarch64_cross-compiler ()