Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Esp32 Improvement #16228

Merged
merged 4 commits into from
Dec 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Marlin/src/HAL/HAL_ESP32/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "../../inc/MarlinConfigPre.h"

#if EITHER(EEPROM_SETTINGS, WEBSUPPORT)
#if ENABLED(WEBSUPPORT)
#include "spiffs.h"
#endif

Expand Down Expand Up @@ -83,7 +83,7 @@ void HAL_init() {
}

void HAL_init_board() {
#if EITHER(EEPROM_SETTINGS, WEBSUPPORT)
#if ENABLED(WEBSUPPORT)
spiffs_init();
#endif

Expand Down
63 changes: 63 additions & 0 deletions Marlin/src/HAL/HAL_ESP32/persistent_store_impl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2019 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 <http://www.gnu.org/licenses/>.
*
*/

#ifdef ARDUINO_ARCH_ESP32

#include "../../inc/MarlinConfig.h"

#if ENABLED(EEPROM_SETTINGS) && DISABLED(FLASH_EEPROM_EMULATION)

#include "../shared/persistent_store_api.h"
#include "EEPROM.h"

#define EEPROM_SIZE 4096

bool PersistentStore::access_start() {
return EEPROM.begin(EEPROM_SIZE);
}

bool PersistentStore::access_finish() {
EEPROM.end();
return true;
}

bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
for (size_t i = 0; i < size; i++) {
EEPROM.write(pos++, value[i]);
crc16(crc, &value[i], 1);
}
return false;
}

bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
for (size_t i = 0; i < size; i++) {
uint8_t c = EEPROM.read(pos++);
if (writing) value[i] = c;
crc16(crc, &c, 1);
}
return false;
}

size_t PersistentStore::capacity() { return EEPROM_SIZE; }

#endif // EEPROM_SETTINGS
#endif // ARDUINO_ARCH_ESP32
106 changes: 0 additions & 106 deletions Marlin/src/HAL/HAL_ESP32/persistent_store_spiffs.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion Marlin/src/HAL/HAL_ESP32/spiffs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "../../inc/MarlinConfigPre.h"

#if EITHER(WEBSUPPORT, EEPROM_SETTINGS)
#if ENABLED(WEBSUPPORT)

#include "../../core/serial.h"

Expand Down
12 changes: 11 additions & 1 deletion Marlin/src/HAL/HAL_ESP32/watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,18 @@
*/
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

esp_err_t esp_task_wdt_reset();

#ifdef __cplusplus
}
#endif

// Initialize watchdog with a 4 second interrupt time
void watchdog_init();

// Reset watchdog.
inline void HAL_watchdog_refresh() {}
inline void HAL_watchdog_refresh() { esp_task_wdt_reset(); }
8 changes: 5 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -694,14 +694,16 @@ monitor_speed = 250000
[env:esp32]
platform = espressif32
board = esp32dev
upload_speed = 115200
monitor_speed = 115200
upload_port = /dev/ttyUSB0
build_flags = ${common.build_flags} -DCORE_DEBUG_LEVEL=0
lib_deps =
AsyncTCP=https://github.com/me-no-dev/AsyncTCP/archive/master.zip
ESPAsyncWebServer=https://github.com/me-no-dev/ESPAsyncWebServer/archive/master.zip
lib_ignore = LiquidCrystal, LiquidTWI2, SailfishLCD, SailfishRGB_LED
src_filter = ${common.default_src_filter} +<src/HAL/HAL_ESP32>
upload_speed = 115200
monitor_speed = 250000
#upload_port = marlinesp.local
#board_build.flash_mode = qio

#
# Native
Expand Down