Visual Studio Ide for Arduino
https://www.visualmicro.com/forums/YaBB.pl
Visual Micro >> Usb/Serial/Udp Debugging >> Debugging works 100% on UNO but fails on my Black Pill (STM32F103C8T6)
https://www.visualmicro.com/forums/YaBB.pl?num=1551877362

Message started by castingflame on Mar 6th, 2019 at 1:02pm

Title: Debugging works 100% on UNO but fails on my Black Pill (STM32F103C8T6)
Post by castingflame on Mar 6th, 2019 at 1:02pm
After struggling for several hours with an Interrupt issue, I decided to dedicate a few hours to going through the tuition for the Visual Micro debugger. I connected my Uno and everything worked as described. I must say is is pretty damn good, very useful and one of the main reasons I paid for Visual Micro again. With a big smile I went to try and debug my own MCU which is a Black Pill (STM32F103C8T6).


I have tried Serial (USART not USB as I have no bootloader) and ST-Link but I am just failing. I guess that my MCU is not supported   :'(

EDIT: With a fresh sketch just using blinky the 'Release' over ST-Link works fine. I made a variable to hold a changing blink rate length so that I have a moving target to monitor.


Code (c++):
int blinkDelay = 100; //Starting delay

void setup() {
  pinMode(PB12, OUTPUT);  //Black Pill LED

  Serial.begin(115200);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(PB12, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(blinkDelay);                       // wait for a second
  blinkDelay++;
  Serial.println("LED On");
 
  digitalWrite(PB12, LOW);    // turn the LED off by making the voltage LOW
  delay(blinkDelay);                       // wait for a second
  blinkDelay++;
  Serial.println("LED Off");
}


I move to Debug mode with Automatic Debugging and Trace Only enabled.

I just get 'Launching Debugger...' in the output window and no flashing LED on the Dev board. As mentioned, I did a 'Release' build first. Obviously I can not do any breakpoints if it is not running.
 

Is there anything I can do to fix this, like creating my own pin map files for VM or is it massively more complicated than that?

This is a real blow and a set back. I am not sure where to go from here. :-[




Edit2: Re starting the IDE and using Serial (USART)

FWIW GoToDefinition reports Serial as extern USBSerial Serial;

NOTE: When using the USART 1 I have to manually hit the Reset button on the dev board before I can upload the Firmware. When Using 'Debug' I have tried hitting reset and not hitting reset. but I just get the error below.
Is this manual reset the problem?



Quote:
Compiling debug version of 'Blink' for 'Generic STM32F103C series'

Blink.ino: In function void setup()
   void setup() {

Error compiling project sources
Blink.ino:3: In file included from
   Debug Build Error: This hardware might not support the default Visual Micro Debugger.
     If this project is using OTA/WiFi upload then please use the vMicro>Debugger menu to set the Serial COM and Remote port for the debugger.
     Otherwise switch the toolbar from 'Debug' to 'Release' and build again.
           or switch off Automatic Debugging
           or configure the SoftwareSerial debugger option.
   void begin(USBSerial *theSerial)
Debug build failed for project 'Blink'
   ^~~~~
   void begin(USBSerial *theSerial, unsigned long baud)



Using STLink As mentioned above the upload works fine in 'Release' but just sits waiting in Debug with the 'Launching Debugger...' message.

Title: Re: Debugging works 100% on UNO but fails on my MCU
Post by Visual Micro on Mar 6th, 2019 at 3:56pm
Thanks for the detailed info and good to hear it has been useful.

We can add support but you might be able to config yourself if you try this...

Add a board.txt to the project with the following line, save the board.txt before upload and trying debug :-

[code]vm.debug.class_type.Serial=VM_DEBUGGER_TYPE_USBSERIAL[/code]


If that doesn't work we can probably try putting the instruction in a different location so let me know the result.

Title: Re: Debugging works 100% on UNO but fails on my Black Pill (STM32F103C8T6)
Post by castingflame on Mar 6th, 2019 at 4:37pm
Thanks for getting back to me Tim.

I added the file in the project directory.

Am I supposed to be using the Serial USART or ST-Link? I am trying both.

I still have the Debugger settings set to Auto Debugging and Trace Only. I have a breakpoint(tracepoint) set as an action on the last 'blinkyDelay++' of my code.


Using Serial USART

I did an MCU reset, then a 'Build' (which the LED confirmed was working), then 'Debug' (tried with and without MCU reset).

This was the result;


Quote:
Compiling debug version of 'Debug_test' for 'Generic STM32F103C series'

Debug_test.ino: In function void setup()
   void setup() {

Debug_test.ino:2: In file included from
Error compiling project sources
   Debug Build Error: This hardware might not support the default Visual Micro Debugger.
     If this project is using OTA/WiFi upload then please use the vMicro>Debugger menu to set the Serial COM and Remote port for the debugger.
     Otherwise switch the toolbar from 'Debug' to 'Release' and build again.
           or switch off Automatic Debugging
           or configure the SoftwareSerial debugger option.
   void begin(USBSerial *theSerial)
Debug build failed for project 'Debug_test'
   ^~~~~
   void begin(USBSerial *theSerial, unsigned long baud)
   ^~~~~




Using ST-Link

No MCU reset required. Done a 'Build' (which the LED confirmed was working), then 'Debug'.

Output  Shows 'Launching Debugger...', the Expressions window opens. I do not see the MCU LED alive or blinking and obviously no tracepoint tripped.



Title: Re: Debugging works 100% on UNO but fails on my Black Pill (STM32F103C8T6)
Post by Visual Micro on Mar 6th, 2019 at 4:42pm
if you use st link programmer upload then you probably need to set the com port for the debug using the vmicro>debugger menu. Local com and remote serial.

I need to try it over the next week or so. Unfortunately Microsoft have just started to force vs2019 onto everyone but it contains a change that obsoletes vs2012 and 2013 + the new system isn't so nice. Therefore the next week or so will be the usual Microsoft time waste for me.

Title: Re: Debugging works 100% on UNO but fails on my Black Pill (STM32F103C8T6)
Post by castingflame on Mar 7th, 2019 at 9:01am
Thanks again for your reply Tim.

I understand you have priorities at the moment and are unable to do anything directly about adding support but look forward to being able to use this when you have time to look at it.


Quote:
if you use st link programmer upload then you probably need to set the com port for the debug using the vmicro>debugger menu. Local com and remote serial.


The ST-Link does not use a traditional com port type driver and is seen by the system as a USB device.

The ST-Link does not appear as 'ST-Link' in either Override Local Port or Override Remote Port in the vmicro>debugger menu.

I have tried the following;

vmicro>Option 2> Upload Method: ST-Link

vmicro>debugger>Override Remote Port All options one by one; [Serial, Serial1, Serial2, Serial3, Serial4, Serial5, SerialUSB]

Results

Serial1 - 5 all error with this type of message...

Compiling debug version of 'Blink' for 'Generic STM32F103C series'
   Uart *transport
   ^~~~
   void begin(Uart *theSerial)
   ^~~~
   void begin(Uart *theSerial, unsigned long baud)
   ^~~~
   ^~~~~~~~~
   ^~~~~~~~~
   ^~~~
   ^~~~~~~~~
   ^~~~
   ^~~~~~~~~
   ^~~~~~~~
   #pragma GCC diagnostic pop
Error compiling libraries
   Debug Build Error: This hardware might not support the default Visual Micro Debugger.
     If this project is using OTA/WiFi upload then please use the vMicro>Debugger menu to set the Serial COM and Remote port for the debugger.
     Otherwise switch the toolbar from 'Debug' to 'Release' and build again.
           or switch off Automatic Debugging
           or configure the SoftwareSerial debugger option.
Debug build failed for project 'Blink'


Serial(0)

This does not error but sits waiting after Launching Debugger...



I am out of my depth here and can only really test and report back as much as possible so I will wait for you to be able to do your magic on this when your other commitments with the core product are complete.  8-)



Title: Re: Debugging works 100% on UNO but fails on my Black Pill (STM32F103C8T6)
Post by Visual Micro on Mar 7th, 2019 at 11:07am
Hi,

You will upload with st link but debug using Serial which is why you need to add override.

One benefit of the recent microsoft changes will be ability to more easily use gdb which would work well with st-link. This will be an alternative to serial debug. Each has its own strengths and weaknesses.

Title: Re: Debugging works 100% on UNO but fails on my Black Pill (STM32F103C8T6)
Post by castingflame on Mar 8th, 2019 at 11:36am
I tested it with St-Link as the Code uploader and USART serial set to Debugger by using the 'Override set to Serial (tried all of them). I tested it again today but it starts up but just sits at the Launching Debugger message.

I'll wait for you to do your stuff.


Thanks for keeping me updated Tim.

Title: Re: Debugging works 100% on UNO but fails on my Black Pill (STM32F103C8T6)
Post by castingflame on Mar 22nd, 2019 at 10:08pm
Just checking in to see how things are going with the core upgrade and if you have had any chance to look at the above issue.

Thanks Tim.

Title: Re: Debugging works 100% on UNO but fails on my Black Pill (STM32F103C8T6)
Post by Visual Micro on Mar 22nd, 2019 at 10:15pm
Sorry iMicrosoft released the 2019 RC and preview 4 which required some changes. Good news for you is the GDB is much easier to integrate tightly so will be done over the next few weeks.

I can test the black pill now but don't think I asked you for the json file you have used to install the board package.

Thanks

Title: Re: Debugging works 100% on UNO but fails on my Black Pill (STM32F103C8T6)
Post by castingflame on Mar 27th, 2019 at 8:10am
Thanks for your response Tim.

Good news about GDB and timelines :)

As for the Blackpill/Bluepill json file, I didn't use one. The libraries & drivers for the board are installed to the Windows local user ...\Documents\Arduino path. I am using Roger Clarkes solution (Teensy based) not the Official ST Arduino one as it came first and has better support for the generic RedPill/BluePill/BlackPill.


Please find below a everything you should need to test your BlackPill. This is all of the libraries, drivers and a quick test sketch. There is also a link in the comments of the sketch to confirm we are using the same BlackPill type.

EDIT: Google drive link to expand to (Windows local user)\Documents\Arduino\      

GoogleDrive:  https://drive.google.com/file/d/1Kq48FwWbcAAvX-rEYLgq6ZudABtykpRs/view?usp=sharing



Thanks Tim.

Title: Re: Debugging works 100% on UNO but fails on my Black Pill (STM32F103C8T6)
Post by Visual Micro on Apr 14th, 2019 at 4:17pm
Sorry for the delay and thanks for the info.

If you add these two lines to a local project board.txt and click save then the serial debugger should work.

[code]genericSTM32F103C.vm.debug.class_type=VM_DEBUGGER_TYPE_USBSERIAL
genericSTM32F103C.vm.debug.main_port_name=Serial
[/code]

An integrated version that supports GDB will be available over the next couple days. It will be in the releases section of this forum if you have enabled notifications you will be email. The initial gdb support is for medium to advanced users with a simpler version to follow after some feedback.


Visual Studio Ide for Arduino » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2019. All Rights Reserved.