Board stops working after class method


At frist i was going to open the question on the Programming Questions topic, but I decided to test some other boards with the same code and realized that the problem was with the board I deloped.

I’m praticing hardware devlopment and I’ve build a SAMD51 board to run with arduino and I’ve already tested all the pins, serial comunication, I2C, SPI, but when I tried the code that I show latter on this topic, I find this strange error.

I’ve created a class that uses a function for debugging with some marks, so I’ve a better understanding what are debug messages and what isn’t.

However, EVERYTHING stops working after I use myClass.begin() that just prints the messages written on the begin method and than looks like the code gets stuck somewhere before starting the loop.

02:33:04.591 -> begin:Entry
02:33:04.591 -> [ML] I'm Alive!!!
02:33:04.591 -> begin:Exit

Whereas if I comment the myClass.begin() it works…

Do any of you have any ideas on where should I start looking for to solve this?

Board Tests

  • Working
    • Arduino Due
    • SparkFun ThingPlus
  • Not working
    • my SAMD51 board



With this sketch, i can not see “Random Stuff” on my Serial Console. But it works if I remove the MC.begin();.

#include "myLibrary_test.h"

void setup() {
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB
  Serial.println(F("End of Setup"));

void loop() {
  Serial.println("Random Stuff");
  digitalWrite(LED_BUILTIN, HIGH);
  digitalWrite(LED_BUILTIN, LOW);


#ifndef _MYCLASS_H_
#define _MYCLASS_H_

#include <Arduino.h>

// General defines
#define MYLIB_PRINT Serial

#define DEBUG_MYLIB		1
#define DEBUG1_MYLIB_PRINT(str1)	              { MYLIB_PRINT.print(F("[ML] ")); MYLIB_PRINT.print(str1); }
#define DEBUG1_MYLIB_PRINTLN(str1)	            { MYLIB_PRINT.print(F("[ML] ")); MYLIB_PRINT.println(str1); }                 

class MyClass {

    bool begin(bool debug = false);

    void printBanner() {
      DEBUG1_MYLIB_PRINTLN(F("I'm Alive!!!"));

extern MyClass



#include <myLibrary_test.h>

bool MyClass::begin(bool debug)

MyClass MC;

I’ve tested this on four computers so far, three windows and one linux running mint. Two of them worked without needing to change a thing and with the other two windows the program didn’t work. It got stuck like before.

Given that I’ve made a fresh arduino and board installation on all four of them, maybe this is related to some drivers. I’ll try to install ubuntu on my computer to check if it will work.

BTW, I’ve already tried reinstalling arduino several times, using the new IDE 2.0 and also running the code through VS Code (who knows what might work, right?), but no progress so far.