Error        ld returned 1 exit status    FreeRTOS_Tutorial    collect2.exe    0

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

 

I am new here I have been followed youtube video https://www.youtube.com/watch?v=dMM9u_1G5Qo to port source code on ATmeg32A. 

 

Atmel Studio 7 

Device: ATmega32A
OS: Window 10

Free RTOS :10.3.0

 

Problem:
When trying the Build code , i obtain the following 

 

Severity    Code    Description    Project    File    Line
Error        ld returned 1 exit status    FreeRTOS_Tutorial    collect2.exe    0
 

I have sent my time to search about errors I do not understand how to remove this error 

This topic has a solution.
Last Edited: Mon. Mar 2, 2020 - 04:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your looking in the wrong place. You are looking at the consequence not the reason.

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

clawson wrote:

Your looking in the wrong place. You are looking at the consequence not the reason.

 

Can you tell me what's the reason and how to remove error 

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

You haven't told us what the actual error is yet (my point above). What you have said so far is that at the very end of the build the linker has told you it cannot link. You've given no detail (which will have been shown earlier in the build) as to why ut could not link.

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

I am trying to port free rtos as shown in video. I did every step as mention in video but bad luck I get error 

This is screenshot I can't see any reason why compiler can't link  What exactly information require to remove error ?

 

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

Go to the output tab, copy paste the build log from it here.

:: Morten

 

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

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

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

meolsen wrote:
Go to the output tab, copy paste the build log from it here.

 

I did look at the output tab, but it gives me nothing useful other than " Severity    Code    Description    Project    File    Line
Error        ld returned 1 exit status    FreeRTOS_Tutorial    collect2.exe    0"

 

I have attached my complete project

Attachment(s): 

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

 

I just loaded your .atsln and built it and get:

 

 

while usually I am not a great fan of "Error List" as it is almost entirely pointless there's already enough there to know this build had SERIOUS build errors. IF I switch to the Output tab (the only thing actually worth looking at if you want to know about build errors) and concentrate on just the very first error output (99 times out of 100 if you fix that you fix the next 50..100!) I see:

 

		FreeRTOS/Source/portable/MemMang/heap_2.o: In function `pvPortMalloc':
C:\Users\Vijendra\Documents\Atmel Studio\7.0\FreeRTOS_Tutorial\FreeRTOS_Tutorial\FreeRTOS\Source\portable\MemMang\heap_2.c(119,1): error: multiple definition of `pvPortMalloc'
		FreeRTOS/Source/portable/MemMang/heap_1.o:C:\Users\Vijendra\Documents\Atmel Studio\7.0\FreeRTOS_Tutorial\FreeRTOS_Tutorial\Debug/../FreeRTOS/Source/portable/MemMang/heap_1.c:70: first defined here

So "pvPortMalloc" is defined at line 119 in heap_2.c and line 70 in heap_1.c

 

I don't know FreeRTOS that well but is this one of these "either / or" things where you were supposed to choose one malloc() or another but not both perhaps?

 

Actually if I open and look at just heap_1.c I see:

/*
 * The simplest possible implementation of pvPortMalloc().  Note that this
 * implementation does NOT allow allocated memory to be freed again.
 *
 * See heap_2.c, heap_3.c and heap_4.c for alternative implementations, and the
 * memory management pages of http://www.FreeRTOS.org for more information.
 */

I have not looked at this in depth but "alternative" to me suggests using 1, 2, 3 OR 4 not 1 AND 2 !

 

In fact here:

 

all 5 of those have the icon to show they will be compiled as part of the project. Surely it's supposed to look more like:

 

 

In this I have used file properties on 4 of the 5 files to set their "Build Action" to be "None" so now only heap_1.c will be part of the build.

 

With that I get:

Build succeeded.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

which is what I think you are looking for.

 

Oh and did I mention that "Error List" is rubbish? If you get build errors ignore that and always switch to "Output" and then always concentrate on clearing just the very top error. I just did and it instantly fixed multiple build problems ;-)

 

PS: reading about heap_1.c I'm guessing that unless resources are VERY tight then you do not want to choose that one - it is "alloc only" - you cannot "free()". It's not going to be much use except in the most limited of designs.

 

BTW is a mega32 really a good choice for an RTOS anyway? I thought it only had 1K of SRAM ?? EDIT: wrong again! so it has 2K, that might just be OK for an RTOS (aka "RAM eater"!)

 

Last Edited: Mon. Mar 2, 2020 - 09:45 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

 

I just loaded your .atsln and built it and get:

 

 

in fact here:

 

 

all 5 of those have the icon to show they will be compiled as part of the project. Surely it's supposed to look more like:

In this I have used file properties on 4 of the 5 files to set their "Build Action" to be "None" so now only heap_1.c will be part of the build.

 

With that I get:

Build succeeded.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

which is what I think you are looking for.

 

Oh and did I mention that "Error List" is rubbish? If you get build errors ignore that and always switch to "Output" and then always concentrate on clearing just the very top error. I just did and it instantly fixed multiple build problems ;-)

 

 

Thanks a lot I missed to delete file in folder MemMang  So when i use heap_4.c  and I delete the remaining files, the codes do not give any error.

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

There's no need to delete (unless you are using Git/SVN in which case I guess it doesn't matter). As I showed above just set all but heap_4.c to "no compile". This is one of the nice features of AS7 being based on Visual Studio so it inherits powerful behaviour like this.

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

clawson wrote:

unless you are using Git/SVN in which case I guess it doesn't matter

I heard a lot about Git but I have never done worked on it. Where it can be used in the process of project development. Does Atmel studio 7 have inbuilt git features or do I have to download and install it? 

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

If this had been my project then the very first thing I would have done after unpacking the files as they come in the distribution would have been "gti init" which would turn the directories into a Git repository. I'd then "git add ." which recursively adds all the files to the repository. What this does (in effect though not exactly in practice) is create a .git subdirectory and in that a kind of "snapshot" of the files as they have started out. Now I can do what ever edits I like to the files. At any point "git status" will tell me whihc ones have changes. I can "git diff filename" on any one to see exactly how it has been changed since it was snapshotted. When I am happy with the changes in various files ("version 2") I can "git add filename" for each one I want to remember the changes on. When I have added all the ones I want to be part of this changeset I can "git commit" which will start an editor into which I can enter a description of what the change involves - perhaps something like "add support for UART". When I exit from the editor having updated such a message those files are committed to the repository. So now there are two versions there. I can continue to work like this, committing changesets with versions of changed files as I develop the project. But the great thing is that this entire history is kept. So if at version 5 I find that something is not working when it had previously I can "git log filename" to find all the places I changed it. I can pull out an older version so I can repair what I inadevrtently changed. On a more short term basis I can just "hack the files about" however I like to try some experiment or other because I can easily put them back how they were before (instead of git add to store my local changes I can "git checkout filename" to get it back to how it was before I started tinkering.

 

If you are in the habit (say) of every few days Zipping up your project directory and storing it somewhere as projectgfoo_v17.zip or something like that then Git is for you.

 

Having said all that Git is actually aimed at huge projects with 10's or even 100's of engineers all working on it at the same time but if you want to do "revision control" (which is what Git and SVN offer) but just want to use it for a one man, simple project then actually SVN is far easier to use. I did SVN for about 5 years then have spent the last 10 using Git. Only after about 10 years have I started to understand about 5% of what you can do with Git. I had a pretty clear view of exactly how everything in SVN works previously after just a few years. What's more, on Windows there's a brilliant "helper" for SVN called TortoiseSVN which integrates with the Windows Explorer so icons are overlayed on to files in directories that are under SVN control to show yo their status and selecting a file and right clicking gives access to all the SVN operations you might want to perform on it and so on.

So if you wanted to "tinker" I would start with TortoiseSVN.

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

clawson wrote:
ATmega32A

 

#include <avr/io.h>
#include <util/delay.h>

#ifndef F_CPU
#define F_CPU 16000000UL // 16 MHz clock speed
#endif

int main(void)
{
	DDRC = 0xFF; //Nakes PORTC as Output

    /* Replace with your application code */
    while (1)
    {
		    PORTC = 0xFF; //Turns ON All LEDs
		    _delay_ms(1000); //1 second delay
		    PORTC= 0x00; //Turns OFF All LEDs
		    _delay_ms(1000); //1 second delay
    }

}

 

I don't find hex file in debug folder

 

 

I saw in both folder  FreeRTOS and inc hex file is not found.  Where is the hex file can be found 

Last Edited: Tue. Mar 3, 2020 - 12:17 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Find the directory where the .atsln and .cproj files for your project are. Beneath that there may be Debug or Release (depending on which build type you chose) the .hex should be in there. For example:

D:\FreeRTOS_Tutorial>dir *.hex /s
 Volume in drive D is DATA
 Volume Serial Number is 1CF4-86D6

 Directory of D:\FreeRTOS_Tutorial\FreeRTOS_Tutorial\Debug

02/03/2020  09:40               447 FreeRTOS_Tutorial.hex
               1 File(s)            447 bytes

     Total Files Listed:
               1 File(s)            447 bytes
               0 Dir(s)  77,155,233,792 bytes free

That's where it put the .hex file when I built your example project the other day.

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

clawson wrote:

Find the directory where the .atsln and .cproj files for your project are. Beneath that there may be Debug or Release (depending on which build type you chose) the .hex should be in there. For example:

D:\FreeRTOS_Tutorial>dir *.hex /s
 Volume in drive D is DATA
 Volume Serial Number is 1CF4-86D6

 Directory of D:\FreeRTOS_Tutorial\FreeRTOS_Tutorial\Debug

02/03/2020  09:40               447 FreeRTOS_Tutorial.hex
               1 File(s)            447 bytes

     Total Files Listed:
               1 File(s)            447 bytes
               0 Dir(s)  77,155,233,792 bytes free

That's where it put the .hex file when I built your example project the other day.

 

It say file not found 

 

C:\Users\Rahul\Documents\Atmel Studio\7.0\FreeRTOS_Tutorial\FreeRTOS_Tutorial>dir *.hex /s
 Volume in drive C has no label.
 Volume Serial Number is 0AD9-4002
File Not Found

 

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

The it presumably had some error when you built it?

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

clawson wrote:

The it presumably had some error when you built it?

Hi clawson

I repeated all Steps again, I do not understand what I am missing. Did you get the hex file when you build the code?

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

Yes, you can see the very thing in #15

 

However I did notice something "odd" when I loaded your project and built it. I simply unzipped it to D:\FreeRTOS_Tutorial\ so absolutely every file in the project was most definitely within that directory tree. However when I built (the original with the multiple heap thing) it I saw error messages like:

C:\Users\Vijendra\Documents\Atmel Studio\7.0\FreeRTOS_Tutorial\FreeRTOS_Tutorial\FreeRTOS\Source\portable\MemMang\heap_3.c(59,1): error: multiple definition of `pvPortMalloc'
		FreeRTOS/Source/portable/MemMang/heap_1.o:D:\FreeRTOS_Tutorial\FreeRTOS_Tutorial\Debug/../FreeRTOS/Source/portable/MemMang/heap_1.c:70: first defined here

That is a very curious error because my own PC simply does ont have a "C:\Users\Vijendra\..." directory tree.

 

So there's something in this project that is (erroneously) making reference to C:\Users\Vijendra\Documents\Atmel Studio\7.0\FreeRTOS_Tutorial\... so I wonder if, on your machine, where I'm guessing that directory tree DOES exist whether it's actually building your .hex file under there somewhere?

 

EDIT: sorry I should have read #15 more closely - I see that is where you were looking and expecting to find it. In that case "Rebuild Solution" then switch to the Output tab and find the lines that say something like:

		Building target: FreeRTOS_Tutorial.elf
		Invoking: AVR/GNU Linker : 5.4.0
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe" -o FreeRTOS_Tutorial.elf  FreeRTOS/Source/croutine.o FreeRTOS/Source/event_groups.o FreeRTOS/Source/list.o FreeRTOS/Source/portable/GCC/ATMega323/port.o FreeRTOS/Source/portable/MemMang/heap_1.o FreeRTOS/Source/queue.o FreeRTOS/Source/stream_buffer.o FreeRTOS/Source/tasks.o FreeRTOS/Source/timers.o main.o   -Wl,-Map="FreeRTOS_Tutorial.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mmcu=atmega32a -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.3.300\gcc\dev\atmega32a"  
		Finished building target: FreeRTOS_Tutorial.elf
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures  "FreeRTOS_Tutorial.elf" "FreeRTOS_Tutorial.hex"
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom  --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0  --no-change-warnings -O ihex "FreeRTOS_Tutorial.elf" "FreeRTOS_Tutorial.eep" || exit 0
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "FreeRTOS_Tutorial.elf" > "FreeRTOS_Tutorial.lss"
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O srec -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "FreeRTOS_Tutorial.elf" "FreeRTOS_Tutorial.srec"
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "FreeRTOS_Tutorial.elf"
		   text	   data	    bss	    dec	    hex	filename
		    152	      0	      0	    152	     98	FreeRTOS_Tutorial.elf

Do you see all the objcopy's completing OK as shown in this ? The line that finally creates the .hex is:

"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures  "FreeRTOS_Tutorial.elf" "FreeRTOS_Tutorial.hex"

 

Last Edited: Wed. Mar 4, 2020 - 09:24 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
I see that is where you were looking and expecting to find it. In that case "Rebuild Solution" then switch to the Output tab and find the lines that say something like:

My output tab is not showing anything like as you shown. I am using windows 10 operating system

 

 

 

 

 

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

Well that is not actually building anything. So throw away this broken project, start a new one and try again.

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

Hi All,

Thought of chipping in. To be able to use Atmel studio needs patience and application. For new users it is a very frustrating. For those aspiring to be experts in embedded world it is good to practice using AS. 
I find Arduino IDE along with Mini and Mighty cores by MCUDUDE is good. The compiled code can be uploaded with an USBASP(AS uses an ATmel ICE... an expensive proposition.). To use a USBASP you need to use AVRDUDE’s command  by navigating to the present working directory and calling avrdude....

My thoughts.....