Skip to content

Commit

Permalink
✨ Creality STM32F401RE board (e.g., Ender-5 S1) (MarlinFirmware#25773)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored and EvilGremlin committed May 8, 2023
1 parent de55bed commit cc951df
Show file tree
Hide file tree
Showing 22 changed files with 1,881 additions and 7 deletions.
1 change: 1 addition & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@
* 11 : 100kΩ Keenovo AC silicone mats, most Wanhao i3 machines - beta 3950, 1%
* 12 : 100kΩ Vishay 0603 SMD NTCS0603E3104FXT (#8) - calibrated for Makibox hot bed
* 13 : 100kΩ Hisens up to 300°C - for "Simple ONE" & "All In ONE" hotend - beta 3950, 1%
* 14 : 100kΩ (R25), 4092K (beta25), 4.7kΩ pull-up, bed thermistor as used in Ender-5 S1
* 15 : 100kΩ Calibrated for JGAurora A5 hotend
* 18 : 200kΩ ATC Semitec 204GT-2 Dagoma.Fr - MKS_Base_DKU001327
* 22 : 100kΩ GTM32 Pro vB - hotend - 4.7kΩ pullup to 3.3V and 220Ω to analog input
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/core/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@
#define BOARD_FYSETC_SPIDER_KING407 5243 // FYSETC Spider King407 (STM32F407ZG)
#define BOARD_MKS_SKIPR_V1 5244 // MKS SKIPR v1.0 all-in-one board (STM32F407VE)
#define BOARD_TRONXY_V10 5245 // TRONXY V10 (STM32F446ZE)
#define BOARD_CREALITY_F401RE 5246 // Creality CR4NS200141C13 (STM32F401RE) as found in the Ender-5 S1

//
// ARM Cortex-M7
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 422: M422(); break; // M422: Set Z Stepper automatic alignment position using probe
#endif

#if ENABLED(OTA_FIRMWARE_UPDATE)
case 936: M936(); break; // M936: OTA update firmware.
#endif

#if SPI_FLASH_BACKUP
case 993: M993(); break; // M993: Backup SPI Flash to SD
case 994: M994(); break; // M994: Load a Backup from SD to SPI Flash
Expand Down
5 changes: 5 additions & 0 deletions Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@
* M913 - Set HYBRID_THRESHOLD speed. (Requires HYBRID_THRESHOLD)
* M914 - Set StallGuard sensitivity. (Requires SENSORLESS_HOMING or SENSORLESS_PROBING)
* 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)
* M936 - OTA update firmware. (Requires OTA_FIRMWARE_UPDATE)
* M951 - Set Magnetic Parking Extruder parameters. (Requires MAGNETIC_PARKING_EXTRUDER)
* M3426 - Read MCP3426 ADC over I2C. (Requires HAS_MCP3426_ADC)
* M7219 - Control Max7219 Matrix LEDs. (Requires MAX7219_GCODE)
Expand Down Expand Up @@ -1199,6 +1200,10 @@ class GcodeSuite {
static void M928();
#endif

#if ENABLED(OTA_FIRMWARE_UPDATE)
static void M936();
#endif

#if ENABLED(MAGNETIC_PARKING_EXTRUDER)
static void M951();
#endif
Expand Down
72 changes: 72 additions & 0 deletions Marlin/src/gcode/ota/M936.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https:/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../inc/MarlinConfig.h"

#if ENABLED(OTA_FIRMWARE_UPDATE)

#include "../gcode.h"
#include "../../libs/BL24CXX.h"

#if ENABLED(CREALITY_RTS)
#include "../../lcd/rts/lcd_rts.h"
#endif

#define OTA_FLAG_EEPROM 90

//#define DEBUG_OUT 1
#include "../../core/debug_out.h"

/**
* M936: Set one of the OTA update flags.
* V2 = Upgrade the motherboard firmware
* V3 = Upgrade the RTS controller firmware
*/
void GcodeSuite::M936() {
static uint8_t ota_update_flag = 0x00;
const int16_t ota = parser.intval('V', -1);
switch (ota) {
case 2:
// Set the OTA board firmware upgrade flag ahead of reboot.
ota_update_flag = 0x01;
DEBUG_ECHOLNPGM("Motherboard upgrade flag set");
TERN_(CREALITY_RTS, RTS_Error(Error_205));
break;

#if ENABLED(CREALITY_RTS)
case 3:
// Set the OTA screen firmware upgrade flag ahead of reboot.
ota_update_flag = 0x02;
DEBUG_ECHOLNPGM("DWIN upgrade flag set");
TERN_(CREALITY_RTS, RTS_Error(Error_206));
break;
#endif
}

switch (ota) {
case 2: TERN_(CREALITY_RTS, case 3:)
BL24CXX::write(OTA_FLAG_EEPROM, &ota_update_flag, sizeof(ota_update_flag));
safe_delay(100);
hal.reboot();
}
}

#endif // OTA_FIRMWARE_UPDATE
4 changes: 4 additions & 0 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
#undef IIC_BL24CXX_EEPROM
#endif

#if DISABLED(IIC_BL24CXX_EEPROM)
#undef OTA_FIRMWARE_UPDATE
#endif

#ifdef TEENSYDUINO
#undef max
#define max(a,b) ((a)>(b)?(a):(b))
Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/inc/Warnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,3 +749,10 @@
#if SDSORT_CACHE_LPC1768_WARNING
#warning "SDCARD_SORT_ALPHA sub-options overridden for LPC1768 with DOGM LCD SCK overlap."
#endif

/**
* Ender-5 S1 bootloader
*/
#ifdef STM32F4_UPDATE_FOLDER
#warning "Place the firmware bin file in a folder named 'STM32F4_UPDATE' on the SD card. Install with 'M936 V2'."
#endif
4 changes: 4 additions & 0 deletions Marlin/src/module/thermistor/thermistor_1.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

// R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor
constexpr temp_entry_t temptable_1[] PROGMEM = {
{ OV( 18), 320 },
{ OV( 19), 315 },
{ OV( 20), 310 },
{ OV( 22), 305 },
{ OV( 23), 300 },
{ OV( 25), 295 },
{ OV( 27), 290 },
Expand Down
85 changes: 85 additions & 0 deletions Marlin/src/module/thermistor/thermistor_14.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2023 MarlinFirmware [https:/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once

// R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor
const temp_entry_t temptable_14[] PROGMEM = {
{ OV( 23), 275 },
{ OV( 25), 270 },
{ OV( 27), 265 },
{ OV( 28), 260 },
{ OV( 31), 255 },
{ OV( 33), 250 },
{ OV( 35), 245 },
{ OV( 38), 240 },
{ OV( 41), 235 },
{ OV( 44), 230 },
{ OV( 47), 225 },
{ OV( 52), 220 },
{ OV( 56), 215 },
{ OV( 62), 210 },
{ OV( 68), 205 },
{ OV( 74), 200 },
{ OV( 81), 195 },
{ OV( 90), 190 },
{ OV( 99), 185 },
{ OV( 108), 180 },
{ OV( 121), 175 },
{ OV( 133), 170 },
{ OV( 147), 165 },
{ OV( 162), 160 },
{ OV( 180), 155 },
{ OV( 199), 150 },
{ OV( 219), 145 },
{ OV( 243), 140 },
{ OV( 268), 135 },
{ OV( 296), 130 },
{ OV( 326), 125 },
{ OV( 358), 120 },
{ OV( 398), 115 },
{ OV( 435), 110 },
{ OV( 476), 105 },
{ OV( 519), 100 },
{ OV( 566), 95 },
{ OV( 610), 90 },
{ OV( 658), 85 },
{ OV( 703), 80 },
{ OV( 742), 75 },
{ OV( 773), 70 },
{ OV( 807), 65 },
{ OV( 841), 60 },
{ OV( 871), 55 },
{ OV( 895), 50 },
{ OV( 918), 45 },
{ OV( 937), 40 },
{ OV( 954), 35 },
{ OV( 968), 30 },
{ OV( 978), 25 },
{ OV( 985), 20 },
{ OV( 993), 15 },
{ OV( 999), 10 },
{ OV(1004), 5 },
{ OV(1008), 0 },
{ OV(1012), -5 },
{ OV(1016), -10 },
{ OV(1020), -15 }
};
3 changes: 3 additions & 0 deletions Marlin/src/module/thermistor/thermistors.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ typedef struct { raw_adc_t value; celsius_t celsius; } temp_entry_t;
#if ANY_THERMISTOR_IS(13) // beta25 = 4100 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "Hisens"
#include "thermistor_13.h"
#endif
#if ANY_THERMISTOR_IS(14) // beta25 = 4092 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "EPCOS" for hot bed
#include "thermistor_14.h"
#endif
#if ANY_THERMISTOR_IS(15) // JGAurora A5 thermistor calibration
#include "thermistor_15.h"
#endif
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/pins/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,8 @@
#include "stm32f4/pins_MKS_SKIPR_V1_0.h" // STM32F4 env:mks_skipr_v1 env:mks_skipr_v1_nobootloader
#elif MB(TRONXY_V10)
#include "stm32f4/pins_TRONXY_V10.h" // STM32F4 env:STM32F446_tronxy
#elif MB(CREALITY_F401RE)
#include "stm32f4/pins_CREALITY_F401.h" // STM32F4 env:STM32F401RE_creality

//
// ARM Cortex M7
Expand Down
Loading

0 comments on commit cc951df

Please sign in to comment.