ESPHome
2026.5.3
Loading...
Searching...
No Matches
esphome
components
esp8266
core.cpp
Go to the documentation of this file.
1
#ifdef USE_ESP8266
2
3
#include "
core.h
"
4
#include "
esphome/core/defines.h
"
5
#include "
esphome/core/hal.h
"
6
#include <Arduino.h>
7
8
namespace
esphome
{
9
10
// HAL functions live in hal.cpp. This file keeps only the ESP8266-specific
11
// firmware bootstrap (Tasmota OTA magic bytes, optional GPIO pre-init).
12
13
void
force_link_symbols
() {
14
// Tasmota uses magic bytes in the binary to check if an OTA firmware is compatible
15
// with their settings - ESPHome uses a different settings system (that can also survive
16
// erases). So set magic bytes indicating all tasmota versions are supported.
17
// This only adds 12 bytes of binary size, which is an acceptable price to pay for easier support
18
// for Tasmota.
19
// https://github.com/arendst/Tasmota/blob/b05301b1497942167a015a6113b7f424e42942cd/tasmota/settings.ino#L346-L380
20
// https://github.com/arendst/Tasmota/blob/b05301b1497942167a015a6113b7f424e42942cd/tasmota/i18n.h#L652-L654
21
const
static
uint32_t
TASMOTA_MAGIC_BYTES[]
PROGMEM
= {0x5AA55AA5, 0xFFFFFFFF, 0xA55AA55A};
22
// Force link symbol by using a volatile integer (GCC attribute used does not work because of LTO)
23
volatile
int
x
= 0;
24
x
= TASMOTA_MAGIC_BYTES[
x
];
25
}
26
27
extern
"C"
void
resetPins
() {
// NOLINT
28
// Added in framework 2.7.0
29
// usually this sets up all pins to be in INPUT mode
30
// however, not strictly needed as we set up the pins properly
31
// ourselves and this causes pins to toggle during reboot.
32
force_link_symbols
();
33
34
#ifdef USE_ESP8266_EARLY_PIN_INIT
35
for
(
int
i = 0; i < 16; i++) {
36
uint8_t
mode
=
progmem_read_byte
(&
ESPHOME_ESP8266_GPIO_INITIAL_MODE
[i]);
37
uint8_t level =
progmem_read_byte
(&
ESPHOME_ESP8266_GPIO_INITIAL_LEVEL
[i]);
38
if
(
mode
!= 255)
39
pinMode(i,
mode
);
// NOLINT
40
if
(level != 255)
41
digitalWrite(i, level);
// NOLINT
42
}
43
#endif
44
}
45
46
}
// namespace esphome
47
48
#endif
// USE_ESP8266
mode
BedjetMode mode
BedJet operating mode.
Definition
bedjet_codec.h:19
hal.h
defines.h
core.h
ESPHOME_ESP8266_GPIO_INITIAL_LEVEL
const uint8_t ESPHOME_ESP8266_GPIO_INITIAL_LEVEL[16]
ESPHOME_ESP8266_GPIO_INITIAL_MODE
const uint8_t ESPHOME_ESP8266_GPIO_INITIAL_MODE[16]
esphome
Definition
a01nyub.cpp:7
esphome::resetPins
void resetPins()
Definition
core.cpp:27
esphome::force_link_symbols
void force_link_symbols()
Definition
core.cpp:13
esphome::progmem_read_byte
uint8_t progmem_read_byte(const uint8_t *addr)
Definition
hal.h:42
uint32_t
static void uint32_t
Definition
crash_handler.cpp:141
x
uint16_t x
Definition
tt21100.cpp:5
PROGMEM
const uint8_t ESPHOME_WEBSERVER_INDEX_HTML[] PROGMEM
Definition
web_server.h:28
Generated by
1.12.0