mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
Fix ESP8266 preferences not set up (#2362)
This commit is contained in:
parent
637b55bfbf
commit
bbac1534a3
2 changed files with 27 additions and 2 deletions
|
@ -10,11 +10,11 @@ from esphome.const import (
|
|||
KEY_TARGET_FRAMEWORK,
|
||||
KEY_TARGET_PLATFORM,
|
||||
)
|
||||
from esphome.core import CORE
|
||||
from esphome.core import CORE, coroutine_with_priority
|
||||
import esphome.config_validation as cv
|
||||
import esphome.codegen as cg
|
||||
|
||||
from .const import CONF_RESTORE_FROM_FLASH, KEY_BOARD, KEY_ESP8266
|
||||
from .const import CONF_RESTORE_FROM_FLASH, KEY_BOARD, KEY_ESP8266, esp8266_ns
|
||||
from .boards import ESP8266_FLASH_SIZES, ESP8266_LD_SCRIPTS
|
||||
|
||||
# force import gpio to register pin schema
|
||||
|
@ -153,7 +153,10 @@ CONFIG_SCHEMA = cv.All(
|
|||
)
|
||||
|
||||
|
||||
@coroutine_with_priority(1000)
|
||||
async def to_code(config):
|
||||
cg.add(esp8266_ns.setup_preferences())
|
||||
|
||||
cg.add_platformio_option("board", config[CONF_BOARD])
|
||||
cg.add_build_flag("-DUSE_ESP8266")
|
||||
cg.add_define("ESPHOME_BOARD", config[CONF_BOARD])
|
||||
|
|
|
@ -32,6 +32,28 @@ uint32_t arch_get_cpu_cycle_count() {
|
|||
}
|
||||
uint32_t arch_get_cpu_freq_hz() { return F_CPU; }
|
||||
|
||||
void force_link_symbols() {
|
||||
// Tasmota uses magic bytes in the binary to check if an OTA firmware is compatible
|
||||
// with their settings - ESPHome uses a different settings system (that can also survive
|
||||
// erases). So set magic bytes indicating all tasmota versions are supported.
|
||||
// This only adds 12 bytes of binary size, which is an acceptable price to pay for easier support
|
||||
// for Tasmota.
|
||||
// https://github.com/arendst/Tasmota/blob/b05301b1497942167a015a6113b7f424e42942cd/tasmota/settings.ino#L346-L380
|
||||
// https://github.com/arendst/Tasmota/blob/b05301b1497942167a015a6113b7f424e42942cd/tasmota/i18n.h#L652-L654
|
||||
const static uint32_t TASMOTA_MAGIC_BYTES[] PROGMEM = {0x5AA55AA5, 0xFFFFFFFF, 0xA55AA55A};
|
||||
// Force link symbol by using a volatile integer (GCC attribute used does not work because of LTO)
|
||||
volatile int x = 0;
|
||||
x = TASMOTA_MAGIC_BYTES[x];
|
||||
}
|
||||
|
||||
extern "C" void resetPins() { // NOLINT
|
||||
// Added in framework 2.7.0
|
||||
// usually this sets up all pins to be in INPUT mode
|
||||
// however, not strictly needed as we set up the pins properly
|
||||
// ourselves and this causes pins to toggle during reboot.
|
||||
force_link_symbols();
|
||||
}
|
||||
|
||||
} // namespace esphome
|
||||
|
||||
#endif // USE_ESP8266
|
||||
|
|
Loading…
Reference in a new issue