VS Arduino
>> >> Inexplicable errors when importing/starting Arduino project in AS7
https://www.visualmicro.com/forums/YaBB.pl?num=1504139067

Message started by Dave Telling on Aug 31st, 2017 at 12:24am

Title: Inexplicable errors when importing/starting Arduino project in AS7
Post by Dave Telling on Aug 31st, 2017 at 12:24am
I have Atmel Studio 7.0.1417 running on a W10 laptop. I would like to make a project using an existing Arduino sketch that compiles and loads correctly on an Uno (using the Arduino IDE environment).

I am confused about how to take an existing Arduino sketch and make a new project in Atmel Studio 7. No matter what I try, including "New Arduino Project" from the file menu and vMicro New Arduino Project or Existing Arduino Project, in addition to the IDE not seeming to recognize keywords of the Arduino IDE, I also get this error consistently: "Visual Micro Error reading variants path". I will typically get several instances of this error when trying to bring in the Arduino sketch, or even if I just try to start a new blank project without any code.



If I try to build the project, I get not only the error mentioned above, but this in the output area:



Compiling 'Sleep_mode_test' for 'Arduino/Genuino Uno'
System.ArgumentException: The path is not of a legal form.
   at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.GetFullPathInternal(String path)
   at System.IO.DirectoryInfo.Init(String path, Boolean checkHost)
   at System.IO.DirectoryInfo..ctor(String path)
   at Visual.Micro.MiroAppAPI.SketchCompiler.CreateFileTimeListXml(String fileType, String sPath, String outputPath)
   at Visual.Micro.MiroAppAPI.SketchCompilerArduino._compile(SketchBuilder lsketch, String primaryClassName, Boolean verbose, Boolean isDebug)
   at Visual.Micro.MiroAppAPI.SketchCompilerArduino.compile(SketchBuilder lsketch, String primaryClassName, Boolean verbose, Boolean isDebug)
   at Visual.Micro.Visual.Studio.Arduino.AddInApp._CompileDo(Object oProject, Boolean IsDebugStartCommand, Boolean isRebuild, Boolean UseGdbIfAvailable)
   at Visual.Micro.Visual.Studio.Arduino.AddInApp.CompileDo(Object oProject, Boolean IsDebugStartCommand, Boolean isRebuild, Boolean UseGdbIfAvailable)
   at Visual.Micro.Visual.Studio.Arduino.AddInApp.OnBeforeCommandEvent(String sGuid, Int32 ID, Object CustomIn, Object CustomOut, Boolean& CancelDefault)



I have no idea what all this means or how to correct it.



If it will help, here is the entire sketch:



#include <avr/interrupt.h>
#include <avr/power.h>
#include <avr/sleep.h>
#include <avr/io.h>
int wakePin = 2;                 // pin used for waking up
int led=13;

void wakeUpNow() {
    // execute code here after wake-up before returning to the loop() function
    // timers and code using timers (serial.print and more...) will not work here.
    // we don't really need to execute any special functions here, since we
    // just want the thing to wake up
}

void setup() {
    pinMode(wakePin, INPUT_PULLUP);
    pinMode(led, OUTPUT);
    attachInterrupt(0, wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function wakeUpNow when pin 2 gets LOW
    Serial.begin(9600);
}

void sleepNow() {
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here
    sleep_enable();          // enables the sleep bit in the mcucr register
    attachInterrupt(0,wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function
    sleep_mode();            // here the device is actually put to sleep!!
    // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
    sleep_disable();         // first thing after waking from sleep: disable sleep...
    detachInterrupt(0);      // disables interrupt 0 on pin 2 so the wakeUpNow code will not be executed during normal running time.
    Serial.println("I'm awake!");
}

void loop() {
    digitalWrite(led, HIGH);
    delay(1000);
    digitalWrite(led, LOW);
    sleepNow();     // sleep function called here
}

Title: Re: Inexplicable errors when importing/starting Arduino project in AS7
Post by Visual Micro on Aug 31st, 2017 at 11:13am
Must be a config error it's supposed to be easy :)

Switch on "vmico>compiler>show build properties" and also "verbose" then build and post the output as a .txt file here


Title: Re: Inexplicable errors when importing/starting Arduino project in AS7
Post by Dave Telling on Aug 31st, 2017 at 5:31pm
OK, I have had some success, but still somewhat confused. I did not realize that there were multiple ways to work with Arduino-based projects in the AS7/VM environment. I finally found the File/New/Project/Create project from Arduino sketch option, and that seemed to work for me.
What I DON'T understand is why there are other, more visible Arduino options (File/New/Arduino Project and File/Open/Arduino project), in addition to the options available from the VMicro menu tab (vMicro/New Arduino Project and vMicro/Open existing Arduino project) that just don't seem to work very well.
At this point, the only thing that I cannot seem to figure out is how to tell AS7 that my clock is the internal 8MHz, rather than the external 16MHz (for getting the correct delays & whatnot; I can select the internal 8MHz clock using the AVR Dragon in ISP mode). Even if I try selecting Uno with 8 MHz RC from the vMicro tab, it doesn't seem to change anything.

Title: Re: Inexplicable errors when importing/starting Arduino project in AS7
Post by Visual Micro on Aug 31st, 2017 at 10:27pm
Hi,

The issue you were having with visual micro sounds like a config or permissions issue.

The best way to see the issue is to switch on vmicro>compiler>verbose and "show build properties". Then try a build and post the output as a .txt file here. or email to info[at]visualmicro.com.

It's possible your arduino ide path is incorrect but the output should show the problem

...

You have ended up using the atmel arduino converter which creates an atmel cpp project from arduino code. Now you are not using visual micro.

Title: Re: Inexplicable errors when importing/starting Arduino project in AS7
Post by Dave Telling on Sep 1st, 2017 at 9:25pm

Tim@Visual Micro wrote on Aug 31st, 2017 at 11:13am:
Must be a config error it's supposed to be easy :)

Switch on "vmico>compiler>show build properties" and also "verbose" then build and post the output as a .txt file here



I selected vMicro\New Arduino project.


OK, here is the code I manually entered (i.e. no imported code):

#define led 9
#include <avr/io.h>

void setup()
{
pinMode(led,OUTPUT);
}

void loop()
{
digitalWrite(led,HIGH);
delay(1000);
digitalWrite(led,LOW);
delay(1000);
}

I selected Arduino/Genuino 8MHz RC as the board. Programmer and debugger are Atmel Studio options (I'm using an AVR Dragon presently)

Here is the build output:
Board Properties
name=Arduino/Genuino Uno 8MHZ RC
vid.0=0x2341
pid.0=0x0043
vid.1=0x2341
pid.1=0x0001
vid.2=0x2A03
pid.2=0x0043
vid.3=0x2341
pid.3=0x0243
upload.tool=avrdude
upload.protocol=arduino
upload.maximum_size=32256
upload.maximum_data_size=2048
upload.speed=19200
bootloader.tool=avrdude
bootloader.low_fuses=0xFF
bootloader.high_fuses=0xDE
bootloader.extended_fuses=0x05
bootloader.unlock_bits=0x3F
bootloader.lock_bits=0x0F
bootloader.file=optiboot/optiboot_atmega328.hex
build.mcu=atmega328p
build.f_cpu=8000000L
build.board=AVR_UNO
build.core=arduino
build.variant=standard
runtime.ide.path=C:\Program Files (x86)\Atmel\Studio\7.0\Extensions\jza3l4un.hdy\Micro Platforms\visualmicro\ide-atmel
runtime.os=windows
build.system.path=C:\Users\Dave\Documents\Arduino\hardware\new_board_description\avr\system
runtime.ide.version=10801
target_package=new_board_description
target_platform=avr
runtime.hardware.path=C:\Users\Dave\Documents\Arduino\hardware\new_board_description
originalid=uno8
intellisense.tools.path={runtime.tools.avr-gcc.path}\
intellisense.include.paths={intellisense.tools.path}avr\include\;{intellisense.tools.path}avr\include\avr\;{intellisense.tools.path}lib\gcc\avr\4.8.1\include
tools.atprogram.cmd.path=%AVRSTUDIO_EXE_PATH%\atbackend\atprogram
tools.atprogram.cmd.setwinpath=true
tools.atprogram.program.params.verbose=-v
tools.atprogram.program.params.quiet=-q
tools.atprogram.program.pattern="{cmd.path}" -d {build.mcu} {program.verbose} {program.extra_params} program -c -f "{build.path}\{build.project_name}.hex"
tools.atprogram.program.xpattern="{cmd.path}" {AVRSTUDIO_BACKEND_CONNECTION} -d {build.mcu} {program.verbose} {program.extra_params} program -c -f "{build.path}\{build.project_name}.hex"
tools.atprogram.erase.params.verbose=-v
tools.atprogram.erase.params.quiet=-q
tools.atprogram.bootloader.params.verbose=-v
tools.atprogram.bootloader.params.quiet=-q
tools.atprogram.bootloader.pattern="{cmd.path}" -d {build.mcu} {bootloader.verbose}  program -c -f "{runtime.ide.path}\hardware\arduino\avr\bootloaders\{bootloader.file}"
vm.platform.root.path=C:\Program Files (x86)\Atmel\Studio\7.0\Extensions\jza3l4un.hdy\Micro Platforms\arduino16x
runtime.vm.boardinfo.id=new_board_description_uno8
runtime.vm.boardinfo.name=new_board_description_uno8
runtime.vm.boardinfo.desc=Arduino/Genuino Uno 8MHZ RC
runtime.vm.boardinfo.src_location=C:\Users\Dave\Documents\Arduino\hardware\new_board_description\avr
ide.hint=Ready-To-Go IDE: Use the Board and Library managers to install.
ide.location.key=visualmicro
ide.location.ide.auto=true
ide.location.ide.winreg=Arduino Default Application
ide.location.sketchbook.winreg=Arduino Default Sketchbook
ide.location.sketchbook.preferences=sketchbook.path
ide.default.revision_name=1.8.1
ide.default.version=10801
ide.platforms.basedon=arduino16x
ide.default.package=arduino
ide.default.platform=avr
ide.multiplatform=true
ide.includes=arduino.h
ide.exe_name=arduino
ide.platformswithoutpackage=false
ide.includes.fallback=wprogram.h
ide.extension=ino
ide.extension.fallback=pde
ide.versionGTEQ=160
ide.hosts=atmel
vm.debug=true
software=ARDUINO
ssh.user.name=root
ssh.user.default.password=arduino
ssh.host.wwwfiles.path=/www/sd
ide.location.preferences.arduinoData={runtime.sketchbook.path}\ArduinoData
ide.location.preferences=%VM_APPDATA_LOCAL%\arduino15\preferences.txt
ide.location.preferences_fallback=%VM_APPDATA_ROAMING%\arduino15\preferences.txt
ide.location.contributions=%VM_APPDATA_LOCAL%\arduino15
ide.location.contributions_fallback=%VM_APPDATA_ROAMING%\arduino15
ide.contributions.boards.allow=true
ide.contributions.boards.ignore_unless_rewrite_found=true
ide.contributions.libraries.allow=true
ide.contributions.boards.support.urls.wiki=https://github.com/arduino/Arduino/wiki/Unofficial-list-of-3rd-party-boards-support-urls
ide.create_platforms_from_boardsTXT.teensy=build.core
ide.appid=visualmicro
location.sketchbook=C:\Users\Dave\Documents\Arduino
vm.core.include=wprogram.h
vm.boardsource.path=C:\Users\Dave\Documents\Arduino\hardware\new_board_description\avr
runtime.platform.path=C:\Users\Dave\Documents\Arduino\hardware\new_board_description\avr
vm.platformname.name=avr
build.arch=AVR
builder.noino=false
build.source.path=C:\Users\Dave\Documents\Arduino\vmicro_test_1\vmicro_test_1.ino
build.path=C:\Users\Dave\AppData\Local\Temp\VMBuilds\vmicro_test_1\new_board_description_uno8\Debug
PreProcessor.HeaderCount=1
PreProcessor.PrototypeCount=4
vm.last.preproc.file.0.file=sleep_wake_1.ino
vm.last.preproc.file.0.offset=1
vm.last.preproc.file.0.length=114
vm.last.preproc.file.0.linecount=14
vm.last.preproc.file.0.linestart=0
vm.last.preproc.file.0.lineend=14
vm.last.preproc.file.0.prefix_lines=0
build.project_name=vmicro_test_1.ino
build.project_path=C:\Users\Dave\Documents\Arduino\vmicro_test_1
ProjectDir=C:\Users\Dave\Documents\Arduino\vmicro_test_1\
vm.runtime.compiler.showwarnings=false
vm.runtime.upload.verbose=false
vm.runtime.upload.verify=false
vm.last.breakpoints.count=1
vm.runtime.compiler.auto_discover_includes=true
vm.runtime.compiler.auto_discover_includes_cache=true
build.vm.build.vmdebug=0
build.vm.build.isgdb=0
build.vm.build.optimised=1
build.vm.extra_flags=   -g   
vm.last.buildpath=C:\Users\Dave\AppData\Local\Temp\VMBuilds\vmicro_test_1\new_board_description_uno8\Debug

Compiling 'vmicro_test_1' for 'Arduino/Genuino Uno 8MHZ RC'
Build Folder: file:///C:/Users/Dave/AppData/Local/Temp/VMBuilds/vmicro_test_1/new_board_description_uno8/Debug
Summary: Header=1 Prototypes=3 Imports=1
Additional Defines:
Sketch Book: file:///C:/Users/Dave/Documents/Arduino
Sketch Include Paths
Core Include Paths
System.ArgumentException: The path is not of a legal form.
   at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.GetFullPathInternal(String path)
   at System.IO.DirectoryInfo.Init(String path, Boolean checkHost)
   at System.IO.DirectoryInfo..ctor(String path)
   at Visual.Micro.MiroAppAPI.SketchCompiler.CreateFileTimeListXml(String fileType, String sPath, String outputPath)
   at Visual.Micro.MiroAppAPI.SketchCompilerArduino._compile(SketchBuilder lsketch, String primaryClassName, Boolean verbose, Boolean isDebug)
   at Visual.Micro.MiroAppAPI.SketchCompilerArduino.compile(SketchBuilder lsketch, String primaryClassName, Boolean verbose, Boolean isDebug)
   at Visual.Micro.Visual.Studio.Arduino.AddInApp._CompileDo(Object oProject, Boolean IsDebugStartCommand, Boolean isRebuild, Boolean UseGdbIfAvailable)
   at Visual.Micro.Visual.Studio.Arduino.AddInApp.CompileDo(Object oProject, Boolean IsDebugStartCommand, Boolean isRebuild, Boolean UseGdbIfAvailable)
   at Visual.Micro.Visual.Studio.Arduino.AddInApp.Compile(Object oProject, Boolean IsDebugStartCommand, Boolean IsRebuild, Boolean UseGdbIfAvailable)

Does this have any clues?

Title: Re: Inexplicable errors when importing/starting Arduino project in AS7
Post by Visual Micro on Sep 1st, 2017 at 9:43pm
Hi,

You have some strange config.

Please delete "C:\Users\Dave\Documents\Arduino\hardware" or if you really need something you have installed into the hardware folder then delete "C:\Users\Dave\Documents\Arduino\hardware\new_board_description"

Install the arduino ide either from the zip on the arduino site or using the windows installer.

Open "vMicro>Visual Micro Explorer>Ide locations". Selected the first entry in the list if it is not selected already (arduino 1.6/1.8). Enter the path of where the arduino ide is installed

Click OK.

On the vMicro menu (or toolbar) change the application name from "Visual Micro" to "Arduino 1.6/1.8"

Now build should work using the arduino avr tool chain that is installed with the arduino ide and not the partial one you have installed into "C:\Users\Dave\Documents\Arduino\hardware\new_board_description".

Does this help?


note: Ensure that you are always using the "Arduino 1.6/1.8" option. The other options are for advanced users.


Title: Re: Inexplicable errors when importing/starting Arduino project in AS7
Post by Dave Telling on Sep 2nd, 2017 at 2:44am

Tim@Visual Micro wrote on Sep 1st, 2017 at 9:43pm:
Hi,

You have some strange config.

Please delete "C:\Users\Dave\Documents\Arduino\hardware" or if you really need something you have installed into the hardware folder then delete "C:\Users\Dave\Documents\Arduino\hardware\new_board_description"

Install the arduino ide either from the zip on the arduino site or using the windows installer.

Open "vMicro>Visual Micro Explorer>Ide locations". Selected the first entry in the list if it is not selected already (arduino 1.6/1.8). Enter the path of where the arduino ide is installed

Click OK.

On the vMicro menu (or toolbar) change the application name from "Visual Micro" to "Arduino 1.6/1.8"

Now build should work using the arduino avr tool chain that is installed with the arduino ide and not the partial one you have installed into "C:\Users\Dave\Documents\Arduino\hardware\new_board_description".

Does this help?


note: Ensure that you are always using the "Arduino 1.6/1.8" option. The other options are for advanced users.


I did point to Arduino 1.6/1.8 IDE, and built the project. I didn't delete the hardware folder. The program seemed to build correctly, and I was able to program the mega328 using the AVR Dragon, so I'd say that things are good to go.
Much thanks for your help!

Title: Re: Inexplicable errors when importing/starting Arduino project in AS7
Post by Visual Micro on Sep 2nd, 2017 at 11:19am
Great, thanks for the update.

VS Arduino » Powered by YaBB 2.6.12!
YaBB Forum Software © 2000-2024. All Rights Reserved.