[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
Last revisionBoth sides next revision
howtos:hardware:arm:gcc_aarch64_cross-compiler [2016/12/17 20:20 (UTC)] – added missing DTB text exagahowtos:hardware:arm:gcc_aarch64_cross-compiler [2017/01/13 10:22 (UTC)] – [Slackware ARM GCC aarch64-linux cross-compiler for the Raspberry Pi] additional text exaga
Line 3: Line 3:
 === Preface === === Preface ===
  
-I was thinking about the Cortex-A53 64-bit CPU on my Raspberry Pi 3 and why I'm mainly using Slackware ARM 32 bit operating system on it. Then I started to wonder if it would be possible to build an arm64 kernel and modules to run with Slackware ARM. After reading about how this could be achieved it seemed clear that some cross-compiling would be required. Although I have some experience in building Linux kernels, especially for the Raspberry Pi platform, I'd never done any cross-compiling before a week ago. So, this whole concept was brand new to me.+I was thinking about the Cortex-A53 64-bit CPU on my Raspberry Pi 3 and why I'm mainly using Slackware ARM 32 bit operating system on it. Then I started to wonder if it would be possible to build an arm64 kernel and modules to run with Slackware ARM. After reading about how this could be achieved it seemed clear that some cross-compiling would be required. Although I have some experience in building Linux kernels, especially for the Raspberry Pi platform, I'd never done any cross-compiling before a week ago (2016-12-15). So, this whole concept was brand new to me.
  
-For my first attempt (and largely based on reading about how other users were doing it) I used an Ubuntu 16.04.1 LTS (64 bit) system to cross-compile an arm64 kernel for the Raspberry Pi 3. However, the results of doing things by this method were somewhat lacking and created many unforeseen errors. Then I remembered something [[http://www.slackware.com/~mozes/|Mozes]] had published on [[http://arm.slackware.com/FAQs]] about Slackware ARM packages being built natively. Further investigation lead me to realise that assured success would most likely be found by cross-compiling on an ARM device using Slackware ARM. So, that's exactly what I did! I used Slackware ARM current on a RPi3 to build a GCC aarch64-linux cross-compiler, and then used it to build the arm64 Linux kernel, modules, and device tree blob(s). Very successfully, might I add. Thanks again, Mozes. <3+For my first attempt (and largely based on reading about how other users were doing it) I used an Ubuntu 16.04.1 LTS (64 bit) system to cross-compile an arm64 kernel for the Raspberry Pi 3. However, the results of doing things by this method were somewhat lacking and created many unforeseen errors. Then I remembered something [[http://www.slackware.com/~mozes/|Mozes]] had published on [[http://arm.slackware.com/FAQs]] about Slackware ARM packages being built natively. Further investigation lead me to realise that assured success would most likely be found by cross-compiling on an ARM device using Slackware ARM. So, that's exactly what I did! Very successfully, might I add. Thanks again, Mozes. <3
  
 As things have turned out, it wasn't //that// difficult. Investing some time into reading about toolchains and how to build cross-compilers was required, as well as testing the results of cross-compiling, but on the whole it's been a relatively simple process. Using Slackware ARM current to cross-compile aarch64 architecture was the key to success here. I'm now very aware that, in comparison, trying to cross-compile aarch64 on an Ubuntu x86_64 system was less than productive.  As things have turned out, it wasn't //that// difficult. Investing some time into reading about toolchains and how to build cross-compilers was required, as well as testing the results of cross-compiling, but on the whole it's been a relatively simple process. Using Slackware ARM current to cross-compile aarch64 architecture was the key to success here. I'm now very aware that, in comparison, trying to cross-compile aarch64 on an Ubuntu x86_64 system was less than productive. 
Line 133: Line 133:
 </code> </code>
  
-You should see the first $PATH entry is to your installation directory's /bin folder.+You should see the first $PATH entry is to your installation directory's /bin folder. It's important that your installation directory's /bin folder appears before any other entry in the $PATH.
  
 <code> <code>
Line 254: Line 254:
 The GCC aarch64-linux cross-compiler on your Slackware ARM system is now ready to //rock-n-roll!//  The GCC aarch64-linux cross-compiler on your Slackware ARM system is now ready to //rock-n-roll!// 
  
-==== Building the arm64 kernel, modules, and device tree blobs (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 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.
Line 282: Line 282:
 === Building the arm64 device tree blob(s) === === Building the arm64 device tree blob(s) ===
  
-Device tree is a means of describing hardware which is read by the kernel at boot time to tell it what hardware exists on the system. In our case it relates to the Raspberry Pi 3 and is the method by which the systems knows which drivers to load for the hardware. On ARM-based devices the use of device trees has become mandatory for all new SOCs, including the Raspberry Pi. The device tree blobs you will be building '**bcm2710-rpi-3-b.dtb**' and '**bcm2837-rpi-3-b.dtb**'+Device tree is a means of describing hardware which is read by the kernel at boot time to tell it what hardware exists on the system. In our case it relates to the Raspberry Pi 3 and is the method by which the systems knows which drivers to load for the hardware. On ARM-based devices the use of device trees has become mandatory for all new SOCs, including the Raspberry Pi. The device tree blobs you will be building are '**bcm2710-rpi-3-b.dtb**' and '**bcm2837-rpi-3-b.dtb**'
  
 To build the Raspberry Pi device tree blob(s) run the following command:  To build the Raspberry Pi device tree blob(s) run the following command: 
Line 304: Line 304:
 === Installing the arm64 modules === === Installing the arm64 modules ===
  
-Once the modules have been built, you have to 'make modules_install' which installs your kernel modules to '/lib/modules/4.8.13-v8'. You could build  //out-of-tree// kernel modules but, to keep things easy and simple, you're going to install them on your current system. Again, you will use the same CFLAGS as before but without any 'LOCALVERSION' set.+Once the modules have been built, you have to 'make modules_install'.  The process will install your kernel modules to '/tmp/lib/modules/4.8.13-v8' 
 + 
 +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.
  
 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:
Line 310: Line 312:
 <code> <code>
 su - su -
-export PATH=/tmp/gcc-cross-compiler/bin:$PATH +make -j4 modules_install ARCH=arm64 CROSS_COMPILE=aarch64-linux-
-make -j 4 modules_install ARCH=arm64 CROSS_COMPILE=aarch64-linux-+
 </code> </code>
  
Line 375: Line 376:
 </code> </code>
  
-The next thing to do is copy the arm64 kernel, modules, and device tree blobsto your mounted directories. It's important to get this right. After all the hard work you've done it would be a shame to mess it up at this stage.+The next thing to do is copy the arm64 kernel, modules, and device tree blobs to your newly mounted directories. It's important to get this right. After all the hard work you've done it would be a shame to mess it up at this stage.
  
 To copy these files, run the following commands, as '**root**' user: To copy these files, run the following commands, as '**root**' user:
Line 382: Line 383:
 cp build-dir/linux/arch/arm64/boot/Image rpi-boot/boot/kernel8.img cp build-dir/linux/arch/arm64/boot/Image rpi-boot/boot/kernel8.img
 cp build-dir/linux/arch/arm64/boot/dts/broadcom/bcm*-rpi-3-b.dtb rpi-boot/boot cp build-dir/linux/arch/arm64/boot/dts/broadcom/bcm*-rpi-3-b.dtb rpi-boot/boot
-cp -arv /lib/modules/4.8.13-v8* rpi-root/lib/modules/+cp -rv /lib/modules/4.8.13-v8* rpi-root/lib/modules/
 </code> </code>
  
Line 416: Line 417:
 Remove the USB microSD card reader and swap microSD cards. Power on the Raspberry Pi and boot the microSD card on which you copied the arm64 kernel, modules, and device tree blobs. Remove the USB microSD card reader and swap microSD cards. Power on the Raspberry Pi and boot the microSD card on which you copied the arm64 kernel, modules, and device tree blobs.
  
 +==== The end result ====
 +
 +After booting the system with the arm64 kernel, I logged in remotely via SSH as 'root' user. Then I ran the following commands:
 +
 +<code>
 +login as: root
 +root@192.168.10.33's password:
 +Last login: Sat Dec 17 20:32:50 2016 from 192.168.10.10
 +Linux 4.8.13-v8-arm64.
 +root@drie:~# cat /proc/version
 +Linux version 4.8.13-v8-arm64 (exaga@drie) (gcc version 5.4.0 (GCC) ) #2 SMP Fri Dec 16 18:43:38 GMT 2016
 +root@drie:~# uname -a
 +Linux drie 4.8.13-v8-arm64 #2 SMP Fri Dec 16 18:43:38 GMT 2016 aarch64 GNU/Linux
 +root@drie:~# cat /etc/slackware-version
 +Slackware 14.2
 +root@drie:~# cat /proc/device-tree/model
 +Raspberry Pi 3 Model B Rev 1.2
 +root@drie:~# cat /proc/cmdline | awk -v RS=" " -F= '/serial/ { print $2 }'
 +0x4135b94e 
 +root@drie:~#
 +</code>
 +
 +Although I've already come across a few things which need some work, and attention, it's a start. I hope to find more time to devote towards Slackware arm64 over Christmas and the New Year 2017. 
 +
 +Thanks for being interested. <3
  
 ====== Sources ====== ====== Sources ======
 howtos:hardware:arm:gcc_aarch64_cross-compiler ()