Giter Club home page Giter Club logo

avr-gcc-build's Introduction

AVR-GCC

This is where I'll be uploading builds of AVR-GCC for Windows 32 bit, 64 bit and Linux 64 bit, which will also include Binutils, AVR-LibC, AVRDUDE, Make and GDB. I'll be trying to keep the builds up to date with the latest tool releases when I can.

The avr-gcc-build.sh script was originally a gist, which I've now turned into a repository so releases can be uploaded to GitHub rather than having them hosted on my website.

Upgrading the Arduino IDE

Upgrading the Arduino IDE is pretty easy, though there could be some incompatibilities with certain libraries. Only tested with Arduino 1.8.13.

  1. Download and extract the latest release
  2. Navigate to your Arduino IDE folder
  3. Go to hardware/tools
  4. Move the avr folder somewhere else, like to your desktop (renaming the folder won't work, Arduino has some auto-detect thing which sometimes gets confused)
  5. Move the extracted folder from earlier to the tools folder and rename it to avr
  6. Copy bin/avrdude.exe and builtin_tools_versions.txt files and etc folder from the old avr folder to the new one
  7. Done! Open up the Arduino IDE, load up the Blink example, upload it to your Arduino and make sure the LED is blinking!

Docker

The script can be ran by itself or within a Docker container.

Build Image

docker build -t avrgccbuild .

Run Container

docker run --rm -it -v "$(pwd)"/output:/output avrgccbuild

On Windows replace $(pwd) with %cd%:

docker run --rm -it -v "%cd%"/output:/output avrgccbuild

You will find the built toolchains in the output directory of your current working directory.

Environment Variables

Variable Default Description
JOBCOUNT Number of CPU cores your system has More jobs require more RAM, so if you get errors like collect2: fatal error: ld terminated with signal 9 [Killed] then you may need to reduce the job count
BASE Docker: /avr-gcc-build/build/
Standalone: [cwd]/build/
Output directory (must have trailing slash)
VER_GCC 14.1.0 GCC version
VER_BINUTILS 2.42 Binutils version
VER_GDB 14.2 GDB version
FOR_LINUX 1 Build for Linux. A Linux AVR-GCC toolchain is required to build a Windows toolchain. If the Linux toolchain has already been built then you can set this to 0. This is a bit broken at the moment and should stay as 1
FOR_WINX86 0 Build for 32 bit Windows
FOR_WINX64 1 Build for 64 bit Windows
BUILD_BINUTILS 1 Build Binutils for selected OSs
BUILD_GCC 1 Build GCC for selected OSs (requires AVR-Binutils)
BUILD_GDB 1 Build GDB for selected OSs
BUILD_LIBC 1 Build AVR-LibC (requires AVR-GCC)

Change environment variables by passing the -e option when running the Docker container:

docker run --rm -it -v "$(pwd)"/output:/output -e VER_GCC="10.1.0" -e BUILD_GDB=0 avrgccbuild

FAQs

avr-size does not show percent used / is missing the -C or --mcu option

Use avr-objdump -Pmem-usage <yourfirmware>.elf instead. See #3

avr-gcc-build's People

Contributors

klotzi111 avatar krakonos avatar zakkemble avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

avr-gcc-build's Issues

Configure avr-gcc with `--with-gnu-ld`

Configuring GCC with --with-gnu-ld can improve the handling of @-files:

Only when the driver knows that the GNU linker is used, it will put options / objects for linking in @-file. This may be required on Windows when the inflated command line is too long for Windows. The behaviour of collect2 also depends on that flag: When the driver calls collect2 for linking with an @-file, collect2 will call ld with an @-file only with the GNU linker.

The configure scripts can't always work this out, e.g. for canadian-cross builds, because configure cannot call the host's ld.exe.

Use proper make install for AVR-LibC

The build script does cumbersome commands like

cp -r "$PREFIX_LIBC"/* "$PREFIX_GCC_LINUX"

in order to "install" AVR-LibC. The proper way to install it in a location other then --prefix is:

make install prefix="${PREFIX_GCC_LINUX}"

etc.

The avr-size.exe is not suit for avr mcu

I download the .zip file below:
image
and unzip it, the path of avr-size.exe is:
avr-gcc-12.1.0-x64-windows\bin
look at the help of avr-size.exe:
image
It lacks the --mcu and --mlist-devices as the following picture shows:
image

Build script uses outdated AVR LibC

The build script uses avr-libc3 which is outdated, last update was 4 years ago . Better use the original avr-libc. You may argue that there is no AVR LibC release yet, but that applies to avr-libc3, too.

GCC doesn't seem to know the size of memory available

I am building a project for ATmega640 using GCC 12.1. I'm passing a -Wl,--print-memory-usage flag to the linker to get the memory usage, but GCC thinks that the device has 128KB of flash, instead of 64KB. The RAM and EEPROM sizes are also wrong.

Linker flags: -mmcu=atmega640 -fno-exceptions -fno-rtti -Wl,--gc-sections -Wl,--print-memory-usage

Output:

Memory region         Used Size  Region Size  %age Used
            text:       49628 B       128 KB     37.86%
            data:         748 B      65440 B      1.14%
          eeprom:          0 GB        64 KB      0.00%
            fuse:          0 GB          3 B      0.00%
            lock:          0 GB         1 KB      0.00%
       signature:          0 GB         1 KB      0.00%
 user_signatures:          0 GB         1 KB      0.00%

When the command from #3, the correct percentage is displayed:

Device: atmega640

Program:   49628 bytes (75.7% Full)
(.text + .data + .bootloader)

Data:        332 bytes (4.1% Full)
(.data + .bss + .noinit)

Unfortunately, this issue means that compiler does not detect when the code exceeds the available memory.

The issue is not present on GCC 5.4, that is bundled with the Microchip Studio.

small issue in delay.h

I tested the latest avr-gcc compiler here at the University of Applied Sciences in Amsterdam. We always attempt :) to compile without any warnings as all are then treated as errors.

In de the function _delay_us(double __us) in delay.h I get a warning (and thus an error) on line 279 that
uint8_t __ticks; is unitialized.

Changing this line into
uint8_t __ticks = 0;

Solved it.

My Euro 0.02 :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.