Build SIMULINK generated code in ATMEL Studio 7.0

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

For a project I am working on, I am trying to build a MATLAB/Simulink generated code in Atmel Studio 7.0. I am getting a bunch of errors which I am unable to decipher. I have included all the necessary header files.

Screen shot of the errors

Last Edited: Mon. May 18, 2020 - 06:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Greetings and Welcome to AVR Freaks!

 

For starters, it is looking for a bunch of header files. The Error List tells you exactly what is missing. 

 

Normally, you put header files in the same directory as the code files. You DO NOT "Add" them to the project. The #include "headername.h" does that.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

Last Edited: Mon. May 18, 2020 - 07:11 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It appears to have created -l (link targets) for files that are really supposed to be compiled?!!

 

How did you actually generate this project?

 

Also, hint for the future, The "Error List" is worse than useless. If you want to know how/why a build failed switch to viewing the "Output" tab.

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

Hello Jim, Thanks for the reply. I had included all files in the same folder already and I think that as @clawson suggested the issue is with the linker.

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

Actually what I have done is created a project in Simulink using "Simulink Support package for Arduino" Toolbox. Now when I build the project in Simulink itself, the project executes properly on to the Arduino Mega2560, but after generating c code specific to this hardware from the Simulink model and trying to compile it inside Atmel Studio the linker errors are arising. I haven't figured the solution yet but thanks for at least pointing me in the right direction. 

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

ad_jatkar wrote:
and trying to compile it inside Atmel Studio the linker errors are arising
So you have used the "create project from Arduino sketch" function inside AS7 ?

 

Or how else dd you create the AS7 project?

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

I did not use the  "create project from Arduino sketch" inside AS7. I created the entire project using Simulink and  then imported it to AS7 and tried to build it. I am not able to find any documentation regarding that error, can you please tell me some way to fix it? At least if you tell me what is the topic I should look into, that would be also very helpful.

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

ad_jatkar wrote:
I created the entire project using Simulink and  then imported it to AS7
Seems like Simulink does NOT know how to create AS7 projects then !

 

As you only posted a picture and not the actual contents of the Build Output tab I cannot tell exactly what your error is but if I am reading the picture right it looks like it has used -l (lower case L) when this is completely the wrong thing to do !!

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

ad_jatkar wrote:
I did not use the  "create project from Arduino sketch" inside AS7.

You need to!

 

ad_jatkar wrote:
I ... created a project in Simulink using "Simulink Support package for Arduino"

So it will have created an Arduino Sketch - that is not an Atmel Studio Project!

 

You need to use the "create project from Arduino sketch" to turn that into an Atmel Studio project.

 

Atmel Studio will not "just build" an Arduino Sketch - it needs to be imported/converted via the proper process.

 

Perhaps you need to go back to Simulink to find if there is a way for it to directly create an Atmel Studio Project ... ?

 

EDIT

 

As clawson said, your screenshot of the Error List gives very little useful information - you need to go to the 'Output' Window for that.

 

For illustrated instructions on how to do that, see: https://www.avrfreaks.net/commen...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Mon. May 18, 2020 - 01:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Seems like Simulink does NOT know how to create AS7 projects then

 

It doesn't seem to claim that it does:

 

https://www.mathworks.com/hardware-support/atmel.html

 

All they say is:

 

MathWorks wrote:
MATLAB Coder™Simulink Coder™, and Embedded Coder® generate ANSI/ISO C/C++ code that can be compiled and executed on Atmel® processors

 

So it just gives plain ol' ANSI 'C' - it's up to the user to put that into a Project in the IDE of their choice

 

But they do add:

MathWorks does not offer an Embedded Coder Hardware Support Package for the devices listed on this page. Third Party Connection hardware and software products may exist

 

ad_jatkar wrote:
using "Simulink Support package for Arduino" Toolbox

 

So is that some 3rd-party tool ?

 

@ad_jatkar - so what, exactly, are you using? give a link!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Mon. May 18, 2020 - 02:22 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh it may well claim to but unless this all stems from an original configuration error inside Simulink (possible?) it seems it does not know what GCC uses -l for (the real job is to list link libraries).

 

(I have a sneaking suspicion  this may all stem from the general misinterpretation of what a "library" is!)

Last Edited: Mon. May 18, 2020 - 02:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
it seems it does not know what GCC uses -l for

AFAICS, it just generates the source code? It's up to the user to decide what compiler to use, and to configure it correctly?

 

 general misinterpretation

Seems the  OP has a general misinterpretation/misunderstanding of what, exactly, this tool is giving her/him?

 

I do wonder what task on an 8-bit AVR needs MathWorks to get it done ... 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had had some problems with some of the simulink generated code.(my problem was different versions of matlab. they changed somethings in the 2018b as I remember, that would not link with some older libs) 

I would first try a very small project, and get it to compile.

 

It was for a customer so I don't have the setup here.

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


 

This is the contents of the output window:

 

This is the simulink configuration window showing that it can directly generate code for the following controllers

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


Link to a Mathworks blog about the code generation process:

https://blogs.mathworks.com/racing-lounge/2019/01/02/code-generation-online-tutorial/

 

This is the simulink support package for arduino hardware, It gives us siumlink blocks to interface with arduino hardware, but I am not exactly sure of the role it plays in the code generation process

https://www.mathworks.com/matlabcentral/fileexchange/40312-simulink-support-package-for-arduino-hardware  

 

I have also attached some code files for reference.

 

Attachment(s): 

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

So, having watched a YouTube video on this support package, I think what it does is generate code that will run on arduino. In that it invokes the compile and link process internally and downloads directly to the board.

I did not get the impression that it generates a pile of files that can be imported into an external tool chain.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

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

ad_jatkar wrote:
This is the contents of the output window

A screenshot isn't much use - that's just a tiny bity of it.

 

You need to copy & paste the entire text from the 'Output' window.

 

But you really need to be contacting Mathworks about this - they are the ones that generated it, so they are the ones to help you with what they generated!

 

Support is one of the things you pay for with Mathworks!

 

However, as Brian says, it doesn't seem that they claim to be generating a Project that will "just work" in Atmel Studio - so where have you read/seen that?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Tue. May 19, 2020 - 07:34 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

A screenshot isn't much use - that's just a tiny bity of it.

 

Exactly.

 

All you have to do is build the code. Switch so "Output" is visible. Click the mouse once in it then type Ctrl-A, Ctrl-C and finally paste the contents here. When I do that for a very simple build:

------ Rebuild All started: Project: test, Configuration: Debug AVR ------
Build started.
Project "test.cproj" (Clean target(s)):
Target "Clean" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "D:\test\test\test.cproj" (entry point):
	Task "RunCompilerTask"
		Shell Utils Path C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils
		C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils\make.exe clean 
		rm -rf  main.o   
		rm -rf  main.d   
		rm -rf "test.elf" "test.a" "test.hex" "test.lss" "test.eep" "test.map" "test.srec" "test.usersignatures"
	Done executing task "RunCompilerTask".
Done building target "Clean" in project "test.cproj".
Done building project "test.cproj".

Build succeeded.
------ Rebuild All started: Project: test, Configuration: Debug AVR ------
Build started.
Project "test.cproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "D:\test\test\test.cproj" (target "Build" depends on it):
	Task "RunCompilerTask"
		Shell Utils Path C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils
		C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils\make.exe all --jobs 8 --output-sync 
		Building file: .././main.c
		Invoking: AVR8/GNU C Compiler : 5.4.0
		. c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h
		.. c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h
		... c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h
		.... c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h
		..... c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h
		.. C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.4.351\include/avr/iom328p.h
		.. c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h
		.. c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h
		.. c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe"  -x c -funsigned-char -funsigned-bitfields -DDEBUG  -I"../some/place/to/look/for/lcd/headers" -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.4.351\include"  -O1 -fpack-struct -fshort-enums -mrelax -g2 -Wall -pedantic -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.4.351\gcc\dev\atmega328p" -c -std=gnu99 -H -fverbose-asm -save-temps -MD -MP -MF "main.d" -MT"main.d" -MT"main.o"   -o "main.o" ".././main.c" 
		Finished building: .././main.c
		.. c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h
		.. c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h
		Multiple include guards may be useful for:
		C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.4.351\include/avr/iom328p.h
		.././main.c: In function 'main':
D:\test\test\main.c(7,8): warning: binary constants are a GCC extension
		  TCCR1A=0b00000000;
		        ^
D:\test\test\main.c(8,8): warning: binary constants are a GCC extension
		  TCCR1B=0b00001100; //WGM = 0b0100 -> CTC mode.
		        ^
		Building target: test.elf
		Invoking: AVR8/GNU Linker : 5.4.0
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-g++.exe" -o test.elf  main.o   -Wl,-Map="test.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -mrelax -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.4.351\gcc\dev\atmega328p" -Wl,-print-gc-sections  
		Finished building target: test.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  "test.elf" "test.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 "test.elf" "test.eep" || exit 0
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "test.elf" > "test.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 "test.elf" "test.srec"
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "test.elf"
		   text	   data	    bss	    dec	    hex	filename
		    178	      0	      0	    178	     b2	test.elf
	Done executing task "RunCompilerTask".
	Task "RunOutputFileVerifyTask"
				Program Memory Usage 	:	178 bytes   0.5 % Full
				Data Memory Usage 		:	0 bytes   0.0 % Full
				Warning: Memory Usage estimation may not be accurate if there are sections other than .text sections in ELF file
	Done executing task "RunOutputFileVerifyTask".
Done building target "CoreBuild" in project "test.cproj".
Target "PostBuildEvent" skipped, due to false condition; ('$(PostBuildEvent)' != '') was evaluated as ('' != '').
Target "Build" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Avr.common.targets" from project "D:\test\test\test.cproj" (entry point):
Done building target "Build" in project "test.cproj".
Done building project "test.cproj".

Build succeeded.
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Suggest you do the same.

 

Either that or simply ZIP the entire project directory and post that as an attachment here so we can all have a go at building/fixing it.

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

------ Build started: Project: Led_simulink_1, Configuration: Debug AVR ------
Build started.
Project "Led_simulink_1.cproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "D:\Atmel\Studio\7.0\Vs\Compiler.targets" from project "D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\Led_simulink_1\Led_simulink_1\Led_simulink_1.cproj" (target "Build" depends on it):
    Using "RunCompilerTask" task from assembly "D:\Atmel\Studio\7.0\Extensions\Application\AvrGCC.dll".
    Task "RunCompilerTask"
        Shell Utils Path D:\Atmel\Studio\7.0\shellUtils
        D:\Atmel\Studio\7.0\shellUtils\make.exe all --jobs 8 --output-sync 
        .././main.c: In function 'rt_OneStep':
D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\Led_simulink_1\Led_simulink_1\main.c(39,7): warning: extra tokens at end of #endif directive [-Wendif-labels]
         #endif;
               ^
D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\Led_simulink_1\Led_simulink_1\main.c(48,7): warning: extra tokens at end of #endif directive [-Wendif-labels]
         #endif;
               ^
        .././main.c: In function 'main':
D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\Led_simulink_1\Led_simulink_1\main.c(59,3): warning: implicit declaration of function 'init' [-Wimplicit-function-declaration]
           init();
           ^
D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\Led_simulink_1\Led_simulink_1\main.c(60,3): warning: implicit declaration of function 'MW_Arduino_Init' [-Wimplicit-function-declaration]
           MW_Arduino_Init();
        Building file: .././main.c
        Invoking: AVR/GNU C Compiler : 5.4.0
        "D:\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe"  -x c -funsigned-char -funsigned-bitfields -DDEBUG  -I"D:\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.3.300\include"  -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -g2 -Wall -mmcu=atmega2560 -B "D:\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.3.300\gcc\dev\atmega2560" -c -std=gnu99 -MD -MP -MF "main.d" -MT"main.d" -MT"main.o"   -o "main.o" ".././main.c" 
        Finished building: .././main.c
           ^
D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\Led_simulink_1\Led_simulink_1\main.c(63,3): warning: implicit declaration of function 'configureArduinoAVRTimer' [-Wimplicit-function-declaration]
           configureArduinoAVRTimer();
           ^
D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\Led_simulink_1\Led_simulink_1\main.c(71,7): warning: extra tokens at end of #endif directive [-Wendif-labels]
         #endif;
               ^
D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\Led_simulink_1\Led_simulink_1\main.c(78,28): warning: implicit declaration of function 'MW_Arduino_Loop' [-Wimplicit-function-declaration]
             runModel = runModel && MW_Arduino_Loop();
                                    ^
D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\Led_simulink_1\Led_simulink_1\main.c(58,9): warning: unused variable 'systemClock' [-Wunused-variable]
           float systemClock = 0;
                 ^
D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\Led_simulink_1\Led_simulink_1\main.c(57,9): warning: unused variable 'modelBaseRate' [-Wunused-variable]
           float modelBaseRate = 1.2;
                 ^
cannot find -lbg_1_LED.ccannot find -lbg_1_LED.hcannot find -lbg_1_LED_data.ccannot find -lbg_1_LED_private.hcannot find -lbg_1_LED_types.hcannot find -lMW_target_hardware_resources.hcannot find -lrtmodel.h        Building target: Led_simulink_1.elf
        Invoking: AVR/GNU Linker : 5.4.0
        "D:\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe" -o Led_simulink_1.elf  main.o   -Wl,-Map="Led_simulink_1.map" -Wl,--start-group -Wl,-lm -Wl,-lbg_1_LED.c -Wl,-lbg_1_LED.h -Wl,-lbg_1_LED_data.c -Wl,-lbg_1_LED_private.h -Wl,-lbg_1_LED_types.h -Wl,-lMW_target_hardware_resources.h -Wl,-lrtmodel.h -Wl,-lrtwtypes.h -Wl,-lMW_digitalio.h  -Wl,--end-group -Wl,-L"D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw"  -Wl,--gc-sections -mrelax -mmcu=atmega2560 -B "D:\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.3.300\gcc\dev\atmega2560"  
D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\Led_simulink_1\Led_simulink_1\Debug\Makefile(106,1): error: recipe for target 'Led_simulink_1.elf' failed
cannot find -lrtwtypes.hcannot find -lMW_digitalio.hcollect2.exe(0,0): error: ld returned 1 exit status
        make: *** [Led_simulink_1.elf] Error 1
        The command exited with code 2.
    Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "Led_simulink_1.cproj" -- FAILED.
Done building project "Led_simulink_1.cproj" -- FAILED.

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

This is the output that I got when building the project. 

I have added two attachments:

Led_simulink_1.rar : Contains the AS7 Project and include files

bg_1_LED_Complete.rar: Contains the AS7 Project and a collection of all the MATLAB header files.

 

Attachment(s): 

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

awneil wrote:

But you really need to be contacting Mathworks about this - they are the ones that generated it, so they are the ones to help you with what they generated!

 

Well I have asked about the problem on Mathworks Forums, I'll update if I get some leads.

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

Learning to read & understand compiler messages - aka "diagnostics" - is a key skill in programming.

 

You need to read the text of the messages - they tell you what is wrong - and where

D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\Led_simulink_1\Led_simulink_1\main.c(39,7): warning: extra tokens at end of #endif directive [-Wendif-labels]
         #endif;
               ^

 main.c  is the name of the file where the problem was found

 

 39  is the line number within that file

 

  7   is the character number along that line (counting from the left)

 

 extra tokens at end of #endif directive  is the description of the problem

 

 -Wendif-labels  is the command-line option which controls the reporting of this issue

 

It even gives you a pointer to the error:

         #endif;
               ^

The 'C' programming language does not have semicolons on the end of preprocessor directives!

 

Are you sure this was actually as generated by Mathworks?

 

EDIT

 

Googling the command-line option - without the leading hyphen - will usually get you to a detailed description of what the message is about.

 

Or just put the message - eg,  "extra tokens at end of #endif directive" - into google

 

 

#HowToReadGccDiagnostics

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Tue. May 19, 2020 - 09:13 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ad_jatkar wrote:
I have asked about the problem on Mathworks Forums,

Jolly good.

 

Please be sure to post a link here to that thread, and a link there to this thread.

 

Always do that when cross-posting the same question to multiple forums - so that everyone can see the full story, and people don't waste time saying what has already bee covered elsewhere.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\Led_simulink_1\Led_simulink_1\main.c(57,9): warning: unused variable 'modelBaseRate' [-Wunused-variable]
           float modelBaseRate = 1.2;
                 ^
cannot find -lbg_1_LED.ccannot find -lbg_1_LED.hcannot find -lbg_1_LED_data.ccannot find -lbg_1_LED_private.hcannot find -lbg_1_LED_types.hcannot find -lMW_target_hardware_resources.hcannot find -lrtmodel.h  

There's something a bit odd in this output. The "cannot find" error does not seem to relate to the "float modelBaseRate" line indicated so I think there is something "missing" from this output.

 

Life may be simpler if you simply ZIP/attach the entire project.

 

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

clawson wrote:

Life may be simpler if you simply ZIP/attach the entire project.

I have attached the entire project in Post #19

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

ad_jatkar wrote:
I have attached the entire project in Post #19
When I try to build that I get:

		In file included from .././main.c:17:0:
D:\Led_simulink_1\Led_simulink_1\bg_1_LED.h(25,87): error: D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\MW_digitalio.h: No such file or directory
		compilation terminated.

which is related to:

#include "D:\AAB_V_A\Mega2560\bg_1_LED_Complete\Mod_1\bg_1_LED_ert_rtw\MW_digitalio.h"

which is an almost perfect illustration of why you should not put absolute path references to .h files into #include statements.

 

Anyway I don't have "D:\AAB_V_A" or what it may contain so cannot get past this error.

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

clawson wrote:

 

Life may be simpler if you simply ZIP/attach the entire project.

ad_jatkar wrote:
I have attached the entire project in Post #19

 

"entire project" means "everything[1] required to build the project"

 

This is why it's good to have everything[1] required to build the project in the folder structure below your projects "root" (top level) folder - makes it so much easier to zip up & give to a collaborator ...

 

EDIT

 

[1] well, all the inputs required for the build.

You wouldn't generally include all the tools, but you do also have to consider how you will manage them if it's a project that's going to be maintained for a long time...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. May 20, 2020 - 09:17 AM