1

I want to add Atmega1281 architecture to my current version of gcc that i am using i.e. v3.3. The Atmega1281 is not supported in the v3.3 and its support got added in v4.2.1 .

I cannot upgrade the gcc to 4.2.1, so i need to add the support to my existing compiler.

Is there any way to do this ?

6
  • 2
    If you want to backport the Atmega1281 support into v3.3, then go for it. Here's the code. Commented Mar 19, 2019 at 6:11
  • its just link to raw gcc. doesn't make sense. Commented Mar 19, 2019 at 10:24
  • Generally, whole the AVR family is the same, so, all you need is it locate all .h files (which are indirectly included inside <avr/io.h> in the new tool chain and include them directly to your project. Commented Mar 19, 2019 at 13:53
  • The compiler should know to generate the executable for the new architecture, including doesn't make sense . Commented Mar 20, 2019 at 5:55
  • The code is the same for the whole AVR mega familiy, let's say there is no difference in code between ATmega328 and ATmega1281, only the difference is size of flash/ram/eeprom, and where and which IO registers are located. Commented Mar 20, 2019 at 11:12

2 Answers 2

1

You don't need to update GCC (I presume you are actually using AVR-GCC to generate AVR specific machine code...). All AVR chips use the same AVR core and instruction set. The only thing that changes from one chip to another are memory sizes, register addresses, and the availability of peripherals.

You might need to update AVRlibc if you use those core libraries, and you'll need to add device configurations for a programming utility like avrdude.

You must update the core headers that define register locations, unless you define your own pointers to the raw memory addresses (like a boss). This can be found in the Atmel Packs, specifically the support for Atmega devices.


When you include io.h in your project, that pulls in the device-specific definitions with nice defined pointers to memory to access peripherals configuration and data registers. This only works if you pass the device in use as a special definition in your compilation command. If you are using the standard Makefile template, the device is one of the things you edit, and it handles those commands. Similarly, an IDE like Atmel Studio will ask what device you are using and generate the Makefile for you.


But don't take it from me, here is the relevant information from the AVR-GCC wiki in the section titled Supporting "unsupported" Devices.

When you feed code into the compiler and compile for a specific device, the compiler will only care for the respective core; it won't care for the exact device. It does not matter to the compiler how many I/O pins the device has, at what voltage it operates, how much RAM is present, how many timers or UARTs are on the silicon or in what package it is shipped. The only thing the compiler does with -mmcu=device is to build-in define a specific macro and to call the linker in a specific way, i.e. the compiler driver behaves a bit differently, but the sub-tools like compiler proper and assembler will generate exactly the same code.

Thus, you can support your device by setting these options by hand.

So, if you cannot update AVR-GCC for whatever reason, you can still compile for your device by manually telling the linker where to look for stuff and specifying the correct includes from the io.h tree.

The wiki also gives more instructions on how to do this.

Sign up to request clarification or add additional context in comments.

2 Comments

if i use my current avr-gcc 3.3 to build for atmega1281, i get error as its a unknown mcu. Also if i do , "avr-gcc --target-help", that architecture is not available. So i need to add the support for Atmega1281 to the current avr-gcc3.3.
See the updated section of my answer. You are misunderstanding what those messages mean. You can still compile for your "unsupported" device because the compiler doesn't care about the device, it's only helping you to include the correct definitions and linked libs.
0

In order to add the architecture, three things need to be updated,

  1. gcc - gcc\config\avr\avr.c, gcc\config\avr\avr.h, gcc\config\avr\t-avr,

  2. Binutils - gas\tc-avr.c

  3. avr-libc - avr\io.h, configure, configure.in, And Header file changes.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.