Import of ARM (Zero, Due, ...) sketches into AS7 not working

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

Hi all,

 

Since 3 years I have been using AS7 for Arduino Uno only, and except for temporary issues with the "Import Arduino sketch" features when Arduino IDE or AS7 got updated, everything went well so far.

Time has passed, and my projects began to grow beyond the limits of the UNO, so I moved forward, using Mega and Due.

For the Mega, everything went well, except that I had to create an empty sketch with the libraries i needed in Arduino IDE, import it in AS7 and then start coding; this is the same story as the Uno, as you can read from my other post here:

https://www.avrfreaks.net/forum/....

 

For the Due, I followed the same workflow and could complete the import of the Arduino template sketch (no code, only the libraries), but at the moment of compiling I hit a "chip.h" not found error.

I searched a lot but have found only this thread (plus some duplicates of it on other forums): 

https://community.atmel.com/foru...

 

which is 3 yrs old and is related to the Zero board (SAMD processor, not SAM). The solution of the directory junction intrigued me and i tested it for a Zero board, finding that it works nicely (I have updated the aforementioned thread with all the details), so i tried to apply the same concept to the Due. Here is what i did, without luck:

 

To be absolutely sure of the outcome, I did a clean reinstall of the Arduino ide and discovered that the uninstall process does not remove the folders in %localappdata%\arduino15.

I manually deleted it.

 

For the Zero, thing stopped working from BSP 1.6.8 (apr 2015) and 1.6.9 (dec 2016) so i looked for Due BSP around the same dates, and found that my starting point could be SAM 1.6.8 (nov 2015).

To stay clean and safe, I copied the Blink example in my sketchbook and used it as test code. At every BSP version change i did the following:

-compiled in Arduino IDE (for Due, programming port target).

-imported in AS7

-selected Release version and hit "Rebuild solution" in AS7.

 

I tried the almost all other SAM BSP versions, before and after 1.6.8, with the following procedure to replace them:

-From IDE board manager, Removed the package.

-Closed Arduino IDE.

-Deleted %localappdata%\arduino15 folder (I also that "Remove" of a BSP from the IDE does not clean everything from that folder as well).

-Started Arduino IDE, installed the next SAM BSP version.

-Reopened my test copy of Blink, set it for Due target (it gets lost following deletion of %localappdata%\arduino15 folder).

-Compiled in the IDE.

-Closed the IDE

-Started AS7 and imported sketch as described above.

-Rebuilt solution for Release target.

 

The constant outcome was compile error: chip.h not found.

 

Being desperate, I have also installed MPlab X with the compilers and the "Arduino importer" plugin, and i discovered that it can only import from AS7: it is not possible to import in MPLAB X directly from Arduino IDE.

 

I hope i have explained everything clearly, if not please just let me know.

Thanks in advance to all who want to help.

 

 

 

 

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

Import from Due is completely broken.

 

Import from Zero should be ok.    But AS7.0 is obviously not as good as the proper Arduino IDE.

 

Why do you want to use AS7.0 ?

If you want to use the CMSIS-DAP debugger on the Zero,  you can change the Linker parameters to run from conventional start address.

Remember to restore the Arduino bootloader when you want to use the Arduino IDE again.

 

I find it easier to build a Due program in Arduino.   Then debug the ELF file with an external debugger in Rowley  or AS7.0.

 

David.

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

Hi david.prentice:

 

I have noticed that import of Arduino sketches for Due and Zero is still not working even with the newest Microchip Studio.

Also, couldn't get anything working from MPLAB X even for AVR chips, maybe it requires more configuration before it can work.

 

In another thread you stated that you obtained a working AS7 solution for Due by manually adding all the required files.

I tried to do the same for my Due (usual Blink sketch) and got something that compiles but doesn't work (does not blink).

Could you please share your working AS7 Due solution for these or provide more details on which files you manually added?

 

Alternatively, do you know if it is possible to get Pickit 4 working with Visual Studio Code and some free plugins? 

Or what do i need to do to get MPLAB X working for AVR and ARM? (i discovered that it compiles for AVR only if it finds the AS7 AVR toolchain)

 

My goal is to be able to program using the Arduino API (digitalRead, digitalWrite, pinMode, etc) for AVR and ARM and to debug with my pickit4 for both AVR and ARM in a single place.
Currently I got AS7 working well only for AVR.

 

Thanks and regards

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

The Arduino IDE works just fine.

Why would anyone want to use AS7.0 for Due ?

If you are debugging an Arduino project it is better to build with the regular tools.  i.e. as installed by Arduino IDE.

 

Personally,   I add a line to platform.txt

C:\Users\David Prentice\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.12\platform.txt

## Save hex
recipe.output.tmp_file={build.project_name}.bin
recipe.output.save_file={build.project_name}.{build.variant}.bin

## Post Build - .kbv
recipe.hooks.postbuild.1.pattern=cmd /c "copy" "{build.path}\{build.project_name}.elf" "C:\Users\David Prentice\Documents\Crossworks Projects\Externally_Built_Executable_1\Externally_Built_SAM3X"

Then use Rowley to debug the "Externally built executable"  ELF

But you can use AS7.0 to debug the "Externally built Object file"

 

I prefer Rowley to AS7.0 but since I only have a Rowley Hobbyist licence I could not use professionally.   (I am a hobbyist)

 

I suspect that PlatformIO will make a better job of importing an Arduino sketch.   

Other readers have experience with PlatformIO.   I do not.

 

I suspect that PlatformIO debug facilities are Eclipse-like.    Which puts me off at the start.

 

David.

Last Edited: Sun. May 9, 2021 - 11:24 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There were a few threads about this recently:

 

https://community.atmel.com/forum/imported-arduino-due-project-wont-compile - and follow the links

 

 

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 tend to say exactly the same thing whenever this comes up.

 

Mind you,  one day AS7.0 might actually import SAM3 and SAMD sketches properly.

After all,  it imports Uno sketches ok.   (providing there are not any pointer or reference arguments)

 

And I presume that the Java code for mangling sketches,  identifying paths etc is all publicly available.

 

Arduino code and libraries have a logical file layout.

AS7.0 seems to want to upset all relative paths.

 

David.