1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

cpu/esp32: module to print startup info

Startup information, including board configuration, is only printed when module esp_log_startup is used. This reduces the amount of information that is printed by default to the console during the startup. The user can enable module esp_log_startup to get the additional startup information.
This commit is contained in:
Gunar Schorcht 2019-11-26 08:36:30 +01:00
parent 575cf05112
commit 8d25e6909e
4 changed files with 46 additions and 22 deletions

View File

@ -115,6 +115,7 @@ Module | Default | Short description
[esp_i2c_hw](#esp32_i2c_interfaces) | not used | use the i2C hardware implementation
[esp_idf_heap](#esp32_esp_idf_heap_implementation) | not used | enable ESP-IDF heap implementation
[esp_log_colored](#esp32_esp_log_module) | not used | enable colored log output
[esp_log_startup](#esp32_esp_log_module) | not used | enable additional startup information
[esp_log_tagged](#esp32_esp_log_module) | not used | add additional information to the log output
[esp_now](#esp32_esp_now_network_interface) | not used | enable the ESP-NOW network device
[esp_spi_ram](#esp32_spi_ram) | not used | enable SPI RAM
@ -412,6 +413,7 @@ esp_gdb | Enable the compilation with debug information for debugging with [QEMU
esp_i2c_hw | Use the hardware I2C implementation, see section [I2C Interfaces](#esp32_i2c_interfaces).
esp_idf_heap | Use the ESP-IDF heap implementation, see section [ESP-IDF Heap Implementation](#esp32_esp_idf_heap_implementation).
esp_log_colored | Enable colored log output, see section [Log output](#esp32_esp_log_module).
esp_log_startup | Enable additional startup information, see section [Log output](#esp32_esp_log_module).
esp_log_tagged | Add additional information to the log output, see section [Log output](#esp32_esp_log_module).
esp_now | Enable the built-in WiFi module with the ESP-NOW protocol as `netdev` network device, see section [ESP-NOW Network Interface](#esp32_esp_now_network_interface).
esp_spiffs | Enable the optional SPIFFS drive in on-board flash memory, see section [SPIFFS Device](#esp32_spiffs_device).
@ -475,6 +477,12 @@ LOG_TAG_ERROR("mod", "error message");
```
a log message with string `mod` in the tag is generated.
The `esp_log_startup` module can be used to enable additional information
about the boot process, the board configuration, the system configuration,
the CPU used by the system, and the available heap. These information may
help to detect problems during the startup. If the application does not
start as expected, this module should be used.
## <a name="esp32_esp_idf_heap_implementation"> ESP-IDF Heap Implementation </a> &nbsp;[[TOC](#esp32_toc)]
ESP-IDF SDK provides a complex heap implementation that supports multiple heap segments in different memory areas such as DRAM, IRAM, and PSRAM. Whenever you want to use these memory areas as heap, you have to use the heap implementation from the ESP-IDF SDK. ESP-IDF heap is not used by default. To use it, it has to be enabled by the the makefile of the application:

View File

@ -954,7 +954,7 @@ void can_init(can_t *dev, const can_conf_t *conf)
void can_print_config(void)
{
ets_printf("\tCAN_DEV(0)\ttxd=%d rxd=%d\n", CAN_TX, CAN_RX);
printf("\tCAN_DEV(0)\ttxd=%d rxd=%d\n", CAN_TX, CAN_RX);
}
/**@}*/

View File

@ -110,11 +110,11 @@ void spi_flash_drive_init (void)
*/
#if SPI_FLASH_DRIVE_START
if (part_top > SPI_FLASH_DRIVE_START) {
LOG_TAG_ERROR("spi_flash", "configured MTD start address in SPI Flash is to less\n");
LOG_ERROR("configured MTD start address in SPI Flash is to less\n");
}
else if (SPI_FLASH_DRIVE_START % _flashchip->sector_size) {
LOG_TAG_ERROR("spi_flash", "configured start address has to be a "
"multiple of %d byte\n", _flashchip->sector_size);
LOG_ERROR("configured start address has to be a "
"multiple of %d byte\n", _flashchip->sector_size);
part_top = ((SPI_FLASH_DRIVE_START +
_flashchip->sector_size)) & ~(_flashchip->sector_size-1);
}
@ -123,8 +123,7 @@ void spi_flash_drive_init (void)
}
#endif
LOG_TAG_INFO("spi_flash",
"MTD in SPI flash starts at address 0x%08x\n", part_top);
LOG_DEBUG("MTD in SPI flash starts at address 0x%08x\n", part_top);
/* second, change flash parameters according to partition table */
_flash_beg = part_top;

View File

@ -70,6 +70,12 @@
#define STRINGIFY(s) STRINGIFY2(s)
#define STRINGIFY2(s) #s
#if MODULE_ESP_LOG_STARTUP
#define LOG_STARTUP(format, ...) LOG_TAG_EARLY(LOG_DEBUG, D, __func__, format, ##__VA_ARGS__)
#else
#define LOG_STARTUP(format, ...)
#endif
/* following variables are defined in linker script */
extern uint8_t _bss_start;
extern uint8_t _bss_end;
@ -137,12 +143,16 @@ NORETURN void IRAM call_start_cpu0 (void)
uint8_t cpu_id[CPUID_LEN];
cpuid_get ((void*)cpu_id);
ets_printf("\nStarting ESP32 with ID: ");
#ifdef MODULE_ESP_LOG_STARTUP
ets_printf("\n");
LOG_STARTUP("Starting ESP32 with ID: ");
for (unsigned i = 0; i < CPUID_LEN; i++) {
ets_printf("%02x", cpu_id[i]);
}
ets_printf("\n");
#endif
ets_printf("\n\nCurrent clocks in Hz: CPU=%d APB=%d XTAL=%d SLOW=%d\n",
LOG_STARTUP("Current clocks in Hz: CPU=%d APB=%d XTAL=%d SLOW=%d\n",
rtc_clk_cpu_freq_value(rtc_clk_cpu_freq_get()),
rtc_clk_apb_freq_get(), rtc_clk_xtal_freq_get()*MHZ,
rtc_clk_slow_freq_get_hz());
@ -159,10 +169,9 @@ NORETURN void IRAM call_start_cpu0 (void)
#endif /* MODULE_ESP_IDF_HEAP */
#endif /* ENABLE_DEBUG */
ets_printf("PRO cpu is up ");
LOG_STARTUP("PRO cpu is up (single core mode, only PRO cpu is used)\n");
/* disable APP cpu */
ets_printf("(single core mode, only PRO cpu is used)\n");
DPORT_CLEAR_PERI_REG_MASK(DPORT_APPCPU_CTRL_B_REG, DPORT_APPCPU_CLKGATE_EN);
#ifdef MODULE_ESP_IDF_HEAP
@ -178,7 +187,7 @@ NORETURN void IRAM call_start_cpu0 (void)
spi_ram_init();
#endif
ets_printf("PRO cpu starts user code\n");
LOG_STARTUP("PRO cpu starts user code\n");
system_init();
UNREACHABLE();
@ -208,7 +217,7 @@ static void IRAM system_clk_init (void)
/* set SLOW_CLK to internal low power clock of 150 kHz */
rtc_select_slow_clk(RTC_SLOW_FREQ_RTC);
ets_printf("Switching system clocks can lead to some unreadable characters\n");
LOG_STARTUP("Switching system clocks can lead to some unreadable characters\n");
/* wait until UART is idle to avoid losing output */
uart_tx_wait_idle(CONFIG_CONSOLE_UART_NUM);
@ -300,18 +309,19 @@ static NORETURN void IRAM system_init (void)
#endif
/* print some infos */
ets_printf("Used clocks in Hz: CPU=%d APB=%d XTAL=%d FAST=%d SLOW=%d\n",
rtc_clk_cpu_freq_value(rtc_clk_cpu_freq_get()),
rtc_clk_apb_freq_get(), rtc_clk_xtal_freq_get()*MHZ,
RTC_FAST_FREQ_8M_MHZ, rtc_clk_slow_freq_get_hz());
ets_printf("XTAL calibration value: %d\n", esp_clk_slowclk_cal_get());
ets_printf("Heap free: %u bytes\n", get_free_heap_size());
LOG_STARTUP("Used clocks in Hz: CPU=%d APB=%d XTAL=%d FAST=%d SLOW=%d\n",
rtc_clk_cpu_freq_value(rtc_clk_cpu_freq_get()),
rtc_clk_apb_freq_get(), rtc_clk_xtal_freq_get()*MHZ,
RTC_FAST_FREQ_8M_MHZ, rtc_clk_slow_freq_get_hz());
LOG_STARTUP("XTAL calibration value: %d\n", esp_clk_slowclk_cal_get());
LOG_STARTUP("Heap free: %u bytes\n", get_free_heap_size());
struct tm _sys_time;
rtc_get_time(&_sys_time);
ets_printf("System time: %04d-%02d-%02d %02d:%02d:%02d\n",
_sys_time.tm_year + 1900, _sys_time.tm_mon + 1, _sys_time.tm_mday,
_sys_time.tm_hour, _sys_time.tm_min, _sys_time.tm_sec);
LOG_STARTUP("System time: %04d-%02d-%02d %02d:%02d:%02d\n",
_sys_time.tm_year + 1900, _sys_time.tm_mon + 1, _sys_time.tm_mday,
_sys_time.tm_hour, _sys_time.tm_min, _sys_time.tm_sec);
uart_tx_wait_idle(CONFIG_CONSOLE_UART_NUM);
/* initialize the board */
board_init();
@ -323,7 +333,9 @@ static NORETURN void IRAM system_init (void)
periph_init();
/* print the board config */
#ifdef MODULE_ESP_LOG_STARTUP
print_board_config();
#endif
#if MODULE_MTD
/* init flash drive */
@ -342,7 +354,12 @@ static NORETURN void IRAM system_init (void)
esp_event_handler_init();
/* starting RIOT */
printf("Starting RIOT kernel on PRO cpu\n");
#ifdef MODULE_ESP_LOG_STARTUP
LOG_STARTUP("Starting RIOT kernel on PRO cpu\n");
uart_tx_wait_idle(CONFIG_CONSOLE_UART_NUM);
#else
puts("");
#endif
kernel_init();
UNREACHABLE();
}