[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.
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
howtos:hardware:arm:gcc_aarch64_cross-compiler [2016/12/17 16:38 (UTC)] – corrections exaga | howtos: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:// | + | 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:// |
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, | 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, | ||
Line 29: | Line 29: | ||
* successfully boot Slackware ARM current on your Raspberry Pi 3 running an aarch64 (arm64) kernel. | * successfully boot Slackware ARM current on your Raspberry Pi 3 running an aarch64 (arm64) kernel. | ||
- | < | + | < |
- | === Getting started | + | ==== Downloading required source and configuration ==== |
First of all, as a normal user (i.e. __not__ ' | First of all, as a normal user (i.e. __not__ ' | ||
Line 37: | Line 37: | ||
< | < | ||
cd /tmp | cd /tmp | ||
- | mkdir build-gcc | + | mkdir build-dir |
- | cd build-gcc | + | cd build-dir |
</ | </ | ||
Line 64: | Line 64: | ||
Before downloading the package source needed to build the GCC cross-compiler, | Before downloading the package source needed to build the GCC cross-compiler, | ||
- | So, first move back into the ' | + | So, first move back into the ' |
< | < | ||
Line 115: | Line 115: | ||
< | < | ||
+ | cd /tmp | ||
mkdir gcc-cross | mkdir gcc-cross | ||
</ | </ | ||
Line 132: | Line 133: | ||
</ | </ | ||
- | You should see the first $PATH entry is to your installation directory' | + | You should see the first $PATH entry is to your installation directory' |
< | < | ||
/ | / | ||
</ | </ | ||
+ | |||
+ | ==== Building the GCC aarch64 cross-compiler ==== | ||
+ | |||
+ | Now with all that in place, concentration focuses on building the cross-assembler, | ||
=== Building binutils === | === Building binutils === | ||
- | Now with all that in place, concentration focuses on building the cross-assembler, | + | First move back into the ' |
< | < | ||
- | cd ../ | + | cd build-dir |
mkdir build-binutils | mkdir build-binutils | ||
cd build-binutils | cd build-binutils | ||
Line 162: | Line 167: | ||
=== Build GCC === | === Build GCC === | ||
- | First move into the ' | + | First move into the ' |
< | < | ||
Line 175: | Line 180: | ||
=== Build and install glibc === | === Build and install glibc === | ||
- | First move into the ' | + | First move into the ' |
< | < | ||
Line 181: | Line 186: | ||
mkdir -p build-glibc | mkdir -p build-glibc | ||
cd build-glibc | cd build-glibc | ||
- | ../ | + | ../ |
make install-bootstrap-headers=yes install-headers | make install-bootstrap-headers=yes install-headers | ||
make -j4 csu/ | make -j4 csu/ | ||
Line 255: | Line 260: | ||
=== 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 ' | + | First of all, as always, you need to be in the Raspberry Pi Linux kernel source directory which is in the ' |
< | < | ||
- | cd /tmp/build-gcc/linux | + | cd /tmp/build-dir/linux |
make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux- bcmrpi3_defconfig | make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux- bcmrpi3_defconfig | ||
</ | </ | ||
Line 277: | 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 blob you will be building | + | 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 |
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 299: | Line 304: | ||
=== Installing the arm64 modules === | === Installing the arm64 modules === | ||
- | Once the modules have been built, you have to 'make modules_install' | + | Once the modules have been built, you have to 'make modules_install' |
+ | |||
+ | You could build // | ||
First you need become ' | First you need become ' | ||
Line 305: | Line 312: | ||
< | < | ||
su - | su - | ||
- | export PATH=/ | + | make -j4 modules_install ARCH=arm64 CROSS_COMPILE=aarch64-linux- |
- | make -j 4 modules_install ARCH=arm64 CROSS_COMPILE=aarch64-linux- | + | |
</ | </ | ||
Line 315: | Line 321: | ||
< | < | ||
ls -lah arch/ | ls -lah arch/ | ||
- | la -lah arch/ | + | la -lah arch/ |
ls -lah / | ls -lah / | ||
</ | </ | ||
Line 321: | Line 327: | ||
If you can see that they all exist, then everything has worked as planned. | If you can see that they all exist, then everything has worked as planned. | ||
- | ==== Copying the arm64 kernel, modules, and device tree blob (DTB) ==== | + | ==== Copying the arm64 kernel, modules, and device tree blobs (DTB) ==== |
Connect the (spare) microSD card containing a working Slackware ARM current system to your Raspberry Pi 3 using a USB microSD card reader. You'll need to mount the partitions first, before copying the arm64 kernel, modules, and device tree blob(s) onto it. | Connect the (spare) microSD card containing a working Slackware ARM current system to your Raspberry Pi 3 using a USB microSD card reader. You'll need to mount the partitions first, before copying the arm64 kernel, modules, and device tree blob(s) onto it. | ||
Line 370: | Line 376: | ||
</ | </ | ||
- | The next thing to do is copy the arm64 kernel, modules, and device tree blob to 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 ' | To copy these files, run the following commands, as ' | ||
< | < | ||
- | cp arch/ | + | cp build-dir/ |
- | cp arch/ | + | cp build-dir/ |
- | cp -arv / | + | cp -rv / |
</ | </ | ||
Line 384: | Line 390: | ||
< | < | ||
ls -lah rpi-boot/ | ls -lah rpi-boot/ | ||
- | ls -lah rpi-boot/ | + | ls -lah rpi-boot/ |
ls -lah rpi-root/ | ls -lah rpi-root/ | ||
</ | </ | ||
- | If it all looks fine and dandy then the next thing you need to do is delete the existing | + | If it all looks fine and dandy then the next thing you need to do is delete the old armv7 kernel in the rpi-boot/ |
< | < | ||
rm -rf rpi-boot/ | rm -rf rpi-boot/ | ||
</ | </ | ||
- | No changes to the config.txt or cmdline.txt file(s) should be necessary. If you are using a recent blootloader/ | + | No changes to the config.txt or cmdline.txt file(s) should be necessary. If you are using a recent blootloader/ |
Now you can unmount the previously mounted directories. | Now you can unmount the previously mounted directories. | ||
Line 409: | Line 415: | ||
</ | </ | ||
- | Remove the USB microSD card reader and swap microSD cards. Power on the Raspberry Pi. | + | 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 ' | ||
+ | |||
+ | < | ||
+ | login as: root | ||
+ | root@192.168.10.33' | ||
+ | Last login: Sat Dec 17 20:32:50 2016 from 192.168.10.10 | ||
+ | Linux 4.8.13-v8-arm64. | ||
+ | root@drie: | ||
+ | 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: | ||
+ | Linux drie 4.8.13-v8-arm64 #2 SMP Fri Dec 16 18:43:38 GMT 2016 aarch64 GNU/Linux | ||
+ | root@drie: | ||
+ | Slackware 14.2 | ||
+ | root@drie: | ||
+ | Raspberry Pi 3 Model B Rev 1.2 | ||
+ | root@drie: | ||
+ | 0x4135b94e | ||
+ | root@drie: | ||
+ | </ | ||
+ | |||
+ | 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 ====== | ||
Line 427: | Line 458: | ||
<!-- * Original source: [[http:// | <!-- * Original source: [[http:// | ||
<!-- Authors are allowed to give credit to themselves! --> | <!-- Authors are allowed to give credit to themselves! --> | ||
- | < | + | |
<!-- * Contributions by [[wiki: | <!-- * Contributions by [[wiki: | ||