gcc - arm-none-eabi toolchain compile from source - Stack Overflow
Whats "gcc-arm-none-eabi" toolchain ??
Standards Support in Arm C/C++ Compiler (arm-gnu-eabi-g++)
arm-eabi-none-g++ cannot find a library
Videos
For those who are running into the same problem, I found a solution for the arm toolchain 12.2. It might also work for the previous version of the toolchain, I haven't checked. 12.2 brings c++ 20 support.
I containerized this as follows
# install dependencies for python3.8
RUN apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget -y
# install arm toolchain
RUN ARM_TOOLCHAIN_VERSION=12.2.Rel1
RUN curl -Lo gcc-arm-none-eabi.tar.xz "https://developer.arm.com/-/media/Files/downloads/gnu/12.2.Rel1/binrel/arm-gnu-toolchain-12.2.Rel1-x86_64-arm-none-eabi.tar.xz"
RUN mkdir -p /opt/gcc-arm-none-eabi
RUN tar xf gcc-arm-none-eabi.tar.xz --strip-components=1 -C /opt/gcc-arm-none-eabi
ENV PATH="/opt/gcc-arm-none-eabi/bin:${PATH}"
# test arm-none-gcc
RUN arm-none-eabi-gcc --version
# install python3.8
RUN wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz
RUN tar -xf Python-3.8.12.tgz
WORKDIR /Python-3.8.12
RUN ./configure --enable-optimizations
RUN make -j 4
RUN make altinstall
#attempt to fix libncursesw.so.5
RUN apt install libncurses5 -y
RUN apt install libncursesw5 -y
# test arm-none-gdb
RUN arm-none-eabi-gdb --version
So it basically :
- installs a bunch of dependencies,
- downloads arm toolchain 12.2
- compiles python3.8 from sources and installs python3.8 next to any existing python version.
- tests if it can execute arm-none-eabi-gdb
If you want to execute this on your host OS, remove the docker RUN commands and add some sudo's here and there :).
If it's of any help, my full docker file (which installs a bunch more, like jlink support to be able to compile/run/debug from vscode when attached to this docker container)
FROM ubuntu
ENV UDEV=on
RUN apt-get update -y
RUN apt-get upgrade -y
# Install dependencies for JLink
RUN apt install libxcb-render-util0-dev -y
RUN apt install libxrender1 libxcb-shape0 libxcb-randr0 libxcb-xfixes0 libxcb-sync1 libxcb-shm0 libxcb-icccm4 libxcb-keysyms1 libxcb-image0 libxkbcommon0 libxkbcommon-x11-0 libfontconfig1 libfreetype6 libxext6 libx11-xcb1 libsm6 libice6 libglib2.0-0 -y
# Install dependencies for JLinkServer
RUN apt install libxcursor-dev libxfixes3 libxrandr2 -y
# install jlink
RUN mkdir -p /home/Downloads
COPY JLink_Linux_V786b_x86_64.deb /home/Downloads/JLink_Linux_V786b_x86_64.deb
RUN dpkg --unpack /home/Downloads/JLink_Linux_V786b_x86_64.deb
RUN rm /var/lib/dpkg/info/jlink.postinst -f
RUN dpkg --configure jlink
RUN apt install -yf
# Install curl
RUN apt install curl bzip2 -y
# install dependencies for arm-none-eabi-gdb
#RUN apt install libncurses5 -y
# install dependencies for python3.8
RUN apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget -y
# install arm toolchain
RUN ARM_TOOLCHAIN_VERSION=12.2.Rel1
RUN curl -Lo gcc-arm-none-eabi.tar.xz "https://developer.arm.com/-/media/Files/downloads/gnu/12.2.Rel1/binrel/arm-gnu-toolchain-12.2.Rel1-x86_64-arm-none-eabi.tar.xz"
RUN mkdir -p /opt/gcc-arm-none-eabi
RUN tar xf gcc-arm-none-eabi.tar.xz --strip-components=1 -C /opt/gcc-arm-none-eabi
ENV PATH="/opt/gcc-arm-none-eabi/bin:${PATH}"
# test arm-none-gcc
RUN arm-none-eabi-gcc --version
# install cmake
RUN apt install cmake -y
RUN apt install udev -y
RUN /lib/systemd/systemd-udevd --daemon
# install git
RUN apt install git -y
# install ninja
RUN apt install ninja-build python3 pip -y
RUN pip install meson
# install python3.8
RUN wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz
RUN tar -xf Python-3.8.12.tgz
WORKDIR /Python-3.8.12
RUN ./configure --enable-optimizations
RUN make -j 4
RUN make altinstall
#attempt to fix libncursesw.so.5
RUN apt install libncurses5 -y
RUN apt install libncursesw5 -y
# test arm-none-gdb
RUN arm-none-eabi-gdb --version
ARG USER_ID
ARG GROUP_ID
RUN addgroup --gid $GROUP_ID user && adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user
USER user
WORKDIR /home/dev/
CMD bash
The release notes available at the download site include build-from-source instructions.
I've made a quick transcription here, but future readers should be warned it may have become out-of-date.
How to build the toolchain from sources
You can build Arm GNU Toolchain from sources using Linaro ABE (Advanced Build Environment) and provided ABE manifest files.
Below example shows how to build gcc-arm-aarch64-none-elf toolchain from sources using Linaro ABE build system.
Instructions
ABE has a dependency on git-new-workdir and needs this tool to be installed in /usr/local/bin directory:
$ wget https://raw.githubusercontent.com/git/git/master/contrib/workdir/git-new-workdir $ sudo mv git-new-workdir /usr/local/bin $ sudo chmod +x /usr/local/bin/git-new-workdirClone ABE from the URL below and checkout the stablebranch (see Getting ABE):
$ git clone https://git.linaro.org/toolchain/abe.gitCreate the build directory and change to it. Any name for the directory will work:
$ mkdir build && cd buildConfigure ABE (from the build directory):
$ ../abe/configureDownload the toolchain manifest file, from https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/downloads, into the build folder, for the required toolchain, for example, gcc-arm-aarch64-none-elf-abe-manifest.txt:
$ wget https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/manifest/gcc-arm-aarch64-none-elf-abe-manifest.txtBuild toolchain (from the build directory):
$ ../abe/abe.sh --manifest gcc-arm-aarch64-none-elf-abe-manifest.txt --build allThe built toolchain will be installed and available for use in the builds/destdir/x86_64-unknown-linux-gnu/bin/ directory.
gcc-arm-none-eabi toolchain, my major question is, why is it made and for what problem to solve ? before toolchains existed, what were the methods used to program a chip ??
also, who makes toolchains and how are they doing it ??