### Install Tools for Multiple Targets Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/get-started/linux-macos-setup-legacy.html If developing for multiple chip targets, list them all and run the install script. This example shows installation for ESP32 and ESP32-S2. ```bash cd ~/esp/esp-idf ./install.sh esp32,esp32s2 ``` -------------------------------- ### Copy ESP-IDF Example Project Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/get-started/linux-macos-start-project.html Copy the 'hello_world' example project from the ESP-IDF installation to your working directory. Ensure no spaces exist in the ESP-IDF or project paths. ```bash cd ~/ esp cp -r $IDF_PATH/examples/get-started/hello_world . ``` -------------------------------- ### Navigate to ESP-IDF Example Directory Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/ble/get-started/ble-connection.html Change directory to the NimBLE_Connection example within your ESP-IDF installation. ```bash cd /examples/bluetooth/ble_get_started/nimble/NimBLE_Connection ``` -------------------------------- ### OpenOCD Version Output Example Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/jtag-debugging/index.html Example output confirming a successful OpenOCD installation and its version details. ```text Open On-Chip Debugger v0.12.0-esp32-20240318 (2024-03-18-18:25) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html ``` -------------------------------- ### Run ULP LP Core Program with Configuration Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/system/ulp-lp-core.html Configure and start the ULP LP Core program. This example uses the LP timer to wake up the core periodically. ```c ulp_lp_core_cfg_t cfg = { .wakeup_source = ULP_LP_CORE_WAKEUP_SOURCE_LP_TIMER, // LP core will be woken up periodically by LP timer .lp_timer_sleep_duration_us = 10000, }; ESP_ERROR_CHECK( ulp_lp_core_run(&cfg) ); ``` -------------------------------- ### Copy 'hello_world' Example Project (Windows) Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/get-started/windows-start-project.html Copies the 'hello_world' example project from the ESP-IDF examples directory to a specified user directory on Windows. ```batch cd %userprofile%\esp xcopy /e /i %IDF_PATH%\examples\get-started\hello_world hello_world ``` -------------------------------- ### Install and Use RMT Sync Manager Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/peripherals/rmt.html Demonstrates the installation of RMT TX channels, the creation of a sync manager, and initiating simultaneous transmissions on multiple channels. Ensure RMT channels are enabled and configured before creating the sync manager. The transmission on one channel will not start until `rmt_transmit()` is called on all managed channels. ```c rmt_channel_handle_t tx_channels[2] = {NULL}; // declare two channels int tx_gpio_number[2] = {0, 2}; // install channels one by one for (int i = 0; i < 2; i++) { rmt_tx_channel_config_t tx_chan_config = { .clk_src = RMT_CLK_SRC_DEFAULT, // select source clock .gpio_num = tx_gpio_number[i], // GPIO number .mem_block_symbols = 64, // memory block size, 64 * 4 = 256 Bytes .resolution_hz = 1 * 1000 * 1000, // 1 MHz resolution .trans_queue_depth = 1, // set the number of transactions that can pend in the background }; ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config, &tx_channels[i])); } // enable the channels for (int i = 0; i < 2; i++) { ESP_ERROR_CHECK(rmt_enable(tx_channels[i])); } // install sync manager rmt_sync_manager_handle_t synchro = NULL; rmt_sync_manager_config_t synchro_config = { .tx_channel_array = tx_channels, .array_size = sizeof(tx_channels) / sizeof(tx_channels[0]), }; ESP_ERROR_CHECK(rmt_new_sync_manager(&synchro_config, &synchro)); ESP_ERROR_CHECK(rmt_transmit(tx_channels[0], led_strip_encoders[0], led_data, led_num * 3, &transmit_config)); // tx_channels[0] does not start transmission until call of `rmt_transmit()` for tx_channels[1] returns ESP_ERROR_CHECK(rmt_transmit(tx_channels[1], led_strip_encoders[1], led_data, led_num * 3, &transmit_config)); ``` -------------------------------- ### Start Protocomm Instance over HTTP Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/provisioning/protocomm.html Example function to initialize and start a Protocomm instance using HTTP transport with Security 1. It configures the HTTP server, sets up security parameters, and adds an echo endpoint. ```c /* The example function for launching a protocomm instance over HTTP. */ protocomm_t *start_pc(const char *pop_string) { protocomm_t *pc = protocomm_new(); /* Config for protocomm_httpd_start(). */ protocomm_httpd_config_t pc_config = { .data = { .config = PROTOCOMM_HTTPD_DEFAULT_CONFIG() } }; /* Start the protocomm server on top of HTTP. */ protocomm_httpd_start(pc, &pc_config); /* Create security1 params object from pop_string. It must be valid throughout the scope of protocomm endpoint. This need not be static, i.e., could be dynamically allocated and freed at the time of endpoint removal. */ const static protocomm_security1_params_t sec1_params = { .data = (const uint8_t *) strdup(pop_string), .len = strlen(pop_string) }; /* Set security for communication at the application level. Just like for request handlers, setting security creates an endpoint and registers the handler provided by protocomm_security1. One can similarly use protocomm_security0. Only one type of security can be set for a protocomm instance at a time. */ protocomm_set_security(pc, "security_endpoint", &protocomm_security1, &sec1_params); /* Private data passed to the endpoint must be valid throughout the scope of protocomm endpoint. This need not be static, i.e., could be dynamically allocated and freed at the time of endpoint removal. */ static uint32_t priv_data = 1234; /* Add a new endpoint for the protocomm instance identified by a unique name, and register a handler function along with the private data to be passed at the time of handler execution. Multiple endpoints can be added as long as they are identified by unique names. */ protocomm_add_endpoint(pc, "echo_req_endpoint", echo_req_handler, (void *) &priv_data); return pc; } ``` -------------------------------- ### Start Application Tracing (Example 1) Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/app_trace.html Collects 2048 bytes of tracing data to 'trace.log' in non-blocking mode. Stops automatically after data collection or a 5-second timeout. ```bash esp apptrace start file://trace.log 1 2048 5 0 0 ``` -------------------------------- ### Install Basic Dependencies Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/contribute/esp-idf-tests-with-pytest.html Installs all basic dependencies required for ESP-IDF testing using the install script with the --enable-ci argument. ```bash $ install.sh --enable-ci ``` -------------------------------- ### Start Application Tracing (Example 2) Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/app_trace.html Collects tracing data indefinitely in non-blocking mode. No trace size limit or idle timeout is set. ```bash esp apptrace start file://trace.log 1 -1 -1 0 0 ``` -------------------------------- ### Install ESP32-C6 Tools Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/get-started/linux-macos-setup-legacy.html After cloning the ESP-IDF, run the install script to set up the necessary tools for the ESP32-C6 target. This command installs the compiler, debugger, and other required packages. ```bash cd ~/esp/esp-idf ./install.sh esp32c6 ``` -------------------------------- ### Example Post-Attach Callback Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/network/esp_netif_driver.html A sample post-attach callback function for an I/O driver. It sets the driver's netif, configures the driver interface, and starts the driver. ```c static esp_err_t my_post_attach_start(esp_netif_t * esp_netif, void * args) { my_netif_driver_t *driver = args; const esp_netif_driver_ifconfig_t driver_ifconfig = { .driver_free_rx_buffer = my_free_rx_buf, .transmit = my_transmit, .handle = driver->driver_impl }; driver->base.netif = esp_netif; ESP_ERROR_CHECK(esp_netif_set_driver_config(esp_netif, &driver_ifconfig)); my_driver_start(driver->driver_impl); return ESP_OK; } ``` -------------------------------- ### Start ESP-WIFI-MESH Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/network/esp-wifi-mesh.html This code snippet demonstrates the command to start the ESP-WIFI-MESH network after configuration. ```c /* mesh start */ ESP_ERROR_CHECK(esp_mesh_start()); ``` -------------------------------- ### Install esp-idf-sbom Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/tools/idf-sbom.html Install the esp-idf-sbom tool from PyPI using pip. ```bash pip install esp-idf-sbom ``` -------------------------------- ### Create and Start Software Timers Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/system/freertos_idf.html Demonstrates creating multiple software timers with auto-reload functionality and unique IDs. Timers are started before the scheduler, ensuring they begin execution immediately upon scheduler start. Includes error handling for timer creation and starting. ```c #define NUM_TIMERS 5 // An array to hold handles to the created timers. TimerHandle_t xTimers[ NUM_TIMERS ]; // An array to hold a count of the number of times each timer expires. int32_t lExpireCounters[ NUM_TIMERS ] = { 0 }; // Define a callback function that will be used by multiple timer instances. // The callback function does nothing but count the number of times the // associated timer expires, and stop the timer once the timer has expired // 10 times. void vTimerCallback( TimerHandle_t pxTimer ) { int32_t lArrayIndex; const int32_t xMaxExpiryCountBeforeStopping = 10; // Optionally do something if the pxTimer parameter is NULL. configASSERT( pxTimer ); // Which timer expired? lArrayIndex = ( int32_t ) pvTimerGetTimerID( pxTimer ); // Increment the number of times that pxTimer has expired. lExpireCounters[ lArrayIndex ] += 1; // If the timer has expired 10 times then stop it from running. if( lExpireCounters[ lArrayIndex ] == xMaxExpiryCountBeforeStopping ) { // Do not use a block time if calling a timer API function from a // timer callback function, as doing so could cause a deadlock! xTimerStop( pxTimer, 0 ); } } void main( void ) { int32_t x; // Create then start some timers. Starting the timers before the scheduler // has been started means the timers will start running immediately that // the scheduler starts. for( x = 0; x < NUM_TIMERS; x++ ) { xTimers[ x ] = xTimerCreate( "Timer", // Just a text name, not used by the kernel. ( 100 * ( x + 1 ) ), // The timer period in ticks. pdTRUE, // The timers will auto-reload themselves when they expire. ( void * ) x, // Assign each timer a unique id equal to its array index. vTimerCallback // Each timer calls the same callback when it expires. ); if( xTimers[ x ] == NULL ) { // The timer was not created. } else { // Start the timer. No block time is specified, and even if one was // it would be ignored because the scheduler has not yet been // started. if( xTimerStart( xTimers[ x ], 0 ) != pdPASS ) { // The timer could not be set into the Active state. } } } // ... // Create tasks here. // ... // Starting the scheduler will start the timers running as they have already // been set into the active state. vTaskStartScheduler(); // Should not reach here. for( ;; ); } ``` -------------------------------- ### Install ESP-IDF Tools (Windows Command Prompt) Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/get-started/windows-setup-update-legacy.html Run this script from the Windows Command Prompt to download and install necessary ESP-IDF tools. If a tool is already installed, no action is taken. ```batch install.bat ``` -------------------------------- ### Starting Remote Provisioning Parameters Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/bluetooth/esp-ble-mesh.html Structure defining parameters for starting Remote Provisioning. ```APIDOC ## struct esp_ble_mesh_rpr_client_start_rpr_t ### Description Parameters of starting remote provisioning. ### Public Members - **model** (esp_ble_mesh_model_t *) - Pointer of Remote Provisioning Client. - **rpr_srv_addr** (uint16_t) - Unicast address of Remote Provisioning Server. ``` -------------------------------- ### Start MCP Server with eim run Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/tools/idf-py.html Use this command with the ESP-IDF Installation Manager (EIM) to start the MCP server. This method is recommended and requires ESP-IDF to be installed via EIM. ```bash eim run "idf.py mcp-server" ``` -------------------------------- ### Navigate to NimBLE_Beacon Example Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/ble/get-started/ble-device-discovery.html Change directory to the NimBLE_Beacon example folder within your ESP-IDF installation. ```bash $ cd /examples/bluetooth/ble_get_started/nimble/NimBLE_Beacon ``` -------------------------------- ### Create Project from Unit-Test-App Example Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/migration-guides/release-6.x/6.0/tools.html Use this command to create a new project from the relocated unit-test-app example. ```bash idf.py create-project-from-example espressif/unit-test-app:unit-test-app ``` -------------------------------- ### Build All Documentation Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/contribute/documenting-code.html Navigate to the 'docs' folder and execute this command to build the entire documentation set. ```bash build-docs build ``` -------------------------------- ### Generic Client Properties Get Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/bluetooth/esp-ble-mesh.html Gets a Generic Client Property starting from a specified Client Property ID. ```APIDOC ## esp_ble_mesh_gen_client_properties_get_t ### Description Parameter of Generic Client Properties Get. ### Public Members - **property_id** (uint16_t) - A starting Client Property ID present within an element. ``` -------------------------------- ### Navigate to NimBLE_GATT_Server Example Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/ble/get-started/ble-introduction.html Change directory to the NimBLE_GATT_Server example project. Replace with your local ESP-IDF folder path. ```bash $ cd /examples/bluetooth/ble_get_started/nimble/NimBLE_GATT_Server ``` -------------------------------- ### Install esptool and Start RFC2217 Server on Linux/macOS Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/tools/idf-docker-image.html Install the esptool package using pip and start the RFC2217 server to expose a serial port (/dev/ttyUSB0) over the network. This enables remote serial port access for Docker containers. ```bash pip install esptool ``` ```bash esp_rfc2217_server -v -p 4000 /dev/ttyUSB0 ``` -------------------------------- ### httpd_start Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/protocols/esp_http_server.html Starts the web server by creating an instance and allocating resources based on the provided configuration. ```APIDOC ## httpd_start ### Description Starts the web server. Create an instance of HTTP server and allocate memory/resources for it depending upon the specified configuration. ### Parameters * **config** (httpd_config_t *) - Required - Configuration for new instance of the server * **handle** (httpd_handle_t *) - Required - Handle to newly created instance of the server. NULL on error ### Returns * ESP_OK : Instance created successfully * ESP_ERR_INVALID_ARG : Null argument(s) * ESP_ERR_HTTPD_ALLOC_MEM : Failed to allocate memory for instance * ESP_ERR_HTTPD_TASK : Failed to launch server task ### Example ```c //Function for starting the webserver httpd_handle_t start_webserver(void) { // Generate default configuration httpd_config_t config = HTTPD_DEFAULT_CONFIG(); // Empty handle to http_server httpd_handle_t server = NULL; // Start the httpd server if (httpd_start(&server, &config) == ESP_OK) { // Register URI handlers httpd_register_uri_handler(server, &uri_get); httpd_register_uri_handler(server, &uri_post); } // If server failed to start, handle will be NULL return server; } ``` ``` -------------------------------- ### Start Ethernet Driver Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/network/esp_eth.html Starts the Ethernet driver state machine after installation. This is a fundamental step to enable Ethernet functionality. ```c esp_eth_start(eth_handle); // start Ethernet driver state machine ``` -------------------------------- ### Build System Output Example Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/get-started/linux-macos-start-project.html Example output from the build system, showing the progress and completion of the build process. This includes details about found components and generated binaries. ```bash $ idf.py build Running cmake in directory /path/to/hello_world/build Executing "cmake -G Ninja --warn-uninitialized /path/to/hello_world"... Warn about uninitialized values. -- Found Git: /usr/bin/git (found version "2.17.0") -- Building empty aws_iot component due to configuration -- Component names: ... -- Component paths: ... ... (more lines of build system output) [527/527] Generating hello_world.bin esptool v5.0.2 Project build complete. To flash, run: idf.py flash or idf.py -p PORT flash or esptool -p (PORT) -b 921600 write-flash --flash-mode dio --flash-size detect --flash-freq 40m 0x10000 build/hello_world.bin build 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin ``` -------------------------------- ### esp_mesh_get_root_healing_delay Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/network/esp-wifi-mesh.html Gets the delay time before the network starts root healing. ```APIDOC ## esp_mesh_get_root_healing_delay ### Description Gets the delay time before the network starts root healing. ### Method `int` ### Returns - Delay time in milliseconds ``` -------------------------------- ### Build the Project Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/get-started/linux-macos-start-project.html Compiles the application and all ESP-IDF components, generating necessary binaries. This is the first step before flashing. ```bash idf.py build ``` -------------------------------- ### Successful ESP-IDF Installation Message Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/get-started/linux-setup.html Example output indicating a successful ESP-IDF installation via the EIM CLI. Confirms that IDF tools are ready for use. ```text 2025-11-03T15:54:12.537993300+08:00 - INFO - Wizard result: %{r} 2025-11-03T15:54:12.544174+08:00 - INFO - Successfully installed IDF 2025-11-03T15:54:12.545913900+08:00 - INFO - Now you can start using IDF tools ``` -------------------------------- ### Doxygen Configuration Example Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/template.html Example lines from the Doxyfile showing paths to header files that are processed to generate API reference documentation. ```bash ## ## Wi-Fi - API Reference ## ../components/esp32/include/esp_wifi.h \ ../components/esp32/include/esp_smartconfig.h \ ``` -------------------------------- ### Start RFC2217 Server on Windows Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/tools/idf-docker-image.html Install and start the RFC2217 server on Windows to expose a serial port (COM3) over the network. This allows Docker containers to access the serial port remotely. ```bash esp_rfc2217_server -v -p 4000 COM3 ``` -------------------------------- ### LCD Panel Driver Installation (ST7789 Example) Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/peripherals/lcd/spi_lcd.html Installs the specific LCD controller driver (e.g., ST7789) using the previously allocated SPI IO device handle and panel-specific configurations. ```APIDOC ## LCD Panel Driver Installation (ST7789 Example) ### Description Installs the driver for a specific LCD controller (ST7789 in this example), using the provided SPI IO handle and panel-specific configurations like reset GPIO, RGB element order, and bits per pixel. ### Function Signature ```c ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle)); ``` ### Parameters * `io_handle` (esp_lcd_panel_io_handle_t): Handle to the initialized SPI IO device. * `panel_config` (esp_lcd_panel_dev_config_t*): Pointer to the panel device configuration structure. * `reset_gpio_num` (int): GPIO number for the hardware reset pin. Set to -1 if not available. * `rgb_ele_order` (esp_lcd_rgb_ele_order_t): Order of RGB elements (e.g., `LCD_RGB_ELEMENT_ORDER_BGR`). * `bits_per_pixel` (uint8_t): Bit width of pixel color data. * `data_endian` (esp_lcd_endian_t): Data endianness for transmission (ignored if not supported or for single-byte color data). * `panel_handle` (esp_lcd_panel_handle_t*): Pointer to store the created LCD panel handle. ### Return Value `ESP_OK` on success, or an error code otherwise. ``` -------------------------------- ### BLE Disconnection Log Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/ble/get-started/ble-connection.html Example log output when a BLE connection is terminated and the device starts advertising again. ```log I (63647) NimBLE_Connection: disconnected from peer; reason=531 I (63647) NimBLE: GAP procedure initiated: advertise; I (63647) NimBLE: disc_mode=2 I (63647) NimBLE: adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=800 adv_itvl_max=801 I (63657) NimBLE: I (63657) NimBLE_Connection: advertising started! ``` -------------------------------- ### Launch GDB with Initialization Files Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/jtag-debugging/using-debugger.html Use this command to load symbols, configure prefix maps, and connect to the target device when launching GDB. ```bash riscv32-esp-elf-gdb -q -x build/gdbinit/symbols -x build/gdbinit/prefix_map -x build/gdbinit/connect build/blink.elf ``` -------------------------------- ### Starting the Web Server Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/protocols/esp_http_server.html Starts the HTTP server with a default configuration. URI handlers can be registered after successful startup. The server handle is returned, or NULL on error. ```c //Function for starting the webserver httpd_handle_t start_webserver(void) { // Generate default configuration httpd_config_t config = HTTPD_DEFAULT_CONFIG(); // Empty handle to http_server httpd_handle_t server = NULL; // Start the httpd server if (httpd_start(&server, &config) == ESP_OK) { // Register URI handlers httpd_register_uri_handler(server, &uri_get); httpd_register_uri_handler(server, &uri_post); } // If server failed to start, handle will be NULL return server; } ``` -------------------------------- ### Get Node Table Entry Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/bluetooth/esp-ble-mesh.html Retrieves a pointer to the start of the node table, allowing iteration through all provisioned nodes. ```APIDOC ## esp_ble_mesh_provisioner_get_node_table_entry ### Description This function is called by Provisioner to get the entry of the node table. Note After invoking the function to get the entry of nodes, users can use the "for" loop combined with the macro CONFIG_BLE_MESH_MAX_PROV_NODES to get each node's information. Before trying to read the node's information, users need to check if the node exists, i.e. if the *(esp_ble_mesh_node_t **node) is NULL. For example: ` const esp_ble_mesh_node_t **entry = esp_ble_mesh_provisioner_get_node_table_entry(); for (int i = 0; i < CONFIG_BLE_MESH_MAX_PROV_NODES; i++) { const esp_ble_mesh_node_t *node = entry[i]; if (node) { ...... } } ` ### Returns Pointer to the start of the node table. ``` -------------------------------- ### esp_console_start_repl Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/system/console.html Starts the REPL environment. ```APIDOC ## esp_console_start_repl ### Description Start REPL environment. Once the REPL gets started, it won't be stopped until the user calls esp_console_stop_repl to destroy the REPL environment. ### Parameters * **repl** (esp_console_repl_t *) - **[in]** REPL handle returned from `esp_console_new_repl_xxx`. ### Returns * ESP_OK on success * ESP_ERR_INVALID_STATE, if repl has started already. ``` -------------------------------- ### Change Timer Period Example Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/system/freertos_idf.html This example demonstrates how to change the period of a FreeRTOS timer. It checks if the timer is active; if so, it deletes the timer. Otherwise, it changes the timer's period to 500ms and starts it, with a timeout for sending the command. ```c /* // This function assumes xTimer has already been created. If the timer * // referenced by xTimer is already active when it is called, then the timer * // is deleted. If the timer referenced by xTimer is not active when it is * // called, then the period of the timer is set to 500ms and the timer is * // started. */ void vAFunction( TimerHandle_t xTimer ) { if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )" { // xTimer is already active - delete it. xTimerDelete( xTimer ); } else { // xTimer is not active, change its period to 500ms. This will also // cause the timer to start. Block for a maximum of 100 ticks if the // change period command cannot immediately be sent to the timer // command queue. if( xTimerChangePeriod( xTimer, 500 / portTICK_PERIOD_MS, 100 ) == pdPASS ) { // The command was successfully sent. } else { // The command could not be sent, even after waiting for 100 ticks // to pass. Take appropriate action here. } } } ``` -------------------------------- ### Example Usage of Queue Creation Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/system/freertos_idf.html Demonstrates the creation of queues and their usage within a task context. This example shows how to define a message structure and create two queues. ```c struct AMessage { char ucMessageID; char ucData[ 20 ]; }; void vATask( void *pvParameters ) { QueueHandle_t xQueue1, xQueue2; ``` -------------------------------- ### Create a Pulse Delimiter Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/peripherals/parlio/parlio_rx.html Create a pulse delimiter for Parallel IO RX. Hardware configurations are lazily installed when a transaction starts. ```c esp_err_t parlio_new_rx_pulse_delimiter(const parlio_rx_pulse_delimiter_config_t *config, parlio_rx_delimiter_handle_t *ret_delimiter); ``` -------------------------------- ### OpenOCD Output for ESP32-C6 Built-in JTAG Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/jtag-debugging/index.html Example output when OpenOCD starts successfully for an ESP32-C6 using its built-in USB JTAG. ```text user-name@computer-name:~/esp/esp-idf$ openocd -f board/esp32c6-builtin.cfg Open On-Chip Debugger v0.11.0-esp32-20221026-85-g0718fffd (2023-01-12-07:28) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : only one transport option; autoselect 'jtag' Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001 Info : esp_usb_jtag: capabilities descriptor set to 0x2000 Warn : Transport "jtag" was already selected WARNING: ESP flash support is disabled! force hard breakpoints Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : esp_usb_jtag: serial (60:55:F9:F6:03:3C) Info : esp_usb_jtag: Device found. Base speed 24000KHz, div range 1 to 255 Info : clock speed 24000 kHz Info : JTAG tap: esp32c6.cpu tap/device found: 0x0000dc25 (mfg: 0x612 (Espressif Systems), part: 0x000d, ver: 0x0) Info : datacount=2 progbufsize=16 Info : Examined RISC-V core; found 2 harts Info : hart 0: XLEN=32, misa=0x40903105 Info : starting gdb server for esp32c6 on 3333 Info : Listening on port 3333 for gdb connections ``` -------------------------------- ### Create and Enable Parallel IO TX Unit Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/peripherals/parlio/parlio_tx.html Demonstrates how to create a TX unit instance with specific configurations for simulating QPI and then enable it. Ensure all GPIO pins and clock source are correctly defined before use. ```c parlio_tx_unit_handle_t tx_unit = NULL; parlio_tx_unit_config_t config = { .clk_src = PARLIO_CLK_SRC_DEFAULT, // Select the default clock source .data_width = 4, // Data width is 4 bits .clk_in_gpio_num = -1, // Do not use an external clock source .valid_gpio_num = EXAMPLE_PIN_CS, // Use the valid signal as chip select .clk_out_gpio_num = EXAMPLE_PIN_CLK, .data_gpio_nums = { EXAMPLE_PIN_DATA0, EXAMPLE_PIN_DATA1, EXAMPLE_PIN_DATA2, EXAMPLE_PIN_DATA3, }, .output_clk_freq_hz = 10 * 1000 * 1000, // Output clock frequency is 10 MHz .trans_queue_depth = 32, // Transaction queue depth is 32 .max_transfer_size = 256, // Maximum transfer size is 256 bytes .shift_edge = PARLIO_SHIFT_EDGE_NEG, // Shift data on the falling edge of the clock .flags = { .invert_valid_out = true, // The valid signal is high by default, inverted to simulate the chip select signal CS in QPI timing } }; // Create TX unit instance ESP_ERROR_CHECK(parlio_new_tx_unit(&config, &tx_unit)); // Enable TX unit ESP_ERROR_CHECK(parlio_tx_unit_enable(tx_unit)); ``` -------------------------------- ### Start GDB GUI with idf.py Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/jtag-debugging/using-debugger.html Launches the gdbgui debugger frontend, which operates in a browser window. Requires installation via `pipx` and system dependencies. ```bash idf.py gdbgui ``` -------------------------------- ### Open Project in VSCode Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/ble/get-started/ble-introduction.html Open the current directory (NimBLE_GATT_Server example) in VSCode. Ensure you are in the example directory via the command line. ```bash $ code . ``` -------------------------------- ### CI Build Directory Structure Example Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/contribute/esp-idf-tests-with-pytest.html Illustrates the typical directory structure for build artifacts in CI, organized by target and configuration. ```text . ├── build_esp32_history/ │ └── ... ├── build_esp32_nohistory/ │ └── ... ├── build_esp32s2_history/ │ └── ... ├── ... ├── main/ ├── CMakeLists.txt ├── sdkconfig.ci.history ├── sdkconfig.ci.nohistory └── ... ``` -------------------------------- ### ESP32-C6 Application Output Example Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/get-started/linux-macos-start-project.html This is an example of the expected output from the 'Hello world!' application running on the ESP32-C6, as seen in the IDF Monitor. ```text ... Hello world! Restarting in 10 seconds... This is esp32c6 chip with 1 CPU core(s), WiFi/BLE, 802.15.4 (Zigbee/Thread), silicon revision v0.0, 2 MB external flash Minimum free heap size: 473816 bytes Restarting in 9 seconds... Restarting in 8 seconds... Restarting in 7 seconds... ``` -------------------------------- ### Example Block Device Usage Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/storage/blockdev.html Demonstrates acquiring a block device handle, checking read operation support and alignment, performing a read, and releasing the handle. Ensure the buffer size is a multiple of the device's read size. ```c esp_blockdev_handle_t dev = my_component_get_blockdev(); const esp_blockdev_geometry_t *geometry = dev->geometry; if (dev->ops->read && (sizeof(buffer) % geometry->read_size) == 0) { ESP_ERROR_CHECK(dev->ops->read(dev, buffer, sizeof(buffer), 0, sizeof(buffer))); } if (dev->ops->release) { ESP_ERROR_CHECK(dev->ops->release(dev)); } ``` -------------------------------- ### Activate ESP-IDF Environment via CLI Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/get-started/linux-macos-start-project.html This command activates the ESP-IDF environment in your current terminal session. Ensure you replace the example path with your actual ESP-IDF installation path. ```bash source "/Users/username/.espressif/tools/activate_idf_v5.4.2.sh" ``` -------------------------------- ### Example ESP32-C6 Application Output Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/get-started/windows-start-project.html This is an example of the expected output from the 'hello_world' application running on an ESP32-C6 device. ```text ... Hello world! Restarting in 10 seconds... This is esp32c6 chip with 1 CPU core(s), WiFi/BLE, 802.15.4 (Zigbee/Thread), silicon revision v0.0, 2 MB external flash Minimum free heap size: 473816 bytes Restarting in 9 seconds... Restarting in 8 seconds... Restarting in 7 seconds... ``` -------------------------------- ### Combine Debugging Actions with idf.py Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/jtag-debugging/using-debugger.html Executes OpenOCD in the background, starts the gdbgui debugger in a browser, and opens a serial monitor in the console simultaneously. This command streamlines the setup for debugging. ```bash idf.py openocd gdbgui monitor ``` -------------------------------- ### Get Ethernet MAC Address and PHY Address Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/network/esp_eth.html Retrieves the MAC address and PHY address of the Ethernet interface using esp_eth_ioctl. Ensure the Ethernet driver is installed before invoking these commands. ```c /* get MAC address */ uint8_t mac_addr[6]; memset(mac_addr, 0, sizeof(mac_addr)); esp_eth_ioctl(eth_handle, ETH_CMD_G_MAC_ADDR, mac_addr); ESP_LOGI(TAG, "Ethernet MAC Address: %02x:%02x:%02x:%02x:%02x:%02x", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]); /* get PHY address */ int phy_addr = -1; esp_eth_ioctl(eth_handle, ETH_CMD_G_PHY_ADDR, &phy_addr); ESP_LOGI(TAG, "Ethernet PHY Address: %d", phy_addr); ``` -------------------------------- ### Install Dependencies with Docs Enabled Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/contribute/documenting-code.html Run this command to install the necessary dependencies for building documentation, including the esp-docs Python package. ```bash ./install.sh --enable-docs ``` -------------------------------- ### Create a Level Delimiter Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/peripherals/parlio/parlio_rx.html Create a level delimiter for Parallel IO RX. Hardware configurations are lazily installed when a transaction starts. The enable signal must align with the valid data. ```c esp_err_t parlio_new_rx_level_delimiter(const parlio_rx_level_delimiter_config_t *config, parlio_rx_delimiter_handle_t *ret_delimiter); ``` -------------------------------- ### Python Extension File Example Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/tools/idf-py.html An example implementation of an `idf_ext.py` file, demonstrating how to define custom actions and global options for idf.py. ```python def action_extensions(base_actions, project_path): # Mandatory: API version of the extension version = "1" # Optional: Global options available for all commands global_options = [ { "names": ["--verbose", "-v"], "help": "Enable verbose output", "type": str, "scope": "global", "is_flag": True, } ] # Optional: Global action callbacks executed before any task def global_callback(ctx, global_args, tasks): print(f"Global callback executed with args: {global_args}") print(f"Tasks to be executed: {tasks}") global_action_callbacks = [global_callback] # Optional: New subcommands (actions) def my_custom_action_callback(subcommand_name, ctx, global_args, **action_args): print(f"Custom action '{subcommand_name}' executed!") print(f"Global args: {global_args}") print(f"Action args: {action_args}") actions = { "my_action": { "callback": my_custom_action_callback, "options": [ { "names": ["--message"], "help": "A message to display", "type": str, "default": "Hello", } ], "arguments": [ { "name": "input_file", "help": "Input file path", "type": str, } ], "dependencies": ["build"], } } return { "version": version, "global_options": global_options, "global_action_callbacks": global_action_callbacks, "actions": actions, } ``` -------------------------------- ### Get Minimum Free Heap Size Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/system/misc_system_api.html Retrieve the minimum amount of free heap memory that has been available since the system started. This is useful for identifying potential memory leaks or allocation issues. ```c uint32_t esp_get_minimum_free_heap_size(void) ``` -------------------------------- ### Get Idle Task Runtime Percentage (C) Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/system/freertos_idf.html Retrieves the total execution time of the idle task as a percentage of total run time. Requires specific FreeRTOS configurations and timer setup. ```c configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent(void) ``` -------------------------------- ### Implement Property Get Handler Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/protocols/esp_local_ctrl.html Handles requests to retrieve property values. This example specifically retrieves a timestamp, using the 'ctx' field to access a time-getting function and a static variable to store the value. ```c static esp_err_t get_property_values(size_t props_count, const esp_local_ctrl_prop_t *props, esp_local_ctrl_prop_val_t *prop_values, void *usr_ctx) { for (uint32_t i = 0; i < props_count; i++) { ESP_LOGI(TAG, "Reading %s", props[i].name); if (props[i].type == TYPE_TIMESTAMP) { /* Obtain the timer function from ctx */ int32_t (*func_get_time)(void) = props[i].ctx; /* Use static variable for saving the value. This is essential because the value has to be valid even after this function returns. Alternative is to use dynamic allocation and set the free_fn field */ static int32_t ts = func_get_time(); prop_values[i].data = &ts; } } return ESP_OK; } ``` -------------------------------- ### Kconfig File Example Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/kconfig/configuration_structure.html This example demonstrates the basic structure of a Kconfig file, defining a boolean configuration option with a default value and help text. Use Kconfig files to define configuration options for individual components. ```kconfig mainmenu "Motors configuration" config SUBLIGHT_DRIVE_ENABLED bool "Enable sublight drive" default y help This option enables sublight on our spaceship. ``` -------------------------------- ### Initialize TCP/IP Stack and Event Loop Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/network/esp_netif.html This snippet shows the initial steps for setting up the network stack. It requires initializing the TCP/IP stack and creating a default event loop before proceeding with network interface creation. ```c esp_netif_init(); esp_event_loop_create_default(); ``` -------------------------------- ### eFuse Field Out of Range Error Example Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/system/efuse.html Shows an error from efuse_table_gen.py indicating an eFuse field is defined outside the valid range of its parent. This requires adjusting the bit start position of the child field. ```plaintext Field at FIELD, EFUSE_BLK3, 0, 50 out of range FIELD.MAJOR_NUMBER, EFUSE_BLK3, 60, 32 ``` -------------------------------- ### GPIO Control of I2S Channel via ETM Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/peripherals/i2s.html This example demonstrates how to use GPIO events to start and stop an I2S channel using the ETM. It involves registering GPIO events, creating I2S ETM tasks, binding them through ETM channels, and then controlling the I2S channel by manipulating the GPIO level. ```c #include "driver/i2s_etm.h" // ... i2s_chan_handle_t tx_handle; // Initialize I2S channel // ...... int ctrl_gpio = 4; // Initialize GPIO // ...... /* Register GPIO ETM events */ gpio_etm_event_config_t gpio_event_cfg = { .edges = {GPIO_ETM_EVENT_EDGE_POS, GPIO_ETM_EVENT_EDGE_NEG}, }; esp_etm_event_handle_t gpio_pos_event_handle; esp_etm_event_handle_t gpio_neg_event_handle; gpio_new_etm_event(&gpio_event_cfg, &gpio_pos_event_handle, &gpio_neg_event_handle); gpio_etm_event_bind_gpio(gpio_pos_event_handle, ctrl_gpio); gpio_etm_event_bind_gpio(gpio_neg_event_handle, ctrl_gpio); /* Register I2S ETM tasks */ i2s_etm_task_config_t i2s_start_task_cfg = { .task_type = I2S_ETM_TASK_START, }; esp_etm_task_handle_t i2s_start_task_handle; i2s_new_etm_task(tx_handle, &i2s_start_task_cfg, &i2s_start_task_handle); i2s_etm_task_config_t i2s_stop_task_cfg = { .task_type = I2S_ETM_TASK_STOP, }; esp_etm_task_handle_t i2s_stop_task_handle; i2s_new_etm_task(tx_handle, &i2s_stop_task_cfg, &i2s_stop_task_handle); /* Bind GPIO events to I2S ETM tasks */ esp_etm_channel_config_t etm_config = {}; esp_etm_channel_handle_t i2s_etm_start_chan = NULL; esp_etm_channel_handle_t i2s_etm_stop_chan = NULL; esp_etm_new_channel(&etm_config, &i2s_etm_start_chan); esp_etm_new_channel(&etm_config, &i2s_etm_stop_chan); esp_etm_channel_connect(i2s_etm_start_chan, gpio_pos_event_handle, i2s_start_task_handle); esp_etm_channel_connect(i2s_etm_stop_chan, gpio_neg_event_handle, i2s_stop_task_handle); esp_etm_channel_enable(i2s_etm_start_chan); esp_etm_channel_enable(i2s_etm_stop_chan); /* Enable I2S channel first before starting I2S channel */ i2s_channel_enable(tx_handle); // (Optional) Able to load the data into the internal DMA buffer here, // but tx_channel does not start yet, will timeout when the internal buffer is full // i2s_channel_write(tx_handle, data, data_size, NULL, 0); /* Start I2S channel by setting the GPIO to high */ gpio_set_level(ctrl_gpio, 1); // Write data ...... // i2s_channel_write(tx_handle, data, data_size, NULL, 1000); /* Stop I2S channel by setting the GPIO to low */ gpio_set_level(ctrl_gpio, 0); /* Free resources */ i2s_channel_disable(tx_handle); esp_etm_channel_disable(i2s_etm_start_chan); esp_etm_channel_disable(i2s_etm_stop_chan); esp_etm_del_event(gpio_pos_event_handle); esp_etm_del_event(gpio_neg_event_handle); esp_etm_del_task(i2s_start_task_handle); esp_etm_del_task(i2s_stop_task_handle); esp_etm_del_channel(i2s_etm_start_chan); esp_etm_del_channel(i2s_etm_stop_chan); // De-initialize I2S and GPIO // ...... ``` -------------------------------- ### Open Project in VSCode Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-guides/ble/get-started/ble-connection.html Open the current directory (the NimBLE_Connection example) in VSCode. ```bash code . ``` -------------------------------- ### UART Detect Bitrate Start Source: https://docs.espressif.com/projects/esp-idf/en/release-v6.0/esp32c6/api-reference/peripherals/uart.html Initiates the bitrate detection process for an incoming data signal, commonly known as auto baud rate detection. This function can be used independently and does not require the UART driver to be installed beforehand. It is recommended that the incoming data line has an alternating bit sequence, such as data bytes like `0x55` or `0xAA`. ```APIDOC ## uart_detect_bitrate_start ### Description Start to do a bitrate detection for an incoming data signal (auto baud rate detection). ### Parameters * **uart_num** (uart_port_t) - The ID of the UART port to be used for measurement. Note that only HP UART ports support this capability. * **config** (const uart_bitrate_detect_config_t *) - Pointer to the configuration structure for the UART port. If the port has already been acquired, this parameter is ignored. ### Returns * ESP_OK on success * ESP_ERR_INVALID_ARG Parameter error * ESP_FAIL No free UART port or source_clk invalid. ```