From 98ef161bfe7545afda2c1ab432aeb420637eedde Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 27 Mar 2020 00:03:27 +0000 Subject: [PATCH 1/5] [cron] Bump distribution date (2020-03-27) --- Marlin/src/inc/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 7025c695a171..afbb5cf3c8db 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2020-03-26" + #define STRING_DISTRIBUTION_DATE "2020-03-27" #endif /** From 3655e240f5796a84d4e89b3524484e37091efad2 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Fri, 27 Mar 2020 17:06:39 -0400 Subject: [PATCH 2/5] Fix SD finished ExtUI / host action (#17285) --- Marlin/src/MarlinCore.cpp | 5 +++-- Marlin/src/gcode/lcd/M0_M1.cpp | 22 +++++++++++----------- Marlin/src/inc/Conditionals_adv.h | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 0ea1a22fd8da..7adc8272ea15 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -423,7 +423,8 @@ void startOrResumeJob() { switch (card.sdprinting_done_state) { case 1: - did_state = print_job_timer.duration() < 60 || queue.enqueue_one_P(PSTR("M31")); + if (print_job_timer.duration() > 60) + did_state = queue.enqueue_one_P(PSTR("M31")); break; case 2: @@ -437,7 +438,7 @@ void startOrResumeJob() { break; case 4: // Display "Click to Continue..." - #if HAS_RESUME_CONTINUE // 30 min timeout with LCD, 1 min without + #if HAS_LEDS_OFF_FLAG // 30 min timeout with LCD, 1 min without did_state = queue.enqueue_one_P( print_job_timer.duration() < 60 ? PSTR("M0Q1P1") : PSTR("M0Q1S" TERN(HAS_LCD_MENU, "1800", "60")) ); diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index 20ce55bd78be..43b39226f71b 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -56,11 +56,11 @@ void GcodeSuite::M0_M1() { planner.synchronize(); - #if HAS_LCD_MENU || HAS_LEDS_OFF_FLAG + #if HAS_LEDS_OFF_FLAG const bool seenQ = parser.seen('Q'); - #if HAS_LEDS_OFF_FLAG - if (seenQ) printerEventLEDs.onPrintCompleted(); // Change LED color for Print Completed - #endif + if (seenQ) printerEventLEDs.onPrintCompleted(); // Change LED color for Print Completed + #else + constexpr bool seenQ = false; #endif #if HAS_LCD_MENU @@ -75,12 +75,12 @@ void GcodeSuite::M0_M1() { } #elif ENABLED(EXTENSIBLE_UI) - - if (parser.string_arg) - ExtUI::onUserConfirmRequired(parser.string_arg); // Can this take an SRAM string?? - else - ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_USERWAIT)); - + if (!seenQ) { + if (parser.string_arg) + ExtUI::onUserConfirmRequired(parser.string_arg); // Can this take an SRAM string?? + else + ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_USERWAIT)); + } #else if (parser.string_arg) { @@ -94,7 +94,7 @@ void GcodeSuite::M0_M1() { wait_for_user = true; #if ENABLED(HOST_PROMPT_SUPPORT) - host_prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? PSTR("M1 Stop") : PSTR("M0 Stop"), CONTINUE_STR); + if (!seenQ) host_prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? PSTR("M1 Stop") : PSTR("M0 Stop"), CONTINUE_STR); #endif if (ms > 0) ms += millis(); // wait until this time for a click diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 09de5d89d70a..a52ae1af2976 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -93,7 +93,7 @@ #if EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS) #define HAS_SOFTWARE_ENDSTOPS 1 #endif -#if ANY(EXTENSIBLE_UI, NEWPANEL, EMERGENCY_PARSER) +#if ANY(EXTENSIBLE_UI, NEWPANEL, EMERGENCY_PARSER, HAS_ADC_BUTTONS) #define HAS_RESUME_CONTINUE 1 #endif From 129b270628781eae776764e63fd514553e6c2204 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Fri, 27 Mar 2020 23:29:17 +0100 Subject: [PATCH 3/5] QSPI EEPROM for SAMD51 (#17292) --- ...persistent_store_eeprom.cpp => eeprom.cpp} | 2 +- Marlin/src/HAL/DUE/EepromEmulation.cpp | 2 +- ...persistent_store_eeprom.cpp => eeprom.cpp} | 2 +- Marlin/src/HAL/DUE/inc/Conditionals_post.h | 2 +- ...sistent_store_impl.cpp => eeprom_impl.cpp} | 2 +- Marlin/src/HAL/ESP32/inc/Conditionals_post.h | 2 +- ...sistent_store_impl.cpp => eeprom_impl.cpp} | 2 +- .../{persistent_store_api.h => eeprom_api.h} | 2 +- ...stent_store_flash.cpp => eeprom_flash.cpp} | 2 +- ...ent_store_sdcard.cpp => eeprom_sdcard.cpp} | 2 +- .../src/HAL/LPC1768/inc/Conditionals_post.h | 2 +- Marlin/src/HAL/SAMD51/QSPIFlash.cpp | 78 +++++++++++ Marlin/src/HAL/SAMD51/QSPIFlash.h | 51 +++++++ Marlin/src/HAL/SAMD51/eeprom.cpp | 66 +++++++++ Marlin/src/HAL/SAMD51/eeprom_flash.cpp | 96 +++++++++++++ Marlin/src/HAL/SAMD51/eeprom_qspi.cpp | 71 ++++++++++ Marlin/src/HAL/SAMD51/inc/Conditionals_post.h | 4 +- .../HAL/SAMD51/persistent_store_eeprom.cpp | 129 ------------------ ...stent_store_flash.cpp => eeprom_flash.cpp} | 2 +- ...sistent_store_impl.cpp => eeprom_impl.cpp} | 12 +- ...ent_store_sdcard.cpp => eeprom_sdcard.cpp} | 2 +- Marlin/src/HAL/STM32/inc/Conditionals_post.h | 2 +- ...persistent_store_eeprom.cpp => eeprom.cpp} | 6 +- ...stent_store_flash.cpp => eeprom_flash.cpp} | 7 +- ...ent_store_sdcard.cpp => eeprom_sdcard.cpp} | 3 +- ...persistent_store_eeprom.cpp => eeprom.cpp} | 2 +- .../HAL/STM32_F4_F7/inc/Conditionals_post.h | 2 +- ...sistent_store_impl.cpp => eeprom_impl.cpp} | 2 +- .../HAL/TEENSY31_32/inc/Conditionals_post.h | 2 +- ...persistent_store_eeprom.cpp => eeprom.cpp} | 2 +- ...ersistent_store_api.cpp => eeprom_api.cpp} | 2 +- .../{persistent_store_api.h => eeprom_api.h} | 0 Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 2 +- Marlin/src/inc/Conditionals_post.h | 11 +- .../screens/interface_settings_screen.cpp | 2 +- Marlin/src/module/configuration_store.cpp | 2 +- Marlin/src/module/configuration_store.h | 2 +- Marlin/src/module/printcounter.cpp | 2 +- Marlin/src/module/printcounter.h | 4 +- Marlin/src/pins/samd/pins_RAMPS_144.h | 3 +- platformio.ini | 1 + 41 files changed, 413 insertions(+), 179 deletions(-) rename Marlin/src/HAL/AVR/{persistent_store_eeprom.cpp => eeprom.cpp} (97%) rename Marlin/src/HAL/DUE/{persistent_store_eeprom.cpp => eeprom.cpp} (98%) rename Marlin/src/HAL/ESP32/{persistent_store_impl.cpp => eeprom_impl.cpp} (97%) rename Marlin/src/HAL/LINUX/{persistent_store_impl.cpp => eeprom_impl.cpp} (98%) rename Marlin/src/HAL/LPC1768/{persistent_store_api.h => eeprom_api.h} (95%) rename Marlin/src/HAL/LPC1768/{persistent_store_flash.cpp => eeprom_flash.cpp} (99%) rename Marlin/src/HAL/LPC1768/{persistent_store_sdcard.cpp => eeprom_sdcard.cpp} (99%) create mode 100644 Marlin/src/HAL/SAMD51/QSPIFlash.cpp create mode 100644 Marlin/src/HAL/SAMD51/QSPIFlash.h create mode 100644 Marlin/src/HAL/SAMD51/eeprom.cpp create mode 100644 Marlin/src/HAL/SAMD51/eeprom_flash.cpp create mode 100644 Marlin/src/HAL/SAMD51/eeprom_qspi.cpp delete mode 100644 Marlin/src/HAL/SAMD51/persistent_store_eeprom.cpp rename Marlin/src/HAL/STM32/{persistent_store_flash.cpp => eeprom_flash.cpp} (99%) rename Marlin/src/HAL/STM32/{persistent_store_impl.cpp => eeprom_impl.cpp} (91%) rename Marlin/src/HAL/STM32/{persistent_store_sdcard.cpp => eeprom_sdcard.cpp} (98%) rename Marlin/src/HAL/STM32F1/{persistent_store_eeprom.cpp => eeprom.cpp} (95%) rename Marlin/src/HAL/STM32F1/{persistent_store_flash.cpp => eeprom_flash.cpp} (95%) rename Marlin/src/HAL/STM32F1/{persistent_store_sdcard.cpp => eeprom_sdcard.cpp} (98%) rename Marlin/src/HAL/STM32_F4_F7/{persistent_store_eeprom.cpp => eeprom.cpp} (98%) rename Marlin/src/HAL/TEENSY31_32/{persistent_store_impl.cpp => eeprom_impl.cpp} (97%) rename Marlin/src/HAL/TEENSY35_36/{persistent_store_eeprom.cpp => eeprom.cpp} (98%) rename Marlin/src/HAL/shared/{persistent_store_api.cpp => eeprom_api.cpp} (96%) rename Marlin/src/HAL/shared/{persistent_store_api.h => eeprom_api.h} (100%) diff --git a/Marlin/src/HAL/AVR/persistent_store_eeprom.cpp b/Marlin/src/HAL/AVR/eeprom.cpp similarity index 97% rename from Marlin/src/HAL/AVR/persistent_store_eeprom.cpp rename to Marlin/src/HAL/AVR/eeprom.cpp index 1ae37f892aa6..ee416b7a12f3 100644 --- a/Marlin/src/HAL/AVR/persistent_store_eeprom.cpp +++ b/Marlin/src/HAL/AVR/eeprom.cpp @@ -25,7 +25,7 @@ #if EITHER(EEPROM_SETTINGS, SD_FIRMWARE_UPDATE) -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" bool PersistentStore::access_start() { return true; } bool PersistentStore::access_finish() { return true; } diff --git a/Marlin/src/HAL/DUE/EepromEmulation.cpp b/Marlin/src/HAL/DUE/EepromEmulation.cpp index f1ae224bfcb5..66af50cfd2e0 100644 --- a/Marlin/src/HAL/DUE/EepromEmulation.cpp +++ b/Marlin/src/HAL/DUE/EepromEmulation.cpp @@ -57,7 +57,7 @@ #if ENABLED(FLASH_EEPROM_EMULATION) #include "../shared/Marduino.h" -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" #define EEPROMSize 4096 #define PagesPerGroup 128 diff --git a/Marlin/src/HAL/DUE/persistent_store_eeprom.cpp b/Marlin/src/HAL/DUE/eeprom.cpp similarity index 98% rename from Marlin/src/HAL/DUE/persistent_store_eeprom.cpp rename to Marlin/src/HAL/DUE/eeprom.cpp index fbdc760e4548..ec9ef51ffcad 100644 --- a/Marlin/src/HAL/DUE/persistent_store_eeprom.cpp +++ b/Marlin/src/HAL/DUE/eeprom.cpp @@ -27,7 +27,7 @@ #if ENABLED(EEPROM_SETTINGS) #include "../../inc/MarlinConfig.h" -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" #if !defined(E2END) && ENABLED(FLASH_EEPROM_EMULATION) #define E2END 0xFFF // Default to Flash emulated EEPROM size (EepromEmulation_Due.cpp) diff --git a/Marlin/src/HAL/DUE/inc/Conditionals_post.h b/Marlin/src/HAL/DUE/inc/Conditionals_post.h index b52462f6d891..8a305009ce27 100644 --- a/Marlin/src/HAL/DUE/inc/Conditionals_post.h +++ b/Marlin/src/HAL/DUE/inc/Conditionals_post.h @@ -21,7 +21,7 @@ */ #pragma once -#if USE_EMULATED_EEPROM +#if USE_FALLBACK_EEPROM #undef SRAM_EEPROM_EMULATION #undef SDCARD_EEPROM_EMULATION #define FLASH_EEPROM_EMULATION diff --git a/Marlin/src/HAL/ESP32/persistent_store_impl.cpp b/Marlin/src/HAL/ESP32/eeprom_impl.cpp similarity index 97% rename from Marlin/src/HAL/ESP32/persistent_store_impl.cpp rename to Marlin/src/HAL/ESP32/eeprom_impl.cpp index 7113b684128e..dbfee14055c4 100644 --- a/Marlin/src/HAL/ESP32/persistent_store_impl.cpp +++ b/Marlin/src/HAL/ESP32/eeprom_impl.cpp @@ -26,7 +26,7 @@ #if ENABLED(EEPROM_SETTINGS) && DISABLED(FLASH_EEPROM_EMULATION) -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" #include "EEPROM.h" #define EEPROM_SIZE 4096 diff --git a/Marlin/src/HAL/ESP32/inc/Conditionals_post.h b/Marlin/src/HAL/ESP32/inc/Conditionals_post.h index e51b55698e49..11603c9ef41d 100644 --- a/Marlin/src/HAL/ESP32/inc/Conditionals_post.h +++ b/Marlin/src/HAL/ESP32/inc/Conditionals_post.h @@ -22,6 +22,6 @@ #pragma once // If no real EEPROM, Flash emulation, or SRAM emulation is available fall back to SD emulation -#if ENABLED(EEPROM_SETTINGS) && NONE(USE_REAL_EEPROM, FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION) +#if ENABLED(EEPROM_SETTINGS) && NONE(USE_WIRED_EEPROM, FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION) #define SDCARD_EEPROM_EMULATION #endif diff --git a/Marlin/src/HAL/LINUX/persistent_store_impl.cpp b/Marlin/src/HAL/LINUX/eeprom_impl.cpp similarity index 98% rename from Marlin/src/HAL/LINUX/persistent_store_impl.cpp rename to Marlin/src/HAL/LINUX/eeprom_impl.cpp index 660ecd56f184..4745f0567392 100644 --- a/Marlin/src/HAL/LINUX/persistent_store_impl.cpp +++ b/Marlin/src/HAL/LINUX/eeprom_impl.cpp @@ -26,7 +26,7 @@ #if ENABLED(EEPROM_SETTINGS) -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" #include #define LINUX_EEPROM_SIZE (E2END + 1) diff --git a/Marlin/src/HAL/LPC1768/persistent_store_api.h b/Marlin/src/HAL/LPC1768/eeprom_api.h similarity index 95% rename from Marlin/src/HAL/LPC1768/persistent_store_api.h rename to Marlin/src/HAL/LPC1768/eeprom_api.h index 55a58fde1dfb..f874eac58a74 100644 --- a/Marlin/src/HAL/LPC1768/persistent_store_api.h +++ b/Marlin/src/HAL/LPC1768/eeprom_api.h @@ -21,6 +21,6 @@ */ #pragma once -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" #define FLASH_EEPROM_EMULATION diff --git a/Marlin/src/HAL/LPC1768/persistent_store_flash.cpp b/Marlin/src/HAL/LPC1768/eeprom_flash.cpp similarity index 99% rename from Marlin/src/HAL/LPC1768/persistent_store_flash.cpp rename to Marlin/src/HAL/LPC1768/eeprom_flash.cpp index e166858d6460..9225807480fe 100644 --- a/Marlin/src/HAL/LPC1768/persistent_store_flash.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom_flash.cpp @@ -40,7 +40,7 @@ #if ENABLED(FLASH_EEPROM_EMULATION) -#include "persistent_store_api.h" +#include "eeprom_api.h" extern "C" { #include diff --git a/Marlin/src/HAL/LPC1768/persistent_store_sdcard.cpp b/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp similarity index 99% rename from Marlin/src/HAL/LPC1768/persistent_store_sdcard.cpp rename to Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp index aa61938b022b..d982bd6268ca 100644 --- a/Marlin/src/HAL/LPC1768/persistent_store_sdcard.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp @@ -26,7 +26,7 @@ #if ENABLED(SDCARD_EEPROM_EMULATION) -#include "persistent_store_api.h" +#include "eeprom_api.h" #include #include diff --git a/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h b/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h index a8d102e865ae..490cfd50e889 100644 --- a/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h +++ b/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h @@ -21,6 +21,6 @@ */ #pragma once -#if USE_EMULATED_EEPROM && NONE(SDCARD_EEPROM_EMULATION, SRAM_EEPROM_EMULATION) +#if USE_FALLBACK_EEPROM && NONE(SDCARD_EEPROM_EMULATION, SRAM_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION #endif diff --git a/Marlin/src/HAL/SAMD51/QSPIFlash.cpp b/Marlin/src/HAL/SAMD51/QSPIFlash.cpp new file mode 100644 index 000000000000..76a332970731 --- /dev/null +++ b/Marlin/src/HAL/SAMD51/QSPIFlash.cpp @@ -0,0 +1,78 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/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 . + * + */ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(QSPI_EEPROM) + +#include "QSPIFlash.h" + +#define INVALID_ADDR 0xffffffff +#define SECTOR_OF(a) (a & ~(SFLASH_SECTOR_SIZE - 1)) +#define OFFSET_OF(a) (a & (SFLASH_SECTOR_SIZE - 1)) + +Adafruit_SPIFlashBase * QSPIFlash::_flashBase = nullptr; +uint8_t QSPIFlash::_buf[SFLASH_SECTOR_SIZE]; +uint32_t QSPIFlash::_addr = INVALID_ADDR; + +void QSPIFlash::begin() { + if (_flashBase != nullptr) return; + + _flashBase = new Adafruit_SPIFlashBase(new Adafruit_FlashTransport_QSPI()); + _flashBase->begin(NULL); +} + +size_t QSPIFlash::size() { + return _flashBase->size(); +} + +uint8_t QSPIFlash::readByte(const uint32_t address) { + if (SECTOR_OF(address) == _addr) return _buf[OFFSET_OF(address)]; + + return _flashBase->read8(address); +} + +void QSPIFlash::writeByte(const uint32_t address, const uint8_t value) { + uint32_t const sector_addr = SECTOR_OF(address); + + // Page changes, flush old and update new cache + if (sector_addr != _addr) { + flush(); + _addr = sector_addr; + + // read a whole page from flash + _flashBase->readBuffer(sector_addr, _buf, SFLASH_SECTOR_SIZE); + } + + _buf[OFFSET_OF(address)] = value; +} + +void QSPIFlash::flush() { + if (_addr == INVALID_ADDR) return; + + _flashBase->eraseSector(_addr / SFLASH_SECTOR_SIZE); + _flashBase->writeBuffer(_addr, _buf, SFLASH_SECTOR_SIZE); + + _addr = INVALID_ADDR; +} + +#endif // QSPI_EEPROM diff --git a/Marlin/src/HAL/SAMD51/QSPIFlash.h b/Marlin/src/HAL/SAMD51/QSPIFlash.h new file mode 100644 index 000000000000..7f75286ebfc1 --- /dev/null +++ b/Marlin/src/HAL/SAMD51/QSPIFlash.h @@ -0,0 +1,51 @@ +/** + * @file QSPIFlash.h + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Ha Thach and Dean Miller for Adafruit Industries LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * Derived from Adafruit_SPIFlash class with no SdFat references + * + */ + +#pragma once + +#include "Adafruit_SPIFlashBase.h" + +// This class extends Adafruit_SPIFlashBase by adding caching support. +// +// This class will use 4096 Bytes of RAM as a block cache. +class QSPIFlash { + public: + static void begin(); + static size_t size(); + static uint8_t readByte(const uint32_t address); + static void writeByte(const uint32_t address, const uint8_t v); + static void flush(); + + private: + static Adafruit_SPIFlashBase * _flashBase; + static uint8_t _buf[SFLASH_SECTOR_SIZE]; + static uint32_t _addr; +}; + +extern QSPIFlash qspi; diff --git a/Marlin/src/HAL/SAMD51/eeprom.cpp b/Marlin/src/HAL/SAMD51/eeprom.cpp new file mode 100644 index 000000000000..e167515bff3a --- /dev/null +++ b/Marlin/src/HAL/SAMD51/eeprom.cpp @@ -0,0 +1,66 @@ +/** + * Marlin 3D Printer Firmware + * + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 . + * + */ + +#ifdef __SAMD51__ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(EEPROM_SETTINGS) && NONE(QSPI_EEPROM, FLASH_EEPROM_EMULATION) + +#include "../shared/eeprom_api.h" + +size_t PersistentStore::capacity() { return E2END + 1; } + +bool PersistentStore::access_start() { return true; } +bool PersistentStore::access_finish() { return true; } + +bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + while (size--) { + const uint8_t v = *value; + uint8_t * const p = (uint8_t * const)pos; + if (v != eeprom_read_byte(p)) { + eeprom_write_byte(p, v); + delay(2); + if (eeprom_read_byte(p) != v) { + SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); + return true; + } + } + crc16(crc, &v, 1); + pos++; + value++; + } + return false; +} + +bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { + while (size--) { + uint8_t c = eeprom_read_byte((uint8_t*)pos); + if (writing) *value = c; + crc16(crc, &c, 1); + pos++; + value++; + } + return false; +} + +#endif // EEPROM_SETTINGS && !(QSPI_EEPROM || FLASH_EEPROM_EMULATION) +#endif // __SAMD51__ diff --git a/Marlin/src/HAL/SAMD51/eeprom_flash.cpp b/Marlin/src/HAL/SAMD51/eeprom_flash.cpp new file mode 100644 index 000000000000..fd8973369a8a --- /dev/null +++ b/Marlin/src/HAL/SAMD51/eeprom_flash.cpp @@ -0,0 +1,96 @@ +/** + * Marlin 3D Printer Firmware + * + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 . + * + */ + +#ifdef __SAMD51__ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(FLASH_EEPROM_EMULATION) + +#include "../shared/eeprom_api.h" + +#define NVMCTRL_CMD(c) do{ \ + SYNC(!NVMCTRL->STATUS.bit.READY); \ + NVMCTRL->INTFLAG.bit.DONE = true; \ + NVMCTRL->CTRLB.reg = c | NVMCTRL_CTRLB_CMDEX_KEY; \ + SYNC(NVMCTRL->INTFLAG.bit.DONE); \ + }while(0) +#define NVMCTRL_FLUSH() do{ \ + if (NVMCTRL->SEESTAT.bit.LOAD) \ + NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_SEEFLUSH); \ + }while(0) + +size_t PersistentStore::capacity() { + const uint8_t psz = NVMCTRL->SEESTAT.bit.PSZ, + sblk = NVMCTRL->SEESTAT.bit.SBLK; + + return (!psz && !sblk) ? 0 + : (psz <= 2) ? (0x200 << psz) + : (sblk == 1 || psz == 3) ? 4096 + : (sblk == 2 || psz == 4) ? 8192 + : (sblk <= 4 || psz == 5) ? 16384 + : (sblk >= 9 && psz == 7) ? 65536 + : 32768; +} + +bool PersistentStore::access_start() { + NVMCTRL->SEECFG.reg = NVMCTRL_SEECFG_WMODE_BUFFERED; // Buffered mode and segment reallocation active + if (NVMCTRL->SEESTAT.bit.RLOCK) + NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_USEE); // Unlock E2P data write access + return true; +} + +bool PersistentStore::access_finish() { + NVMCTRL_FLUSH(); + if (!NVMCTRL->SEESTAT.bit.LOCK) + NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_LSEE); // Lock E2P data write access + return true; +} + +bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + while (size--) { + const uint8_t v = *value; + SYNC(NVMCTRL->SEESTAT.bit.BUSY); + if (NVMCTRL->INTFLAG.bit.SEESFULL) + NVMCTRL_FLUSH(); // Next write will trigger a sector reallocation. I need to flush 'pagebuffer' + ((volatile uint8_t *)SEEPROM_ADDR)[pos] = v; + SYNC(!NVMCTRL->INTFLAG.bit.SEEWRC); + crc16(crc, &v, 1); + pos++; + value++; + } + return false; +} + +bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { + while (size--) { + SYNC(NVMCTRL->SEESTAT.bit.BUSY); + uint8_t c = ((volatile uint8_t *)SEEPROM_ADDR)[pos]; + if (writing) *value = c; + crc16(crc, &c, 1); + pos++; + value++; + } + return false; +} + +#endif // FLASH_EEPROM_EMULATION +#endif // __SAMD51__ diff --git a/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp b/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp new file mode 100644 index 000000000000..c6aa383f9f40 --- /dev/null +++ b/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp @@ -0,0 +1,71 @@ +/** + * Marlin 3D Printer Firmware + * + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 . + * + */ +#ifdef __SAMD51__ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(QSPI_EEPROM) + +#include "../shared/eeprom_api.h" + +#include "QSPIFlash.h" + +static bool initialized; + +size_t PersistentStore::capacity() { return qspi.size(); } + +bool PersistentStore::access_start() { + if (!initialized) { + qspi.begin(); + initialized = true; + } + return true; +} + +bool PersistentStore::access_finish() { + qspi.flush(); + return true; +} + +bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + while (size--) { + const uint8_t v = *value; + qspi.writeByte(pos, v); + crc16(crc, &v, 1); + pos++; + value++; + } + return false; +} + +bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { + while (size--) { + uint8_t c = qspi.readByte(pos); + if (writing) *value = c; + crc16(crc, &c, 1); + pos++; + value++; + } + return false; +} + +#endif // QSPI_EEPROM +#endif // __SAMD51__ diff --git a/Marlin/src/HAL/SAMD51/inc/Conditionals_post.h b/Marlin/src/HAL/SAMD51/inc/Conditionals_post.h index b52462f6d891..490cfd50e889 100644 --- a/Marlin/src/HAL/SAMD51/inc/Conditionals_post.h +++ b/Marlin/src/HAL/SAMD51/inc/Conditionals_post.h @@ -21,8 +21,6 @@ */ #pragma once -#if USE_EMULATED_EEPROM - #undef SRAM_EEPROM_EMULATION - #undef SDCARD_EEPROM_EMULATION +#if USE_FALLBACK_EEPROM && NONE(SDCARD_EEPROM_EMULATION, SRAM_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION #endif diff --git a/Marlin/src/HAL/SAMD51/persistent_store_eeprom.cpp b/Marlin/src/HAL/SAMD51/persistent_store_eeprom.cpp deleted file mode 100644 index 6b7326bb25b4..000000000000 --- a/Marlin/src/HAL/SAMD51/persistent_store_eeprom.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) - * - * 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 . - * - */ - -#ifdef __SAMD51__ - -#include "../../inc/MarlinConfig.h" - -#if ENABLED(EEPROM_SETTINGS) - -#include "../shared/persistent_store_api.h" - -#if ENABLED(FLASH_EEPROM_EMULATION) - #define NVMCTRL_CMD(c) do{ \ - SYNC(!NVMCTRL->STATUS.bit.READY); \ - NVMCTRL->INTFLAG.bit.DONE = true; \ - NVMCTRL->CTRLB.reg = c | NVMCTRL_CTRLB_CMDEX_KEY; \ - SYNC(NVMCTRL->INTFLAG.bit.DONE); \ - }while(0) - #define NVMCTRL_FLUSH() do{ \ - if (NVMCTRL->SEESTAT.bit.LOAD) \ - NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_SEEFLUSH); \ - }while(0) -#endif - -bool PersistentStore::access_start() { - #if ENABLED(FLASH_EEPROM_EMULATION) - NVMCTRL->SEECFG.reg = NVMCTRL_SEECFG_WMODE_BUFFERED; // Buffered mode and segment reallocation active - #endif - - return true; -} - -bool PersistentStore::access_finish() { - #if ENABLED(FLASH_EEPROM_EMULATION) - NVMCTRL_FLUSH(); - if (!NVMCTRL->SEESTAT.bit.LOCK) - NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_LSEE); // Lock E2P data write access - #endif - - return true; -} - -bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { - #if ENABLED(FLASH_EEPROM_EMULATION) - if (NVMCTRL->SEESTAT.bit.RLOCK) - NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_USEE); // Unlock E2P data write access - #endif - - while (size--) { - const uint8_t v = *value; - #if ENABLED(FLASH_EEPROM_EMULATION) - SYNC(NVMCTRL->SEESTAT.bit.BUSY); - if (NVMCTRL->INTFLAG.bit.SEESFULL) - NVMCTRL_FLUSH(); // Next write will trigger a sector reallocation. I need to flush 'pagebuffer' - ((volatile uint8_t *)SEEPROM_ADDR)[pos] = v; - SYNC(!NVMCTRL->INTFLAG.bit.SEEWRC); - #else - uint8_t * const p = (uint8_t * const)pos; - if (v != eeprom_read_byte(p)) { - eeprom_write_byte(p, v); - delay(2); - if (eeprom_read_byte(p) != v) { - SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); - return true; - } - } - #endif - crc16(crc, &v, 1); - pos++; - value++; - } - return false; -} - -bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) { - while (size--) { - uint8_t c; - #if ENABLED(FLASH_EEPROM_EMULATION) - SYNC(NVMCTRL->SEESTAT.bit.BUSY); - c = ((volatile uint8_t *)SEEPROM_ADDR)[pos]; - #else - c = eeprom_read_byte((uint8_t*)pos); - #endif - if (writing) *value = c; - crc16(crc, &c, 1); - pos++; - value++; - } - return false; -} - -size_t PersistentStore::capacity() { - #if ENABLED(FLASH_EEPROM_EMULATION) - const uint8_t psz = NVMCTRL->SEESTAT.bit.PSZ, - sblk = NVMCTRL->SEESTAT.bit.SBLK; - - if (!psz && !sblk) return 0; - else if (psz <= 2) return (0x200 << psz); - else if (sblk == 1 || psz == 3) return 4096; - else if (sblk == 2 || psz == 4) return 8192; - else if (sblk <= 4 || psz == 5) return 16384; - else if (sblk >= 9 && psz == 7) return 65536; - else return 32768; - #else - return E2END + 1; - #endif -} - -#endif // EEPROM_SETTINGS - -#endif // __SAMD51__ diff --git a/Marlin/src/HAL/STM32/persistent_store_flash.cpp b/Marlin/src/HAL/STM32/eeprom_flash.cpp similarity index 99% rename from Marlin/src/HAL/STM32/persistent_store_flash.cpp rename to Marlin/src/HAL/STM32/eeprom_flash.cpp index 80ef901ceba9..39012f8205e0 100644 --- a/Marlin/src/HAL/STM32/persistent_store_flash.cpp +++ b/Marlin/src/HAL/STM32/eeprom_flash.cpp @@ -27,7 +27,7 @@ #if BOTH(EEPROM_SETTINGS, FLASH_EEPROM_EMULATION) -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" // Only STM32F4 can support wear leveling at this time diff --git a/Marlin/src/HAL/STM32/persistent_store_impl.cpp b/Marlin/src/HAL/STM32/eeprom_impl.cpp similarity index 91% rename from Marlin/src/HAL/STM32/persistent_store_impl.cpp rename to Marlin/src/HAL/STM32/eeprom_impl.cpp index d9538741dda7..cd0f93e8d878 100644 --- a/Marlin/src/HAL/STM32/persistent_store_impl.cpp +++ b/Marlin/src/HAL/STM32/eeprom_impl.cpp @@ -24,9 +24,9 @@ #include "../../inc/MarlinConfig.h" -#if EITHER(USE_REAL_EEPROM, SRAM_EEPROM_EMULATION) +#if EITHER(USE_WIRED_EEPROM, SRAM_EEPROM_EMULATION) -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" bool PersistentStore::access_start() { return true; @@ -41,7 +41,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui uint8_t v = *value; // Save to either external EEPROM, program flash or Backup SRAM - #if USE_REAL_EEPROM + #if USE_WIRED_EEPROM // EEPROM has only ~100,000 write cycles, // so only write bytes that have changed! uint8_t * const p = (uint8_t * const)pos; @@ -68,7 +68,7 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t do { // Read from either external EEPROM, program flash or Backup SRAM const uint8_t c = ( - #if USE_REAL_EEPROM + #if USE_WIRED_EEPROM eeprom_read_byte((uint8_t*)pos) #else (*(__IO uint8_t *)(BKPSRAM_BASE + ((uint8_t*)pos))) @@ -85,7 +85,7 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t size_t PersistentStore::capacity() { return ( - #if USE_REAL_EEPROM + #if USE_WIRED_EEPROM E2END + 1 #else 4096 // 4kB @@ -93,5 +93,5 @@ size_t PersistentStore::capacity() { ); } -#endif // USE_REAL_EEPROM || SRAM_EEPROM_EMULATION +#endif // USE_WIRED_EEPROM || SRAM_EEPROM_EMULATION #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC diff --git a/Marlin/src/HAL/STM32/persistent_store_sdcard.cpp b/Marlin/src/HAL/STM32/eeprom_sdcard.cpp similarity index 98% rename from Marlin/src/HAL/STM32/persistent_store_sdcard.cpp rename to Marlin/src/HAL/STM32/eeprom_sdcard.cpp index c5afc557e91f..2b89c21b8997 100644 --- a/Marlin/src/HAL/STM32/persistent_store_sdcard.cpp +++ b/Marlin/src/HAL/STM32/eeprom_sdcard.cpp @@ -30,7 +30,7 @@ #if ENABLED(SDCARD_EEPROM_EMULATION) -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" #ifndef E2END #define E2END 0xFFF // 4KB diff --git a/Marlin/src/HAL/STM32/inc/Conditionals_post.h b/Marlin/src/HAL/STM32/inc/Conditionals_post.h index e51b55698e49..11603c9ef41d 100644 --- a/Marlin/src/HAL/STM32/inc/Conditionals_post.h +++ b/Marlin/src/HAL/STM32/inc/Conditionals_post.h @@ -22,6 +22,6 @@ #pragma once // If no real EEPROM, Flash emulation, or SRAM emulation is available fall back to SD emulation -#if ENABLED(EEPROM_SETTINGS) && NONE(USE_REAL_EEPROM, FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION) +#if ENABLED(EEPROM_SETTINGS) && NONE(USE_WIRED_EEPROM, FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION) #define SDCARD_EEPROM_EMULATION #endif diff --git a/Marlin/src/HAL/STM32F1/persistent_store_eeprom.cpp b/Marlin/src/HAL/STM32F1/eeprom.cpp similarity index 95% rename from Marlin/src/HAL/STM32F1/persistent_store_eeprom.cpp rename to Marlin/src/HAL/STM32F1/eeprom.cpp index 1b3714c56d00..ed5d50cbdea4 100644 --- a/Marlin/src/HAL/STM32F1/persistent_store_eeprom.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom.cpp @@ -22,9 +22,9 @@ #include "../../inc/MarlinConfig.h" -#if USE_REAL_EEPROM +#if USE_WIRED_EEPROM -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" bool PersistentStore::access_start() { #if ENABLED(SPI_EEPROM) @@ -73,5 +73,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t size_t PersistentStore::capacity() { return E2END + 1; } -#endif // USE_REAL_EEPROM +#endif // USE_WIRED_EEPROM #endif // __STM32F1__ diff --git a/Marlin/src/HAL/STM32F1/persistent_store_flash.cpp b/Marlin/src/HAL/STM32F1/eeprom_flash.cpp similarity index 95% rename from Marlin/src/HAL/STM32F1/persistent_store_flash.cpp rename to Marlin/src/HAL/STM32F1/eeprom_flash.cpp index 3d6a3b4591f0..9c81730465c8 100644 --- a/Marlin/src/HAL/STM32F1/persistent_store_flash.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_flash.cpp @@ -31,10 +31,9 @@ #include "../../inc/MarlinConfig.h" -// This is for EEPROM emulation in flash -#if BOTH(EEPROM_SETTINGS, FLASH_EEPROM_EMULATION) +#if ENABLED(FLASH_EEPROM_EMULATION) -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" #include #include @@ -108,5 +107,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin size_t PersistentStore::capacity() { return EEPROM_SIZE; } -#endif // EEPROM_SETTINGS && EEPROM FLASH +#endif // FLASH_EEPROM_EMULATION #endif // __STM32F1__ diff --git a/Marlin/src/HAL/STM32F1/persistent_store_sdcard.cpp b/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp similarity index 98% rename from Marlin/src/HAL/STM32F1/persistent_store_sdcard.cpp rename to Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp index 8b5d89ad83ec..7894e69787dd 100644 --- a/Marlin/src/HAL/STM32F1/persistent_store_sdcard.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp @@ -31,7 +31,7 @@ #if ENABLED(SDCARD_EEPROM_EMULATION) -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" #ifndef E2END #define E2END 0xFFF // 4KB @@ -101,5 +101,4 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin size_t PersistentStore::capacity() { return HAL_EEPROM_SIZE; } #endif // SDCARD_EEPROM_EMULATION - #endif // __STM32F1__ diff --git a/Marlin/src/HAL/STM32_F4_F7/persistent_store_eeprom.cpp b/Marlin/src/HAL/STM32_F4_F7/eeprom.cpp similarity index 98% rename from Marlin/src/HAL/STM32_F4_F7/persistent_store_eeprom.cpp rename to Marlin/src/HAL/STM32_F4_F7/eeprom.cpp index 2ffbc609ecf5..b957aae6a88f 100644 --- a/Marlin/src/HAL/STM32_F4_F7/persistent_store_eeprom.cpp +++ b/Marlin/src/HAL/STM32_F4_F7/eeprom.cpp @@ -27,7 +27,7 @@ #if ENABLED(EEPROM_SETTINGS) -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" bool PersistentStore::access_start() { return true; } bool PersistentStore::access_finish() { return true; } diff --git a/Marlin/src/HAL/STM32_F4_F7/inc/Conditionals_post.h b/Marlin/src/HAL/STM32_F4_F7/inc/Conditionals_post.h index 5a190342ac7c..d21624955ec4 100644 --- a/Marlin/src/HAL/STM32_F4_F7/inc/Conditionals_post.h +++ b/Marlin/src/HAL/STM32_F4_F7/inc/Conditionals_post.h @@ -22,7 +22,7 @@ #pragma once #if ENABLED(EEPROM_SETTINGS) && defined(STM32F7) - #undef USE_REAL_EEPROM + #undef USE_WIRED_EEPROM #undef SRAM_EEPROM_EMULATION #undef SDCARD_EEPROM_EMULATION #define FLASH_EEPROM_EMULATION diff --git a/Marlin/src/HAL/TEENSY31_32/persistent_store_impl.cpp b/Marlin/src/HAL/TEENSY31_32/eeprom_impl.cpp similarity index 97% rename from Marlin/src/HAL/TEENSY31_32/persistent_store_impl.cpp rename to Marlin/src/HAL/TEENSY31_32/eeprom_impl.cpp index 6a179cd962ea..96499d4f19d1 100644 --- a/Marlin/src/HAL/TEENSY31_32/persistent_store_impl.cpp +++ b/Marlin/src/HAL/TEENSY31_32/eeprom_impl.cpp @@ -22,7 +22,7 @@ #if ENABLED(EEPROM_SETTINGS) -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" bool PersistentStore::access_start() { return true; } bool PersistentStore::access_finish() { return true; } diff --git a/Marlin/src/HAL/TEENSY31_32/inc/Conditionals_post.h b/Marlin/src/HAL/TEENSY31_32/inc/Conditionals_post.h index e51b55698e49..11603c9ef41d 100644 --- a/Marlin/src/HAL/TEENSY31_32/inc/Conditionals_post.h +++ b/Marlin/src/HAL/TEENSY31_32/inc/Conditionals_post.h @@ -22,6 +22,6 @@ #pragma once // If no real EEPROM, Flash emulation, or SRAM emulation is available fall back to SD emulation -#if ENABLED(EEPROM_SETTINGS) && NONE(USE_REAL_EEPROM, FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION) +#if ENABLED(EEPROM_SETTINGS) && NONE(USE_WIRED_EEPROM, FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION) #define SDCARD_EEPROM_EMULATION #endif diff --git a/Marlin/src/HAL/TEENSY35_36/persistent_store_eeprom.cpp b/Marlin/src/HAL/TEENSY35_36/eeprom.cpp similarity index 98% rename from Marlin/src/HAL/TEENSY35_36/persistent_store_eeprom.cpp rename to Marlin/src/HAL/TEENSY35_36/eeprom.cpp index 32b215ee6e12..c66a45e2a54f 100644 --- a/Marlin/src/HAL/TEENSY35_36/persistent_store_eeprom.cpp +++ b/Marlin/src/HAL/TEENSY35_36/eeprom.cpp @@ -27,7 +27,7 @@ #if ENABLED(EEPROM_SETTINGS) -#include "../shared/persistent_store_api.h" +#include "../shared/eeprom_api.h" #include bool PersistentStore::access_start() { return true; } diff --git a/Marlin/src/HAL/shared/persistent_store_api.cpp b/Marlin/src/HAL/shared/eeprom_api.cpp similarity index 96% rename from Marlin/src/HAL/shared/persistent_store_api.cpp rename to Marlin/src/HAL/shared/eeprom_api.cpp index 735fa4278b7f..d8839e3d9d32 100644 --- a/Marlin/src/HAL/shared/persistent_store_api.cpp +++ b/Marlin/src/HAL/shared/eeprom_api.cpp @@ -24,7 +24,7 @@ #if EITHER(EEPROM_SETTINGS, SD_FIRMWARE_UPDATE) - #include "persistent_store_api.h" + #include "eeprom_api.h" PersistentStore persistentStore; #endif diff --git a/Marlin/src/HAL/shared/persistent_store_api.h b/Marlin/src/HAL/shared/eeprom_api.h similarity index 100% rename from Marlin/src/HAL/shared/persistent_store_api.h rename to Marlin/src/HAL/shared/eeprom_api.h diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 1ac036e5bc29..217d8945437f 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -27,7 +27,7 @@ #include "../bedlevel.h" #include "../../../MarlinCore.h" - #include "../../../HAL/shared/persistent_store_api.h" + #include "../../../HAL/shared/eeprom_api.h" #include "../../../libs/hex_print_routines.h" #include "../../../module/configuration_store.h" #include "../../../lcd/ultralcd.h" diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index ebc77b9383a7..d9db98646648 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -35,16 +35,19 @@ #define HAS_LINEAR_E_JERK 1 #endif -// If no real EEPROM, Flash emulation, or SRAM emulation is available fall back to SD emulation +// Determine which type of 'EEPROM' is in use #if ENABLED(EEPROM_SETTINGS) - #if NONE(FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SDCARD_EEPROM_EMULATION) && EITHER(I2C_EEPROM, SPI_EEPROM) - #define USE_REAL_EEPROM 1 + // EEPROM type may be defined by compile flags, configs, HALs, or pins + // Set additional flags to let HALs choose in their Conditionals_post.h + #if NONE(FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SDCARD_EEPROM_EMULATION) && ANY(I2C_EEPROM, SPI_EEPROM, QSPI_EEPROM) + #define USE_WIRED_EEPROM 1 #else - #define USE_EMULATED_EEPROM 1 + #define USE_FALLBACK_EEPROM 1 #endif #else #undef I2C_EEPROM #undef SPI_EEPROM + #undef QSPI_EEPROM #undef SDCARD_EEPROM_EMULATION #undef SRAM_EEPROM_EMULATION #undef FLASH_EEPROM_EMULATION diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_settings_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_settings_screen.cpp index 61875c52f1f3..3de03579e4b0 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_settings_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/interface_settings_screen.cpp @@ -252,7 +252,7 @@ void InterfaceSettingsScreen::loadSettings(const char *buff) { } #ifdef ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE - #include "../../../../../HAL/shared/persistent_store_api.h" + #include "../../../../../HAL/shared/eeprom_api.h" bool restoreEEPROM() { uint8_t data[ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE]; diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index 129e207d2948..d80fe501955e 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -57,7 +57,7 @@ #include "../MarlinCore.h" #if EITHER(EEPROM_SETTINGS, SD_FIRMWARE_UPDATE) - #include "../HAL/shared/persistent_store_api.h" + #include "../HAL/shared/eeprom_api.h" #endif #include "probe.h" diff --git a/Marlin/src/module/configuration_store.h b/Marlin/src/module/configuration_store.h index a2c8d97dfad1..f2e84c96649b 100644 --- a/Marlin/src/module/configuration_store.h +++ b/Marlin/src/module/configuration_store.h @@ -24,7 +24,7 @@ #include "../inc/MarlinConfig.h" #if ENABLED(EEPROM_SETTINGS) - #include "../HAL/shared/persistent_store_api.h" + #include "../HAL/shared/eeprom_api.h" #endif class MarlinSettings { diff --git a/Marlin/src/module/printcounter.cpp b/Marlin/src/module/printcounter.cpp index 4b4d4b60ad9f..3623c88a13de 100644 --- a/Marlin/src/module/printcounter.cpp +++ b/Marlin/src/module/printcounter.cpp @@ -35,7 +35,7 @@ Stopwatch print_job_timer; // Global Print Job Timer instance #include "printcounter.h" #include "../MarlinCore.h" -#include "../HAL/shared/persistent_store_api.h" +#include "../HAL/shared/eeprom_api.h" #if HAS_BUZZER && SERVICE_WARNING_BUZZES > 0 #include "../libs/buzzer.h" diff --git a/Marlin/src/module/printcounter.h b/Marlin/src/module/printcounter.h index 261cdf058b59..39a237cc4451 100644 --- a/Marlin/src/module/printcounter.h +++ b/Marlin/src/module/printcounter.h @@ -28,7 +28,7 @@ // Print debug messages with M111 S2 //#define DEBUG_PRINTCOUNTER -#if USE_REAL_EEPROM +#if USE_WIRED_EEPROM // round up address to next page boundary (assuming 32 byte pages) #define STATS_EEPROM_ADDRESS 0x40 #else @@ -57,7 +57,7 @@ class PrintCounter: public Stopwatch { private: typedef Stopwatch super; - #if USE_REAL_EEPROM || defined(CPU_32_BIT) + #if USE_WIRED_EEPROM || defined(CPU_32_BIT) typedef uint32_t eeprom_address_t; #else typedef uint16_t eeprom_address_t; diff --git a/Marlin/src/pins/samd/pins_RAMPS_144.h b/Marlin/src/pins/samd/pins_RAMPS_144.h index b7d5172e0d94..f02a8b86bd55 100644 --- a/Marlin/src/pins/samd/pins_RAMPS_144.h +++ b/Marlin/src/pins/samd/pins_RAMPS_144.h @@ -44,8 +44,9 @@ // // EEPROM // -#define E2END 0x7FFF // 32Kb (24lc256) +//#define QSPI_EEPROM // Use AGCM4 onboard QSPI EEPROM (Uses 4K of RAM) #define I2C_EEPROM // EEPROM on I2C-0 +#define E2END 0x7FFF // 32K (24lc256) // // Limit Switches diff --git a/platformio.ini b/platformio.ini index 2f3e86c31612..13808d299a3d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -792,6 +792,7 @@ build_unflags = -std=gnu++11 src_filter = ${common.default_src_filter} + lib_deps = ${common.lib_deps} SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip + Adafruit_SPIFlash=https://github.com/adafruit/Adafruit_SPIFlash/archive/master.zip debug_tool = jlink # From bed41af868f352bc0ca72b0b6936a97420c64ecf Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Fri, 27 Mar 2020 18:30:17 -0400 Subject: [PATCH 4/5] Fix Stepper PWM menu (#17298) --- Marlin/src/lcd/menu/menu_advanced.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 1577e59fc117..f2327b75e5e4 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -84,7 +84,7 @@ void menu_cancelobject(); START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); #define EDIT_CURRENT_PWM(LABEL,I) EDIT_ITEM_P(long5, PSTR(LABEL), &stepper.motor_current_setting[I], 100, 2000, stepper.refresh_motor_power) - #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) + #if ANY_PIN(MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y) EDIT_CURRENT_PWM(STR_X STR_Y, 0); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) From 8752fbd92c8edcd777b6a2afe54f4d70d3fc4d85 Mon Sep 17 00:00:00 2001 From: Mathias Rasmussen Date: Fri, 27 Mar 2020 23:38:28 +0100 Subject: [PATCH 5/5] Store case light brightness in EEPROM (#17307) --- Marlin/src/module/configuration_store.cpp | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index d80fe501955e..2ecc9299c9b3 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -127,6 +127,11 @@ void M710_report(const bool forReplay); #endif +#define HAS_CASE_LIGHT_BRIGHTNESS (ENABLED(CASE_LIGHT_MENU) && DISABLED(CASE_LIGHT_NO_BRIGHTNESS)) +#if HAS_CASE_LIGHT_BRIGHTNESS + #include "../feature/caselight.h" +#endif + #pragma pack(push, 1) // No padding between variables typedef struct { uint16_t X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5; } tmc_stepper_current_t; @@ -376,6 +381,13 @@ typedef struct SettingsDataStruct { uint8_t extui_data[ExtUI::eeprom_data_size]; #endif + // + // HAS_CASE_LIGHT_BRIGHTNESS + // + #if HAS_CASE_LIGHT_BRIGHTNESS + uint8_t case_light_brightness; + #endif + } SettingsData; //static_assert(sizeof(SettingsData) <= E2END + 1, "EEPROM too small to contain SettingsData!"); @@ -441,6 +453,10 @@ void MarlinSettings::postprocess() { planner.recalculate_max_e_jerk(); #endif + #if HAS_CASE_LIGHT_BRIGHTNESS + update_case_light(); + #endif + // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm // and init stepper.count[], planner.position[] with current_position planner.refresh_positioning(); @@ -1309,6 +1325,13 @@ void MarlinSettings::postprocess() { } #endif + // + // Case Light Brightness + // + #if HAS_CASE_LIGHT_BRIGHTNESS + EEPROM_WRITE(case_light_brightness); + #endif + // // Validate CRC and Data Size // @@ -2163,6 +2186,14 @@ void MarlinSettings::postprocess() { } #endif + // + // Case Light Brightness + // + #if HAS_CASE_LIGHT_BRIGHTNESS + _FIELD_TEST(case_light_brightness); + EEPROM_READ(case_light_brightness); + #endif + eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET)); if (eeprom_error) { DEBUG_ECHO_START(); @@ -2458,6 +2489,14 @@ void MarlinSettings::reset() { ExtUI::onFactoryReset(); #endif + // + // Case Light Brightness + // + + #if HAS_CASE_LIGHT_BRIGHTNESS + case_light_brightness = CASE_LIGHT_DEFAULT_BRIGHTNESS; + #endif + // // Magnetic Parking Extruder //