Sysprogs forums › Forums › VisualGDB › Flashing Arduino Zero Clone does not work
- This topic has 18 replies, 3 voices, and was last updated 6 years, 1 month ago by support.
-
AuthorPosts
-
August 8, 2018 at 21:49 #21628thomas.kunze@gmx.comParticipant
Hi,
I’m very exited about the new arduino support. But I can’t flash my arduino zero clone with visual-studio. I pressed “program FLASH memory” in the context menu, but the command never returns. The command is:
C:\Users\user\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.7.0\bossac.exe –port=COM7 -U true -i -e -w -v “C:\Users\user\Source\samd\Output\Arduino_Genuino_Zero__Native_USB_Port_\Debug\samd-demo.ino.bin” -R
I noticed that the arduino IDE has a slightly different command and it resets the device before flashing:
Forcing reset using 1200bps open/close on port COM7
PORTS {COM3, COM7, } / {COM3, } => {}
PORTS {COM3, } / {COM3, COM8, } => {COM8, }
Found upload port: COM8
C:\Users\user\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.7.0/bossac.exe -i -d –port=COM8 -U true -i -e -w -v C:\Users\user\AppData\Local\Temp\arduino_build_343404/samd-demo.ino.bin -RAnother small issue:
I get “warn: WARNING: Spurious .vs folder in ‘foobar_samd’ library”. warnings. I develop a lib and changed
<SketchSubdirectory>examples\samd-demo</SketchSubdirectory> to add the example sketch in Visual Studio. Then I added the lib itself as a reference.
So I have in the project dir:
examples\samd-demo\samd-demo.ino
src (the code of the lib)
foobar.sln
foobar.vgdbproj
library.properties
The warning doen’t hurt, but I wanted to report this just in case.
Regards,
Thomas
August 9, 2018 at 18:45 #21640supportKeymasterHi,
Thanks for reporting this, it looks like we indeed missed this scenario (we tested with the Arduino Due, but not with Zero).
From the log file you attached, it looks like the upload COM port (used with the bossac tool) appears after Arduino Studio runs the 1200 bps sequence on the regular COM port selected for programming. Could you please confirm that via Device Manager? If this is the case, we can easily add support for this.
The warning might indeed indicate another bug. The Arduino builder tool expects the source folders to contain no other files, hence VisualGDB places the sketches and library files inside subfolders (instead of storing them in the project directory). Did you try adding a library residing directly in the project directory? If yes, please relocate it to a subfolder instead (please also confirm if this is the case, so we would add a more meaningful warning for this).
August 11, 2018 at 23:00 #21647thomas.kunze@gmx.comParticipantIn the device manager I have “Arduino Zero (COM7)” after the reset sequence this disappears and “Arduino Bootloader (COM8)” appears. After flashing it’s “Arduino Zero (COM7)” again.
My project directory layout can be seen here:
https://github.com/thelsing/knx-samd
I can’t change it because I want to be able to use the library by cloning it into the arduino libraries folder.
August 12, 2018 at 21:58 #21653thomas.kunze@gmx.comParticipantDoes VisualGdb provide something like the Serial Monitor of arduino IDE? If yes, where is it hidden?
August 13, 2018 at 22:45 #21672supportKeymasterHi,
Thanks for confirming this. We have fixed the programming port location logic in this build: http://sysprogs.com/files/tmp/VisualGDB-5.4.4.2396.msi
If you want to be able to clone the library into the Arduino libraries folder, please consider moving your Visual Studio solution (and VisualGDB project) into a subdirectory instead (e.g. examples). It cannot be the same directory as the sketch files though, as Arduino will try to copy it recursively to the build directory. If this doesn’t help, let us know and we will try to suggest something better.
VisualGDB does provide a built-in terminal (Raw Terminal in VisualGDB Project Properties), although it is only available in the Custom edition and higher. If you are using a lower edition, please consider our free SmarTTY tool. It is functionally equivalent, although will run in a separate window and won’t be synchronized with launching the project.
August 14, 2018 at 22:05 #21679thomas.kunze@gmx.comParticipantHi,
Flashing works fine now. I put the Visual Studio files in their own folder. Now there are now more “Spurios .vs folder” warnings. But I noticed some other things:
- Special chars in build output are broken for info lines:
info: Using board ‘arduino_zero_native’ from platform in folder: C%3A%5CUsers%5Ctkunze%5CAppData%5CLocal%5CArduino15%5Cpackages%5Carduino%5Chardware%5Csamd%5C1.6.19
===info ||| Using library {0} at version {1} in folder: {2} {3} ||| [FlashStorage 0.7.1 C%3A%5CUsers%5Ctkunze%5CDocuments%5CArduino%5CLibraries%5CFlashStorage ]- “Program Flash Memory” should build the project if necessary, or better ask if it should.
- I like SmarTTY. But there are some small issues with it:
- I have to disconnect SmartTTY to flash the device and reconnect after.
- It disconnects when device is reset with button. I have to reconnect manually.
- Does this work with the buildin TTY of Custom Edition?
- I think a serial console should be included in a “Arduino Edition” of VisualGDB because most sketches use serial console for debugging printouts. Or are they redirected to “Program output” during debugging? (I don’t have a JTAG-SWD adapter yet, so I can’t test debugging.)
- It would be nice to be able to reset the connected device from context menu.
- It would be nice to have “Build”, “Flash”, “Build & Flash”, “Reset”, “Serial Console” Buttons in the VisualGdb Toolbar.
August 16, 2018 at 23:07 #21697thomas.kunze@gmx.comParticipantSome more issues:
- It’s not possible to add .vgdbproj files to an existing solution with VisualStudio. You have to edit the .sln-file manually.
- I can’t choose OpenOCD as a debug method for esp8266 NodeMCU Board.
BTW: Is it ok to report additional issues here or should I create a new thread?
August 21, 2018 at 07:02 #21731supportKeymasterHi,
Sorry for the delayed reply. Please try this build: http://sysprogs.com/files/tmp/VisualGDB-5.4.4.2402.msi
The Arduino projects are indeed more dependent on the serial connection, so we have added an equivalent of the Raw Terminal (called Arduino Serial Terminal) that uses the COM port used for communicating with the device. This terminal will work on all VisualGDB editions, but only for Arduino projects.
Resetting the Arduino target from the toolbar/terminal sounds reasonable, however it looks like something platform-specific (i.e. there is no universal command line that will do it for all supported targets). We could add a setting specifying the reset sequence with commands like “connect at a specified BPS”, “set/clear various UART signals”, “send bytes”, etc. In one of the next major releases we could include out-of-the-box definitions for this reset sequence for popular targets, although initially you would have to provide it manually (e.g. by looking through esptool.py sources). Would that be a reasonable workaround?
With OpenOCD, unfortunately the ESP8266 Arduino core modifies some internal registers in a way that completely blocks JTAG debugging. We have contacted Espressif regarding this and could not get any reply from them. As ESP8266 is generally less reliable than the newer ESP32 chip (that doesn’t have this issue and works with JTAG), we would advise switching to it instead, or using the ESP8266 gdb stub, that is also very limited when used with the Arduino core (we will publish a tutorial soon explaining the limitations).
We have added the rest of the features/fixes as you described them. Thanks for your suggestions and feel free to get back to us if you have more ideas on making Arduino support more convenient. The Arduino project subsystem is very new and we appreciate any feedback that helps us make it better.
Regarding the forum threads, it is normally easier for other users to find relevant threads if separate issues are reported in separate threads, but you don’t need to worry about it – we can always split the thread from our side if we post a workaround that would be otherwise hard to find based on the original title.
August 23, 2018 at 22:04 #21755thomas.kunze@gmx.comParticipantThe workaroud for resetting the device sounds like a good idea to me.
I did some tests with my arduino zero clone. First VisualGDB could not flash the device. It would stay in “bootloader mode” and in the flash popup was some exception. Flash was already deleted, because after hardware reset the device was still in bootloader mode. I flashed the device with arduino ide. I had to press the reset button on the device during the flashing process because arduino ide could not reset the device as it was already in bootloader mode. (After restart of VS flashing worked again after I reflashed the device with arduino ide. I could no reproduce this error any more.)
Because the flashing magic in visual gdb happends behind the “Uploading sketch” popup. I like the arduino flashing was with console output better. So please integrate flashing in the build output again or add an option for that? I also don’t like the “Flashing successful” messagebox. In the code->flash->debug workflow you always have to close this anoying box.
The build in serial console is great. The startup is a bit slow even if the window is already open (2s to first println in setup()). Maybe this is because the console is only connected after I close the messagebox?
When I want’t to flash the device when console is still connected I get an “Access to Com7″ denied” error. After I disconnect the console it work. Maybe this can be automated?
After closing the console window the connection stays open. I think it should ask if the connection should be close. So the user knows that it stays open otherwise.
Reseting the device closes the connection of the serial console. Maybe it could reconnect automatically after the COM port becomes available again?
Some options if the console should be cleared on disconnect/reconnect would be nice. This way I could produce some output on serial console, change some code, flash device, produce output, compare to last output by scrolling up.
Sometimes I get a visual studio exception. Not sure if it’s related to visualgdb. It says that I should inspect the ActivityLog.xml. Here is the entry from there:
<entry>
<record>893</record>
<time>2018/08/23 20:33:02.513</time>
<type>Error</type>
<source>Editor or Editor Extension</source>
<description>System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at Microsoft.VisualStudio.VC.Editor.TemplateBarAdornmentManager.AddTextView(IWpfTextView textView) at Microsoft.VisualStudio.VC.Editor.TemplateBarAdornmentFactory.TextViewCreated(IWpfTextView textView) at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.<>c__DisplayClass251_0.<BindContentTypeSpecificAssets>b__1() at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call) — End of stack trace from previous location where exception was thrown — at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)</description>
</entry>- This reply was modified 6 years, 3 months ago by thomas.kunze@gmx.com.
August 23, 2018 at 22:46 #21757thomas.kunze@gmx.comParticipantHere are some more entries of the acitivity log:
<entry>
<record>889</record>
<time>2018/08/23 20:32:56.048</time>
<type>Information</type>
<source>MruList</source>
<description>Entering OnAddVerbInvoked</description>
</entry>
<entry>
<record>890</record>
<time>2018/08/23 20:32:56.048</time>
<type>Information</type>
<source>MruList</source>
<description>Entering AddItem. Persistence data for item: C:\Users\tkunze\Source\knx-samd\examples\knx-samd-demo\knx-samd-demo.ino</description>
</entry>
<entry>
<record>891</record>
<time>2018/08/23 20:32:56.048</time>
<type>Information</type>
<source>MruList</source>
<description>Entering TryPromoteItem</description>
</entry>
<entry>
<record>892</record>
<time>2018/08/23 20:32:56.048</time>
<type>Information</type>
<source>MruList</source>
<description>Entering PromoteItemAt and found the index of the item to be 0</description>
</entry>
<entry>
<record>893</record>
<time>2018/08/23 20:33:02.513</time>
<type>Error</type>
<source>Editor or Editor Extension</source>
<description>System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at Microsoft.VisualStudio.VC.Editor.TemplateBarAdornmentManager.AddTextView(IWpfTextView textView) at Microsoft.VisualStudio.VC.Editor.TemplateBarAdornmentFactory.TextViewCreated(IWpfTextView textView) at Microsoft.VisualStudio.Text.Editor.Implementation.WpfTextView.<>c__DisplayClass251_0.<BindContentTypeSpecificAssets>b__1() at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call) — End of stack trace from previous location where exception was thrown — at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)</description>
</entry>September 1, 2018 at 07:19 #21864supportKeymasterHi,
Thanks for your input. We have redesigned the Raw Terminal/Arduino Terminal window to support automatic reconnecting, easier editing of settings, graying out previous text instead of clearing it and several other usability features. We have also resolved several issues you reported. Please try this build: http://sysprogs.com/files/tmp/VisualGDB-5.4.4.2418.msi
We have also added support for defining reset sequences for Arduino targets. The easiest way to get started with them would be to edit the ArduinoDeviceIDRules.xml file in the VisualGDB directory. Add the <TerminalResetSequence> element under the <Rule> element for the ARM devices (see the ESP32 rule for an example of the TerminalResetSequence syntax) and restart Visual Studio. Next time you open the raw terminal for your Arduino project, it will show the “Reset target” button that will execute the specified script on the COM port. Let us know if you need more details about reset scripting and we will help you get it to work.
With the VS exceptions, unfortunately we were not able to reproduce them on our side, however it looks like they are caused by the recently added VC++ template bar. Please try checking if the issue can be reproduced on a regular VC++ project (not VisualGDB-based), specifically if you try unloading/reloading it via context menu. If this is the case, please feel free to submit a bug report to Microsoft. If not, please let us know if you manage to get a reliable way to reproduce the problem and we will re-investigate it.
Let us know if you have any feedback/further suggestions and we will be happy to make VisualGDB even better.
- This reply was modified 6 years, 2 months ago by support. Reason: Added support for reset sequences
September 5, 2018 at 22:09 #21885thomas.kunze@gmx.comParticipantHi,
I tried this build today it works really great. Some minor things I noticed:
- the “Build and Flash” command does not work. I have to build first, and flash later. Otherwise Flashing fails and the device can’t be flashed with VisualGDB any more (flash was already erased, so it only starts in bootloader mode and can’t be reset any more. Flashing with arduino ide works as it waits a while until a new com port becomes available. I can simulate the device reset by pressing the reset button (or unplug an replug the usb cable)
- When creating a new project I can only choose the samples from my chosen platform. I would like to also choose the general arduino samples and the samples of my installed arduino libs.
- It would be nice to be able to change the colors of the serial console (background, old content, new content). The serial console is really awesome now btw.
- The “flashing successful” messagebox comes even if flashing fails.
- I don’t get why it is possible to add multiple sketches to a project. I get compile errors (multiple definitions of setup() and loop()) when I do so.
- I understood where I should place the TerminalResetSequence. But I don’t know what I should put there to reset the arduino zero.
September 6, 2018 at 20:48 #21896supportKeymasterHi,
Thanks for your feedback. The “build and Flash” issue might be caused by a timing error somewhere in the FLASHing logic. If you could share the output from an unsuccessful FLASHing operation, we might be able to tell more. We could also add a delay setting between the completion of the build and FLASHing.
With samples, thanks for the suggestion. We will consider searching more directories for samples in one of the next VisualGDB versions, although we won’t change this logic now due to our release schedule.
You can change the colors of the Arduino terminal via the corresponding page of VisualGDB Project Properties (you need to enable it first). We have added an option to change the inactive color to this build: http://sysprogs.com/files/tmp/VisualGDB-5.4.4.2427.msi
We have also double-checked the behavior for failed FLASHing, however could not reproduce any problems. Could you please share the internal output from such a session? Perhaps the underlying tool still exits with code 0 despite the error?
With terminal reset sequence, this is specific to your Arduino board. Please check its schematics and Arduino forums/documentation. Most likely there is a sequence of events (e.g. setting/clearing signals like DTR) that lead to a reset. Once you find that sequence, let us know and we can help you configure VisualGDB to use it.
September 7, 2018 at 18:37 #21902thomas.kunze@gmx.comParticipant“Build and Flash” builds the whole solution. My project wasn’t configured for build in the configuration manager. So it wasn’t build. I think “Build and Flash” should only build the active project and flash it an ignore the configuration manager as the build command from context menu does.
-Projects have no arduino icon in the solution-explorer in the current build. (only a red dot with an x). Building is broken, too:
—— Build started: Project: BcuTest, Configuration: Debug Arduino Genuino Zero (Native USB Port) ——
VisualGDB: Run “C:\Program Files (x86)\Sysprogs\VisualGDB\Arduino\arduino-builder.exe -compile -logger=machine -fqbn=arduino:samd:arduino_zero_native -build-path C:\Users\tkunze\Source\knx-stack\BcuTest\Output\Arduino_Genuino_Zero__Native_USB_Port_\Debug -unoptimize=sketch -verbose -hardware “C:/Program Files (x86)/Arduino/hardware” -hardware C:\Users\tkunze\AppData\Local/Arduino15/packages -tools “C:/Program Files (x86)/Arduino/tools-builder” -tools C:\Users\tkunze\AppData\Local/Arduino15/packages -built-in-libraries “C:/Program Files (x86)/Arduino/libraries” -libraries C:\Users\tkunze\Documents/Arduino/Libraries -prefs=runtime.tools.avrdude.path=C:\Users\tkunze\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.arduinoOTA.path=C:\Users\tkunze\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.2.0 sketches/BcuTest.ino” in directory “C:\Users\tkunze\Source\knx-stack\BcuTest” on local computer
————————————————————-
Command exited with code -1
Executable: C:\Program Files (x86)\Sysprogs\VisualGDB\Arduino\arduino-builder.exe
Arguments: -compile -logger=machine -fqbn=arduino:samd:arduino_zero_native -build-path C:\Users\tkunze\Source\knx-stack\BcuTest\Output\Arduino_Genuino_Zero__Native_USB_Port_\Debug -unoptimize=sketch -verbose -hardware “C:/Program Files (x86)/Arduino/hardware” -hardware C:\Users\tkunze\AppData\Local/Arduino15/packages -tools “C:/Program Files (x86)/Arduino/tools-builder” -tools C:\Users\tkunze\AppData\Local/Arduino15/packages -built-in-libraries “C:/Program Files (x86)/Arduino/libraries” -libraries C:\Users\tkunze\Documents/Arduino/Libraries -prefs=runtime.tools.avrdude.path=C:\Users\tkunze\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9 -prefs=runtime.tools.arduinoOTA.path=C:\Users\tkunze\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA\1.2.0 sketches/BcuTest.ino
Directory: C:\Users\tkunze\Source\knx-stack\BcuTest
Environment: EFP_BASE=C:/Users/tkunze/AppData/Local/VisualGDB/EmbeddedEFPs|TESTFW_BASE=C:/Users/tkunze/AppData/Local/VisualGDB/TestFrameworks
VisualGDB: Error: Command-line action failed
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========– For flashing failures: I will post the command output the time it fails.
Unfortunately the Zero doesn’t seem to have a reset sequence. Only a soft erase sequence.
A bit offtopic: is the olimex arm-usb-ocd-h with the swd adapter supposed to work with arduino zero?
- This reply was modified 6 years, 2 months ago by thomas.kunze@gmx.com.
September 7, 2018 at 20:17 #21904supportKeymasterHi,
Sorry about that, looks like the previous build was missing the Arduino builder component. Please try this build: http://sysprogs.com/files/tmp/VisualGDB-5.4.4.2428.msi
-
AuthorPosts
- You must be logged in to reply to this topic.