How to compile for Arduino Uno atmega328p with Atmel AVR 8-bit Toolchain 3.5.4

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I started to test Atmel tool chain as an option to get rid off Arduino IDE.

I downloaded and unpacked  "Atmel AVR 8-bit Toolchain 3.5.4 - Linux 64-bitAtmel AVR 8-bit Toolchain 3.5.4 - Linux 64-bit (46.7 MB, updated September 2016)".

 

Then opened http://www.atmel.com/Images/avr8..., it is listing the supported processors/architectures:

"... atmega168 atmega328 atmega6450a m3000 atmega168a atmega328p atmega6450p.."

 

I started with example "../avr8-gnu-toolchain-linux_x86_64/doc/avr-libc/examples/demo.

 

I ran make once, and found out it telling very little about what's going on. After openingMakefile I found MCU_TARGET     = atmega8 set as default value.
 

Which MCU_TARGET I should select for atmega328p, and especially for Arduino Uno ver3 (if that makes any difference)?

 

MCU_TARGET     = atmega329 is available as an option but no atmega328p.

 

This topic has a solution.

Last Edited: Mon. Dec 25, 2017 - 01:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The makefile can be augmented with a new row for the ATmega328p, like this:

 

MCU_TARGET     = atmega328p

but that won't make the demo buildable. The file iocompat.h has it's own conditional compiling directives for "known AVR models" and ATmega328p isn't one of them. Not even the ATmega328 (no 'p') is among the models that iocompat.h handles. I.e. the demo is not updated for all existing AVR models.

 

The iocompat.h file hides differences between peripherals of different AVR models. E.g. Timers/Counters differing is what registers, register bits etc they have and what their principles of operation are.

 

For someone with a Arduino / ATmega328p that demo might not be a good starting point. The problems are most likely solvable, but it might involve substantial work, comparing different data sheets etc.

 

I'd start with a simple "blinky" using the _delay_ms() function in <util/delay.h>.

 

For creating your own makefile I strongly recommend the MFile utility which you can find here. It has some prerequisites (e.g. Tkl, Tkl/Tk) so if you don't have those you need to install them too. No, setting up a development environment and use it on Linux might not be ass trivial as running one monolithic installer. It takes tinkering and some knowledge about Linux system maintenance.

 

Question: Why do you want to get rid of the Arduino IDE?

 

The Arduino IDE does all that "dirty work" for you and you don't need to use the Arduino framework. E.g. you can do your own digital I/O instead of using the venerable digitalWrite().

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hej Johan,

Thanks for your answer.

I am not able to comprehensively express my dislike to Arduino IDE. A part of it is maybe just a personal taste of doing things but I'm also interested in "dirty things under the hood..", although I'm not too experienced in this, as my question obviously reflects.
Lately I have done some timer-, event- (interrupts) and io-centric stuff that has also some critical timing requirements. Also I'd like to sort of harmonize my set of tools, and I hope I can re-use some of my own libs/sources in AVR-, ARM- and x86 architectures. But, that's for the reasoning.

I'm a bit confused that 328p was just the one missing. My expectation was that I have really missed something, there must be lot of people wanting to move from Arduino IDE to avr-gcc cross compiler.

EDIT: I found this: https://github.com/sudar/Arduino...

It propably answers my needs, so I close this.

Last Edited: Mon. Dec 25, 2017 - 01:35 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hej själv! ;-)

 

corcovado wrote:
there must be lot of people wanting to move from Arduino IDE to avr-gcc cross compiler.

Perhaps, but the number of people that locates a demo in one of the subdirectories of the doolchain dorectory tree is probably close to one.

 

I'm guessing no-one in the avrlibc community and no-one at Atmel/Microchip, maintains that demo.

 

corcovado wrote:
I'm a bit confused that 328p was just the one missing.

If you meant "the only one missing" then that isn't so. Several new(ish) AVR models are missing, not only the ATmega328p.

 

Let us know about your experiences and your like/dislike of the Arduino-Makefile project you found on github once you tested it out! 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]