62 char *buf = buffer.data();
63 const size_t size = RESET_REASON_BUFFER_SIZE;
65 unsigned reason = esp_reset_reason();
66 if (reason <
sizeof(RESET_REASONS) /
sizeof(RESET_REASONS[0])) {
67 if (reason == ESP_RST_SW) {
69 char reboot_source[REBOOT_MAX_LEN]{};
70 if (pref.load(&reboot_source)) {
71 reboot_source[REBOOT_MAX_LEN - 1] =
'\0';
72 snprintf(buf,
size,
"Reboot request from %s", reboot_source);
74 snprintf(buf,
size,
"%s", RESET_REASONS[reason]);
77 snprintf(buf,
size,
"%s", RESET_REASONS[reason]);
80 snprintf(buf,
size,
"unknown source");
116 " %-12s %-4s %-8s %-10s %-10s",
117 "Name",
"Type",
"Subtype",
"Address",
"Size");
118 esp_partition_iterator_t it = esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL);
120 const esp_partition_t *partition = esp_partition_get(it);
121 ESP_LOGCONFIG(TAG,
" %-12s %-4d %-8d 0x%08" PRIX32
" 0x%08" PRIX32, partition->label, partition->type,
122 partition->subtype, partition->address, partition->size);
123 it = esp_partition_next(it);
125 esp_partition_iterator_release(it);
144 constexpr size_t size = DEVICE_INFO_BUFFER_SIZE;
145 char *buf = buffer.data();
147#if defined(USE_ARDUINO)
148 const char *flash_mode;
149 switch (ESP.getFlashChipMode()) {
163 flash_mode =
"FAST_READ";
166 flash_mode =
"SLOW_READ";
169 flash_mode =
"UNKNOWN";
171 uint32_t flash_size = ESP.getFlashChipSize() / 1024;
172 uint32_t flash_speed = ESP.getFlashChipSpeed() / 1000000;
173 pos = buf_append_printf(buf,
size,
pos,
"|Flash: %" PRIu32
"kB Speed:%" PRIu32
"MHz Mode:%s", flash_size, flash_speed,
177 esp_chip_info_t info;
178 esp_chip_info(&info);
179 const char *model = ESPHOME_VARIANT;
182 pos = buf_append_printf(buf,
size,
pos,
"|Chip: %s Features:", model);
183 bool first_feature =
true;
184 for (
const auto &feature : CHIP_FEATURES) {
185 if (info.features & feature.bit) {
186 pos = buf_append_printf(buf,
size,
pos,
"%s%s", first_feature ?
"" :
", ", feature.name);
187 first_feature =
false;
188 info.features &= ~feature.bit;
191 if (info.features != 0) {
192 pos = buf_append_printf(buf,
size,
pos,
"%sOther:0x%" PRIx32, first_feature ?
"" :
", ", info.features);
194 pos = buf_append_printf(buf,
size,
pos,
" Cores:%u Revision:%u", info.cores, info.revision);
197 pos = buf_append_printf(buf,
size,
pos,
"|CPU Frequency: %" PRIu32
" MHz", cpu_freq_mhz);
199 char reason_buffer[RESET_REASON_BUFFER_SIZE];
200 const char *reset_reason =
get_reset_reason_(std::span<char, RESET_REASON_BUFFER_SIZE>(reason_buffer));
201 const char *wakeup_cause =
get_wakeup_cause_(std::span<char, RESET_REASON_BUFFER_SIZE>(reason_buffer));
207 "ESP32 debug info:\n"
211 " CPU Frequency: %" PRIu32
" MHz\n"
212 " ESP-IDF Version: %s\n"
213 " EFuse MAC: %02X:%02X:%02X:%02X:%02X:%02X\n"
214 " Reset Reason: %s\n"
216 model, info.cores, info.revision, cpu_freq_mhz, esp_get_idf_version(), mac[0], mac[1], mac[2], mac[3],
217 mac[4], mac[5], reset_reason, wakeup_cause);
218#if defined(USE_ARDUINO)
219 ESP_LOGD(TAG,
" Flash: Size=%" PRIu32
"kB Speed=%" PRIu32
"MHz Mode=%s", flash_size, flash_speed, flash_mode);
223 ESP_LOGD(TAG,
" Framework: Arduino");
224 pos = buf_append_printf(buf,
size,
pos,
"|Framework: Arduino");
226 ESP_LOGD(TAG,
" Framework: ESP-IDF");
227 pos = buf_append_printf(buf,
size,
pos,
"|Framework: ESP-IDF");
230 pos = buf_append_printf(buf,
size,
pos,
"|ESP-IDF: %s", esp_get_idf_version());
231 pos = buf_append_printf(buf,
size,
pos,
"|EFuse MAC: %02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3],
233 pos = buf_append_printf(buf,
size,
pos,
"|Reset: %s", reset_reason);
234 pos = buf_append_printf(buf,
size,
pos,
"|Wakeup: %s", wakeup_cause);