Toolchain Package configuration Atmel studio 6

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

Hello,

Im using ATmega8A since a while already, and today i just looked into Tools->Optons in Atmel Studio 6 (and 6.1 too) and noticed that "Toolchains" is set to Atmel ARM 32-bit while ATmega8 that im using is 8-bit AVR.

Is is wrong? Should i change it?

The other options (in Atmel studio 6) are
- AVR Assembler
- Atmel AVR 32-bit
- Atmel AVR 8-bit.

In Atmel studio 6.1 options are:
- Atmel AVR 32-bit (C language or C++ language)
- Atmel AVR 8-bit (C language or C++ language)
- Atmel ARM 32-bit (C language or C++ language)
- AVR Assembler

Also it seems it wont let me change it, i switch it to Atmel AVR 8-bit (C language) click OK but when i open it again it jumps back to Atmel ARM :/

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

That screen allows you to configure the installed toolchains, but it doesn't change the toolchain for the current project. The correct toolchain will be selected for your project when building.

- Dean :twisted:

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

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

OH! So it selects the toolchain automatically from amongst avaliable toolchains?

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

Yup - Studio queries the installed toolchains to figure out which one supports the device you have selected, and uses that automatically. If multiple supported toolchains are installed, you can pick the one you want to use from your Project Options screen (not the general Atmel Studio options screen) as detailed here:

http://www.atmel.no/webdoc/atmel...

- Dean :twisted:

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

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

Dean,
I have a toolchain question: I'm using AS 6.1beta.

I want to use c++ with an atxemga128a1. While creating a new project, if I have C/C++ highlighted, I get a list of projects that includes a gcc c++ executable project selection.
But that doesn't select the right board -- which for me is "User Board". If I select "User Board" from the installed templates, the gcc c++ executable choice goes away.
If I pick "C/C++" and "GCC C++ Executable Project", when I build the default main that the AS makes for me, when I go to program it, selecting the right device, the "Program" button is grayed out, because, I think, something in the project still thinks I have a UC3 board.
When I pick "User Board" and "User Board - XMEGA A", the main that it makes is a .c file. Changing that to .cpp doesn't trigger the use of the avr-g++ tool. I can't find a way to make the main be c++.

How do I make an atxega128A1 C++ project?

Thanks,
madGambol

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

Are you sure that you want a User Board project and not a normal GCC C++ project?

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

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

How do I select the XMEGA part? When I select GCC C++, the only part listed is the UC3 part.
madGambol

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

There's a dropdown that should make you able to choose...

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

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

I am red faced!
That very sequence -- I thought -- didn't work when I tried it a little while ago. I only got the UC3 part.
Thanks for your help!
madGambol

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

meolsen wrote:
Are you sure that you want a User Board project and not a normal GCC C++ project?

Can you explain the choice here?

I don't seem to be able to pick a User Board project AND a C++ project? How can those choices be mutually exclusive?

Thanks,
madGambol

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

In updating AVR Studio 6, I was prompted that my firmware on the Dragon was out of date. I reluctantly clicked "upgrade firmware" expecting it to fail, and it did.

My dragon appears to be broken in that windows won't recognize it.

Searching for similar topics I find 9 year old solutions that don't appear to be applicable to AVR Studio 6.1.

I'd really like to cut loose from Windows, AVR Studio and all the obstacles I'm running into there. I realize this will mean a lot more hand coding, but at least there will be a sense of progress instead of hurdles I can't pass.

I wouldn't have tried the update but it appeared that there was a malfunction in the project type selection -- but the update didn't fix that.

Why did the update to the Dragon fail? I really doubt I'm the first to try that under VirtualBox.

Is there a current solution I missed?
Thanks!
madGambol

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

While this is about the JTAGICE mkII it might help: https://www.avrfreaks.net/index.p...

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:
While this is about the JTAGICE mkII it might help: https://www.avrfreaks.net/index.p...

That almost got it: it went through some operations with LED's flashing, but then I got
"GenericError thrown during firmware upgrade, USB driver timed out"
There is no way to lengthen that timeout to allow it to work? Or do I need to stand up a windows box and retry this procedure?

Ah nuts, I'll just stand up a windows box and retry.

Thanks!
madGambol

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

So, this indicates that something disturbs the USB comms between the VM and the Dragon? Likely something in how the VM is configured? It's been a long time since I dabbled with USB functionality in VirtualBox..

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

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

Also note that on some host OSes (I forget which, Linux perhaps?) the VirtualBox USB stack only emulates two USB endpoints per device, while some tools need three. That leads to some serious issues debugging and using the tools in general under VirtualBox depending on your setup.

- Dean :twisted:

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

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

clawson wrote:
I wrote this tutorial

https://www.avrfreaks.net/index.p...


That was it.
I would have taken quite a while to find that permutation. Quite a while!

Thanks!!!
madGambol

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

madGambol wrote:
clawson wrote:
I wrote this tutorial

https://www.avrfreaks.net/index.p...


That was it.
I would have taken quite a while to find that permutation. Quite a while!

Thanks!!!
madGambol


One point I should have mentioned: a fresh install of AVR Studio 6.1 on a new Win XP couldn't recover the Dragon. I had to use the correct procedure under Virtual Box. And I was greatly relieved that it worked!

Thanks again, everyone.
madGambol

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

madGambol wrote:
meolsen wrote:
Are you sure that you want a User Board project and not a normal GCC C++ project?

Can you explain the choice here?

I don't seem to be able to pick a User Board project AND a C++ project? How can those choices be mutually exclusive?

Thanks,
madGambol


I don't understand what's going on behind the scenes in making this choice. Are the choices of a USER_BOARD and C++ project mutually exclusive?

The menu around the choice doesn't appear to operate the way someone might expect. When you click on the C++ choice, then the USER_BOARD choice, you get the USER_BOARD choice but not the C++ selection.

Have I had too few cups of coffee or too many?

Thanks,
madGambol

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

ASF is a C library, and while you can tack C++ files onto an ASF project it isn't tested enough in a C++ environment for us to supply C++ user board templates. In that respect they are "mutually exclusive" however there's nothing stopping you from making a new User Board project and adding C++ files to it.

- Dean :twisted:

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

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

abcminiuser wrote:
ASF is a C library, and while you can tack C++ files onto an ASF project it isn't tested enough in a C++ environment for us to supply C++ user board templates. In that respect they are "mutually exclusive" however there's nothing stopping you from making a new User Board project and adding C++ files to it.

- Dean :twisted:


Dean,
That didn't work, but maybe I misunderstood what you meant; I tried to add the cpp file to my c project. I couldn't add a cpp file directly through the "Add -> New Item" mechanism, so I added a .c file and renamed it through the IDE's "rename" operation -- so I was expecting the file to be recognized.

The IDE doesn't appear to want to compile that file. I put a syntax error into it and got no warning or complain -- hence, my conclusion its not compiling.

Is this sort of thing in the manual -- should I RTFM?

Thanks,
madGambol

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

madGambol wrote:
abcminiuser wrote:
ASF is a C library, and while you can tack C++ files onto an ASF project it isn't tested enough in a C++ environment for us to supply C++ user board templates. In that respect they are "mutually exclusive" however there's nothing stopping you from making a new User Board project and adding C++ files to it.

- Dean :twisted:


Dean,
That didn't work, but maybe I misunderstood what you meant; I tried to add the cpp file to my c project. I couldn't add a cpp file directly through the "Add -> New Item" mechanism, so I added a .c file and renamed it through the IDE's "rename" operation -- so I was expecting the file to be recognized.

The IDE doesn't appear to want to compile that file. I put a syntax error into it and got no warning or complain -- hence, my conclusion its not compiling.

Is this sort of thing in the manual -- should I RTFM?

Thanks,
madGambol


Dean,
The g++ compiler isn't in the tool chain -- how do I add that to compile c++ files?

Thanks,
madGambol

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

Hrm, I just tried this and it seems that the CPP toolchain isn't loaded into the project like I thought it was when a C++ file was detected (I was thinking of adding ASF modules to a C++ project which works with a warning -- but no board template).

I guess Senthil or someone else from the Toolchain/Studio teams will have to chime in with the magic project file modifications needed to substitute in the C++ toolchain in an ASF project template.

- Dean :twisted:

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

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

Dean,
Is anyone going to answer this question?
I and others are interested, I would expect.
Thanks!
madGambol

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

I'll see if I can scrounge up a developer with the relevant know-how to force Studio into compiling C++ files in a regular C project.

- Dean :twisted:

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

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

Sorry I'm late responding - flagged the response from the Tools team, then it got buried.

The current workaround for this is to add "-x c++" to the compiler flags (open the C++ file, then open the Properties window) to force the C++ compiler to be invoked. It's only a workaround at the moment but we'll look into better support in the future for C++ in ASF projects.

- Dean :twisted:

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

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

Hello,

I have similar problems... I've to use cpp files in my User-Board project.

At first, I'm using Atmel Studio 6 (6.1.2674 - Service Pack 1) and I've created an "User Board - UC3 C0/C1/C2" project to program my AT32UC3C1512C.

Until now everything works fine. I use ASF and c-files to init and start my simple application. Now I have to implement the existing application (a colleague already wrote some application code on a 128Atmega). There are some cpp files. If I use them I always get the error "undefined reference" - I think it's because the cpp files aren't compiled. In my toolchain the c++ compiler ist also missing.
I've tried your workaround, without any success... please see the attachment.

Do you have any idea what I'm doing wrong?

My colleague found another possible solution... But it's very painful (http://asf.atmel.com/bugzilla/sh...)

Thank you very much.

K-laus

Attachment(s): 

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

Quote:

I think it's because the cpp files aren't compiled.

Surely, when you build, you can see in the Output tab whether the files are built or not? It certainly looks like the file containing InitUsart should be build from the Solution Explorer so I wonder if it contains code that prevents such functions being compiled if the target is not mega128? Something like:

#ifdef __AVR_ATmega128__
void InitUsart(...) {
  code
}
#endif

Also I guess it's obvious but the .cpp does include the .h doesn't it? If not the functions might be built without extern "C" linkage.

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

Hello,

thank you for the very fast answer.

I've checked the build output and can't find my USART_SPS.cpp file...

The header is included in the cpp. I've also added following in my header:

#ifdef __cplusplus
extern "C" {
#endif
void InitUSART (void);
...
#ifdef __cplusplus
};
#endif

At the moment I've copied single functions from the other project and adapt them to my solution (something like a Fifo...). Before I do that, the USART_SPS.cpp was a simple c (everything works fine). Then I renamed it to cpp. Could this be the problem?

K-laus

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

Quote:

Before I do that, the USART_SPS.cpp was a simple c (everything works fine). Then I renamed it to cpp. Could this be the problem?

Perhaps. What if you simply remove the file from the project and then add it again?

Was he project set up as a C++ project in the first place, or as a C project?

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

It's fine (usually) to just rename .c to .cpp but, as the .h appears to be doing, you have to ensure that anything that crosses the C++ to C barrier is extern "C".

Of more interest is:

Quote:

I've checked the build output and can't find my USART_SPS.cpp file...

yet I can see it listed in the Solution Explorer image. I think AS6 probably has the feature of VS2010 (on which it is based) that files listed can be right-clicked and have their properties set to "do not build". (or words to that effect). I wonder if that is true for USART_SPS.cpp ?

If the file was "missing" I would have expected a compile time error to say the file could not be found.

You may also want to study the "Makefile" in the build directory and see if that file was listed within.

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

Hello,

it was set up as a User-Board project. I couldn't choose between C or C++, there was only C/C++. So I thought I could use both. But You are right, there is no c++ compiler when I have a look at the project toolchain. That's the reason I testet the workarount with adding "-x c++" to the compiler flags... but unfortunately with no success....

Shouldn't be there a c++ compiler in my toolchain?

I'll try your suggestion (remove and add again) the day after tomorrow, because tomorrow are only conferences.

K-laus

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

Quote:

But You are right, there is no c++ compiler when I have a look at the project toolchain.

Yes there is. When avr32-gcc is invoked with a .cpp file it passes it to avr32-g++ which is the GNU C++ compiler.

EDIT: Just tried what you did and when I added a new file (which I called plus.cpp) I found that by default if I right-click and look at properties the "Build action" is set to "None". As such the function I had put in it was an "undefined reference". After I changed the build action to "Compile" nothing happened and it still wasn't passed to the compiler.

I think we're going to need to hear from someone at Atmel at this stage as this certainly looks like a problem.

EDIT: Oh and when I look at the generated Makefile it seems to have rules for handling .c and .S files but nothing for .cpp ?!?

Maybe "User Board" projects don't support C++?

EDIT2: If I go back to the start of Project creation and forget "User Boards" but just elect for a generic C++ Executable project it has rules in the Makefile for a .cpp file (which it passes direct to avr32-g++)

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

Hello JohanEkdahl , hello clawson,

thank you very much for your help.

To complete:
-Removing and adding again doesn't help
-The build action is on "compile"
-Make file doesn't list the file

I'll write directly to Atmel to tell my problem. If there is a solution I'll tell you of course.

K-laus

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

Hello gents. Hopefully I'm not too far off the topic. I'm new to Atmel Studio. I'd like to know what other programmers/debuggers I can use apart from the Atmel ones. Can one use third-party ones?

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

In general not directly, you would have to set up an external tool inside the IDE and make it call avrdude.exe or other third party programming tool. For debuggers, there's no integrated solution at all.

If the third party programmer or debugger clones the Atmel tools and uses the same protocols they will work without modification, but there are very, very few clone debuggers on the market.

- Dean :twisted:

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

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

If you want debugging as well as programming just spend $50 on an Atmel Dragon. It's your cheapest option to include debugging. If you are happy with programming alone then a $3 USBAsp driven by avrdude.exe (which can be launched by a button you configure in AS6) is the cheapest/easiest option.

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

Hello,

I get an answer from atmel and now it seems like I can use c++ and asf :D

Here is the answer from atmel support:
The two workarounds which are already mentioned in freaks link (adding –x cpp option) and another one in the bug (comment#7) you have mentioned. I hope you have already tried them both.
One another option would be to take a C++ project (File -> New Project -> GCC C++ Executable Project) and add ASF files to it through ASF wizard as you do for other C projects.
This feature is supported in latest Atmel Studio 6.1 (+service pack 1).
It will be much easier than the previous method. However you will get a warning when opening ASF wizard for first time that the features are not fully tested and user board file should be added (which you should add by yourself).
You can continue using provided taken care of these things.

If I do that, I only have to do some small adaptions (like 'extern "C"' in the c files ...).
With one exception: I get the error "multiple definition of '_start'" adn "multiple definition of '_stext'". To solve the errors I have to set the nostartfiles option in the linker settings. Does anyone know which consequences do I have to expect when setting nostartfiles?

Thank you very much!

K-laus

Attachment(s): 

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

Quote:

Does anyone know which consequences do I have to expect when setting nostartfiles?

The manual has some details:

http://gcc.gnu.org/onlinedocs/gc...

Basically if I build a virtually empty program:

#include 

char text[] = "hello";
int16_t data[10];

int main(void) {
}

then when I build I get:

Disassembly of section .text:

00000000 <__vectors>:
   0:	29 c0       	rjmp	.+82     	; 0x54 <__ctors_end>
   2:	00 00       	nop
   4:	42 c0       	rjmp	.+132    	; 0x8a <__bad_interrupt>
   6:	00 00       	nop
   8:	40 c0       	rjmp	.+128    	; 0x8a <__bad_interrupt>
   a:	00 00       	nop
   c:	3e c0       	rjmp	.+124    	; 0x8a <__bad_interrupt>
   e:	00 00       	nop
  10:	3c c0       	rjmp	.+120    	; 0x8a <__bad_interrupt>
  12:	00 00       	nop
  14:	3a c0       	rjmp	.+116    	; 0x8a <__bad_interrupt>
  16:	00 00       	nop
  18:	38 c0       	rjmp	.+112    	; 0x8a <__bad_interrupt>
  1a:	00 00       	nop
  1c:	36 c0       	rjmp	.+108    	; 0x8a <__bad_interrupt>
  1e:	00 00       	nop
  20:	34 c0       	rjmp	.+104    	; 0x8a <__bad_interrupt>
  22:	00 00       	nop
  24:	32 c0       	rjmp	.+100    	; 0x8a <__bad_interrupt>
  26:	00 00       	nop
  28:	30 c0       	rjmp	.+96     	; 0x8a <__bad_interrupt>
  2a:	00 00       	nop
  2c:	2e c0       	rjmp	.+92     	; 0x8a <__bad_interrupt>
  2e:	00 00       	nop
  30:	2c c0       	rjmp	.+88     	; 0x8a <__bad_interrupt>
  32:	00 00       	nop
  34:	2a c0       	rjmp	.+84     	; 0x8a <__bad_interrupt>
  36:	00 00       	nop
  38:	28 c0       	rjmp	.+80     	; 0x8a <__bad_interrupt>
  3a:	00 00       	nop
  3c:	26 c0       	rjmp	.+76     	; 0x8a <__bad_interrupt>
  3e:	00 00       	nop
  40:	24 c0       	rjmp	.+72     	; 0x8a <__bad_interrupt>
  42:	00 00       	nop
  44:	22 c0       	rjmp	.+68     	; 0x8a <__bad_interrupt>
  46:	00 00       	nop
  48:	20 c0       	rjmp	.+64     	; 0x8a <__bad_interrupt>
  4a:	00 00       	nop
  4c:	1e c0       	rjmp	.+60     	; 0x8a <__bad_interrupt>
  4e:	00 00       	nop
  50:	1c c0       	rjmp	.+56     	; 0x8a <__bad_interrupt>
	...

00000054 <__ctors_end>:
  54:	11 24       	eor	r1, r1
  56:	1f be       	out	0x3f, r1	; 63
  58:	cf e5       	ldi	r28, 0x5F	; 95
  5a:	d4 e0       	ldi	r29, 0x04	; 4
  5c:	de bf       	out	0x3e, r29	; 62
  5e:	cd bf       	out	0x3d, r28	; 61

00000060 <__do_copy_data>:
  60:	10 e0       	ldi	r17, 0x00	; 0
  62:	a0 e6       	ldi	r26, 0x60	; 96
  64:	b0 e0       	ldi	r27, 0x00	; 0
  66:	e6 e9       	ldi	r30, 0x96	; 150
  68:	f0 e0       	ldi	r31, 0x00	; 0
  6a:	02 c0       	rjmp	.+4      	; 0x70 <__do_copy_data+0x10>
  6c:	05 90       	lpm	r0, Z+
  6e:	0d 92       	st	X+, r0
  70:	a6 36       	cpi	r26, 0x66	; 102
  72:	b1 07       	cpc	r27, r17
  74:	d9 f7       	brne	.-10     	; 0x6c <__do_copy_data+0xc>

00000076 <__do_clear_bss>:
  76:	20 e0       	ldi	r18, 0x00	; 0
  78:	a6 e6       	ldi	r26, 0x66	; 102
  7a:	b0 e0       	ldi	r27, 0x00	; 0
  7c:	01 c0       	rjmp	.+2      	; 0x80 <.do_clear_bss_start>

0000007e <.do_clear_bss_loop>:
  7e:	1d 92       	st	X+, r1

00000080 <.do_clear_bss_start>:
  80:	aa 37       	cpi	r26, 0x7A	; 122
  82:	b2 07       	cpc	r27, r18
  84:	e1 f7       	brne	.-8      	; 0x7e <.do_clear_bss_loop>
  86:	02 d0       	rcall	.+4      	; 0x8c 
88: 04 c0 rjmp .+8 ; 0x92 <_exit> 0000008a <__bad_interrupt>: 8a: ba cf rjmp .-140 ; 0x0 <__vectors> 0000008c
: char text[] = "hello"; int16_t data[10]; int main(void) { 8c: 80 e0 ldi r24, 0x00 ; 0 8e: 90 e0 ldi r25, 0x00 ; 0 90: 08 95 ret 00000092 <_exit>: 92: f8 94 cli 00000094 <__stop_program>: 94: ff cf rjmp .-2 ; 0x94 <__stop_program>

The linker has provided a jump at 0, then a default interrupt vector table, then some startup code (54:) that clears R1 (__zero_reg__), writes it to SREG (so clears interrupts), sets the default stack pointer and this is followed by loops that copy the .data ("hello") and clear .bss (ie data[]). Then there is code to "call main" which is how the main() function is finally entered. beyond this is code to catch execution should main() return (it does).

If I now build that same code with -nostartfiles I get:

Disassembly of section .text:

00000000 <__ctors_end>:
   0:	10 e0       	ldi	r17, 0x00	; 0
   2:	a0 e6       	ldi	r26, 0x60	; 96
   4:	b0 e0       	ldi	r27, 0x00	; 0
   6:	ec e2       	ldi	r30, 0x2C	; 44
   8:	f0 e0       	ldi	r31, 0x00	; 0
   a:	02 c0       	rjmp	.+4      	; 0x10 <__zero_reg__+0xf>
   c:	05 90       	lpm	r0, Z+
   e:	0d 92       	st	X+, r0
  10:	a6 36       	cpi	r26, 0x66	; 102
  12:	b1 07       	cpc	r27, r17
  14:	d9 f7       	brne	.-10     	; 0xc <__zero_reg__+0xb>

00000016 <__do_clear_bss>:
  16:	20 e0       	ldi	r18, 0x00	; 0
  18:	a6 e6       	ldi	r26, 0x66	; 102
  1a:	b0 e0       	ldi	r27, 0x00	; 0
  1c:	01 c0       	rjmp	.+2      	; 0x20 <.do_clear_bss_start>

0000001e <.do_clear_bss_loop>:
  1e:	1d 92       	st	X+, r1

00000020 <.do_clear_bss_start>:
  20:	aa 37       	cpi	r26, 0x7A	; 122
  22:	b2 07       	cpc	r27, r18
  24:	e1 f7       	brne	.-8      	; 0x1e <.do_clear_bss_loop>

00000026 
: char text[] = "hello"; int16_t data[10]; int main(void) { 26: 80 e0 ldi r24, 0x00 ; 0 28: 90 e0 ldi r25, 0x00 ; 0 2a: 08 95 ret

So the data setup loops are still there but all the init stuff (stack pointer etc) and the pre-filled vector table and the stuff to catch a return from main() have gone. It becomes your responsibility to provide some/all of those things (as this was built for a mega16 it would be very unwise not to provide code to set SP!).

==========================================================================

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

Hello clawson,

thank you very much for the infos.

Now I want to use the startup code. But as you can see above I got some errors. It's because the are 2 "startup codes" - startup_uc3.s and crt0.o, isn't it?
Where can I find/read, what do I have to do to use only one of these both? And which one should I use?

Thank you very much.

K-laus

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

I can't help with AVR32 questions, you are best asking about those in one of the AVR32 forums.