+ ESP_ERROR_CHECK(err);
+}
+
+static void initialize_console() {
+ /* Disable buffering on stdin */
+ setvbuf(stdin, NULL, _IONBF, 0);
+
+ /* Minicom, screen, idf_monitor send CR when ENTER key is pressed */
+ esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR);
+ /* Move the caret to the beginning of the next line on '\n' */
+ esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);
+
+ /* Configure UART. Note that REF_TICK is used so that the baud rate remains
+ * correct while APB frequency is changing in light sleep mode.
+ */
+ uart_config_t uart_config = {
+ .baud_rate = CONFIG_ESP_CONSOLE_UART_BAUDRATE,
+ .data_bits = UART_DATA_8_BITS,
+ .parity = UART_PARITY_DISABLE,
+ .stop_bits = UART_STOP_BITS_1,
+ };
+ ESP_ERROR_CHECK(uart_param_config(CONFIG_ESP_CONSOLE_UART_NUM, &uart_config));
+
+ /* Install UART driver for interrupt-driven reads and writes */
+ ESP_ERROR_CHECK(uart_driver_install(CONFIG_ESP_CONSOLE_UART_NUM,
+ 256, 0, 0, NULL, 0));
+
+ /* Tell VFS to use UART driver */
+ esp_vfs_dev_uart_use_driver(CONFIG_ESP_CONSOLE_UART_NUM);
+
+ /* Initialize the console */
+ esp_console_config_t console_config = {
+ .max_cmdline_args = 8,
+ .max_cmdline_length = 256,
+#if CONFIG_LOG_COLORS
+ .hint_color = atoi(LOG_COLOR_CYAN)
+#endif
+ };
+ ESP_ERROR_CHECK(esp_console_init(&console_config));
+}
+
+
+void app_main(void) {
+ /* Print chip information */
+ esp_chip_info_t chip_info;
+ esp_chip_info(&chip_info);
+ printf("This is ESP8266 chip with %d CPU cores, WiFi, ",
+ chip_info.cores);
+
+ printf("silicon revision %d, ", chip_info.revision);
+
+ printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024),
+ (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
+
+ initialize_nvs();
+ initialize_console();
+
+ esp_console_register_help_command();