MFile missing from avr tool chain? [Solved]

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

I used WinAVR in the past, and I remember there was a tool in start menu to create makefile, I can't remember what it was called, may be mfile, any way, I downloaded avr tool chain today, and I looked inside the folders after installation, seems there is no utility to create makefile, how can I solve this problem, in general, get back the avr-gcc tools missing from avr tool chain?

P.S. Do I really have to download a CD sized software that I don't need to compile my codes!

Signature: We need more peripherals in DIP packages. Namely, USB, 12-bit ADC, 16-bit timer, cheaper tool as a programmer/debugger coz STK600 is expensive! Atmel Studio 5/6 sucks! coz it brings MS visual studio crap to AVR world..

Last Edited: Mon. Mar 5, 2012 - 06:42 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

WinAVR and AVR toolchain are different tool chain packages made by different people.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Atmel would presumably say that Studio itself is so good at generating Makefiles there'd never be any need to use Mfile. It is, however, a shame that things like Mfile, avrdude and many of the gnuwin32 utilities are missing from their distribution as it always forces an installation of WinAVR20100110 alongside to get all the things they missed.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For Mfile specifically, you can download it from it's home: http://www.sax.de/~joerg/mfile/

I guess you need the AVR Toolchain from Atmel for support for new(ish) devices? If not, then an alternative would be to skip AVR Toolchain altogether and use WinAVR-20100110.

Or you could continue to use AVR Toochain but for the side-dishes missing from it have a parallel WinAVR installation.

Quote:
Do I really have to download a CD sized software that I don't need to compile my codes!

For the time being that seems to be it, yes. While the world is moving towards modularized stuff Atmel is going monolithic.. They have talked about more modularization of Atmel Studio, but that seems to imply starting with Studio, and you want it the other way around - a separate download for AVR Toolchain - so there might be less hope for solving your situation.

Finally: There was talk about a new WinAVR build a while back but nothing has been heard about it lately..

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]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The toolchain can be downloaded as a standalone installer here:

http://www.atmel.com/tools/ATMEL...

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Brilliant info, Dean! (Our mole in the ministry is doing well :mrgreen:)

EDIT: I see it is dated June 2011. Is that the version that ships with Atmel Studio 6?

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]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
[...] Is that the version that ships with Atmel Studio 6?

No it is not(Even 5.1 ships with 3.3.1.27) Maybe we can find a standalone download somewhere else.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've just emailed the Toolchain developers asking for the latest version to be put up. Their office is now closed for the weekend, but hopefully I'll receive a response Monday.

Quote:

Brilliant info, Dean! (Our mole in the ministry is doing well Mr. Green)

My (and Thomas') aim is to be some Atmel engineers that Freaks actually like ;). Hopefully with us on the inside we can help out better here and make everyone a little less grumpy.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Microchip users are forced to download MPLAB in order to write their codes for PICC compilers from Hi-Tech, because their command line is a serious PITA. Now Atmel is following the same policy, but unfortunately creating more chips that hobbyists can never use, contrary to Microchip, interesting... Also squeezing us on the software we have to use, more and more interesting...

I was feeling very comfortable with WinAVR "Ok, I did not like the icons ;- )", and seems I will just go back to it. Technically speaking, does avr tool chain offer major improvements or it is just the newer chips support?

One thing, why is WinAVR no longer updated? Everyone who used WinAVR alone, knew very well that they did not want to use that silly studio..

abcminiuser: Why does Atmel ask me to give my email in order to download software? Most large companies are doing this, and most of us ended up creating a dummy email for this dumb policy that we never check unless we register to download some software... Just you know...

I do feel sorry for what things turned out to be these days, much effort, and less satisfaction.

Signature: We need more peripherals in DIP packages. Namely, USB, 12-bit ADC, 16-bit timer, cheaper tool as a programmer/debugger coz STK600 is expensive! Atmel Studio 5/6 sucks! coz it brings MS visual studio crap to AVR world..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

or it is just the newer chips support?


that

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Now Atmel is following the same policy, but unfortunately creating more chips that hobbyists can never use

How so? The maXTouch chips aren't sold to the unwashed masses, but all the rest generally are.

Quote:

I was feeling very comfortable with WinAVR "Ok, I did not like the icons ;- )", and seems I will just go back to it. Technically speaking, does avr tool chain offer major improvements or it is just the newer chips support?

Bug fixes and device support. You can install the new toolchain and use your old makefiles from WinAVR, if you keep WinAVR installed and preferenced second in your PATH variable.

Quote:

One thing, why is WinAVR no longer updated? Everyone who used WinAVR alone, knew very well that they did not want to use that silly studio..

The creator, Eric (EW) got hired at Atmel, and a dedicated toolchain team has taken over.

Quote:

abcminiuser: Why does Atmel ask me to give my email in order to download software? Most large companies are doing this, and most of us ended up creating a dummy email for this dumb policy that we never check unless we register to download some software... Just you know...

Marketing wants it. There is a Greasemonkey script to bypass the registration floating around...

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

oshaker wrote:
I was feeling very comfortable with WinAVR "Ok, I did not like the icons ;- )", and seems I will just go back to it. Technically speaking, does avr tool chain offer major improvements or it is just the newer chips support?
As far as I can see, there is
  • Support of Xmega core
  • Tentative support of tiny Tiny core
  • Optimized support of some fixed point types
  • Support of AVR-specific built-ins
  • Support of nmi function attribute
I could not find documentation of nmi attribute anywere, so maybe nmi is just noise on the sources...
Quote:
One thing, why is WinAVR no longer updated? Everyone who used WinAVR alone, knew very well that they did not want to use that silly studio..
There was an announcement in https://www.avrfreaks.net/index.p...

I don't know what was the reason for the delay; AFAIK there was no WinAVR release after 20100110 (avr-gcc 4.3.3).

Such a release is a lot of work so that alone might already be a good reason for why there is no new WinAVR yet.

Moreover, it was unclear what GCC base version would be best. Maybe just waiting for 4.7.0 release to base a new WinAVR on; would make much more sense than 4.6.3 because:

  • Tentative support of Xmega core
  • Tentative support of named address spaces like __flash
  • Better optimization
  • Support of AVR-specific built-ins
GCC 4.7-branch has been created just now, so that we can expect 4.7.0 release very soon.

avrfreaks does not support Opera. Profile inactive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

AFAIK there was no WinAVR release after 20100110

That is correct.

Quote:

There was an announcement in [...]

I've posed a question about the state of things in that thread. Let's see if Eric can/wants to/may answer.

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]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How to modify the makefile to be able to compile an asm file. Code is written for use with AVR-GCC in assembler mode, I never came across compiling assembler file only under AVR-GCC, I am used to compiling c files indeed, and I am no expert with assembler.

Attachment(s): 

Signature: We need more peripherals in DIP packages. Namely, USB, 12-bit ADC, 16-bit timer, cheaper tool as a programmer/debugger coz STK600 is expensive! Atmel Studio 5/6 sucks! coz it brings MS visual studio crap to AVR world..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You just change the extension to .S (that is upper case) and add it to a normal "C" project. avr-gcc knows to hand off any .S files to avr-as

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd prefer the solution as mentioned in the source:

-x assembler-with-cpp

Under windos I'd avoid .S extension becuae it meght get messed up with .s. If you cannot add -x assembler-wih-cpp, you can also use extension .sx which is detected as "assembler with preprocessor" like .S.

Some notes on the code:

  • The ISR messes up SREG. You will get wrong additions in the main loop because of messed-up carry.
  • Instead of

    down_ten:
    	sbiw	r24,10		
    	clr	r23
    	sbc	r26,r23
    	ret

    you can write

    down_ten:
    	sbiw	r24,10		
    	sbci	r26,0
    	ret

  • You can let the binutils machinery setup the vector table for you:
    #include 
    
    #define SFR(X) _SFR_IO_ADDR(X)
    
    .text
    
    ;; Interrupt Service Routine (ISR)
    ;; Vector Names are defined in avr/io.h
    ;; The binutils Machinery will setup the Vector Table for you
    
    .global TIMER2_COMPA_vect
    TIMER2_COMPA_vect:
        ; Toggle PORTB.0
        sbi SFR(PINB), 0
        reti

avrfreaks does not support Opera. Profile inactive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you all indeed, this is a great help to me, I appreciate all the replies, seems people here have extremely good knowledge :- )

I attached makefile, main.c and minidds.S files. There are too many errors when I compile :?

SprinterSB:
I hope I cound have more understanding of what you said, but I did not know how to apply all the things you said, sorry :?

-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Compiling C: main.c
avr-gcc -c -mmcu=attiny2313 -I. -gdwarf-2 -DF_CPU=11059200UL -Os -funsigned-char
 -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,
-adhlns=./main.lst  -std=gnu99 -MMD -MP -MF .dep/main.o.d main.c -o main.o
In file included from main.c:2:
minidds.S:2: warning: return type defaults to 'int'
minidds.S:2: warning: function declaration isn't a prototype
minidds.S: In function 'Copyright':
minidds.S:2: error: expected declaration specifiers before numeric constant
minidds.S:2: error: stray '@' in program
minidds.S:4: error: expected declaration specifiers before ';' token
minidds.S:4: error: expected declaration specifiers before 'This'
minidds.S:4: error: expected declaration specifiers before 'you'
minidds.S:5: error: expected declaration specifiers before 'modify'
minidds.S:6: error: expected declaration specifiers before 'as'
minidds.S:6: error: expected declaration specifiers before 'either'
minidds.S:7: error: expected declaration specifiers before 'of'
minidds.S:9: error: expected declaration specifiers before ';' token
minidds.S:9: error: expected declaration specifiers before 'This'
minidds.S:10: error: expected declaration specifiers before 'but'
minidds.S:10: error: expected declaration specifiers before 'without'
minidds.S:11: error: expected declaration specifiers before 'MERCHANTABILITY'
minidds.S:12: error: expected declaration specifiers before 'GNU'
minidds.S:14: error: expected declaration specifiers before ';' token
minidds.S:14: error: expected declaration specifiers before 'You'
minidds.S:15: error: expected declaration specifiers before 'along'
minidds.S:15: error: expected declaration specifiers before 'if'
minidds.S:16: error: expected declaration specifiers before 'Inc'
minidds.S:18: error: expected declaration specifiers before ';' token
minidds.S:19: error: expected declaration specifiers before ';' token
minidds.S:19: error: expected declaration specifiers before '*' token
minidds.S:20: error: expected declaration specifiers before '*' token
minidds.S:22: error: expected declaration specifiers before ';' token
minidds.S:22: error: expected declaration specifiers before 'Description'
minidds.S:24: error: expected declaration specifiers before ';' token
minidds.S:24: error: expected declaration specifiers before 'Poor'
minidds.S:26: error: expected declaration specifiers before ';' token
minidds.S:26: error: expected declaration specifiers before 'Author'
minidds.S:27: error: expected declaration specifiers before 'Target'
minidds.S:28: error: expected declaration specifiers before 'Date'
minidds.S:30: error: expected declaration specifiers before ';' token
minidds.S:30: error: expected declaration specifiers before 'Code'
minidds.S:31: error: expected declaration specifiers before 'flag'
minidds.S:33: error: expected declaration specifiers before ';' token
minidds.S:34: error: expected declaration specifiers before ';' token
minidds.S:34: error: expected declaration specifiers before 'PB0'
minidds.S:36: error: expected declaration specifiers before ';' token
minidds.S:36: error: expected declaration specifiers before 'PD0'
minidds.S:37: error: expected declaration specifiers before 'PD1'
minidds.S:38: error: expected declaration specifiers before 'PD2'
minidds.S:41: error: expected declaration specifiers before ';' token
minidds.S:41: error: expected declaration specifiers before '*' token
minidds.S:42: error: expected declaration specifiers before '*' token
minidds.S:44: error: expected declaration specifiers before ';' token
minidds.S:45: error: expected declaration specifiers before ';' token
minidds.S:46: error: expected declaration specifiers before ';' token
minidds.S:46: error: expected declaration specifiers before 'Output'
minidds.S:48: error: expected declaration specifiers before ';' token
minidds.S:48: error: expected declaration specifiers before 'f'
minidds.S:50: error: expected declaration specifiers before ';' token
minidds.S:50: error: expected declaration specifiers before 'fClock'
minidds.S:51: error: expected declaration specifiers before 'number'
minidds.S:53: error: expected declaration specifiers before ';' token
minidds.S:53: error: expected declaration specifiers before 'f'
minidds.S:55: error: expected declaration specifiers before ';' token
minidds.S:55: error: expected declaration specifiers before 'f'
minidds.S:57: error: expected declaration specifiers before ';' token
minidds.S:57: error: expected declaration specifiers before 'fMax'
minidds.S:61: error: expected declaration specifiers before ';' token
minidds.S:61: error: expected declaration specifiers before '*' token
minidds.S:62: error: expected declaration specifiers before 'start'
minidds.S:63: error: expected declaration specifiers before '*' token
minidds.S:66: error: stray '#' in program
minidds.S:66: error: expected declaration specifiers before 'include'
minidds.S:78: error: expected declaration specifiers before '*' token
minidds.S:79: error: expected declaration specifiers before 'data'
minidds.S:80: error: expected declaration specifiers before '*' token
minidds.S:82: error: expected declaration specifiers before 'force'
minidds.S:86: error: expected declaration specifiers before numeric constant
minidds.S:104: error: expected declaration specifiers before numeric constant
minidds.S:122: error: expected declaration specifiers before numeric constant
minidds.S:142: error: expected declaration specifiers before numeric constant
minidds.S:162: error: expected declaration specifiers before '*' token
minidds.S:163: error: expected declaration specifiers before 'code'
minidds.S:164: error: expected declaration specifiers before '*' token
minidds.S:169: error: expected declaration specifiers before 'setup'
minidds.S:171: error: expected declaration specifiers before 'set'
minidds.S:174: error: expected declaration specifiers before 'enable'
minidds.S:177: error: expected declaration specifiers before 'global'
minidds.S:180: error: expected declaration specifiers before 'out'
minidds.S:180: error: expected declaration specifiers before 'set'
minidds.S:183: error: expected declaration specifiers before 'set'
minidds.S:185: error: expected declaration specifiers before 'setup'
minidds.S:186: error: expected declaration specifiers before 'setup'
minidds.S:188: error: expected declaration specifiers before 'clear'
minidds.S:190: error: expected declaration specifiers before 'clear'
minidds.S:191: error: expected declaration specifiers before 'clear'
minidds.S:193: error: expected declaration specifiers before 'setup'
minidds.S:195: error: expected declaration specifiers before 'setup'
minidds.S:196: error: expected declaration specifiers before 'to'
minidds.S:201: error: expected declaration specifiers before ';' token
minidds.S:201: error: expected declaration specifiers before 'main'
minidds.S:203: error: expected declaration specifiers before ';' token
minidds.S:203: error: expected declaration specifiers before 'r28'
minidds.S:204: error: expected declaration specifiers before 'r24'
minidds.S:206: error: expected declaration specifiers before ';' token
minidds.S:206: error: expected declaration specifiers before 'add'
minidds.S:207: error: expected declaration specifiers before 'load'
minidds.S:208: error: expected declaration specifiers before 'output'
minidds.S:209: error: expected declaration specifiers before 'repeat'
minidds.S:211: error: expected declaration specifiers before 'LOOP1'
minidds.S:212: error: expected declaration specifiers before numeric constant
minidds.S:213: error: expected declaration specifiers before numeric constant
minidds.S:214: error: expected declaration specifiers before numeric constant
minidds.S:215: error: expected declaration specifiers before numeric constant
minidds.S:216: error: expected declaration specifiers before numeric constant
minidds.S:217: error: expected declaration specifiers before numeric constant
minidds.S:220: error: expected declaration specifiers before '*' token
minidds.S:221: error: expected declaration specifiers before 'communication'
minidds.S:222: error: expected declaration specifiers before '*' token
minidds.S:225: error: expected declaration specifiers before ';' token
minidds.S:225: error: expected declaration specifiers before 'get'
minidds.S:227: error: expected declaration specifiers before 'get_char'
minidds.S:228: error: expected declaration specifiers before 'wait'
minidds.S:229: error: expected declaration specifiers before 'ready'
minidds.S:230: error: expected declaration specifiers before 'no'
minidds.S:231: error: expected declaration specifiers before 'get'
minidds.S:232: error: expected declaration specifiers before 'and'
minidds.S:235: error: expected declaration specifiers before ';' token
minidds.S:235: error: expected declaration specifiers before 'send'
minidds.S:237: error: expected declaration specifiers before 'send_char'
minidds.S:238: error: expected declaration specifiers before 'save'
minidds.S:240: error: expected declaration specifiers before 'wait'
minidds.S:241: error: expected declaration specifiers before 'ready'
minidds.S:242: error: expected declaration specifiers before 'no'
minidds.S:243: error: expected declaration specifiers before 'restore'
minidds.S:244: error: expected declaration specifiers before 'send'
minidds.S:245: error: expected declaration specifiers before 'ans'
minidds.S:248: error: expected declaration specifiers before ';' token
minidds.S:248: error: expected declaration specifiers before 'send'
minidds.S:249: error: expected declaration specifiers before 'as'
minidds.S:250: error: expected declaration specifiers before 'F'
minidds.S:252: error: expected declaration specifiers before ';' token
minidds.S:253: error: expected declaration specifiers before 'send_data'
minidds.S:254: error: expected declaration specifiers before 'save'
minidds.S:255: error: expected declaration specifiers before 'flag'
minidds.S:258: error: expected declaration specifiers before 'zero'
minidds.S:259: error: expected declaration specifiers before 'MSB'
minidds.S:262: error: expected declaration specifiers before 'high'
minidds.S:265: error: expected declaration specifiers before 'mid'
minidds.S:268: error: expected declaration specifiers before 'low'
minidds.S:271: error: expected declaration specifiers before 'terminator'
minidds.S:276: error: expected declaration specifiers before 'add'
minidds.S:283: error: expected declaration specifiers before 'add'
minidds.S:290: error: expected declaration specifiers before 'add'
minidds.S:299: error: expected declaration specifiers before 'subtract'
minidds.S:306: error: expected declaration specifiers before 'subtract'
minidds.S:313: error: expected declaration specifiers before 'subtract'
minidds.S:322: error: expected declaration specifiers before ';' token
minidds.S:322: error: expected declaration specifiers before 'read'
minidds.S:324: error: expected declaration specifiers before 'read_4'
minidds.S:325: error: expected declaration specifiers before 'read'
In file included from main.c:2:
minidds.S:325:42: error: too many decimal points in number
minidds.S:326: error: expected declaration specifiers before 'read'
minidds.S:326:31: error: too many decimal points in number
minidds.S:328: error: expected declaration specifiers before 'read'
minidds.S:328:31: error: too many decimal points in number
minidds.S:330: error: expected declaration specifiers before 'read'
minidds.S:330:31: error: too many decimal points in number
minidds.S:335: error: expected declaration specifiers before ';' token
minidds.S:335: error: expected declaration specifiers before 'Interrupt'
minidds.S:338: error: expected declaration specifiers before 'RX_COMPLETE_INT'
minidds.S:341: error: expected declaration specifiers before 'up'
minidds.S:346: error: expected declaration specifiers before 'up'
minidds.S:351: error: expected declaration specifiers before 'up'
minidds.S:356: error: expected declaration specifiers before 'down'
minidds.S:361: error: expected declaration specifiers before 'down'
minidds.S:366: error: expected declaration specifiers before 'down'
minidds.S:371: error: expected declaration specifiers before 'frequency'
minidds.S:376: error: expected declaration specifiers before 'just'
minidds.S:380: error: expected declaration specifiers before 'request'
minidds.S:382: error: expected declaration specifiers before 'setup'
minidds.S:383: error: expected declaration specifiers before 'setup'
minidds.S:386: error: expected declaration specifiers before 'request'
minidds.S:388: error: expected declaration specifiers before 'setup'
minidds.S:389: error: expected declaration specifiers before 'setup'
minidds.S:392: error: expected declaration specifiers before 'request'
minidds.S:394: error: expected declaration specifiers before 'setup'
minidds.S:395: error: expected declaration specifiers before 'setup'
minidds.S:398: error: expected declaration specifiers before 'request'
minidds.S:400: error: expected declaration specifiers before 'setup'
minidds.S:401: error: expected declaration specifiers before 'setup'
minidds.S:404: error: expected declaration specifiers before 'unknown'
minidds.S:408: error: expected declaration specifiers before 'always'
minidds.S:418: error: expected declaration specifiers before '*' token
minidds.S:419: error: expected declaration specifiers before 'end'
minidds.S:420: error: expected declaration specifiers before '*' token
main.c:8: warning: type of 'C' defaults to 'int'
main.c:6: error: expected '{' at end of input
make: *** [main.o] Error 1

Attachment(s): 

Signature: We need more peripherals in DIP packages. Namely, USB, 12-bit ADC, 16-bit timer, cheaper tool as a programmer/debugger coz STK600 is expensive! Atmel Studio 5/6 sucks! coz it brings MS visual studio crap to AVR world..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You should stop for a while and look at what you are trying to do.

Instead of using Makefile that are more complex than Linux kernel, write it yourself or use a simple shell script.

If there is a small (but obvious) error you will drown in the flood of messages...

Don't include assembly in a C file.

avrfreaks does not support Opera. Profile inactive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay, I removed the include of assembly file from main.c as you suggested, and I added #include in the assembly file as well, things have changed much indeed:

minidds.S:169: Error: number must be positive and less than 64
minidds.S:172: Error: constant value required
minidds.S:175: Error: constant value required
minidds.S:228: Error: constant value required
minidds.S:240: Error: constant value required
make: *** [minidds.o] Error 1

Attachment(s): 

Signature: We need more peripherals in DIP packages. Namely, USB, 12-bit ADC, 16-bit timer, cheaper tool as a programmer/debugger coz STK600 is expensive! Atmel Studio 5/6 sucks! coz it brings MS visual studio crap to AVR world..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Look at _SFR_IO_ADDR() as shown in this example:

http://www.nongnu.org/avr-libc/u...

but read this:

http://www.nongnu.org/avr-libc/u...
http://www.nongnu.org/avr-libc/u...

You may prefer the "#define __SFR_OFFSET 0" solution (I do).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I read them, the example shows how to declare variables in assembler and C files in order to use them in both files, this is not what I need. I only need to compile this assembler file under avr-gcc. Using a main.c will be meaningless indeed, because the code in this assembler file is already complete. There must be a way to compile an assembler file under avr-gcc without the need for a c file. I can't figure out what the command line should look like.

Signature: We need more peripherals in DIP packages. Namely, USB, 12-bit ADC, 16-bit timer, cheaper tool as a programmer/debugger coz STK600 is expensive! Atmel Studio 5/6 sucks! coz it brings MS visual studio crap to AVR world..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just compiler it:

avr-gcc main.S -mmcu=atmega8 -o main.elf

or, if you frefer other extension:

avr-gcc -x assembler-with-cpp main.asm -mmcu=atmega8 -o main.elf

This will use avr-gcc as driver to call assembler and linker. You get the C run time as explained in this example:

#include 

;; Redefine __SFR_OFFSET to 0 so that we
;; get I/O Addresses instead of RAM Addresses
;; for SFRs that are I/O-addressable by
;; IN, OUT, SBI, etc.
#undef __SFR_OFFSET
#define __SFR_OFFSET 0

;; Some convenient Macros

#define F_CPU       1000000
#define IRQs        1000
#define PRESCALE    8

.text

;; The Startup-Code calls main
.global main
main:

    ; Timer2: Mode #2 (CTC) and PRESCALE = 8
    ldi     r24, 1 << WGM21
    sts     TCCR2A, r24
    ldi     r24, 1 << CS21
    sts     TCCR2B, r24

    ; Timer2: 1000 IRQs/Second
    ldi     r24, F_CPU / IRQs / PRESCALE -1
    sts     OCR2A, r24
    
    ; Timer2: Enable Output-Compare Interrupt A
    ldi     r24, 1 << OCIE2A
    sts     TIMSK2, r24

    ; PORTB.1 = 1: Output Push/Pull Drive
    sbi     DDRB, 1

    ; PORTC.3 = 1: Output Push/Pull Drive
    sbi     DDRC, 3

    ; Activate IRQs globaly
    sei

    ; Infinte Main Loop
main_loop:

    ;; Compare irq_count against 100
    ;; Wrap the Read into an atomic Block.
    ;; Notice that SEI has a Latency of 1 so
    ;; that it can be done before the second LDS
    cli
    lds     r24, irq_count
    cpi     r24, lo8 (100+1)
    sei
    lds     r24, irq_count+1
    ;; R24 is unused after the Comparison;
    ;; we may clobber it and use
    ;; SBCI in Absence of a CPCI "Compare with
    ;; Carry Immediate" Instruction
    sbci    r24, hi8 (100+1)

    ;; If irq_count <= 100, clear Port C3
    ;; If irq_count > 100, set Port C3
    ;; This generates a 1Hz Signal with
    ;; Duty-Cycle of 10%
    brlo    1f
    sbi     PORTC, 3
    rjmp    2f
1:  cbi     PORTC, 3  
2:
    rjmp main_loop


;; Interrupt Service Routine (ISR)
;; Vector Names are defined in avr/io.h
;; The binutils/AVR-Libc Machinery will setup
;; the Vector Table for you

;; The ISR toggles Port B1 every Second

.global TIMER2_COMPA_vect
TIMER2_COMPA_vect:
    ;; Start ISR Prologue
    push    r25
    push    r24
    in      r24, SREG
    push    r24
    ;; End Prologue

    ;; Count down irq_count to Zero
    lds     r24, irq_count
    lds     r25, irq_count+1
    sbiw    r24, 1
    brne    1f
    ;; If Zero is reached: Reload the
    ;; IRQ-Counter and ...
    ldi     r24, lo8 (1000)
    ldi     r25, hi8 (1000)
    ;; ... toggle PORTB.1
    sbi     PINB, 1
1:
    ;; Write back irq_count
    sts     irq_count,   r24
    sts     irq_count+1, r25
    
    ;; Epilogue
    pop     r24
    out     SREG, r24
    pop     r24
    pop     r25
    reti

;; .data Section: Static data initialized at
;; Load-Time
.data

irq_count:
    .word 1000

;; Section .data must be initialized at Load-Time.
;; Refer to the respective Bit of Startup-Code
;; to drag it in
.global __do_copy_data

;; Similar for Data in .bss, i.e. initialized
;; to 0 at Load-Time
; .global __do_clear_bss

If you prefer bare metal without any vector- or startup-magic, use -nostartfiles -nostdlib (don't remenber exact writing, consult the documentation)

avrfreaks does not support Opera. Profile inactive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks a lot. I replaced:

.org 0
rjmp	RESET

with

.global 	main

and changed:

RESET:

to

main:

Then I used this command line:

avr-gcc.exe -x assembler-with-cpp minidds.asm -mmcu=attiny2313 -o minidds.elf

Now to produce hex file, I executed this command:

avr-objcopy.exe -j .text -j .data -O ihex minidds.elf minidds.hex

Is omitting .org 0 Ok?
Also, are the command lines I am using correct, is there any thing I am missing?

Signature: We need more peripherals in DIP packages. Namely, USB, 12-bit ADC, 16-bit timer, cheaper tool as a programmer/debugger coz STK600 is expensive! Atmel Studio 5/6 sucks! coz it brings MS visual studio crap to AVR world..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

.org is deprecates since 20 years now...

The commands look reasonable. Also look as a disassembly, e.g. with avr-objdump -d minidds.elf to see if everything is in order.

avrfreaks does not support Opera. Profile inactive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks SprinterSB.

BTW, how can I show the size of the hex file and memory used?

Signature: We need more peripherals in DIP packages. Namely, USB, 12-bit ADC, 16-bit timer, cheaper tool as a programmer/debugger coz STK600 is expensive! Atmel Studio 5/6 sucks! coz it brings MS visual studio crap to AVR world..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The size of teh hex file is not interesting. Wat is interesting is the size occupied on the device. For data in static storage and code you can use avr-size. For dynamic data there is no general clue. Static code analysis is an option but not all programs can be statically analyzed.

avrfreaks does not support Opera. Profile inactive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Great, I am done, thanks to all. Thanks for the info SprinterSB.

avr-gcc.exe -x assembler-with-cpp minidds.asm -mmcu=attiny2313 -Wl,-Map,minidds.map -o minidds.elf

avr-objcopy.exe -j .text -j .data -O ihex minidds.elf minidds.hex

avr-size.exe --mcu=attiny2313 --format=avr minidds.elf

Signature: We need more peripherals in DIP packages. Namely, USB, 12-bit ADC, 16-bit timer, cheaper tool as a programmer/debugger coz STK600 is expensive! Atmel Studio 5/6 sucks! coz it brings MS visual studio crap to AVR world..