How can i add a architecture which is available in new version of gcc to a old version of gcc?

陌路散爱 提交于 2019-12-25 01:49:56

问题


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 ?


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/55234417/how-can-i-add-a-architecture-which-is-available-in-new-version-of-gcc-to-a-old-v

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!