Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Reset board before upload (OpenOCD) (Read 2271 times)
cirlam12
Newbies
*
Offline


Posts: 4
Joined: Jun 24th, 2019
Reset board before upload (OpenOCD)
Jun 24th, 2019 at 8:29am
Print Post  
I have a custom board based on the SamD21 (original prototypes were Arduino Zero based, and therefore my OpenOCD scripts are almost identical to those supplied).

On my custom board, I reconfigure the SWD pins in software as GPIOs, meaning the board NEEDS a reset before it can be uploaded to. 

I can successfully upload to the device if I manually reset the board the moment before the upload takes place from vMicro, however if I time the reset wrong, it obviously fails as the pins are then configured as a GPIO within ~2 seconds of power up.  I'd like to avoid lengthening this delay if at all possible.

Is there anyway I can automatically initiate this reset the moment before upload? Atmel Studio is able to upload all the time, without fail (watching with my logic analyzer Atmel Studio pulls the reset pin low everytime the moment before upload, whereas vMicro does not). 

I have tried within my board platform.txt (which I have confirmed vMicro is using) adding "init; reset halt;" just before the program command. I.e:

tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; reset halt; program {{{build.path}/{build.project_name}.bin}} verify reset 0x2000; shutdown"

tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f "{runtime.platform.path}/variants/{build.variant}/{build.openocdscript}" -c "telnet_port disabled; init; reset halt; program {{{build.path}/{build.project_name}.elf}} verify reset; shutdown"

However, this fails to pull the reset line low when checked with my logic analyser, and when trying to program the device. I believe my reset-config is correct in openOCD as if I add "connect_assert_srst" (which pulls the reset line low when the target connects automatically - as described here: http://openocd.org/doc/html/Reset-Configuration.html) in my arduino_zero.cfg file, the reset line does get pulled low.

I am using an Atmel ICE programmer. Does anyone have any idea what I'm doing wrong?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Reset board before upload (OpenOCD)
Reply #1 - Jun 24th, 2019 at 12:31pm
Print Post  
Hi,

We are missing some info here.

The Zero has two usb ports. One called programming port and one called native usb port. 

By default both arduino ide and visual micro will use the default upload based on each port type but in both cases they do not use the ICE for upload. 

In the case of programming port the built in EDBG programmer is used, for the Native port the board is triggered into bootloader mode by connecting serial at 1200 baud then the upload happens over serial

Both of the above do not use ICE to upload. 

I don't believe that arduino have produced an ICE programmer definition for a zero. If they did that would be defined in programmers.txt not platform.txt (same folder)

To use visual micro or the arduino ide with an external programmer you would need to select the programmer in the ide from the programmers list and in visual micro click "always use programmer for upload". In the arduino ide you have to specifically click "Upload using programmer" to make a single upload using the selected programmer.

Visual Micro in atmel studio adds a special programmer name called "Use atmel studio device programming". When enabled, visual micro, will build and then hand the upload over to atmel studio to use whatever device you have selected for your atmel project.

I hope this information helps resolve some gray areas and that you are now able to report which type of upload you are using from visual micro and from the arduino ide.

Feel free to ask anything that is not clear. External programmers are not so well documented between arduino and atmel. Thanks
  
Back to top
WWW  
IP Logged
 
cirlam12
Newbies
*
Offline


Posts: 4
Joined: Jun 24th, 2019
Re: Reset board before upload (OpenOCD)
Reply #2 - Jun 24th, 2019 at 1:34pm
Print Post  
Hi Tim,

Thanks for the response. The OpenOCD files are copied from the Arduino SamD core: https://github.com/arduino/ArduinoCore-samd, which does include Atmel ICE programmer definition and the openocd scripts.

We do have "always use programmer for upload" ticked - and are using vMicro plugin for Visual Studio (no Arduino IDE). I imagine, if we were to port the project over to Atmel Studio and use the "use atmel studio device programming" option this problem would be solved, but in the interest of avoiding rebuilding the project in Atmel Studio would prefer to make it work in Visual Studio if there is something obvious missing from my openocd scripts.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Reset board before upload (OpenOCD)
Reply #3 - Jun 24th, 2019 at 1:41pm
Print Post  
Hi,

Thanks for the info. I agree that VS is better than Atmel for most things however Visual Micro will open the same project using Visual Micro in "Atmel Studio >File>Open Arduino Project"

Having said that I would like to resolve the problem. Does the reset work using the ICE programmer to upload from the Arduino IDE?

Thanks
  
Back to top
WWW  
IP Logged
 
cirlam12
Newbies
*
Offline


Posts: 4
Joined: Jun 24th, 2019
Re: Reset board before upload (OpenOCD)
Reply #4 - Jun 24th, 2019 at 2:39pm
Print Post  
Hi Tim,

I haven't been able to test this just yet, as we have our header/source files loaded into a folder structure, such that all the header and source files aren't just lumped into 1 folder. Unfortunately when opening in Arduino (and Atmel Studio, when opening as an Arduino project), it flattens this structure (and loads them as if they are just lumped into the same folder) and will require me to change how the majority of my files include each other.

I hope I might get some time tomorrow to quickly change these includes to test this though.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Reset board before upload (OpenOCD)
Reply #5 - Jun 26th, 2019 at 1:30am
Print Post  
1)
In Visual Studio, are you using shared projects or just one Arduino project?

2)
If you use the latest release of visual micro from this forum (1906.26). Do you see the new "Debug" tool bar? If so when you select "Hardware Debugging" do you see a list of "debuggers"? The ICE will not be in the list yet but it is important to know if you see the list that is there? If not we will need a bit more info about your platform.


Thanks
« Last Edit: Jun 26th, 2019 at 1:33am by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
cirlam12
Newbies
*
Offline


Posts: 4
Joined: Jun 24th, 2019
Re: Reset board before upload (OpenOCD)
Reply #6 - Jun 27th, 2019 at 8:19am
Print Post  
1. No, just a regular arduino project

2. Yes I have upgraded to 1906.26.4 - although I can't see the debug tool bar. The closest thing I get to it is in the Add/Remove buttons toolbar:

https://ibb.co/XYQHZsr

Cheers, Chris

  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Reset board before upload (OpenOCD)
Reply #7 - Jun 27th, 2019 at 12:11pm
Print Post  
1)
If you are not using shared projects then I don't understand your point about arduino and atmel flattening your projects. They work the same. Maybe in atmel you need to click the little "show all files" icon above the solution explorer to see physical file view.

2)
The debug tool bar is empty because your platform is unknown platform. we would need the build output mentioned in the yellow box at the top of this page to give more advice about gdb in VS
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint