Port busy - upload nicht möglich

Hallo in die Runde,

seit kurzem habe ich Probleme mit einer Konfiguration, die bis dato immer ohne Probleme lief. Ich verwende ein ESP32-board an der Arduino IDE 1.8.4 unter MAC OS 10.10.5 (Yosemite).

Hier der letzte Sketch aus den Beispielen

/*
  ESP32 mDNS responder sample

  This is an example of an HTTP server that is accessible
  via http://esp32.local URL thanks to mDNS responder.

  Instructions:
  - Update WiFi SSID and password as necessary.
  - Flash the sketch to the ESP32 board
  - Install host software:
    - For Linux, install Avahi (http://avahi.org/).
    - For Windows, install Bonjour (http://www.apple.com/support/bonjour/).
    - For Mac OSX and iOS support is built in through Bonjour already.
  - Point your browser to http://esp32.local, you should see a response.

 */


#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiClient.h>

const char* ssid = "***";
const char* password = "***";

// TCP server at port 80 will respond to HTTP requests
WiFiServer server(80);

void setup(void)
{  
    Serial.begin(115200);

    // Connect to WiFi network
    WiFi.begin(ssid, password);
    Serial.println("");

    // Wait for connection
    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }
    Serial.println("");
    Serial.print("Connected to ");
    Serial.println(ssid);
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());

    // Set up mDNS responder:
    // - first argument is the domain name, in this example
    //   the fully-qualified domain name is "esp8266.local"
    // - second argument is the IP address to advertise
    //   we send our IP address on the WiFi network
    if (!MDNS.begin("esp32")) {
        Serial.println("Error setting up MDNS responder!");
        while(1) {
            delay(1000);
        }
    }
    Serial.println("mDNS responder started");

    // Start TCP (HTTP) server
    server.begin();
    Serial.println("TCP server started");

    // Add service to MDNS-SD
    MDNS.addService("http", "tcp", 80);
}

void loop(void)
{
    // Check if a client has connected
    WiFiClient client = server.available();
    if (!client) {
        return;
    }
    Serial.println("");
    Serial.println("New client");

    // Wait for data from client to become available
    while(client.connected() && !client.available()){
        delay(1);
    }

    // Read the first line of HTTP request
    String req = client.readStringUntil('\r');

    // First line of HTTP request looks like "GET /path HTTP/1.1"
    // Retrieve the "/path" part by finding the spaces
    int addr_start = req.indexOf(' ');
    int addr_end = req.indexOf(' ', addr_start + 1);
    if (addr_start == -1 || addr_end == -1) {
        Serial.print("Invalid request: ");
        Serial.println(req);
        return;
    }
    req = req.substring(addr_start + 1, addr_end);
    Serial.print("Request: ");
    Serial.println(req);
    client.flush();

    String s;
    if (req == "/")
    {
        IPAddress ip = WiFi.localIP();
        String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
        s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>Hello from ESP32 at ";
        s += ipStr;
        s += "</html>\r\n\r\n";
        Serial.println("Sending 200");
    }
    else
    {
        s = "HTTP/1.1 404 Not Found\r\n\r\n";
        Serial.println("Sending 404");
    }
    client.print(s);

    Serial.println("Done with client");
}

Nach dem Start der Arduino-IDE scheint der Upload einmal zu funktionieren, obwohl sich dann die Seite http://esp32.local nicht auflösen lässt.

Alle weiteren Versuche scheitern so:

Arduino: 1.8.4 (Mac OS X), Board: "DOIT ESP32 DEVKIT V1, 80MHz, 921600, None"

Archiving built core (caching) in: /var/folders/71/5csrzsms2ql656c5g1brxsyc0000gn/T/arduino_cache_652882/core/core_espressif_esp32_esp32doit-devkit-v1_FlashFreq_80,UploadSpeed_921600,DebugLevel_none_81022c23036f627a596faae2df69ec69.a
Der Sketch verwendet 491899 Bytes (37%) des Programmspeicherplatzes. Das Maximum sind 1310720 Bytes.
Globale Variablen verwenden 40368 Bytes (13%) des dynamischen Speichers, 254544 Bytes für lokale Variablen verbleiben. Das Maximum sind 294912 Bytes.
esptool.py v2.1
Traceback (most recent call last):
  File "esptool.py", line 2524, in <module>
  File "esptool.py", line 2517, in _main
  File "esptool.py", line 2246, in main
  File "esptool.py", line 177, in __init__
  File "serial/__init__.py", line 88, in serial_for_url
  File "serial/serialposix.py", line 268, in open
serial.serialutil.SerialException:[b] [Errno 16] could not open port /dev/cu.SLAB_USBtoUART: [Errno 16] Resource busy: '/dev/cu.SLAB_USBtoUART'
Failed to execute script esptool
Beim Hochladen des Sketches ist ein Fehler aufgetreten
processing.app.SerialException: Fehler beim Öffnen des seriellen Ports "/dev/cu.SLAB_USBtoUART".
	at processing.app.Serial.<init>(Serial.java:147)
	at processing.app.Serial.<init>(Serial.java:82)
	at processing.app.SerialMonitor$4.<init>(SerialMonitor.java:101)
	at processing.app.SerialMonitor.open(SerialMonitor.java:101)
	at processing.app.AbstractMonitor.resume(AbstractMonitor.java:104)
	at processing.app.Editor.resumeOrCloseSerialMonitor(Editor.java:2218)
	at processing.app.Editor.access$2200(Editor.java:79)
	at processing.app.Editor$DefaultExportHandler.run(Editor.java:2196)
	at java.lang.Thread.run(Thread.java:748)
Caused by: jssc.SerialPortException: Port name - /dev/cu.SLAB_USBtoUART; Method name - openPort(); Exception type - Port busy.
	at jssc.SerialPort.openPort(SerialPort.java:164)
	at processing.app.Serial.<init>(Serial.java:136)
	... 8 more
Fehler beim Öffnen des seriellen Ports "/dev/cu.SLAB_USBtoUART".

Dieser Bericht wäre detaillierter, wenn die Option
"Ausführliche Ausgabe während der Kompilierung"
in Datei -> Voreinstellungen aktiviert wäre.

Ich denke der Fehler liegt an dem "busy Port", aber woran liegt das auf einmal (wie gesagt, bislang keine Probleme mit der Konfiguration.

Durch Google bin ich bereits auf dies Seite https://www.baldengineer.com/arduino-fixing-serial-port-in-use.html aufmerksam geworden und habe die Anleitung durchlaufen, ohne Erfolg. Habt Ihr noch Ideen?

Danke

Michael

Hi

Naja - die IDE kann das Port nicht öffnen.
Unter Linux muß ich z.B. das IDE-interne-Terminal (Serial-Monitor) schließen, damit ich einen Upload starten kann.
Unter Windows (Win7, 64bit,VM in VirtualBox) kann das Fenster offen bleiben - einzig ein Abziehen des Arduino bei geöffnetem und verbundenem Arduino lässt die VM abschmieren (im VM-Manager wird die VM mit 'Abgebrochen' gelistet, kann gestartet werden und zeigt dann das Auswahlmenü mit abgesichertem Modus).

Lange Rede, fast kein Sinn: Besteht noch irgend eine serielle Verbindung zum Arduino?

MfG

Besteht noch irgend eine serielle Verbindung zum Arduino?

Nicht das ich wüsste, und nach dem Bereinigungsprozess gem. https://www.baldengineer.com/arduino-fixing-serial-port-in-use.html hätte diese Verbindung doch gefunden werden müssen, oder?

Hier ist noch eine Fehlermeldung, die ich nicht verstehe.

Arduino: 1.8.4 (Mac OS X), Board: "DOIT ESP32 DEVKIT V1, 80MHz, 921600, None"

Archiving built core (caching) in: /var/folders/71/5csrzsms2ql656c5g1brxsyc0000gn/T/arduino_cache_882829/core/core_espressif_esp32_esp32doit-devkit-v1_FlashFreq_80,UploadSpeed_921600,DebugLevel_none_81022c23036f627a596faae2df69ec69.a
Der Sketch verwendet 491899 Bytes (37%) des Programmspeicherplatzes. Das Maximum sind 1310720 Bytes.
Globale Variablen verwenden 40368 Bytes (13%) des dynamischen Speichers, 254544 Bytes für lokale Variablen verbleiben. Das Maximum sind 294912 Bytes.
esptool.py v2.1
Connecting......Traceback (most recent call last):
  File "esptool.py", line 2524, in <module>
  File "esptool.py", line 2517, in _main
  File "esptool.py", line 2247, in main
  File "esptool.py", line 365, in connect
  File "esptool.py", line 342, in _connect_attempt
  File "esptool.py", line 293, in flush_input
  File "serial/serialutil.py", line 582, in flushInput
  File "serial/serialposix.py", line 584, in reset_input_buffer
termios.error: (6, 'Device not configured')
Failed to execute script esptool
Der ausgewählte serielle Port Failed to execute script esptool
 ist nicht vorhanden oder das Board ist nicht angeschlossen
.

Dieser Bericht wäre detaillierter, wenn die Option
"Ausführliche Ausgabe während der Kompilierung"
in Datei -> Voreinstellungen aktiviert wäre.

Ich kriege einfach keinen vernünftigen Gedanken zur Fehlersuche hin..

Im vorigen Post sah es ja so aus, als wäre das ESP32-board nicht angeschlossen gewesen - war es aber! Der nächste Upload-Versuch lief dann bis zur 100%-Meldung und dem Hard-Reset erfolgreich durch.

Dann aber ließ sich der serielle Monitor zwar öffnen, aber es erschien diese Fehlermeldung (letzte Zeile):

Arduino: 1.8.4 (Mac OS X), Board: "DOIT ESP32 DEVKIT V1, 80MHz, 921600, None"

Archiving built core (caching) in: /var/folders/71/5csrzsms2ql656c5g1brxsyc0000gn/T/arduino_cache_882829/core/core_espressif_esp32_esp32doit-devkit-v1_FlashFreq_80,UploadSpeed_921600,DebugLevel_none_81022c23036f627a596faae2df69ec69.a
Der Sketch verwendet 491899 Bytes (37%) des Programmspeicherplatzes. Das Maximum sind 1310720 Bytes.
Globale Variablen verwenden 40368 Bytes (13%) des dynamischen Speichers, 254544 Bytes für lokale Variablen verbleiben. Das Maximum sind 294912 Bytes.
esptool.py v2.1
Connecting........___
Chip is ESP32D0WDQ6 (revision 0)
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...

Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 7725.6 kbit/s)...
Hash of data verified.
Flash params set to 0x022f
Compressed 11120 bytes to 7467...

Writing at 0x00001000... (100 %)
Wrote 11120 bytes (7467 compressed) at 0x00001000 in 0.1 seconds (effective 949.6 kbit/s)...
Hash of data verified.
Compressed 493040 bytes to 318978...

Writing at 0x00010000... (5 %)
Writing at 0x00014000... (10 %)
Writing at 0x00018000... (15 %)
Writing at 0x0001c000... (20 %)
Writing at 0x00020000... (25 %)
Writing at 0x00024000... (30 %)
Writing at 0x00028000... (35 %)
Writing at 0x0002c000... (40 %)
Writing at 0x00030000... (45 %)
Writing at 0x00034000... (50 %)
Writing at 0x00038000... (55 %)
Writing at 0x0003c000... (60 %)
Writing at 0x00040000... (65 %)
Writing at 0x00044000... (70 %)
Writing at 0x00048000... (75 %)
Writing at 0x0004c000... (80 %)
Writing at 0x00050000... (85 %)
Writing at 0x00054000... (90 %)
Writing at 0x00058000... (95 %)
Writing at 0x0005c000... (100 %)
Wrote 493040 bytes (318978 compressed) at 0x00010000 in 4.9 seconds (effective 803.7 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 122...

Writing at 0x00008000... (100 %)
Wrote 3072 bytes (122 compressed) at 0x00008000 in 0.0 seconds (effective 2906.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting...
Fehler beim Öffnen des seriellen Ports "/dev/cu.SLAB_USBtoUART". (Port busy)

Das sieht doch so aus, als würde der letzte Upload den Port immernoch offen halten, oder? Der Sketch funktioniert auch nicht und die Seite http://esp32.local lässt sich nicht aufrufen??? Ich weiß nicht weiter und bitte um Hilfe - Danke!

Michael

Hi

Ich verstehe Das so, daß das 'Terminal' - also Da, wo die ganzen Compiler-Ausgaben rein kamen - die Verbindung zum Target in dem Moment verloren hat, wo Du den Seriellen Monitor öffnest.
Bekommst Du dann im Monitor Ausgaben des µC?
Was passiert, wenn Du jetzt erneut auf Hochladen klickst?
Was passiert, wenn der Monitor wieder geschlossen wird?

MfG