Arduino imported sketch does not find any include file

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

Hi all,

I installed Atmel Studio 7 and I would like to import an Arduino project in order to have more debugging capabilities.

When I try to build the solution, many include files are not found, but all my libraries are correctly installed. With Arduino IDE everything works fine.

All libraries are located under the sketch path of the Arduino IDE

 

Additionally, at Visual Studio startup, I see four instances of the same error in the bottom part of the screen:

"13:37:35: [ERROR] Object reference not set to an instance of an object."

 

Thanks a lot!

 

/*Begining of Auto generated code by Atmel studio */
#include <Arduino.h>

/*End of auto generated code by Atmel studio */

//#include <avr/power.h>
#include <HardwareSerial.h>
#include <EEPROM.h>
#include <SPI.h>
#include <Ethernet2.h>
#include "asplitter_inc.h"
#include "timers_c.h"
#include "monitor_c.h"
#include "serial_c.h"
#include "ethernet_c.h"
#include "testmode_c.h"
#include "setup_c.h"
//Beginning of Auto generated function prototypes by Atmel Studio
void runLed();
void errTimeout();
//End of Auto generated function prototypes by Atmel Studio

 

MRN

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

You have not actually shown the errors ?

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


No, but I can..

 

 

If I change EEPROM.h with avr/eeprom.h I obtain:

 

MRN

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

So in the tree of files that were created by the import do files called EEPROM.h and SPI.h actually exist? IOW were they copied but it's simply forgotten to set search paths to find them? or were they not copied at all?

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

None of these files are present in the created tree. I believed that include and libraries were searched at run-time during the build...

 

C:\Users\Marco\Documents\Atmel Studio\7.0>dir/s *.h
 Il volume nell'unità C è OS
 Numero di serie del volume: DEF7-4184

 Directory di C:\Users\Marco\Documents\Atmel Studio\7.0\ArduinoSketch1\ArduinoSketch1\ArduinoCore\include

11/11/2018  12:51             5.083 asplitter_inc.h
11/11/2018  19:37             6.202 ethernet_c.h
07/11/2018  22:18             2.328 monitor_c.h
19/10/2018  20:45            13.667 serial_c.h
11/11/2018  18:22            27.267 setup_c.h
25/10/2018  09:59               213 testmode_c.h
04/11/2018  22:44             2.151 timers_c.h
               7 File         56.911 byte

 Directory di C:\Users\Marco\Documents\Atmel Studio\7.0\ArduinoSketch1\ArduinoSketch1\ArduinoCore\include\core

10/09/2018  11:48             7.483 Arduino.h
10/09/2018  11:48            11.214 binary.h
10/09/2018  11:48             1.529 Client.h
10/09/2018  11:48             5.262 HardwareSerial.h
10/09/2018  11:48             4.469 HardwareSerial_private.h
10/09/2018  11:48             2.861 IPAddress.h
16/10/2017  13:20               979 new.h
10/09/2018  11:48             2.063 PluggableUSB.h
10/09/2018  11:48             2.963 Print.h
10/09/2018  11:48             1.335 Printable.h
10/09/2018  11:48               963 Server.h
10/09/2018  11:48             6.060 Stream.h
10/09/2018  11:48             4.363 Udp.h
10/09/2018  11:48             6.261 USBAPI.h
10/09/2018  11:48             8.275 USBCore.h
10/09/2018  11:48             1.519 USBDesc.h
10/09/2018  11:48             4.576 WCharacter.h
16/10/2017  13:20             2.255 wiring_private.h
10/09/2018  11:48             9.910 WString.h
              19 File         84.340 byte

 Directory di C:\Users\Marco\Documents\Atmel Studio\7.0\ArduinoSketch1\ArduinoSketch1\ArduinoCore\include\variants\mega

16/10/2017  13:20            13.685 pins_arduino.h
               1 File         13.685 byte

     Totale file elencati:
              27 File        154.936 byte
               0 Directory  272.213.245.952 byte disponibili

 

MRN

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

marconap wrote:
With Arduino IDE everything works fine.

Surely this explains everything.

 

The "Import Sketch" is not very good.

It makes no attempt to add local H, C, CPP, INO files from your project.

Nor does it create forward declarations correctly.

 

Life is much simpler if you just build the ELF with the Arduino IDE.

You can debug the Arduino generated ELF with AS7.0 "Open Object File for Debugging"

 

It also means that your project always keeps in step with Arduino Core version, library versions, any code edits, ...

When you "import" your project into AS7.0 you lose track.

 

David.

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

Hi David, I imported the ELF file into AS7, and my board seems to be connected. When I select "Debug->Start Debugging and break" or any other debug command, I see "Loading executable", the STK500 led, flick a lot and the program starts on the board, but I don't see any break in the source window. The program starts normally. What's my mistake?

Thanks

M

MRN

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

Which debugger do you own?

The STK500 is only a programmer.

 

There is little point in importing a working Arduino project into AS7.0 whether you own a debugger or not.

Much better to just build in the Arduino IDE.   You can always use some Serial.print() statements for debugging.

 

David.

Last Edited: Wed. Dec 4, 2019 - 10:47 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh noo I cant use a println to debug my program. It s very complex with a lot of timers and tcp connection. I have stk500 and Atmel Ice. I'll try to use the lasr one.
Thanks

MRN

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

david.prentice wrote:
whether you own a debugger or not.

Not sure about that.

 

A debugger is an invaluable tool - so definitely worth making some effort to have a system that can use it!

 

@ marconap : have you seen the new Arduino "Pro" IDE - which claims to support debuggers -   https://www.avrfreaks.net/forum/... ?

 

marconap wrote:
I cant use a println to debug my program. It s very complex with a lot of timers and tcp connection

Never dismiss "printf" debugging!

 

There are things that "printf" debugging can do which a debugger can't - especially when it comes to watching how the system behaves in action.

 

Another valuable tool is writing "trace" information to a memory buffer - which can be done without a "real" debugger ...

The most important tool for debugging is the one between your ears !

 

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'll try this. Which kind of hardware i need?

MRN

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

marconap wrote:
I'll try this.

Which are you referring to?

 

See tutorial for how to identify what a forum reply is referring to: https://www.avrfreaks.net/forum/...

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

Error, my bad

Last Edited: Sun. Dec 22, 2019 - 02:26 AM