Browse Source

Teensy 4.1 Ethernet support (#19801)

bilsef 3 years ago
parent
commit
9baa944460
No account linked to committer's email address

+ 2
- 1
Marlin/Configuration.h View File

@@ -107,7 +107,8 @@
107 107
 
108 108
 /**
109 109
  * Select a secondary serial port on the board to use for communication with the host.
110
- * :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
110
+ * Currently Ethernet (-2) is only supported on Teensy 4.1 boards.
111
+ * :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7]
111 112
  */
112 113
 //#define SERIAL_PORT_2 -1
113 114
 

+ 7
- 0
Marlin/Configuration_adv.h View File

@@ -3457,6 +3457,13 @@
3457 3457
 #endif
3458 3458
 
3459 3459
 /**
3460
+ * Ethernet. Use M552 to enable and set the IP address.
3461
+ */
3462
+#if HAS_ETHERNET
3463
+  #define MAC_ADDRESS { 0xDE, 0xAD, 0xBE, 0xEF, 0xF0, 0x0D }  // A MAC address unique to your network
3464
+#endif
3465
+
3466
+/**
3460 3467
  * WiFi Support (Espressif ESP32 WiFi)
3461 3468
  */
3462 3469
 //#define WIFISUPPORT         // Marlin embedded WiFi managenent

+ 2
- 0
Marlin/src/HAL/TEENSY40_41/HAL.h View File

@@ -66,6 +66,8 @@
66 66
 #ifdef SERIAL_PORT_2
67 67
   #if SERIAL_PORT_2 == -1
68 68
     #define MYSERIAL1 usbSerial
69
+  #elif SERIAL_PORT_2 == -2
70
+    #define MYSERIAL1 ethernet.telnetClient
69 71
   #elif WITHIN(SERIAL_PORT_2, 0, 8)
70 72
     #define MYSERIAL1 MSERIAL(SERIAL_PORT_2)
71 73
   #else

+ 12
- 1
Marlin/src/MarlinCore.cpp View File

@@ -77,6 +77,10 @@
77 77
   #include "lcd/dwin/e3v2/rotary_encoder.h"
78 78
 #endif
79 79
 
80
+#if HAS_ETHERNET
81
+  #include "feature/ethernet.h"
82
+#endif
83
+
80 84
 #if ENABLED(IIC_BL24CXX_EEPROM)
81 85
   #include "libs/BL24CXX.h"
82 86
 #endif
@@ -713,6 +717,9 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
713 717
     HAL_idletask();
714 718
   #endif
715 719
 
720
+  // Check network connection
721
+  TERN_(HAS_ETHERNET, ethernet.check());
722
+
716 723
   // Handle Power-Loss Recovery
717 724
   #if ENABLED(POWER_LOSS_RECOVERY) && PIN_EXISTS(POWER_LOSS)
718 725
     if (printJobOngoing()) recovery.outage();
@@ -968,7 +975,7 @@ void setup() {
968 975
   MYSERIAL0.begin(BAUDRATE);
969 976
   uint32_t serial_connect_timeout = millis() + 1000UL;
970 977
   while (!MYSERIAL0 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
971
-  #if HAS_MULTI_SERIAL
978
+  #if HAS_MULTI_SERIAL && !HAS_ETHERNET
972 979
     MYSERIAL1.begin(BAUDRATE);
973 980
     serial_connect_timeout = millis() + 1000UL;
974 981
     while (!MYSERIAL1 && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
@@ -1090,6 +1097,10 @@ void setup() {
1090 1097
   SETUP_RUN(settings.first_load());   // Load data from EEPROM if available (or use defaults)
1091 1098
                                       // This also updates variables in the planner, elsewhere
1092 1099
 
1100
+  #if HAS_ETHERNET
1101
+    SETUP_RUN(ethernet.init());
1102
+  #endif
1103
+
1093 1104
   #if HAS_TOUCH_XPT2046
1094 1105
     SETUP_RUN(touch.init());
1095 1106
   #endif

+ 7
- 2
Marlin/src/core/serial.h View File

@@ -23,6 +23,10 @@
23 23
 
24 24
 #include "../inc/MarlinConfig.h"
25 25
 
26
+#if HAS_ETHERNET
27
+  #include "../feature/ethernet.h"
28
+#endif
29
+
26 30
 /**
27 31
  * Define debug bit-masks
28 32
  */
@@ -56,8 +60,9 @@ extern uint8_t marlin_debug_flags;
56 60
     #define SERIAL_OUT(WHAT, V...) (void)CAT(MYSERIAL,SERIAL_CATCHALL).WHAT(V)
57 61
   #else
58 62
     #define SERIAL_OUT(WHAT, V...) do{ \
59
-      if (!serial_port_index || serial_port_index == SERIAL_BOTH) (void)MYSERIAL0.WHAT(V); \
60
-      if ( serial_port_index) (void)MYSERIAL1.WHAT(V); \
63
+      const bool port2_open = TERN1(HAS_ETHERNET, ethernet.have_telnet_client); \
64
+      if ( serial_port_index == 0 || serial_port_index == SERIAL_BOTH)                (void)MYSERIAL0.WHAT(V); \
65
+      if ((serial_port_index == 1 || serial_port_index == SERIAL_BOTH) && port2_open) (void)MYSERIAL1.WHAT(V); \
61 66
     }while(0)
62 67
   #endif
63 68
 

+ 175
- 0
Marlin/src/feature/ethernet.cpp View File

@@ -0,0 +1,175 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "../inc/MarlinConfigPre.h"
24
+
25
+#if HAS_ETHERNET
26
+
27
+#include "ethernet.h"
28
+#include "../core/serial.h"
29
+
30
+#define DEBUG_OUT ENABLED(DEBUG_ETHERNET)
31
+#include "../core/debug_out.h"
32
+
33
+bool MarlinEthernet::hardware_enabled, // = false
34
+     MarlinEthernet::have_telnet_client; // = false
35
+
36
+IPAddress MarlinEthernet::ip,
37
+          MarlinEthernet::myDns,
38
+          MarlinEthernet::gateway,
39
+          MarlinEthernet::subnet;
40
+
41
+EthernetClient  MarlinEthernet::telnetClient;  // connected client
42
+
43
+MarlinEthernet ethernet;
44
+
45
+EthernetServer server(23);    // telnet server
46
+
47
+enum linkStates { UNLINKED, LINKING, LINKED, CONNECTING, CONNECTED, NO_HARDWARE } linkState;
48
+
49
+#ifdef __IMXRT1062__
50
+
51
+  static void teensyMAC(uint8_t * const mac) {
52
+    const uint32_t m1 = HW_OCOTP_MAC1, m2 = HW_OCOTP_MAC0;
53
+    mac[0] = m1 >> 8;
54
+    mac[1] = m1 >> 0;
55
+    mac[2] = m2 >> 24;
56
+    mac[3] = m2 >> 16;
57
+    mac[4] = m2 >> 8;
58
+    mac[5] = m2 >> 0;
59
+  }
60
+
61
+#else
62
+
63
+  byte mac[] = MAC_ADDRESS;
64
+
65
+#endif
66
+
67
+void ethernet_cable_error() { SERIAL_ERROR_MSG("Ethernet cable is not connected."); }
68
+
69
+void MarlinEthernet::init() {
70
+  if (!hardware_enabled) return;
71
+
72
+  SERIAL_ECHO_MSG("Starting network...");
73
+
74
+  // Init the Ethernet device
75
+  #ifdef __IMXRT1062__
76
+    uint8_t mac[6];
77
+    teensyMAC(mac);
78
+  #endif
79
+
80
+  if (!ip) {
81
+    Ethernet.begin(mac); // use DHCP
82
+  }
83
+  else {
84
+    if (!gateway) {
85
+      gateway = ip;
86
+      gateway[3] = 1;
87
+      myDns = gateway;
88
+      subnet = IPAddress(255,255,255,0);
89
+    }
90
+    if (!myDns) myDns = gateway;
91
+    if (!subnet) subnet = IPAddress(255,255,255,0);
92
+    Ethernet.begin(mac, ip, myDns, gateway, subnet);
93
+  }
94
+
95
+  // Check for Ethernet hardware present
96
+  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
97
+    SERIAL_ERROR_MSG("No Ethernet hardware found.");
98
+    linkState = NO_HARDWARE;
99
+    return;
100
+  }
101
+
102
+  linkState = UNLINKED;
103
+
104
+  if (Ethernet.linkStatus() == LinkOFF)
105
+    ethernet_cable_error();
106
+}
107
+
108
+void MarlinEthernet::check() {
109
+  if (!hardware_enabled) return;
110
+
111
+  switch (linkState) {
112
+    case NO_HARDWARE:
113
+      break;
114
+
115
+    case UNLINKED:
116
+      if (Ethernet.linkStatus() == LinkOFF) break;
117
+
118
+      SERIAL_ECHOLNPGM("Ethernet cable connected");
119
+      server.begin();
120
+      linkState = LINKING;
121
+      break;
122
+
123
+    case LINKING:
124
+      if (!Ethernet.localIP()) break;
125
+
126
+      SERIAL_ECHOPGM("Successfully started telnet server with IP ");
127
+      MYSERIAL0.println(Ethernet.localIP());
128
+
129
+      linkState = LINKED;
130
+      break;
131
+
132
+    case LINKED:
133
+      if (Ethernet.linkStatus() == LinkOFF) {
134
+        ethernet_cable_error();
135
+        linkState = UNLINKED;
136
+        break;
137
+      }
138
+      telnetClient = server.accept();
139
+      if (telnetClient) linkState = CONNECTING;
140
+      break;
141
+
142
+    case CONNECTING:
143
+      telnetClient.println("Marlin " SHORT_BUILD_VERSION);
144
+      #if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR)
145
+        telnetClient.println(
146
+          " Last Updated: " STRING_DISTRIBUTION_DATE
147
+          " | Author: " STRING_CONFIG_H_AUTHOR
148
+        );
149
+      #endif
150
+      telnetClient.println("Compiled: " __DATE__);
151
+
152
+      SERIAL_ECHOLNPGM("Client connected");
153
+      have_telnet_client = true;
154
+      linkState = CONNECTED;
155
+      break;
156
+
157
+    case CONNECTED:
158
+      if (telnetClient && !telnetClient.connected()) {
159
+        SERIAL_ECHOLNPGM("Client disconnected");
160
+        telnetClient.stop();
161
+        have_telnet_client = false;
162
+        linkState = LINKED;
163
+      }
164
+      if (Ethernet.linkStatus() == LinkOFF) {
165
+        ethernet_cable_error();
166
+        if (telnetClient) telnetClient.stop();
167
+        linkState = UNLINKED;
168
+      }
169
+      break;
170
+
171
+    default: break;
172
+  }
173
+}
174
+
175
+#endif // HAS_ETHERNET

+ 39
- 0
Marlin/src/feature/ethernet.h View File

@@ -0,0 +1,39 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#ifdef __IMXRT1062__
25
+  #include <NativeEthernet.h>
26
+#endif
27
+
28
+// Teensy 4.1 uses internal MAC Address
29
+
30
+class MarlinEthernet {
31
+  public:
32
+    static bool hardware_enabled, have_telnet_client;
33
+    static IPAddress ip, myDns, gateway, subnet;
34
+    static EthernetClient telnetClient;
35
+    static void init();
36
+    static void check();
37
+};
38
+
39
+extern MarlinEthernet ethernet;

+ 125
- 0
Marlin/src/gcode/feature/network/M552-M554.cpp View File

@@ -0,0 +1,125 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "../../../inc/MarlinConfigPre.h"
24
+
25
+#if HAS_ETHERNET
26
+
27
+#include "../../../feature/ethernet.h"
28
+#include "../../../core/serial.h"
29
+#include "../../gcode.h"
30
+
31
+void say_ethernet() { SERIAL_ECHOPGM("  Ethernet "); }
32
+
33
+void ETH0_report() {
34
+  say_ethernet();
35
+  SERIAL_ECHO_TERNARY(ethernet.hardware_enabled, "port ", "en", "dis", "abled.\n");
36
+  if (ethernet.hardware_enabled) {
37
+    say_ethernet();
38
+    SERIAL_ECHO_TERNARY(ethernet.have_telnet_client, "client ", "en", "dis", "abled.\n");
39
+  }
40
+  else
41
+    SERIAL_ECHOLNPGM("Send 'M552 S1' to enable.");
42
+}
43
+
44
+void MAC_report() {
45
+  uint8_t mac[6];
46
+  if (ethernet.hardware_enabled) {
47
+    Ethernet.MACAddress(mac);
48
+    SERIAL_ECHOPGM("  MAC: ");
49
+    LOOP_L_N(i, 6) {
50
+      SERIAL_PRINTF("%02X", mac[i]);
51
+      if (i < 5) SERIAL_CHAR(':');
52
+    }
53
+  }
54
+  SERIAL_EOL();
55
+}
56
+
57
+// Display current values when the link is active,
58
+// otherwise show the stored values
59
+void ip_report(const uint16_t cmd, PGM_P const post, const IPAddress &ipo) {
60
+  SERIAL_CHAR('M'); SERIAL_ECHO(cmd); SERIAL_CHAR(' ');
61
+  LOOP_L_N(i, 4) {
62
+    SERIAL_ECHO(ipo[i]);
63
+    if (i < 3) SERIAL_CHAR('.');
64
+  }
65
+  SERIAL_ECHOPGM(" ; ");
66
+  SERIAL_ECHOPGM_P(post);
67
+  SERIAL_EOL();
68
+}
69
+void M552_report() {
70
+  ip_report(552, PSTR("ip address"), Ethernet.linkStatus() == LinkON ? Ethernet.localIP() : ethernet.ip);
71
+}
72
+void M553_report() {
73
+  ip_report(553, PSTR("subnet mask"), Ethernet.linkStatus() == LinkON ? Ethernet.subnetMask() : ethernet.subnet);
74
+}
75
+void M554_report() {
76
+  ip_report(554, PSTR("gateway"), Ethernet.linkStatus() == LinkON ? Ethernet.gatewayIP() : ethernet.gateway);
77
+}
78
+
79
+/**
80
+ * M552: Set IP address, enable/disable network interface
81
+ *
82
+ *  S0   : disable networking
83
+ *  S1   : enable networking
84
+ *  S-1  : reset network interface
85
+ *
86
+ *  Pnnn : Set IP address, 0.0.0.0 means acquire an IP address using DHCP
87
+ */
88
+void GcodeSuite::M552() {
89
+  const bool seenP = parser.seenval('P');
90
+  if (seenP) ethernet.ip.fromString(parser.value_string());
91
+
92
+  const bool seenS = parser.seenval('S');
93
+  if (seenS) {
94
+    switch (parser.value_int()) {
95
+      case -1:
96
+        if (ethernet.telnetClient) ethernet.telnetClient.stop();
97
+        ethernet.init();
98
+        break;
99
+      case 0: ethernet.hardware_enabled = false; break;
100
+      case 1: ethernet.hardware_enabled = true; break;
101
+      default: break;
102
+    }
103
+  }
104
+  const bool nopar = !seenS && !seenP;
105
+  if (nopar || seenS) ETH0_report();
106
+  if (nopar || seenP) M552_report();
107
+}
108
+
109
+/**
110
+ * M553 Pnnn - Set netmask
111
+ */
112
+void GcodeSuite::M553() {
113
+  if (parser.seenval('P')) ethernet.subnet.fromString(parser.value_string());
114
+  M553_report();
115
+}
116
+
117
+/**
118
+ * M554 Pnnn - Set Gateway
119
+ */
120
+void GcodeSuite::M554() {
121
+  if (parser.seenval('P')) ethernet.gateway.fromString(parser.value_string());
122
+  M554_report();
123
+}
124
+
125
+#endif // HAS_ETHERNET

+ 6
- 0
Marlin/src/gcode/gcode.cpp View File

@@ -766,6 +766,12 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
766 766
         case 540: M540(); break;                                  // M540: Set abort on endstop hit for SD printing
767 767
       #endif
768 768
 
769
+      #if HAS_ETHERNET
770
+        case 552: M552(); break;                                  // M552: Set IP address
771
+        case 553: M553(); break;                                  // M553: Set gateway
772
+        case 554: M554(); break;                                  // M554: Set netmask
773
+      #endif
774
+
769 775
       #if ENABLED(BAUD_RATE_GCODE)
770 776
         case 575: M575(); break;                                  // M575: Set serial baudrate
771 777
       #endif

+ 9
- 0
Marlin/src/gcode/gcode.h View File

@@ -230,6 +230,9 @@
230 230
  * M512 - Set/Change/Remove Password
231 231
  * M524 - Abort the current SD print job started with M24. (Requires SDSUPPORT)
232 232
  * M540 - Enable/disable SD card abort on endstop hit: "M540 S<state>". (Requires SD_ABORT_ON_ENDSTOP_HIT)
233
+ * M552 - Get or set IP address. Enable/disable network interface. (Requires enabled Ethernet port)
234
+ * M553 - Get or set IP netmask. (Requires enabled Ethernet port)
235
+ * M554 - Get or set IP gateway. (Requires enabled Ethernet port)
233 236
  * M569 - Enable stealthChop on an axis. (Requires at least one _DRIVER_TYPE to be TMC2130/2160/2208/2209/5130/5160)
234 237
  * M600 - Pause for filament change: "M600 X<pos> Y<pos> Z<raise> E<first_retract> L<later_retract>". (Requires ADVANCED_PAUSE_FEATURE)
235 238
  * M603 - Configure filament change: "M603 T<tool> U<unload_length> L<load_length>". (Requires ADVANCED_PAUSE_FEATURE)
@@ -778,6 +781,12 @@ private:
778 781
 
779 782
   TERN_(SD_ABORT_ON_ENDSTOP_HIT, static void M540());
780 783
 
784
+  #if HAS_ETHERNET
785
+    static void M552();
786
+    static void M553();
787
+    static void M554();
788
+  #endif
789
+
781 790
   TERN_(BAUD_RATE_GCODE, static void M575());
782 791
 
783 792
   #if ENABLED(ADVANCED_PAUSE_FEATURE)

+ 17
- 4
Marlin/src/gcode/queue.cpp View File

@@ -39,6 +39,10 @@ GCodeQueue queue;
39 39
   #include "../feature/leds/printer_event_leds.h"
40 40
 #endif
41 41
 
42
+#if HAS_ETHERNET
43
+  #include "../feature/ethernet.h"
44
+#endif
45
+
42 46
 #if ENABLED(BINARY_FILE_TRANSFER)
43 47
   #include "../feature/binary_stream.h"
44 48
 #endif
@@ -312,15 +316,24 @@ void GCodeQueue::flush_and_request_resend() {
312 316
 }
313 317
 
314 318
 inline bool serial_data_available() {
315
-  return MYSERIAL0.available() || TERN0(HAS_MULTI_SERIAL, MYSERIAL1.available());
319
+  byte data_available = 0;
320
+  if (MYSERIAL0.available()) data_available++;
321
+  #ifdef SERIAL_PORT_2
322
+    const bool port2_open = TERN1(HAS_ETHERNET, ethernet.have_telnet_client);
323
+    if (port2_open && MYSERIAL1.available()) data_available++;
324
+  #endif
325
+  return data_available > 0;
316 326
 }
317 327
 
318 328
 inline int read_serial(const uint8_t index) {
319 329
   switch (index) {
320 330
     case 0: return MYSERIAL0.read();
321
-    #if HAS_MULTI_SERIAL
322
-      case 1: return MYSERIAL1.read();
323
-    #endif
331
+    case 1: {
332
+      #if HAS_MULTI_SERIAL
333
+        const bool port2_open = TERN1(HAS_ETHERNET, ethernet.have_telnet_client);
334
+        if (port2_open) return MYSERIAL1.read();
335
+      #endif
336
+    }
324 337
     default: return -1;
325 338
   }
326 339
 }

+ 3
- 0
Marlin/src/inc/Conditionals_LCD.h View File

@@ -777,6 +777,9 @@
777 777
 #if SERIAL_PORT == -1 || SERIAL_PORT_2 == -1
778 778
   #define HAS_USB_SERIAL 1
779 779
 #endif
780
+#if SERIAL_PORT_2 == -2
781
+  #define HAS_ETHERNET 1
782
+#endif
780 783
 
781 784
 // Fallback Stepper Driver types
782 785
 #ifndef X_DRIVER_TYPE

+ 66
- 1
Marlin/src/module/settings.cpp View File

@@ -150,8 +150,20 @@
150 150
   #include "../lcd/tft/touch.h"
151 151
 #endif
152 152
 
153
+#if HAS_ETHERNET
154
+  #include "../feature/ethernet.h"
155
+#endif
156
+
153 157
 #pragma pack(push, 1) // No padding between variables
154 158
 
159
+#if HAS_ETHERNET
160
+  void ETH0_report();
161
+  void MAC_report();
162
+  void M552_report();
163
+  void M553_report();
164
+  void M554_report();
165
+#endif
166
+
155 167
 typedef struct { uint16_t X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_stepper_current_t;
156 168
 typedef struct { uint32_t X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_hybrid_threshold_t;
157 169
 typedef struct {  int16_t X, Y, Z, X2, Y2, Z2, Z3, Z4;                                 } tmc_sgt_t;
@@ -431,6 +443,15 @@ typedef struct SettingsDataStruct {
431 443
     touch_calibration_t touch_calibration;
432 444
   #endif
433 445
 
446
+  // Ethernet settings
447
+  #if HAS_ETHERNET
448
+    bool ethernet_hardware_enabled;                     // M552 S
449
+    uint32_t ethernet_ip,                               // M552 P
450
+             ethernet_dns,
451
+             ethernet_gateway,                          // M553 P
452
+             ethernet_subnet;                           // M554 P
453
+  #endif
454
+
434 455
 } SettingsData;
435 456
 
436 457
 //static_assert(sizeof(SettingsData) <= MARLIN_EEPROM_SIZE, "EEPROM too small to contain SettingsData!");
@@ -1384,7 +1405,26 @@ void MarlinSettings::postprocess() {
1384 1405
     #endif
1385 1406
 
1386 1407
     //
1387
-    // Validate CRC and Data Size
1408
+    // Ethernet network info
1409
+    //
1410
+    #if HAS_ETHERNET
1411
+    {
1412
+      _FIELD_TEST(ethernet_hardware_enabled);
1413
+      const bool ethernet_hardware_enabled = ethernet.hardware_enabled;
1414
+      const uint32_t ethernet_ip      = ethernet.ip,
1415
+                     ethernet_dns     = ethernet.myDns,
1416
+                     ethernet_gateway = ethernet.gateway,
1417
+                     ethernet_subnet  = ethernet.subnet;
1418
+      EEPROM_WRITE(ethernet_hardware_enabled);
1419
+      EEPROM_WRITE(ethernet_ip);
1420
+      EEPROM_WRITE(ethernet_dns);
1421
+      EEPROM_WRITE(ethernet_gateway);
1422
+      EEPROM_WRITE(ethernet_subnet);
1423
+    }
1424
+    #endif
1425
+
1426
+    //
1427
+    // Report final CRC and Data Size
1388 1428
     //
1389 1429
     if (!eeprom_error) {
1390 1430
       const uint16_t eeprom_size = eeprom_index - (EEPROM_OFFSET),
@@ -2241,6 +2281,22 @@ void MarlinSettings::postprocess() {
2241 2281
         EEPROM_READ(touch.calibration);
2242 2282
       #endif
2243 2283
 
2284
+      //
2285
+      // Ethernet network info
2286
+      //
2287
+      #if HAS_ETHERNET
2288
+        _FIELD_TEST(ethernet_hardware_enabled);
2289
+        uint32_t ethernet_ip, ethernet_dns, ethernet_gateway, ethernet_subnet;
2290
+        EEPROM_READ(ethernet.hardware_enabled);
2291
+        EEPROM_READ(ethernet_ip);      ethernet.ip      = ethernet_ip;
2292
+        EEPROM_READ(ethernet_dns);     ethernet.myDns   = ethernet_dns;
2293
+        EEPROM_READ(ethernet_gateway); ethernet.gateway = ethernet_gateway;
2294
+        EEPROM_READ(ethernet_subnet);  ethernet.subnet  = ethernet_subnet;
2295
+      #endif
2296
+
2297
+      //
2298
+      // Validate Final Size and CRC
2299
+      //
2244 2300
       eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET));
2245 2301
       if (eeprom_error) {
2246 2302
         DEBUG_ECHO_START();
@@ -3784,6 +3840,15 @@ void MarlinSettings::reset() {
3784 3840
         #endif
3785 3841
       );
3786 3842
     #endif
3843
+
3844
+    #if HAS_ETHERNET
3845
+      CONFIG_ECHO_HEADING("Ethernet:");
3846
+      if (!forReplay) { CONFIG_ECHO_START(); ETH0_report(); }
3847
+      CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); MAC_report();
3848
+      CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); M552_report();
3849
+      CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); M553_report();
3850
+      CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); M554_report();
3851
+    #endif
3787 3852
   }
3788 3853
 
3789 3854
 #endif // !DISABLE_M503

+ 3
- 2
buildroot/tests/teensy41-tests View File

@@ -63,8 +63,9 @@ restore_configs
63 63
 opt_set MOTHERBOARD BOARD_TEENSY41
64 64
 opt_set EXTRUDERS 2
65 65
 opt_set TEMP_SENSOR_1 1
66
-opt_enable MAGNETIC_PARKING_EXTRUDER
67
-exec_test $1 $2 "MAGNETIC_PARKING_EXTRUDER with LCD"
66
+opt_set SERIAL_PORT_2 -2
67
+opt_enable EEPROM_SETTINGS MAGNETIC_PARKING_EXTRUDER
68
+exec_test $1 $2 "Ethernet, EEPROM, Magnetic Parking Extruder, No LCD"
68 69
 
69 70
 #
70 71
 # Mixing Extruder

+ 5
- 0
platformio.ini View File

@@ -284,6 +284,7 @@ EMERGENCY_PARSER        = src_filter=+<src/feature/e_parser.cpp> -<src/gcode/con
284 284
 I2C_POSITION_ENCODERS   = src_filter=+<src/feature/encoder_i2c.cpp>
285 285
 IIC_BL24CXX_EEPROM      = src_filter=+<src/libs/BL24CXX.cpp>
286 286
 HAS_SPI_FLASH           = src_filter=+<src/libs/W25Qxx.cpp>
287
+HAS_ETHERNET            = src_filter=+<src/feature/ethernet.cpp>
287 288
 HAS_FANMUX              = src_filter=+<src/feature/fanmux.cpp>
288 289
 FILAMENT_WIDTH_SENSOR   = src_filter=+<src/feature/filwidth.cpp> +<src/gcode/feature/filwidth>
289 290
 FWRETRACT               = src_filter=+<src/feature/fwretract.cpp> +<src/gcode/feature/fwretract>
@@ -1321,6 +1322,7 @@ platform      = espressif32@1.11.2
1321 1322
 board         = esp32dev
1322 1323
 build_flags   = ${common.build_flags} -DCORE_DEBUG_LEVEL=0
1323 1324
 src_filter    = ${common.default_src_filter} +<src/HAL/ESP32>
1325
+lib_ignore    = NativeEthernet
1324 1326
 upload_speed  = 115200
1325 1327
 #upload_port   = marlinesp.local
1326 1328
 #board_build.flash_mode = qio
@@ -1332,6 +1334,7 @@ upload_speed  = 115200
1332 1334
 platform      = teensy
1333 1335
 board         = teensy31
1334 1336
 src_filter    = ${common.default_src_filter} +<src/HAL/TEENSY31_32>
1337
+lib_ignore    = NativeEthernet
1335 1338
 
1336 1339
 #
1337 1340
 # Teensy 3.5 / 3.6 (ARM Cortex-M4)
@@ -1340,11 +1343,13 @@ src_filter    = ${common.default_src_filter} +<src/HAL/TEENSY31_32>
1340 1343
 platform      = teensy
1341 1344
 board         = teensy35
1342 1345
 src_filter    = ${common.default_src_filter} +<src/HAL/TEENSY35_36>
1346
+lib_ignore    = NativeEthernet
1343 1347
 
1344 1348
 [env:teensy36]
1345 1349
 platform      = teensy
1346 1350
 board         = teensy36
1347 1351
 src_filter    = ${common.default_src_filter} +<src/HAL/TEENSY35_36>
1352
+lib_ignore    = NativeEthernet
1348 1353
 
1349 1354
 #
1350 1355
 # Teensy 4.0 / 4.1 (ARM Cortex-M7)

Loading…
Cancel
Save