VS Arduino
Visual Micro >> Usb/Serial/WiFi Debugging >> Upload-error in VS with VM, but works OK in Arduino IDE
https://www.visualmicro.com/forums/YaBB.pl?num=1574108400

Message started by gj on Nov 18th, 2019 at 8:20pm

Title: Upload-error in VS with VM, but works OK in Arduino IDE
Post by gj on Nov 18th, 2019 at 8:20pm
I have this simple sketch that uploads perfectly using Arduino IDE V1.8.9, but gives error in VS2017 (Community, V15.9.17) using Visual Micro (v19.0).
I'm using a Nano with the CH340-chip. I have the driver from CH341SER.EXE installed.

Since the uploading works flawlessly in the Arduino IDE, but not in VS/VM I'm assuming the problem is not with the hardware but with VM.


Code (c++):

const int pin = 12;

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

void loop() {
  digitalWrite(pin, HIGH);
  delay(random(100, 2000));
  digitalWrite(pin, LOW);
  delay(random(100, 500));
}


Error:
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x09
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=Upload-Error_002.txt ( 37 KB | 2 Downloads )

Title: Re: Upload-error in VS with VM, but works OK in Arduino IDE
Post by Visual Micro on Nov 18th, 2019 at 8:30pm
Please try with compile and upload with the tool bar set to Release instead of Debug.

If that still fails you can see the upload command at the end of the trace

Does it work fro the cmd prompt?

[code]"D:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude" "-CD:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM6" -b57600 -D "-Uflash:w:C:\Users\****\AppData\Local\Temp\VMBuilds\Test\NANO_A~1\Debug/Test.ino.hex:i"[/code]

Title: Re: Upload-error in VS with VM, but works OK in Arduino IDE
Post by gj on Nov 18th, 2019 at 8:49pm
[code]C:\Users\****>"D:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude" "-CD:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM6" -b57600 -D "-Uflash:w:C:\Users\****\AppData\Local\Temp\VMBuilds\Test\NANO_A~1\Release/Test.ino.hex:i"

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "D:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM6
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
avrdude: ser_open(): can't open device "\\.\COM6": Access is denied.


avrdude done.  Thank you.[/code]


ArduinoIDE_003.png ( 67 KB | 7 Downloads )

Title: Re: Upload-error in VS with VM, but works OK in Arduino IDE
Post by Visual Micro on Nov 18th, 2019 at 8:51pm
That failed because the port is open and being used. Maybe arduino ide or vs has serial monitor open?

Title: Re: Upload-error in VS with VM, but works OK in Arduino IDE
Post by gj on Nov 18th, 2019 at 8:57pm
[code]
C:\Users\****>"D:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude" "-CD:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM6" -b57600 -D "-Uflash:w:C:\Users\****\AppData\Local\Temp\VMBuilds\Test\NANO_A~1\Release/Test.ino.hex:i"

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "D:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM6
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x43
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x43
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x43
^C
C:\Users\****>[/code]

Title: Re: Upload-error in VS with VM, but works OK in Arduino IDE
Post by Visual Micro on Nov 18th, 2019 at 9:00pm
Thanks that shows avrdude is failing.

I think you have verbose upload enabled in the arduino ide. Please upload and copy/paste the upload command into this thread. You can highlight and copy the output from arduino using mouse to highlight and keyboard to copy.

Title: Re: Upload-error in VS with VM, but works OK in Arduino IDE
Post by gj on Nov 18th, 2019 at 9:08pm

Code (]D:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CD:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM6 -b115200 -D -Uflash:w:C:\Users\****\AppData\Local\Temp\arduino_build_653940/Test.ino.hex:i [/code):


I ran this from the command-line:
[code]
C:\Users\****>"D:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude" "-CD:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -v -patmega328p -carduino -PCOM6 -b115200 -D -Uflash:w:C:\Users\****\AppData\Local\Temp\arduino_build_653940/Test.ino.hex:i

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "D:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM6
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 3
         Firmware Version: 4.4
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% -0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: reading input file "C:\Users\****\AppData\Local\Temp\arduino_build_653940/Test.ino.hex"
avrdude: writing flash (1546 bytes):

Writing | ################################################## | 100% 0.36s

avrdude: 1546 bytes of flash written
avrdude: verifying flash memory against C:\Users\****\AppData\Local\Temp\arduino_build_653940/Test.ino.hex:
avrdude: load data flash data from input file C:\Users\****\AppData\Local\Temp\arduino_build_653940/Test.ino.hex:
avrdude: input file C:\Users\****\AppData\Local\Temp\arduino_build_653940/Test.ino.hex contains 1546 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.34s

avrdude: verifying ...
avrdude: 1546 bytes of flash verified

avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.


Title: Re: Upload-error in VS with VM, but works OK in Arduino IDE
Post by Visual Micro on Nov 18th, 2019 at 9:16pm
Well let's ignore that last issue in arduino for now because it is unrelated.

The issue you have with vm and infact with the external avrdude program might be one of two things.

Arduino sometimes has a random upload bug due to some program size mangic number. Did you confirm the issue happens in Visual Micro in release mode. Your initial post was in debug mode. That can be one way to alter the program size.

I also note that you have a chinese usb driver installed instead of the one that is installed by the arduino ide. Is that intentional? This type of issue is closly related to usb driver.

tip: The usb drivers are in a sub folder called \drivers below the arduino ide. When the board is connected you can use device manager to update the usb driver from that location.

Title: Re: Upload-error in VS with VM, but works OK in Arduino IDE
Post by gj on Nov 18th, 2019 at 9:33pm
Compiling in either Debug or Release shows:
[code]
D:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude "-CD:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM6" -b57600 -D "-Uflash:w:C:\Users\****\AppData\Local\Temp\VMBuilds\Test\NANO_A~1\Debug/Test.ino.hex:i"
The specified executable is not a valid application for this OS platform.
[/code]

The chinese driver CH341SER was advised by many people across forums having the same (or similar) issue.

Title: Re: Upload-error in VS with VM, but works OK in Arduino IDE
Post by Visual Micro on Nov 18th, 2019 at 11:07pm
That would probably work but it's missing the quotes around the avrdude program at the start

I know this issue can be an inherent problem for some users and sadly it's unrelated to visual micro or we could do something about it.

I think in the past a few things have been established by some users...

1) Sometimes hitting a magic program size number. Adding a little more code can solve the issue.

2) Sometimes using a different avr version can resolve the issue. For example installing the latest arduino 1.8.10 might solve the issue or even using one of the the zip downloads for an older arduino ide such as 1.8.6 might solve the issue. You can use the zips from arduino.cc to install as many arduino versions as you want to try.

3) Sometimes a different usb cable can help but the fact that it works from the arduino ide suggests it's a slightly different end result program size.

It might be useful to note that visual micro uses the avr toolchain that is installed with the arduino IDE and each provides a slightly different avr version. I doubt it really matters which you use.


Title: Re: Upload-error in VS with VM, but works OK in Arduino IDE
Post by gj on Nov 20th, 2019 at 11:17am
Ok, I uninstalled Arduino IDE and VS2017.
Then reinstalled VS2017, VM-extension and Arduino IDE.
And it's uploading.
No idea as to why this suddenly stopped working.

Thanks for your support. You guys (and gals?) are so quick to respond. Really good. :D

And that's just one of the reasons I chose to buy your product in the past.

So, now back to the original project I was working on when upload-stuff started to break down on me.  :)

Title: Re: Upload-error in VS with VM, but works OK in Arduino IDE
Post by Visual Micro on Jan 6th, 2020 at 9:06pm
Thanks, I suspect that when you installed the arduino ide it was a newer version. They have been at arduino adding new toolchains. I guess the newer avrdude.exe uploader tool is happier with your usb driver/cables/something.

[code]C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude [/code]

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