Unable to bulid some Arduino examples with Atmel Studio 7

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

Hi,

I have Atmel Studio 7.0.1645 and Arduino 1.8.4.

I am trying to creat a project from an Arduino sketch in AS7, and build it, so that i may simulate it in AS7.

Some projects work, some do not. In particular, several of the Arduino built in examples (blink, analogwritemega, bargrahp, ArduinoISP) build successfully. But most of the RF24 type of examples do not. I am setting Arduino/Genuino Mega or Mega 2560 for the board and ATMega 2560 for the device.

 

I am trying just to get RF24/Gettingstarted to build successfully, but the build fails with 10 errors :

Error        recipe for target 'src/libraries/rf24/examples/scanner/output/scanner.o' failed    ArduinoCore    d:\users\puppy\Documents\Atmel Studio\7.0\ArduinoSketch17\ArduinoSketch17\ArduinoCore\Debug\Makefile    515
Error        recipe for target 'src/libraries/rf24/examples_linux/extra/scanner.o' failed    ArduinoCore    d:\users\puppy\Documents\Atmel Studio\7.0\ArduinoSketch17\ArduinoSketch17\ArduinoCore\Debug\Makefile    529
Error        recipe for target 'src/libraries/rf24/examples_linux/extra/rpi-hub.o' failed    ArduinoCore    d:\users\puppy\Documents\Atmel Studio\7.0\ArduinoSketch17\ArduinoSketch17\ArduinoCore\Debug\Makefile    529
Error        WProgram.h: No such file or directory    ArduinoCore    d:\users\puppy\Documents\Atmel Studio\7.0\ArduinoSketch17\ArduinoSketch17\ArduinoCore\src\libraries\rf24\examples\scanner\output\scanner.cpp    1
Error        cstdlib: No such file or directory    ArduinoCore    d:\users\puppy\Documents\Atmel Studio\7.0\ArduinoSketch17\ArduinoSketch17\ArduinoCore\src\libraries\rf24\examples_linux\extra\rpi-hub.cpp    30
Error        cstdlib: No such file or directory    ArduinoCore    d:\users\puppy\Documents\Atmel Studio\7.0\ArduinoSketch17\ArduinoSketch17\ArduinoCore\src\libraries\rf24\examples_linux\extra\scanner.cpp    26
Error        cannot find -lArduinoCore    GettingStarted        1
Error        ld returned 1 exit status    GettingStarted    collect2.exe    0
Error        recipe for target 'GettingStarted.elf' failed    GettingStarted    d:\users\puppy\Documents\Atmel Studio\7.0\ArduinoSketch17\ArduinoSketch17\GettingStarted\Debug\Makefile    108
Error        [N]  710 : 'Arduino.h' file not found    GettingStarted    d:\users\puppy\Documents\Atmel Studio\7.0\ArduinoSketch17\ArduinoSketch17\GettingStarted\Sketch.cpp    2

 

All examples do successfully complie in Arduino.

So, why do the RF24 examples not build in AS7 ?

Any help appreciated :)

 

 

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

That error summary is hopeless. Use the actual build Output tab and locate the FIRST error that occurred. Generally speaking it's usually the only one to concentrate on because often when you fix one you fix the next 20 that were simply a knock on effect from what happened previously.

 

While we can't tell from that list (why DO they bother?) I am kind of guessing the missing WProgram.h might have started it all.

 

Interestingly I just google "wprogram,h arduino" in an attempt to find more about that file (I don't see it in a standard Arduino installation) and the Arduino fora seem to be alive with questions about it. One suggestion I read there was that the #include of Wprogram.h should really be a #include of Arduino.h in fact.

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

I could explain the Wprogram.h but the best way to ask your question is:
1. Quote Arduino IDE version
2. Quote RF24 library version
3. Quote RF24 library example
4. Quote Arduino target e.g. Mega2560
5. Quote AS7 version
.
Then someone might attempt to replicate your project. And possibly resolve your problem.
.
The real mystery is WHY?.
The Arduino IDE makes a pretty good job of building Arduino projects. You can use an external editor if you prefer.
AS7 can import simple sketches. It is flaky for any real life sketches. But we can possibly help.
.
Note that if you migrate to AS7 you are stranded in time. A new Arduino release or library Release will be used in Arduino IDE. Your AS7 project is stuck with the code that you originally imported.
.
David.

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

david.prentice wrote:
the best way to ask your question is:

also:

 

6. Describe, in detail, the steps you took to create the the AS7 Project from the Arduino sketch.

 

Note that if you migrate to AS7 you are stranded in time

Indeed.

AS7 takes a "snapshot" of your sketch (including all the Arduino stuff) at the point of import - it will not be aware of any subsequent updates or modifications that happen on the "Arduino side" ...

 

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

Quoting the example, versions etc will show if it is AS7 error?
Describing your exact steps is useful. Is it your error?

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

Hi all,

Many thanks for all of your input.

Just to re-cap

Atmel Studio 7.0.1645

Arduino 1.8.4

RF24 library by TMHR20 ver 1.3.1

In Arduino the example is in - "File - Examples from custom libraries - RF24 - GettingStarted"

Target board Arduino/Mega

Target Device ATMega2560

The Arduino sketches do compile successfully in Arduino.

It seems that the "built in" Arduino sketches will build in AS&, whilst the RF24 sketches will not.

 

In AS7 to create a project from an Arduino sketch, i select :

New Project

Create project from Arduino Sketch

Choose the sketch, ie. select the .ino file

Pick the board and device (as above)

Select the tool "Simulator"

Click the "Start debugging and break" button.

 

I do not think i am doing anything wrong, because i can do exactly the same proceedure, except selecting a different .ino file, and the AS7 build will work. The only difference being the location of the selected .ino, and the contents of the .ino itself.

 

Now based on some of the comments above (thank you), i looked at the "output" log, which does seem to list a lot more detail.

Every time it said it had an error, it seemed to me, that the Sketch i had selected, should not need to include, or use, the particular directory it was compalining about. So for example, for one of the errors :

 

"d:\users\puppy\Documents\Atmel Studio\7.0\ArduinoSketch23\ArduinoSketch23\ArduinoCore\src\libraries\rf24\examples_linux\extra\scanner.cpp(26,19): error: cstdlib: No such file or directory"

 

I found the "....rf24\examples_linux\extra\..." entry in the AS7 solution explorer, and removed it from the project. I did this for all of the similar errors to above. Then it compiled. I did not add any new libraries, or file locations etc. It looks to me like it had imported into the AS7 project, all sorts of files/directories which were superfluous to the "GettingStarted" example.

 

So by just deleting these items it built successfully.

 

I have played with the simulation, and does seem to be "good".

 

Being an absolute novice, i have based my approach on laymans common sense, however, my one question is why does it "import" or "include" many different directories/files which are nothing to do with the project - in particular, it includes linux examples (eg. ...rf24\examples_linux\extra\rpi-hub.cpp). I am using a Windows environment. I suspect i do not understand it properly!!

 

My view at this moment is that any file/directories it says it could not access, are due to the superfluous file inclusions in the Solution Explorer.

 

The reason i wanted to use AS7, was to simulate my program (or parts of it) before i got to try it out on a real nRF24L01+.

 

I can submit the output logs with some screen shots of AS7 if it helps ?

 

What do we all think about that? Should i take the view that because it builds ok, it is ok, or is that too much of a simplistic view? Beginner's luck?

 

Thanks

 

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

Nibbles wrote:
was to simulate my program (or parts of it) before i got to try it out on a real nRF24L01+
I fear you are very rapidly going to find the shortcomings of the simulator. Because (unlike Proteus) it only simulates what is inside the AVR, not what is outside as soon as the code gets to a point where it's expecting an event/response from the external device it will stall. Sometimes you can kind of "fake" inputs but that takes you further from the action of the real hardware. So it's a fun toy while it lasts and for checking things like "does timer 2 execute the right number of cycles between interrupts" it is fine but for "system simulation" it's not much use.

 

Anyway, if this has identified a fault in Atmel's INO importer I guess we should hope that someone from Atmel wil spot this and consider recreating the import process you followed. It might be an idea to actually open a support ticket on the Microchip site to ensure someone from Micochip/Atmel will investigate this.

 

OTOH it could well be a fault in the structure of the Arduino library itself and the import process is simply highlighting something that is already wrong.

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

Nibbles wrote:
Should i take the view that because it builds ok, it is ok

In general, NO!

 

The fact that it builds just shows that you have no language syntax errors - that does not guarantee that it will "work" as required!

 

The reason i wanted to use AS7, was to simulate my program (or parts of it) before i got to try it out on a real nRF24L01+.

As clawson said, the AS7 Simulator is unlikely to be of much help with that. 

 

A far more useful tool for that would be real hardware and a debugger ...

 

 

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 made these steps:

1.  Installed RF24 library with Library Manager

2.  Selected Mega2560 as Target Board

3.  Imported C:\Users\David Prentice\Documents\Arduino\libraries\RF24\examples\GettingStarted\GettingStarted.ino sketch

4.  Selecting IDE, Board, MCU

5.  AS7 whirred for a bit.

6.  AS7 has added several directories to the src/libraries/rf24 node in ArduinoCore

7.  Click on all of these i.e. examples, examples_linux, pyRF24, utility and select Remove.

 

8.  This just leaves RF24.cpp under the ArduinoCore/src/libraries/rf24 node.

9.  Clean Solution

10. Build Solution.

 

It should work fine for your trivial example.

 

The problem is that AS7 does not know how to import libraries very well.    It assumes that every directory should be built when many libraries have utilities that are not part of the working library.

 

A regular Arduino library may have examples and src directories.    The Arduino IDE knows what to build.    Libraries have a regular directory structure.   AS7 tries to mangle the intelligent directory structure into its own weird way of separating include and src into parallel hereditary order.

 

David. 

 

Edit.   AS7 seems to scan through the original library directory e.g. RF24.

If it finds an H file it adds it to the include node (according to the relative directory hierarchy)

If it finds a C, CPP, S file it adds it to the src node (according to the relative directory hierarchy)

Of course most of these C, CPP, S files are not part of the library proper.    So should not be added to the list of files to build.

My advice to right-click-remove these from the node removes from the build but leaves them on  the disk.

You might want to add one of these at a later date.

 

Most examples just contain INO files.    So AS7 does not add these to the src tree.

 

The whole arrangement is very messy.    If an author puts a local header file in a relative directory,   she does not want some AS7 to rearrange it into AS7's idea of disk hierarchy.    Hey-ho,  AS7 knows better.

Last Edited: Tue. Jun 12, 2018 - 10:32 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for all of your comments.

Having had another play with AS7, i can see your points about its shortcomings!

Thanks for trying it out David, and your comments thereafter......

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

I only "built" the imported sketch.    I would expect it to work on the hardware.

 

Just accept that you have to make "corrections" to the AS7 project.   i.e. remove the extraneous nodes from the tree of source files to compile.

 

You could choose "Delete" instead of "Remove".     You can do the same for the include tree.

 

I would prefer to build library files from their original location in the Arduino User libraries.

Of course any edits would affect the real Arduino files.    It is safer to create copies of these files.

 

For gaining experience,   it is wise to use copies.    You can learn which library files are actually relevant.   Hint.   CPP, H in src and possibly some H, C, CPP in src/utility  

 

David.