Skip to content

Commit 6e14150

Browse files
authored
Merge pull request #3139 from pareenaverma/content_review
Update the gcc baremetal cross-compile instructions
2 parents b67f0be + 2a8d694 commit 6e14150

2 files changed

Lines changed: 26 additions & 54 deletions

File tree

content/install-guides/gcc/arm-gnu.md

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ weight: 4
1919

2020
## Before you begin
2121

22-
Arm GNU Toolchain is a community-supported, pre-built GNU compiler toolchain for Arm-based CPUs.
22+
Arm GNU Toolchain is a community-supported, pre-built GNU compiler toolchain for Arm-based CPUs. This guide covers installing the toolchain directly from the [Arm GNU Toolchain downloads page](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads), which is the recommended approach for bare-metal and embedded targets such as `arm-none-eabi`.
2323

24-
There are many versions of the [Arm GNU Toolchain](https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain) available. In general, the latest version is recommended for use, as this will contain the latest optimization improvements, as well as support for the latest Arm IP.
24+
If you need a cross-compiler targeting Arm Linux (for example `aarch64-linux-gnu` or `arm-linux-gnueabihf`), see the [Cross-compiler](../cross) install guide instead, which installs those toolchains via the Linux package manager.
25+
26+
There are many versions of the [Arm GNU Toolchain](https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain) available. In general, the latest version is recommended, as this will contain the latest optimization improvements and support for the latest Arm IP.
2527

2628
However there are reasons you may wish to use earlier compiler versions, so older versions are also available.
2729

@@ -45,18 +47,6 @@ Download the correct toolchain variant for your development needs from the [Arm
4547

4648
## How do I install the Arm GNU Toolchain on Linux?
4749

48-
### Use package installer
49-
50-
Many Linux distributions make the toolchain available with their package installers. However they may not be the latest versions or desired variant.
51-
```command
52-
sudo apt update
53-
sudo apt install gcc-arm-none-eabi
54-
```
55-
56-
If the installed version does not meet your needs, you can install another Arm GNU Toolchain version.
57-
58-
### Manual install {#manual}
59-
6050
Unpack the downloaded file to the install directory. The exact file name will depend on the flavor selected.
6151

6252
```console
@@ -148,7 +138,7 @@ Double-click on the installer, such as `arm-gnu-toolchain-15.2.rel1-mingw-w64-i
148138
To install silently from the command line, use similar to the following:
149139

150140
```console
151-
msiexec /i arm-gnu-toolchain-<version>--mingw-w64-i686-arm-none-eabi.msi EULA=1 /quiet
141+
msiexec /i arm-gnu-toolchain-<version>-mingw-w64-i686-arm-none-eabi.msi EULA=1 /quiet
152142
```
153143

154144
The zip package is a backup to Windows installer for those who cannot run the installer. You can unzip the package and then run the tools directly.
@@ -161,12 +151,12 @@ To use the Arm GNU Toolchain in conjunction with [Arm Development Studio](https:
161151

162152
## Get started
163153

164-
To verify the installation is correct enter:
154+
To verify the installation is correct, enter:
165155
```console
166156
arm-none-eabi-gcc -v
167157
```
168158

169-
Additional examples are included in the toolchain installation at:
159+
Additional examples are included in the toolchain installation. If you installed to `$HOME` using the example above, you can find them at:
170160
```console
171-
${install_dir}/share/gcc-arm-none-eabi/samples
161+
$HOME/arm-gnu-toolchain-15.2.rel1-aarch64-arm-none-eabi/share/doc/gcc-arm-none-eabi/examples
172162
```

content/install-guides/gcc/cross.md

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,51 +18,46 @@ weight: 3
1818
---
1919
GCC is available on all Linux distributions and can be installed using the package manager.
2020

21-
This covers `gcc` and `g++` for compiling C and C++ as a cross-compiler targeting the Arm architecture.
21+
This covers `gcc` and `g++` for compiling C and C++ as a cross-compiler targeting the Arm Linux architecture. For bare-metal and embedded targets such as `arm-none-eabi`, see the [Arm GNU Toolchain](../arm-gnu) install guide.
2222

2323
## Before you begin
2424

25-
GCC is often used to cross-compile software for Arm microcontrollers and embedded devices which have firmware and other low-level software. The executables are `arm-none-eabi-gcc` and `arm-none-eabi-g++`.
26-
27-
GCC is also used to cross compile Linux applications. Applications can be compiled for 32-bit or 64-bit Linux systems.
25+
GCC is used to cross-compile Linux applications targeting Arm. Applications can be compiled for 32-bit or 64-bit Arm Linux systems.
2826

2927
The executables for 32-bit are `arm-linux-gnueabihf-gcc` and `arm-linux-gnueabihf-g++`.
3028

3129
The executables for 64-bit are `aarch64-linux-gnu-gcc` and `aarch64-linux-gnu-g++`.
3230

33-
Software can be compiled on an `x86` or `Arm` host machine.
31+
Software can be compiled on an `x86_64` or `Arm` host machine.
3432

3533
## How do I download a GCC cross compiler targeting Arm?
3634

37-
The Linux package manager will download the required files so there are no special download instructions.
35+
The Linux package manager downloads the required files. No manual download is needed.
3836

3937
## How do I install a GCC cross compiler on Linux?
4038

4139
You can install a GCC cross compiler with Arm as a target architecture using Linux package managers.
4240

4341
### Installing on Debian based distributions such as Ubuntu
4442

45-
Use the `apt` command to install software packages on any Debian based Linux distribution.
43+
Use the `apt` command to install the cross-compilers for 32-bit and 64-bit Arm Linux targets.
4644

4745
```bash { target="ubuntu:latest" }
4846
sudo apt update
49-
sudo apt install gcc-arm-none-eabi -y
5047
sudo apt install gcc-arm-linux-gnueabihf -y
5148
sudo apt install gcc-aarch64-linux-gnu -y
5249
```
5350

51+
The GCC version installed is tied to your Ubuntu release. For example, Ubuntu 24.04 LTS provides GCC 13 and Ubuntu 25.10 provides GCC 15. This is normal Ubuntu packaging behaviour.
52+
5453
### Installing on Fedora
5554

5655
Fedora uses the `dnf` package manager.
5756

58-
To install the most common development tools use the commands below.
59-
6057
- If the machine has `sudo` you can use it:
6158

6259
```bash { target="fedora:latest" }
6360
sudo dnf update -y
64-
sudo dnf install arm-none-eabi-gcc-cs -y
65-
sudo dnf install arm-none-eabi-newlib -y
6661
sudo dnf install gcc-aarch64-linux-gnu -y
6762
sudo dnf install gcc-arm-linux-gnu -y
6863
```
@@ -71,35 +66,28 @@ To install the most common development tools use the commands below.
7166

7267
```console
7368
dnf update -y
74-
dnf install arm-none-eabi-gcc-cs -y
75-
dnf install arm-none-eabi-newlib -y
7669
dnf install gcc-aarch64-linux-gnu -y
7770
dnf install gcc-arm-linux-gnu -y
7871
```
7972

80-
## How do I install a GCC cross compiler on macOS?
81-
82-
You can install a GCC cross compiler with Arm as a target architecture using Homebrew, a package manager for macOS (and Linux).
83-
84-
```console
85-
brew install arm-none-eabi-gcc
86-
```
73+
On Fedora, only building kernels is currently supported. Support for cross-building user space programs is not currently provided, as that would massively multiply the number of packages.
8774

8875
## Setting up product license {#license}
8976

9077
GCC is open source and freely available for use.
9178

9279
## Get started {#start}
9380

94-
To confirm the installation is successful, enter:
81+
To confirm the installations are successful, enter:
9582

96-
```bash
97-
arm-none-eabi-gcc --version
83+
```bash { target="ubuntu:latest" }
84+
aarch64-linux-gnu-gcc --version
85+
arm-linux-gnueabihf-gcc --version
9886
```
9987

100-
To compile an example program, create a text file named `hello-world-embedded.c` with the contents below.
88+
To cross-compile an example program, create a text file named `hello-world.c` with the contents below.
10189

102-
```C { file_name="hello-world-embedded.c" }
90+
```C { file_name="hello-world.c" }
10391
#include <stdio.h>
10492

10593
int main()
@@ -109,20 +97,14 @@ int main()
10997
}
11098
```
11199

112-
To compile hello-world as a bare-metal application:
113-
114-
```bash { target="ubuntu:latest" }
115-
arm-none-eabi-gcc --specs=rdimon.specs hello-world-embedded.c -o hello-world.elf
116-
```
117-
118-
To cross-compile hello-world as a 32-bit Linux application. On Fedora, only building kernels is currently supported. Support for cross-building user space programs is not currently provided as that would massively multiply the number of packages.
100+
To cross-compile for a 64-bit Arm Linux target. On Fedora, only building kernels is currently supported, so these examples apply to Ubuntu.
119101

120102
```bash { target="ubuntu:latest" }
121-
arm-linux-gnueabihf-gcc hello-world-embedded.c -o hello-world.elf
103+
aarch64-linux-gnu-gcc hello-world.c -o hello-world-aarch64.elf
122104
```
123105

124-
To cross-compile hello-world as a 64-bit Linux application. On Fedora, only building kernels is currently supported. Support for cross-building user space programs is not currently provided as that would massively multiply the number of packages.
106+
To cross-compile for a 32-bit Arm Linux target:
125107

126108
```bash { target="ubuntu:latest" }
127-
aarch64-linux-gnu-gcc hello-world-embedded.c -o hello-world.elf
109+
arm-linux-gnueabihf-gcc hello-world.c -o hello-world-arm.elf
128110
```

0 commit comments

Comments
 (0)