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 SAMD21 'SerialUSB' was not declared in this scope in Debug (Read 4568 times)
Martin Boissonneault
Newbies
*
Offline


Posts: 6
Location: near Montreal, Quebec, Canada
Joined: Sep 19th, 2018
SAMD21 'SerialUSB' was not declared in this scope in Debug
Sep 20th, 2018 at 1:19am
Print Post  
Hi!
  On my Adafruit Metro M0 Express (ATSAMD21G18A) I keep getting
Code
Select All
BlinkWithoutDelay.ino: 46:57: error: 'SerialUSB' was not declared in this scope 

while building in Debug configuration. The code compiles and runs correctly while in Release configuration. 

  I was trying to follow: https://www.visualmicro.com/page/User-Guide.aspx?doc=Debugging-Walkthrough-1.htm...

  I have attached the compiler output in verbose modes and the project.

  Should the #include be <Arduino.h> ??? The Adafruit SAMD core uses Arduino.h I think es\arduino\Arduino.h). I tried to add it to the example but it still failed to compile with the same error. 

Here is the .cpp code created by vMicro from the .ino:
Code (C++)
Select All
#include <arduino.h>
#line 1 "C:\\Users\\Martin\\Documents\\Arduino\\My Examples\\BlinkWithoutDelay\\BlinkWithoutDelay.ino"
#line 1 "C:\\Users\\Martin\\Documents\\Arduino\\My Examples\\BlinkWithoutDelay\\BlinkWithoutDelay.ino"

 #include <VM_DBG.h>

//
//

#line 32 "C:\\Users\\Martin\\Documents\\Arduino\\My Examples\\BlinkWithoutDelay\\BlinkWithoutDelay.ino"
unsigned long __VisualMicro_DEBUG_1_HITCOUNTER__=0L;bool __VisualMicro_DEBUG_1_HITCOUNTER___COMPLETE=0;unsigned long __VisualMicro_DEBUG_1_GLastMillis__=0L;

const int ledPin =  LED_BUILTIN;

int ledState = LOW;

unsigned long previousMillis = 0;

const long interval = 1000;

void setup() { MicroDebug.init(3000); MicroDebug.begin(&SerialUSB,115200);if (MicroDebug.outPacketStart(true)) {MicroDebug.outPacketEnd();} MicroDebug.start(false,true);

pinMode(ledPin, OUTPUT);
}

void loop() {if (millis()>0 || millis()>1) {__VisualMicro_DEBUG_1_GLastMillis__=MicroDebug.DBG_Millis();if ( __VisualMicro_DEBUG_1_GLastMillis__<__VisualMicro_DEBUG_1_HITCOUNTER__ ){__VisualMicro_DEBUG_1_HITCOUNTER__=__VisualMicro_DEBUG_1_GLastMillis__;}if   ) { g.OnBreakPointBegin(500);if (MicroDebug.outPacketStart(true)) ketEnd();}MicroDebug.DBG_YieldAndWait(5);MicroDebug.OnBreakPointEnd();}}

unsigned long currentMillis = millis();

if (currentMillis - previousMillis >= interval) {

previousMillis = currentMillis;

if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}

digitalWrite(ledPin, ledState);
}
}
 



Thanks! The extension is great!

Martin Boissonneault
near Montreal, Quebec, Canada
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12207
Location: United Kingdom
Joined: Apr 10th, 2010
Re: SAMD21 'SerialUSB' was not declared in this scope in Debug
Reply #1 - Sep 30th, 2018 at 7:57pm
Print Post  
Resolved in the next release thanks
  
Back to top
IP Logged
 
gj
Junior Member
**
Offline


Posts: 46
Joined: Feb 12th, 2016
Re: SAMD21 'SerialUSB' was not declared in this scope in Debug
Reply #2 - Jul 19th, 2025 at 9:40pm
Print Post  
I'm running VM v2025.606.2207 in VS2022, with the Blink with delay sketch.
I was getting the exact same error. It didn't upload to the Seeeduino on COM4. although COM4 shows up in the device manager and in the Serial-port dropdown in the VM-toolbar.

When I plug the USB-C in a Wemos D1 Clone it compiles, uploads (to COM3) and runs without issues.

Code
Select All
SerialUSB was not declared in this scope
VM_DEBUGGER_SOFT_TRANSPORT.print("VMDPE_")
^~~~~~~~~~~~~~~~~~~~~~~~~~
note  suggested alternative  Serial
VM_DEBUGGER_SOFT_TRANSPORT.print("VMDPE_")
^~~~~~~~~~~~~~~~~~~~~~~~~~

SerialUSB was not declared in this scope
b = VM_DEBUGGER_SOFT_TRANSPORT.peek()
^~~~~~~~~~~~~~~~~~~~~~~~~~
note  suggested alternative  Serial
b = VM_DEBUGGER_SOFT_TRANSPORT.peek()

Attempt to set a read-only variable or data type not supported\r\n")
^~~~~~~~~~~~~~~~~~~~~~~~~~
note  suggested alternative  Serial
 



Changing the "Override Remote port" to "Serial" helped
(Extensions -> vMicro -> Debugger), although it seems the Seeeduino seems to toggle between COM4 and COM5.

Just hoping this addition might help someone.
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2931
Joined: Feb 13th, 2019
Re: SAMD21 'SerialUSB' was not declared in this scope in Debug
Reply #3 - Jul 22nd, 2025 at 3:58pm
Print Post  
Could you attach the full build log as a text file with the below settings enabled so we can investigate this further:
  • vMicro > Compiler > Verbose
  • vMicro > Compiler > Show Build Properties
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint