This example demonstrates how to get the target info including the flash chip size and the WIFI MAC address of an Espressif SoC from another (host) MCU using esp-serial-flasher
. In this case, an ESP32 is used as the host MCU.
The following steps are performed:
esp_loader_connect()
.Note: In addition, to steps mentioned above, esp_loader_change_transmission_rate()
is called after connection is established in order to increase communication speed. This does not apply for the ESP8266, as its bootloader does not support this command. However, the ESP8266 is capable of detecting the baud rate during connection phase, and can be changed before calling esp_loader_connect()
, if necessary.
In the majority of cases ESP_LOADER_CONNECT_DEFAULT
helper macro is used in order to initialize loader_connect_args_t
data structure passed to esp_loader_connect()
. Helper macro sets the maximum time to wait for a response and the number of retrials. For more detailed information refer to serial protocol.
Table below shows connection between two ESP32 devices.
ESP32 (host) | ESP32 (target) |
---|---|
IO26 | IO0 |
IO25 | RESET |
IO4 | RX0 |
IO5 | TX0 |
Note: interconnection is the same for ESP32, ESP32-S2 and ESP8266 targets.
To run the example, type the following command:
CMake
idf.py -p PORT flash monitor
(To exit the serial monitor, type Ctrl-]
.)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
Here is the example's console output:
Plaintext
...
Connected to target
Transmission rate changed.
I (1341) serial_flasher: Target flash size [B]: 8388608
I (1341) serial_flasher: Target WIFI MAC:
I (1341) serial_flasher: e4 65 b8 7e 13 60
I (1341) main_task: Returned from app_main()
To create a project from this example, run:
idf.py create-project-from-example "espressif/esp-serial-flasher=1.5.0:esp32_get_target_info_example"