Skip to content

Commit e1f6435

Browse files
authored
✨ Creality STM32F401RE board (e.g., Ender-5 S1) (MarlinFirmware#25773)
1 parent 21ea9bf commit e1f6435

22 files changed

+1881
-7
lines changed

Marlin/Configuration.h

+1
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@
462462
* 11 : 100kΩ Keenovo AC silicone mats, most Wanhao i3 machines - beta 3950, 1%
463463
* 12 : 100kΩ Vishay 0603 SMD NTCS0603E3104FXT (#8) - calibrated for Makibox hot bed
464464
* 13 : 100kΩ Hisens up to 300°C - for "Simple ONE" & "All In ONE" hotend - beta 3950, 1%
465+
* 14 : 100kΩ (R25), 4092K (beta25), 4.7kΩ pull-up, bed thermistor as used in Ender-5 S1
465466
* 15 : 100kΩ Calibrated for JGAurora A5 hotend
466467
* 18 : 200kΩ ATC Semitec 204GT-2 Dagoma.Fr - MKS_Base_DKU001327
467468
* 22 : 100kΩ GTM32 Pro vB - hotend - 4.7kΩ pullup to 3.3V and 220Ω to analog input

Marlin/src/core/boards.h

+1
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@
449449
#define BOARD_FYSETC_SPIDER_KING407 5243 // FYSETC Spider King407 (STM32F407ZG)
450450
#define BOARD_MKS_SKIPR_V1 5244 // MKS SKIPR v1.0 all-in-one board (STM32F407VE)
451451
#define BOARD_TRONXY_V10 5245 // TRONXY V10 (STM32F446ZE)
452+
#define BOARD_CREALITY_F401RE 5246 // Creality CR4NS200141C13 (STM32F401RE) as found in the Ender-5 S1
452453

453454
//
454455
// ARM Cortex-M7

Marlin/src/gcode/gcode.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
10611061
case 422: M422(); break; // M422: Set Z Stepper automatic alignment position using probe
10621062
#endif
10631063

1064+
#if ENABLED(OTA_FIRMWARE_UPDATE)
1065+
case 936: M936(); break; // M936: OTA update firmware.
1066+
#endif
1067+
10641068
#if SPI_FLASH_BACKUP
10651069
case 993: M993(); break; // M993: Backup SPI Flash to SD
10661070
case 994: M994(); break; // M994: Load a Backup from SD to SPI Flash

Marlin/src/gcode/gcode.h

+5
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@
300300
* M913 - Set HYBRID_THRESHOLD speed. (Requires HYBRID_THRESHOLD)
301301
* M914 - Set StallGuard sensitivity. (Requires SENSORLESS_HOMING or SENSORLESS_PROBING)
302302
* M919 - Get or Set motor Chopper Times (time_off, hysteresis_end, hysteresis_start) using axis codes XYZE, etc. If no parameters are given, report. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660)
303+
* M936 - OTA update firmware. (Requires OTA_FIRMWARE_UPDATE)
303304
* M951 - Set Magnetic Parking Extruder parameters. (Requires MAGNETIC_PARKING_EXTRUDER)
304305
* M3426 - Read MCP3426 ADC over I2C. (Requires HAS_MCP3426_ADC)
305306
* M7219 - Control Max7219 Matrix LEDs. (Requires MAX7219_GCODE)
@@ -1199,6 +1200,10 @@ class GcodeSuite {
11991200
static void M928();
12001201
#endif
12011202

1203+
#if ENABLED(OTA_FIRMWARE_UPDATE)
1204+
static void M936();
1205+
#endif
1206+
12021207
#if ENABLED(MAGNETIC_PARKING_EXTRUDER)
12031208
static void M951();
12041209
#endif

Marlin/src/gcode/ota/M936.cpp

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* Marlin 3D Printer Firmware
3+
* Copyright (c) 2023 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+
#include "../../inc/MarlinConfig.h"
23+
24+
#if ENABLED(OTA_FIRMWARE_UPDATE)
25+
26+
#include "../gcode.h"
27+
#include "../../libs/BL24CXX.h"
28+
29+
#if ENABLED(CREALITY_RTS)
30+
#include "../../lcd/rts/lcd_rts.h"
31+
#endif
32+
33+
#define OTA_FLAG_EEPROM 90
34+
35+
//#define DEBUG_OUT 1
36+
#include "../../core/debug_out.h"
37+
38+
/**
39+
* M936: Set one of the OTA update flags.
40+
* V2 = Upgrade the motherboard firmware
41+
* V3 = Upgrade the RTS controller firmware
42+
*/
43+
void GcodeSuite::M936() {
44+
static uint8_t ota_update_flag = 0x00;
45+
const int16_t ota = parser.intval('V', -1);
46+
switch (ota) {
47+
case 2:
48+
// Set the OTA board firmware upgrade flag ahead of reboot.
49+
ota_update_flag = 0x01;
50+
DEBUG_ECHOLNPGM("Motherboard upgrade flag set");
51+
TERN_(CREALITY_RTS, RTS_Error(Error_205));
52+
break;
53+
54+
#if ENABLED(CREALITY_RTS)
55+
case 3:
56+
// Set the OTA screen firmware upgrade flag ahead of reboot.
57+
ota_update_flag = 0x02;
58+
DEBUG_ECHOLNPGM("DWIN upgrade flag set");
59+
TERN_(CREALITY_RTS, RTS_Error(Error_206));
60+
break;
61+
#endif
62+
}
63+
64+
switch (ota) {
65+
case 2: TERN_(CREALITY_RTS, case 3:)
66+
BL24CXX::write(OTA_FLAG_EEPROM, &ota_update_flag, sizeof(ota_update_flag));
67+
safe_delay(100);
68+
hal.reboot();
69+
}
70+
}
71+
72+
#endif // OTA_FIRMWARE_UPDATE

Marlin/src/inc/Conditionals_post.h

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
#undef IIC_BL24CXX_EEPROM
6666
#endif
6767

68+
#if DISABLED(IIC_BL24CXX_EEPROM)
69+
#undef OTA_FIRMWARE_UPDATE
70+
#endif
71+
6872
#ifdef TEENSYDUINO
6973
#undef max
7074
#define max(a,b) ((a)>(b)?(a):(b))

Marlin/src/inc/Warnings.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -749,3 +749,10 @@
749749
#if SDSORT_CACHE_LPC1768_WARNING
750750
#warning "SDCARD_SORT_ALPHA sub-options overridden for LPC1768 with DOGM LCD SCK overlap."
751751
#endif
752+
753+
/**
754+
* Ender-5 S1 bootloader
755+
*/
756+
#ifdef STM32F4_UPDATE_FOLDER
757+
#warning "Place the firmware bin file in a folder named 'STM32F4_UPDATE' on the SD card. Install with 'M936 V2'."
758+
#endif

Marlin/src/module/thermistor/thermistor_1.h

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323

2424
// R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor
2525
constexpr temp_entry_t temptable_1[] PROGMEM = {
26+
{ OV( 18), 320 },
27+
{ OV( 19), 315 },
28+
{ OV( 20), 310 },
29+
{ OV( 22), 305 },
2630
{ OV( 23), 300 },
2731
{ OV( 25), 295 },
2832
{ OV( 27), 290 },
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* Marlin 3D Printer Firmware
3+
* Copyright (c) 2023 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+
// R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor
25+
const temp_entry_t temptable_14[] PROGMEM = {
26+
{ OV( 23), 275 },
27+
{ OV( 25), 270 },
28+
{ OV( 27), 265 },
29+
{ OV( 28), 260 },
30+
{ OV( 31), 255 },
31+
{ OV( 33), 250 },
32+
{ OV( 35), 245 },
33+
{ OV( 38), 240 },
34+
{ OV( 41), 235 },
35+
{ OV( 44), 230 },
36+
{ OV( 47), 225 },
37+
{ OV( 52), 220 },
38+
{ OV( 56), 215 },
39+
{ OV( 62), 210 },
40+
{ OV( 68), 205 },
41+
{ OV( 74), 200 },
42+
{ OV( 81), 195 },
43+
{ OV( 90), 190 },
44+
{ OV( 99), 185 },
45+
{ OV( 108), 180 },
46+
{ OV( 121), 175 },
47+
{ OV( 133), 170 },
48+
{ OV( 147), 165 },
49+
{ OV( 162), 160 },
50+
{ OV( 180), 155 },
51+
{ OV( 199), 150 },
52+
{ OV( 219), 145 },
53+
{ OV( 243), 140 },
54+
{ OV( 268), 135 },
55+
{ OV( 296), 130 },
56+
{ OV( 326), 125 },
57+
{ OV( 358), 120 },
58+
{ OV( 398), 115 },
59+
{ OV( 435), 110 },
60+
{ OV( 476), 105 },
61+
{ OV( 519), 100 },
62+
{ OV( 566), 95 },
63+
{ OV( 610), 90 },
64+
{ OV( 658), 85 },
65+
{ OV( 703), 80 },
66+
{ OV( 742), 75 },
67+
{ OV( 773), 70 },
68+
{ OV( 807), 65 },
69+
{ OV( 841), 60 },
70+
{ OV( 871), 55 },
71+
{ OV( 895), 50 },
72+
{ OV( 918), 45 },
73+
{ OV( 937), 40 },
74+
{ OV( 954), 35 },
75+
{ OV( 968), 30 },
76+
{ OV( 978), 25 },
77+
{ OV( 985), 20 },
78+
{ OV( 993), 15 },
79+
{ OV( 999), 10 },
80+
{ OV(1004), 5 },
81+
{ OV(1008), 0 },
82+
{ OV(1012), -5 },
83+
{ OV(1016), -10 },
84+
{ OV(1020), -15 }
85+
};

Marlin/src/module/thermistor/thermistors.h

+3
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ typedef struct { raw_adc_t value; celsius_t celsius; } temp_entry_t;
109109
#if ANY_THERMISTOR_IS(13) // beta25 = 4100 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "Hisens"
110110
#include "thermistor_13.h"
111111
#endif
112+
#if ANY_THERMISTOR_IS(14) // beta25 = 4092 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "EPCOS" for hot bed
113+
#include "thermistor_14.h"
114+
#endif
112115
#if ANY_THERMISTOR_IS(15) // JGAurora A5 thermistor calibration
113116
#include "thermistor_15.h"
114117
#endif

Marlin/src/pins/pins.h

+2
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,8 @@
788788
#include "stm32f4/pins_MKS_SKIPR_V1_0.h" // STM32F4 env:mks_skipr_v1 env:mks_skipr_v1_nobootloader
789789
#elif MB(TRONXY_V10)
790790
#include "stm32f4/pins_TRONXY_V10.h" // STM32F4 env:STM32F446_tronxy
791+
#elif MB(CREALITY_F401RE)
792+
#include "stm32f4/pins_CREALITY_F401.h" // STM32F4 env:STM32F401RE_creality
791793

792794
//
793795
// ARM Cortex M7

0 commit comments

Comments
 (0)