Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to GCC 10.2 #3

Merged
merged 3 commits into from
Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
command: |
mkdir -p workspace
cp -r test/ workspace/
tar cjf workspace/avr-gcc.tar.bz2 -C /work avr-gcc
tar cjf workspace/avr-gcc.tar.bz2 -C /opt avr-gcc
- store_artifacts:
path: workspace/avr-gcc.tar.bz2
destination: avr-gcc.tar.bz2
Expand All @@ -40,12 +40,13 @@ jobs:
at: workspace
- run:
name: Unpack Toolchain
command: tar xf workspace/avr-gcc.tar.bz2 --directory /work
command: tar xf workspace/avr-gcc.tar.bz2 --directory /opt
- run:
name: Compiling test files
command: |
/work/avr-gcc/avr-gcc/bin/avr-g++ -mmcu=atmega328p workspace/test/main1.cpp
/work/avr-gcc/avr-gcc/bin/avr-g++ -mmcu=atmega328p workspace/test/main2.cpp
/opt/avr-gcc/avr-gcc/bin/avr-g++ --version
/opt/avr-gcc/avr-gcc/bin/avr-g++ -mmcu=atmega328p workspace/test/main1.cpp
/opt/avr-gcc/avr-gcc/bin/avr-g++ -mmcu=atmega328p workspace/test/main2.cpp
deploy:
docker:
- image: circleci/golang:latest
Expand Down
38 changes: 31 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,53 @@
# Build AVR GNU GCC Toolchain from source
# Up-to-date AVR GNU GCC Toolchain from source

[![CircleCI](https://circleci.com/gh/modm-ext/docker-avr-gcc.svg?style=svg)](https://circleci.com/gh/modm-ext/docker-avr-gcc)

## Installation

Download the latest `avr-gcc.tar.bz2` from [Releases](https://github.com/modm-ext/docker-avr-gcc/releases)
and unpack it to `/opt`:

```sh
tar xf avr-gcc.tar.bz2 --directory /opt
```

Add the `bin/` directories of avr-gcc and avr-binutils to your `$PATH`,
e.g. by adding the following line to your `~/.bashrc` file:

```sh
export PATH="/work/avr-gcc/avr-gcc/bin:/work/avr-gcc/avr-binutils/bin:$PATH"
```

## Building locally with Docker

There is a Docker image with all prerequisites for building. Start it with:
There is a Docker image with all prerequisites for building, created from the `Dockerfile` in this repository.
Pull and start the image from Dockerhub with:

```sh
docker run -it modm/avr-gcc-prerequisites
```

Or build the image from the local `Dockerfile` and start it:

```sh
docker run -it modm/avr-gcc-prerequisites bash
docker build --tag avr-gcc-prerequisites:local .
docker run -it avr-gcc-prerequisites:local
```

Inside the Docker container get this repository

```sh
git clone https://github.com/modm-ext/docker-avr-gcc.git
git clone https://github.com/modm-ext/docker-avr-gcc.git
```

Run the build.sh script

```sh
cd docker-avr-gcc
time bash build.sh
cd docker-avr-gcc
time ./build.sh
```

The toolchain will be in `avr-gcc`.
The toolchain will be in `/opt/avr-gcc`.

## Building in CircleCI

Expand Down
32 changes: 16 additions & 16 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,61 @@

SRC="src"
BUILD="build"
INSTALL="avr-gcc" # tar.bz2 needs a prefix of 'avr-gcc'
INSTALL="/opt/avr-gcc" # tar.bz2 needs a prefix of 'avr-gcc'
DOWNLOAD="download"
mkdir ${SRC}
mkdir ${BUILD}
mkdir ${INSTALL}
root=$(pwd)
cores=4
VERSION_BINUTILS="2.32"
VERSION_GCC="9.2.0"
#VERSION_BINUTILS="2.33"
VERSION_GCC="10.2.0"
VERSION_LIBC="2.0.0"

# Get sources
wget -q "https://dl.bintray.com/osx-cross/avr-patches/avr-binutils-${VERSION_BINUTILS}-size.patch" &
wget -q "https://dl.bintray.com/osx-cross/avr-patches/avr-binutils-2.33-size.patch" &
wget -q "https://dl.bintray.com/osx-cross/avr-patches/avr-libc-${VERSION_LIBC}-atmega168pb.patch" &
wget -qO- "https://ftp.gnu.org/gnu/binutils/binutils-${VERSION_BINUTILS}.tar.bz2" | tar xj --directory ${SRC} &
wget -qO- "https://ftp.gnu.org/gnu/binutils/binutils-2.33.1.tar.bz2" | tar xj --directory ${SRC} &
wget -qO- "https://ftp.gnu.org/gnu/gcc/gcc-${VERSION_GCC}/gcc-${VERSION_GCC}.tar.xz" | tar xJ --directory ${SRC} &
wget -qO- "https://download.savannah.gnu.org/releases/avr-libc/avr-libc-${VERSION_LIBC}.tar.bz2" | tar xj --directory ${SRC} &
wait

# Build binutils first
cd ${SRC}/binutils-${VERSION_BINUTILS}
cd ${SRC}/binutils-2.33.1
# patch size file
patch -g 0 -f -p0 -i ../../avr-binutils-${VERSION_BINUTILS}-size.patch
patch -g 0 -f -p0 -i ../../avr-binutils-2.33-size.patch
mkdir build && cd build
# configure and make
../configure --prefix=${root}/${INSTALL}/avr-binutils/ --target=avr --disable-nls --disable-werror
../configure --prefix=${INSTALL}/avr-binutils/ --target=avr --disable-nls --disable-werror
make -j${cores}
make install

# prepend path of newly compiled avr-gcc
export PATH=${root}/${INSTALL}/avr-binutils/bin:$PATH
# prepend path of newly compiled avr-binutils
export PATH=${INSTALL}/avr-binutils/bin:$PATH

cd ${root}
cd ${SRC}/gcc-${VERSION_GCC}
mkdir build && cd build
../configure --target=avr --prefix=${root}/${INSTALL}/avr-gcc/ \
--with-ld=${root}/${INSTALL}/avr-binutils/bin/avr-ld \
--with-as=${root}/${INSTALL}/avr-binutils/bin/avr-as \
../configure --target=avr --prefix=${INSTALL}/avr-gcc/ \
--with-ld=${INSTALL}/avr-binutils/bin/avr-ld \
--with-as=${INSTALL}/avr-binutils/bin/avr-as \
--enable-languages=c,c++ --with-dwarf2 \
--disable-nls --disable-libssp --disable-shared \
--disable-threads --disable-libgomp --disable-bootstrap
make -j${cores}
make install

# prepend path of newly compiled avr-gcc
export PATH=${root}/${INSTALL}/avr-gcc/bin:$PATH
export PATH=${INSTALL}/avr-gcc/bin:$PATH

cd ${root}
cd ${SRC}/avr-libc-${VERSION_LIBC}
patch -g 0 -f -p0 -i ../../avr-libc-${VERSION_LIBC}-atmega168pb.patch
build=`./config.guess`
./configure --build=${build} --prefix=${root}/${INSTALL}/avr-gcc --host=avr
./configure --build=${build} --prefix=${INSTALL}/avr-gcc --host=avr
make install -j${cores}

cd ${root}
rm -r build src
rm avr-binutils-${VERSION_BINUTILS}-size.patch
rm avr-binutils-2.33-size.patch
rm avr-libc-${VERSION_LIBC}-atmega168pb.patch