main.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: CC0-1.0
  5. */
  6. #include <stdio.h>
  7. #include "freertos/FreeRTOS.h"
  8. #include "freertos/task.h"
  9. #include "esp_chip_info.h"
  10. #include "esp_system.h"
  11. #include "esp_flash.h"
  12. void app_main(void)
  13. {
  14. printf("Hello world!\n");
  15. /* Print chip information */
  16. esp_chip_info_t chip_info;
  17. uint32_t flash_size;
  18. esp_chip_info(&chip_info);
  19. printf("This is ESP32 chip with %d CPU cores, WiFi%s%s, ",
  20. chip_info.cores,
  21. (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
  22. (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
  23. unsigned major_rev = chip_info.revision / 100;
  24. unsigned minor_rev = chip_info.revision % 100;
  25. printf("silicon revision v%d.%d, ", major_rev, minor_rev);
  26. if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) {
  27. printf("Get flash size failed");
  28. return;
  29. }
  30. printf("%dMB %s flash\n", flash_size / (1024 * 1024),
  31. (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
  32. for (int i = 10; i >= 0; i--) {
  33. printf("Restarting in %d seconds...\n", i);
  34. vTaskDelay(1000 / portTICK_PERIOD_MS);
  35. }
  36. printf("Restarting now.\n");
  37. fflush(stdout);
  38. esp_restart();
  39. }