In this article, we will show you how to install and use the Linaro embedded toolchain on Ubuntu 64-Bit, which is a Linux distribution based on Debian. The Linaro embedded toolchain is designed for developing software for embedded systems, such as microcontrollers, IoT devices, and single-board computers. The Linaro embedded toolchain supports the Arm A-profile cores, which are used in most smartphones, tablets, and laptops, as well as the Arm R-profile and M-profile cores, which are used in real-time and low-power applications.
Installing the Linaro embedded toolchain
The easiest way to install the Linaro embedded toolchain on Ubuntu 64-Bit is to download the pre-built binary packages from the Linaro website. You can choose between the GNU Toolchain and the LLVM Toolchain, depending on your preference and needs. The GNU Toolchain is based on GCC, which is a widely used and mature compiler that supports many languages and features. The LLVM Toolchain is based on LLVM, which is a newer and modular compiler that offers better optimization and code generation for some targets.
For this article, we will use the GNU Toolchain as an example. The latest version of the GNU Toolchain for Arm A-profile cores is gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz, which is based on GCC 7.3.1. To download and install it, follow these steps:
Open a terminal window and navigate to the directory where you want to save the toolchain.
Use the wget command to download the toolchain package from the Linaro website: wget -c --no-check-certificate
Use the tar command to extract the toolchain package: tar xf gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz
Add the toolchain bin directory to your PATH environment variable: export PATH=$PATH:`pwd`/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf/bin
Verify that the toolchain is installed correctly by checking its version: arm-linux-gnueabihf-gcc --version
You should see something like this: arm-linux-gnueabihf-gcc (Linaro GCC 7.3-2018.05) 7.3.1 20180425 [linaro-7.3-2018.05 revision d29120a424ecfbc167ef90065c0eeb7f91977701] Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Using the Linaro embedded toolchain
Once you have installed the Linaro embedded toolchain, you can use it to cross-compile software for your target device. For example, if you want to compile a simple C program that prints "Hello, world!" to the standard output, you can follow these steps:
Create a file named hello.c with the following content: #include <stdio.h> int main(void) printf("Hello, world!\n"); return 0;
Use the arm-linux-gnueabihf-gcc command to compile the program with the Linaro embedded toolchain: arm-linux-gnueabihf-gcc hello.c -o hello
Copy the executable file hello to your target device using a USB cable, a network connection, or any other method.
Run the executable file on your target device and see the output: ./hello Hello, world!
You can also use the Linaro embedded toolchain to compile more complex programs that use external libraries and dependencies. For example, if you want to compile a program that uses the WiringPi library, which is a GPIO access library for Raspberry Pi, you can follow these steps:
Download and install the WiringPi library on your host machine using the instructions from its website.
Create a file named blink.c with the following content: #include <wiringPi.h> #define LED_PIN 0 int main(void) wiringPiSetup(); pinMode(LED_PIN, OUTPUT); while (1) digitalWrite(LED_PIN, HIGH); delay(500); digitalWrite(LED_PIN, LOW); delay(500); return 0;
Use the arm-linux-gnueabihf-gcc command to compile the program with the Linaro embedded toolchain and link it with the WiringPi library: arm-linux-gnueabihf-gcc blink.c -o blink -lwiringPi
Copy the executable file blink to your target device using a USB cable, a network connection, or any other method.
Run the executable file on your target device and see the LED connected to pin 0 blink: ./blink
Conclusion
In this article, we have shown you how to install and use the Linaro embedded toolchain on Ubuntu 64-Bit. The Linaro embedded toolchain is a powerful and convenient tool for developing software for Arm-based devices. You can use it to cross-compile software for different architectures and platforms, such as microcontrollers, IoT devices, and single-board computers. You can also use it to compile software that uses external libraries and dependencies, such as WiringPi. We hope that this article has been helpful and informative for you. If you have any questions or feedback, please feel free to leave a comment below.
a7a7d27f09