Skip to content

ESP32 Build/Compile/ Example sketches work nothing else & no execution #7821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
Surfacve opened this issue Feb 9, 2023 · 12 comments
Closed
1 task done
Assignees
Labels
Type: For reference Common questions & problems Type: Question Only question

Comments

@Surfacve
Copy link

Surfacve commented Feb 9, 2023

Board

Adafruit ESP32 S3 2MB PSRAM

Device Description

Adafruit feather

Hardware Configuration

I2C device, AdafruitMotorshield

Version

latest master (checkout manually)

IDE Name

Arduino IDE 1.8.19

Operating System

Windows 10

Flash frequency

80Mhz

PSRAM enabled

yes

Upload speed

921600

Description

Example sketches function, Anything else does not function. If I make a simple blink sketch, it will not function outside of the examples. The code will compile, the sketch will upload, the IDE sees the port changes depending on the board state, everything works fine.

I have verbose for example upload vs a custom sketch upload, I can not see any fatal errors or issues that would cause this behaviour, code uploaded other than the example sketches eventually does not Execute at all. I have tried to read through the verbose but I just cannot see anything that is wrong that I should be aware of, as it stands, I am using the version 2.0.6 in the board manager. I'm not sure how I can move foward with this project, this code functions fine on every other arduino compatible board (tested on teensy 4.0,4.1) The verbose from the terminal in arduino is just immense, I imbedded it into Microsoft word and at 181 pages @7118 words, I'm not sure why this amount of verbose is coming out. I have attached both the verbose of the successful wifi scan and the custom sketch as a zip.

What am I missing?

verbose attached as cpp files using visual studio.

Custom sketch verbose.zip

Sketch

///----------------------------------- DESCRIPTION------------------------------------//
/* very basic non-blocking sequential dosing system, it can easily not be sequential, pump built by James this is version 1, 
no data logging, no IOT, no dosing function (speed, time, amount), just the basic master structure. my target is AN ESP32S3- 2MB 4MBPS model
 */

//---------------------------- LIBRARIES-----------------------------------------------//
#include <Adafruit_MotorShield.h>
#include <EdgeDebounceLite.h>
//#include <ezBuzzer.h>//



//to do figure out timing intervals and whether or not you will remove the delay
EdgeDebounceLite debounce;

//----------------------------------- OBJECTS------------------------------------//

Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_DCMotor *Dose1 = AFMS.getMotor(1);   //pump 1
Adafruit_DCMotor *Dose2 = AFMS.getMotor(2);  //pump 2
Adafruit_DCMotor *Dose3 = AFMS.getMotor(3); //pump 3
Adafruit_DCMotor *Dose4 = AFMS.getMotor(4);//pump 4

//----------------------------------- GLOBALS------------------------------------//

//PINS & BUTTONS//
byte RoutinePin[2] = {13, 12}; //push buttons to be used with debounce
byte StatusLEDS[3] = {11, 10, 9}; //G (6), B(7), R(8).
const int Buz_Pin = 6; //buzzer pin



//GLOBAL FLAGS

bool DoneRoutine1= false; // these will become true when the last state of each routine is reached
bool DoneRoutine2= false;
bool doseAcmp = false;
bool doseBcmp = false;
//Buzzer states
bool bzer_on = false;
//Led states
bool ledR = false; //Red led 
bool ledG = false; //Green led 
bool ledB = false; // Blue led 
int StrtUpBuz = 0; //The start up tone will run once for now

//GLOBAL TIMING VARIABLES
unsigned long currentMillis; 


//ROUTINE 1 TIMING VARIABLES //
//Global to routine 1 and 2 maybe?? as time tracking variables//
unsigned long mDc_on; // similar to how previousMillis= currentmillis, a variable for how long a dose has run for
unsigned long Routine1Millis; //how long since routine 1 button was pressed

//Changing timwe intervals//
//I have left them all the same value for now for my brain

unsigned long mD1wait_interval = 2500; // Pump off time
unsigned long mD1run_interval = 5000; // Pump on time
//dose 2 with motor 2
unsigned long mD2wait_interval = 500; //
unsigned long mD2run_interval = 5000; //
// dose 3 with motor 3
unsigned long mD3wait_interval = 500; //
unsigned long mD3run_interval = 5000; //
//dose 4 with motor 4
unsigned long mD4wait_interval = 500; //
unsigned long mD4run_interval = 5000; //

/*ROUTINE 2 TIMING VARIABLES*/

//routine 2 as time tracking variables unsure if I need these//
unsigned long mDc2_on; // similar to how previousMillis= currentmillis, a variable for how long a dose has run for
unsigned long Routine2Millis; //how long since routine 2 button was pressed

//Changing time intervals//
//I have left them all the same value for now for my brain

unsigned long mD1bwait_interval = 2500; // Pump off time
unsigned long mD1brun_interval = 5000; // Pump on time
//dose 2 with motor 2
unsigned long mD2bwait_interval = 500; //
unsigned long mD2brun_interval = 15000; //
// dose 3 with motor 3
unsigned long mD3bwait_interval = 500; //
unsigned long mD3brun_interval = 15000; //
//dose 4 with motor 4
unsigned long mD4bwait_interval = 500; //
unsigned long mD4brun_interval = 15000; //

//----------------------------------- MAIN STATES------------------------------------//

// DOSING STATES
enum DosingSystemStates{IDLE, DOSINGA, DOSINGB, DOSEFINISH };
DosingSystemStates dosingSystemState = IDLE;

// SWITCH MODES
enum SwitchStates {IS_OPEN, IS_RISING, IS_CLOSED, IS_FALLING };
SwitchStates switchState[2] = {IS_OPEN, IS_OPEN }; // both switches are in is open

// SWITCH MODES
enum SwitchModes {MY1_PULLUP, MY1_PULLDOWN}; //the two possible modes the pins could be in
SwitchModes switchMode[2] = {MY1_PULLUP, MY1_PULLUP}; // I am focused on states where both switches are in pullup mode.

// BUTTON FLAGS
bool hasRout1_strtd() {                     //Routine 1 active?
  switchMachine(0);                           //Read switch 0
  if (switchState[0] == IS_FALLING)           //If it is in the state IS_FALLING
    return true;                                //R1 started, return true
  else                                        //If not
    return false;                               //return false
}

bool hasRout2_strtd() {                     //Routine 2 active?
  switchMachine(1);                           //Read switch 1
  if (switchState[1] == IS_FALLING)           //If it is in the state IS_FALLING
    return true;                                //R2 started, return true
  else                                        //If not
    return false;                               //return false
}

//----------------------------------- MAIN STATE MACHINES------------------------------------//
//SWITCH STATE MACHINE
void switchMachine(byte i) {
  byte pinIs = debounce.pin(RoutinePin[i]);
 if (switchMode[i] == MY1_PULLUP){pinIs = !pinIs;  //reverse the result for pullup 
    switch (switchState[i]) {
      case IS_OPEN:    {                                //State is IS_OPEN
      if(pinIs == HIGH)                                 //If the pin is HIGH
        switchState[i] = IS_RISING;                       //We just changed form LOW to HIGH: State is now IS_RISING 
      break;                                            //Get out of switch
    }
    case IS_RISING:  {                                //State is IS_RISING
      switchState[i] = IS_CLOSED;                       //It is not rising anymore, State is now IS_CLOSED
      break;                                            //Get out of switch
    }
    case IS_CLOSED:  {                               //State is IS_CLOSED
      if(pinIs == LOW)                                 //If the pin is LOW
        switchState[i] = IS_FALLING;                     //We just changed from HIGH to LOW: State is now IS_FALLING 
      break;                                           //Get out of switch 
    }
    case IS_FALLING: {                               //State is IS_FALLING
      switchState[i] = IS_OPEN;                        //It is not falling anymore, State is now IS_OPEN    
      break;
    }                     
    }
  }
}

//DOSING STATE MACHINE 
void DosingSystem(){
switch(dosingSystemState) {
  case IDLE: {
    Serial.println( "I am in idle");
    //buzstrt(); //startup tone
    digitalWrite(StatusLEDS[2], HIGH);


    if (hasRout1_strtd()){
    digitalWrite(StatusLEDS[0], HIGH);
    digitalWrite(StatusLEDS[2], LOW);
    //bbbuzz();
    Routine1Millis = currentMillis; //if routine 1 button is pressed/TRUE start routine 1 timer/ get a snapshot of the time for void DoseR1()
    dosingSystemState = DOSINGA; // go to dosing state A
    }
    if (hasRout2_strtd()){         //if routine 2 button is pressed/TRUE same for the above
    digitalWrite(StatusLEDS[1], HIGH);
    digitalWrite(StatusLEDS[2], LOW);
    //bbbuzz();
    Routine2Millis = currentMillis;
    dosingSystemState = DOSINGB;// go to dosing state B
    }
    //might add connection to https server here, depends on my ESP32 abilities
    //might be my 2nd forum post when I break it :3
    break;
  }
  case DOSINGA: {
   Serial.println( "I am in DOSINGA");
   DoseR1();    
    if(DoseR1()) {
    digitalWrite(StatusLEDS[0], LOW);  //Green led goes off
    Serial.println( "doseR1 is cmp");
    doseAcmp = true;
    dosingSystemState = DOSEFINISH;
    }
    break;
  }
  case DOSINGB: {
  DoseR2();
  Serial.println( "I am in DOSINGB");
   if(DoseR2()) {
   Serial.println( "doseR2 is cmp");
   digitalWrite(StatusLEDS[1], LOW); //Blue led goes off
   doseBcmp = true;
   dosingSystemState = DOSEFINISH;
  }
    break;
  }
  case DOSEFINISH: {
    Serial.println( "I am in DOSEFINISH");
    digitalWrite(StatusLEDS[2], HIGH);
     if (doseAcmp || doseBcmp){
      StrtUpBuz = 0; //reset the counter for the buzz tone, whilst in IDLE itll go once
       dosingSystemState = IDLE;
    break;
  }
 }
}
}

void setup() {
  // put your setup code here, to run once:
Serial.begin(115200);           // Serial connection for Debug
  Serial.println("begin");
  
  // put your setup code here, to run once:
if (!AFMS.begin()) {         // create with the default frequency 1.6KHz
  // if (!AFMS.begin(1000)) {  // OR with a different frequency, say 1KHz
    Serial.println("MDriver not working");
    while (1);
  }
  Serial.println("MDriver working.");

//Setting buttons as pull ups
for (int i = 0 ; i < 2 ; i++) {          //For each switch
    pinMode(RoutinePin[i], INPUT_PULLUP);
}

for (int l = 0 ; l < 3 ; l++){
  pinMode(StatusLEDS[l], OUTPUT);}
  
for (int l = 0 ; l < 3 ; l++){
    digitalWrite(StatusLEDS[l], HIGH);}
 delay(2000);
 for (int l = 0 ; l < 3 ; l++){
    digitalWrite(StatusLEDS[l], LOW);}  
}

void loop() {
  // put your main code here, to run repeatedly:
currentMillis = millis(); //start the time globally
//buzzer.loop();
DosingSystem();

}

int DoseR1()
{
static enum {DOSE1ra, DOSE1a, DOSE2ra, DOSE2a, DOSE3ra,  // 1a is run. 1ra is wait to run
DOSE3a, DOSE4ra, DOSE4a, DOSEr1CMP} pumpR1State = DOSE1ra; 
  switch (pumpR1State)
  {
    case DOSE1ra: {
      //Serial.println("pump1 should have been on after .5 seconds");
      if (currentMillis - Routine1Millis >= mD1wait_interval)
      {
        Dose1->setSpeed(150);
        Dose1->run(FORWARD);
        mDc_on = currentMillis;
        pumpR1State = DOSE1a;
      }
      break;
    }
    case DOSE1a: {
      if (currentMillis - mDc_on >= mD1run_interval) //will shut down after the run interval is met
      {
        Dose1->fullOff();
        mDc_on = currentMillis;//resetting the difference everytime 
        pumpR1State = DOSE2ra;
        Serial.println("Dose1 has begun");
      }
      break;
    }
    case DOSE2ra: {
       if (currentMillis - mDc_on >= mD2wait_interval) //wait then run
      {
        Dose2->setSpeed(150);
        Dose2->run(FORWARD);
        mDc_on = currentMillis; //resetting the difference everytime 
        pumpR1State = DOSE2a;
      }
    break;
    }
   case DOSE2a: {
       if (currentMillis - mDc_on >= mD2run_interval) //will shut down after the run interval is met
      {
        Dose2->fullOff();
        mDc_on = currentMillis; //resetting the difference everytime 
        pumpR1State = DOSE3ra;
      }
    break;
   }
   case DOSE3ra: {
       if (currentMillis - mDc_on >= mD3wait_interval) //wait then run
      {
        Dose3->setSpeed(150);
        Dose3->run(FORWARD);
        mDc_on = currentMillis;
        pumpR1State = DOSE3a;
      }
    break;
   }
    case DOSE3a: {
       if (currentMillis - mDc_on >= mD3run_interval) //will shut down after the run interval is met 
      {
        Dose3->fullOff();
        mDc_on = currentMillis; //resetting the difference everytime
        pumpR1State = DOSE4ra;
      }
    break;
    }
    case DOSE4ra: {
       if (currentMillis - mDc_on >= mD4wait_interval) //wait then run 
      {
        Dose1->setSpeed(150);
        Dose1->run(FORWARD);
        mDc_on = currentMillis; //resetting the difference everytime
       pumpR1State = DOSE4a;
      }
    break;
    }
    case DOSE4a: {
       if (currentMillis - mDc_on >= mD4run_interval) //will shut down after the run interval is met 
      {
        Dose1->fullOff();
        mDc_on = currentMillis; //resetting the difference everytime
        pumpR1State = DOSEr1CMP;
      }
      break;
    }
    case DOSEr1CMP: {
        // DO something with the web interface probably a data logging or function tracking statement, some led's, some buzzer, still thinking for now.
        mDc_on = currentMillis; //resetting the difference everything
        pumpR1State = DOSE1ra; //opting to use named flags just to keep track of everything for now in this phase
        Serial.println("Dose A is complete");
        StrtUpBuz = 0;
        return 1; //dose is done
        break;
        //test return 
      
  }
 }
 return 0; //dose is not done
}

Debug Message

verbose attached as zip files

Other Steps to Reproduce

I have tried to compare the example files with my code, but I am no longer sure what to be looking for. The Board is functional, the wifiscan works, compiles, and uploads as instructed. Every code made as a new sketch, compiles, uploads, but the board will not do anything.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@Surfacve Surfacve added the Status: Awaiting triage Issue is waiting for triage label Feb 9, 2023
@SuGlider
Copy link
Collaborator

SuGlider commented Feb 9, 2023

@Surfacve -
I could not understand the issue.
Both files (with the building messages) end up on:

Leaving...
Hard resetting via RTS pin...

It means that the compilation and upload had success.
If necessary, you can press the RESET button in the board and then open the IDE Serial Monitor to see the output.
After that, you shall see it running.

@SuGlider SuGlider added Type: Question Only question and removed Status: Awaiting triage Issue is waiting for triage labels Feb 9, 2023
@Surfacve
Copy link
Author

Hi @SuGlider sure, I would agree with you, everything looks perfect, the libraries, resolve, I don't get a fatal/ELF/build error, but for such a simple program, the expectation is that the terminal/serial monitor will print
void setup() { // put your setup code here, to run once: Serial.begin(115200); // Serial connection for Debug Serial.println("begin");

The issue is that no matter what I do, delete the rest of the code for example and compile, leaving just void setup as print begin, and void loop as print end, the serial monitor outputs nothing. If you have an S3, or if anyone has an S3, please attempt because I am confused!

@Surfacve
Copy link
Author

Okay, two things have happened since. I have been continuous flashing the Adafruit ESP32 S3 with the wifi scan and I came up with two random errors. The most recent one was after the hard resetting:

Leaving... Hard resetting via RTS pin... Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at processing.app.Serial.write(Serial.java:256) at processing.app.Serial.write(Serial.java:276) at processing.app.SerialMonitor.send(SerialMonitor.java:122) at processing.app.SerialMonitor.lambda$new$1(SerialMonitor.java:66) at javax.swing.JTextField.fireActionPerformed(JTextField.java:508) at javax.swing.JTextField.postActionEvent(JTextField.java:721) at javax.swing.JTextField$NotifyAction.actionPerformed(JTextField.java:836) at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1668) at javax.swing.JComponent.processKeyBinding(JComponent.java:2882) at javax.swing.JComponent.processKeyBindings(JComponent.java:2929) at javax.swing.JComponent.processKeyEvent(JComponent.java:2845) at java.awt.Component.processEvent(Component.java:6316) at java.awt.Container.processEvent(Container.java:2239) at java.awt.Component.dispatchEventImpl(Component.java:4889) at java.awt.Container.dispatchEventImpl(Container.java:2297) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:835) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1103) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:974) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:800) at java.awt.Component.dispatchEventImpl(Component.java:4760) at java.awt.Container.dispatchEventImpl(Container.java:2297) at java.awt.Window.dispatchEventImpl(Window.java:2746) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84) at java.awt.EventQueue$4.run(EventQueue.java:733) at java.awt.EventQueue$4.run(EventQueue.java:731) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) at java.awt.EventQueue.dispatchEvent(EventQueue.java:730) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

The second error is a build error that I hadn't seen before:

A fatal error occurred: Failed to read a valid ELF header I have not been able remake this as of yet.

I read this might have to do with the board installation!

@SuGlider
Copy link
Collaborator

The Adafruit S3 has just the USB CDC plug on it.
The Serial output will go through USB port using TinyUSB software layer.
Did you select the right board in the IDE Menu?

image

@SuGlider
Copy link
Collaborator

I tested a S3 with USB port and uploaded a simple sketch that prints "loop..." in the loop() function.
After uploading it using the Adafruit Feather ESP32-S3 2MB PSRAM board option, and then I wait it to reset the board and I open the Serial Monitor with the USB COM port, it is displaying the text in the terminal.

I see no issue so far.

@Surfacve
Copy link
Author

Surfacve commented Feb 10, 2023

Hi I have the exact same settings. I have noticed something. Since I have you attention. Sometimes, when I plug in the s3, the Arduino IDE assigns the board random different board names. For the time being, this board has been stable in flash mode (as ESP32 S3 Dev Module) and in run mode it comes up as (Adafruit Feather ESP32-S3 2MB PSRAM) , but sometimes, the port name would be a random ESP32S3 board from the board manager. This has subsided since I deleted Arduino and reinstalled the boards in the board manager a number of times.

Test results, I have made a blank sketch as standard run the same code.
This is the code I have ran:
`void setup() {
// put your setup code here, to run once:
//LET US PRINT LOOP

Serial.begin(115200);
Serial.println("we are in setup");
}

void loop() {
// put your main code here, to run repeatedly:
Serial.println("we are in loop");
}`
Nothing is coming out of the serial monitor, Nothing. But I can upload wifi scan it it works haha. However this time I removed the usb and plugged it back in and was greeted immediately with:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at processing.app.Serial.write(Serial.java:256) at processing.app.Serial.write(Serial.java:276) at processing.app.SerialMonitor.send(SerialMonitor.java:122) at processing.app.SerialMonitor.lambda$new$1(SerialMonitor.java:66) at javax.swing.JTextField.fireActionPerformed(JTextField.java:508) at javax.swing.JTextField.postActionEvent(JTextField.java:721) at javax.swing.JTextField$NotifyAction.actionPerformed(JTextField.java:836) at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1668) at javax.swing.JComponent.processKeyBinding(JComponent.java:2882) at javax.swing.JComponent.processKeyBindings(JComponent.java:2929) at javax.swing.JComponent.processKeyEvent(JComponent.java:2845) at java.awt.Component.processEvent(Component.java:6316) at java.awt.Container.processEvent(Container.java:2239) at java.awt.Component.dispatchEventImpl(Component.java:4889) at java.awt.Container.dispatchEventImpl(Container.java:2297) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:835) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1103) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:974) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:800) at java.awt.Component.dispatchEventImpl(Component.java:4760) at java.awt.Container.dispatchEventImpl(Container.java:2297) at java.awt.Window.dispatchEventImpl(Window.java:2746) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84) at java.awt.EventQueue$4.run(EventQueue.java:733) at java.awt.EventQueue$4.run(EventQueue.java:731) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) at java.awt.EventQueue.dispatchEvent(EventQueue.java:730) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

I cam across this thread/issue on github here. about this error being a broken JSON file, but I am confused, why would this problem not affect example sketches. I have looked on my PC and I do have this Arduino15 folder structure, I also have 3 instances of the IDE, the 2.0.0 Beta, 1.8.19 and the IDE 2.0.3.

@Surfacve
Copy link
Author

Okay, okay some interesting progress. I set the baud rate to 9600, I unplugged and plugged the S3 in a couple of times, I can see the we are in loop output. I am not sure what is causing this. I have tested on two other identical boards, is this hardware or software?

image

@SuGlider
Copy link
Collaborator

Sometimes, when I plug in the s3, the Arduino IDE assigns the board random different board names.

The S3 has in the same USB plug pins, two different modes: Hardware Serial JTAG/CDC and Native USB OTG.
This 2 modes can be selected in the Arduino IDE Menu, under "USB Mode:" option.
The Adafruit also has its own boot loader and it opens a file driver in Windows, as USB MSC, like there is a pendrive plugged into the computer. But it can also be selected, as in the default board mode, with "USB CDC on Boot: Enabled".

Each of those modes, when the is plugged or the sketh is running may change the name of the device in Windows.

Okay, okay some interesting progress. I set the baud rate to 9600, I unplugged and plugged the S3 in a couple of times, I can see the we are in loop output. I am not sure what is causing this. I have tested on two other identical boards, is this hardware or software?

The Serial USB CDC COM port will be availble only after Windows is able to enumerate the USB device.
So, in order to see the Serial output, you may have to wait a second or so before opening the Serial Monitor.
Whenever you reset the board or a new sketch is uploaded, the Window with the Serial Monitor won't work anymore, threfore it is necessary to close it and open a new open again.

This may explain the issue. Remember to alway close and open a new Serial Terminal window after uploading or reseting the board.

This is bug in the IDE that should treat it correctly.
Other Terminal software will open an alert telling you that the USB CDC Serial has been terminated. For instance PuTTY does it correclty and forces the user to open the terminal again.

@SuGlider SuGlider added the Type: For reference Common questions & problems label Feb 10, 2023
@SuGlider SuGlider self-assigned this Feb 10, 2023
@Surfacve
Copy link
Author

Hi @SuGlider thank you for your insight. What I am experiencing isn't plug and play behaviour of these boards and that is frustrating because it makes them unreliable. I stress tested it this past weekend and it just won't work reliably. (I use both platformIO VSCode) and Arduino IDE.

@SuGlider
Copy link
Collaborator

I see. The board is just a USB device that will react to the USB Host (the computer).
It depends a lot on the Windows drivers, software (such as the terminal application) etc.

A possible alternative woud be used UART through an external USB-Serial chip or board.

Such as the CH340 USB-UART converter. It will be connected to the UART Rx/Tx pins and to the computer USB.
image

@SuGlider
Copy link
Collaborator

SuGlider commented Feb 15, 2023

Hi @SuGlider thank you for your insight. What I am experiencing isn't plug and play behaviour of these boards and that is frustrating because it makes them unreliable. I stress tested it this past weekend and it just won't work reliably. (I use both platformIO VSCode) and Arduino IDE.

Another way to go it to always put the S3 in Upload Mode before starting the IDE upload process.
It can be achieved by holding BOOT button while pressing and releasing RESET.
This procedure will force the S3 to enter in the Uploading mode and therefore, making this process more reliable.

@VojtechBartoska
Copy link
Contributor

I'm closing this issue as expired, if needed you can reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: For reference Common questions & problems Type: Question Only question
Projects
None yet
Development

No branches or pull requests

3 participants