-
Notifications
You must be signed in to change notification settings - Fork 822
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ESPAT-1918): Supported to use external module_config
- Supported to override the system configuration - Supported to override the patch directory - Supported to override the system partition table - Supported to override the secondary partition table - Supported to override the esp-idf version - Added an at_override_module_config example and detailed readme
- Loading branch information
Showing
33 changed files
with
643 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
branch:release/v5.0 | ||
commit:bcca689866db3dfda47f77670bf8df2a7ec94721 | ||
repository:https://github.com/espressif/esp-idf.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
### 1. Description | ||
This `at_override_module_config` example works as an external directory, allowing you to override the default module configurations (`esp-at/module_config/<your_module>`) for your module, and you will no longer need to modify the source code of the [esp-at repository](https://github.com/espressif/esp-at). This allows you to just host `at_override_module_config` directory in your git repository in a light-weight way, and it also allows you to freely choose any commit from the esp-at repository snapshot starting from March 2024 as the main project. | ||
|
||
### 2. About the Override | ||
Here are five optional configurations that you may want to override, and you can choose to override one or more of them. Below are detailed descriptions of each override. | ||
|
||
**Notes:** | ||
- If you don't override a configuration, the native configuration will be used. | ||
- You must use the same filename and directory name to override. | ||
|
||
#### 2.1 Override the system configuration | ||
The native system configuration file is `esp-at/module_config/<your_module>/sdkconfig.defaults` (disable silence mode) or `esp-at/module_config/<your_module>/sdkconfig_silence.defaults` (enable silence mode). You may want to enable or disable some features, for example, to enable WebSocket functionality and disable mDNS functionality. You can copy the native system configuration file to `at_override_module_config` directory, and add the following lines to `at_override_module_config/sdkconfig.defaults` file: | ||
|
||
``` | ||
# Enable WebSocket and disable mDNS | ||
CONFIG_AT_WS_COMMAND_SUPPORT=y | ||
CONFIG_AT_MDNS_COMMAND_SUPPORT=n | ||
``` | ||
|
||
The build system will use `at_override_module_config/sdkconfig.defaults` as your system configuration. | ||
|
||
#### 2.2 Override the patch directory | ||
The native patch directory is `esp-at/module_config/<your_module>/patch`. You may want to add more patches, for example, to output one prompt message after esp-at is ready. You can copy the native patch directory to `at_override_module_config` directory, and add the `at_example.patch` file to `at_override_module_config/patch`, then specify this patch by adding the following lines to `at_override_module_config/patch/patch_list.ini` file: | ||
|
||
``` | ||
[at_example.patch] | ||
path = . | ||
note = "This is a simple example to demonstrate how to override the patch directory" | ||
``` | ||
|
||
The build system will use `at_override_module_config/patch` as your patch configuration. | ||
|
||
**Notes:** | ||
- You can create the patch using either the `git format-patch` or `git diff` command. | ||
|
||
#### 2.3 Override the system partition table | ||
The native system partition table file is `esp-at/module_config/<your_module>/partitions_at.csv`. You may want to modify it, for example, to enlarge app partition (`ota_0`) size to support more features. You can copy the native system partition table to `at_override_module_config/partitions_at.csv`, and update the system partition table by replacing the following lines to `at_override_module_config/partitions_at.csv` file: | ||
|
||
``` | ||
# Name, Type, SubType, Offset, Size | ||
otadata, data, ota, 0xd000, 0x2000 | ||
phy_init, data, phy, 0xf000, 0x1000 | ||
nvs, data, nvs, 0x10000, 0xE000 | ||
at_customize, 0x40, 0, 0x1E000, 0x42000 | ||
ota_0, app, ota_0, 0x60000, 0x3a0000 | ||
``` | ||
|
||
The build system will use `at_override_module_config/partitions_at.csv` as your system partition table configuration. | ||
|
||
**Notes:** | ||
- In order to increase the size of the `ota_0` partition, the `ota_1` partition has been removed in this example. This means that you cannot use the OTA commands (`AT+USEROTA` and `AT+CIUPDATE`) provided by the AT firmware. Therefore, your host MCU needs to support firmware updates of esp-at via the [esptool protocol](https://docs.espressif.com/projects/esptool/en/latest/esp32/advanced-topics/serial-protocol.html). Otherwise, if any issues occur, the AT firmware will be unable to be updated. | ||
- You need to override `sdkconfig.defaults` as you need to specify the relative path of the system partition table in `sdkconfig.defaults` using `CONFIG_PARTITION_TABLE_CUSTOM_FILENAME` and `CONFIG_PARTITION_TABLE_FILENAME`. The relative path is relative to `at_override_module_config` for `partitions_at.csv`. | ||
|
||
#### 2.4 Override the secondary partition table | ||
The native secondary partition table (also called user partition table) file is `esp-at/module_config/<your_module>/at_customize.csv`. You may want to modify it, for example, to enlarge manufacturing nvs partition (`mfg_nvs`) size to support more parameters. You can copy the native secondary partition table to `at_override_module_config/at_customize.csv`, and update the secondary partition table by replacing the following lines to `at_override_module_config/at_customize.csv` file: | ||
|
||
``` | ||
# Name, Type, SubType, Offset, Size | ||
mfg_nvs, data, nvs, 0x1f000, 0x41000 | ||
``` | ||
|
||
The build system will use `at_override_module_config/at_customize.csv` as your secondary partition table configuration. | ||
|
||
**Notes:** | ||
- In order to increase the size of the `mfg_nvs` partition, the `fatfs` partition has been removed in this example. This means that you cannot use the FileSystem command (`AT+FS`) provided by the AT firmware. | ||
- You need to override `sdkconfig.defaults` as you need to specify the relative path of the secondary partition table in `sdkconfig.defaults` using `CONFIG_AT_CUSTOMIZED_PARTITION_TABLE_FILE`. The relative path is relative to `at_override_module_config` for `at_customize.csv`. | ||
|
||
#### 2.5 Override the esp-idf version | ||
It is strongly recommended to use the default `ESP-IDF` version of the `ESP-AT` project, and **NOT** recommended to update it (because of the potential [application binary interface](https://en.wikipedia.org/wiki/Application_binary_interface) incompatibility between the underlying ESP-IDF versions of `libesp_at_core.a` and the esp-at repository, which may cause incorrect operation of the firmware.), but we still keep the option to update the ESP-IDF for testing purposes. The native esp-idf version file is `esp-at/module_config/<your_module>/IDF_VERSION`. You can copy the native esp-idf version to `at_override_module_config/IDF_VERSION`, and keep it as it is. | ||
|
||
``` | ||
branch:release/v5.0 | ||
commit:bcca689866db3dfda47f77670bf8df2a7ec94721 | ||
repository:https://github.com/espressif/esp-idf.git | ||
``` | ||
|
||
The build system will use `at_override_module_config/IDF_VERSION` as your esp-idf version configuration. | ||
|
||
### 3. Usage | ||
3.1 Based on the content of `2. About the Override` above and your needs, modify the configurations. | ||
|
||
3.2 Add your `at_override_module_config` directory into the build system of esp-at project. | ||
|
||
- Linux or macOS | ||
``` | ||
export AT_EXT_MODULE_CFG=(path_of_at_override_module_config) | ||
``` | ||
|
||
- Windows | ||
``` | ||
set AT_EXT_MODULE_CFG=(path_of_at_override_module_config) | ||
``` | ||
|
||
Notes: | ||
- You need to replace (path_of_at_override_module_config) with your real absolute path of your `at_override_module_config` directory. | ||
|
||
3.3 Compile your firmware according to the [Compile ESP-AT Project](https://docs.espressif.com/projects/esp-at/en/latest/esp32/Compile_and_Develop/How_to_clone_project_and_compile_it.html#compile-esp-at-project-locally) guide. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Name, Type, SubType, Offset, Size | ||
mfg_nvs, data, nvs, 0x1f000, 0x41000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Name, Type, SubType, Offset, Size | ||
otadata, data, ota, 0xd000, 0x2000 | ||
phy_init, data, phy, 0xf000, 0x1000 | ||
nvs, data, nvs, 0x10000, 0xE000 | ||
at_customize, 0x40, 0, 0x1E000, 0x42000 | ||
ota_0, app, ota_0, 0x60000, 0x3a0000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
diff --git a/main/app_main.c b/main/app_main.c | ||
index 06939b6a..de98fbab 100644 | ||
--- a/main/app_main.c | ||
+++ b/main/app_main.c | ||
@@ -3,6 +3,7 @@ | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
+#include <string.h> | ||
#include "nvs_flash.h" | ||
#include "esp_event.h" | ||
#include "esp_err.h" | ||
@@ -19,4 +20,7 @@ void app_main(void) | ||
ESP_ERROR_CHECK(esp_event_loop_create_default()); | ||
|
||
esp_at_init(); | ||
+ | ||
+ char *prompt = "Welcome to the world of ESP-AT!\r\n"; | ||
+ esp_at_port_active_write_data((uint8_t *)prompt, strlen(prompt)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
; Add your patches to the section below | ||
|
||
[support_ext_partition.patch] | ||
path = esp-idf | ||
note = "[IDF-9560] Support to use partition table outside of the project directory" | ||
|
||
[at_example.patch] | ||
path = . | ||
note = "This is a simple example to demonstrate how to override the patch directory" |
20 changes: 20 additions & 0 deletions
20
examples/at_override_module_config/patch/support_ext_partition.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
diff --git a/components/partition_table/project_include.cmake b/components/partition_table/project_include.cmake | ||
index d0969ba408..89a0f02cbd 100644 | ||
--- a/components/partition_table/project_include.cmake | ||
+++ b/components/partition_table/project_include.cmake | ||
@@ -9,10 +9,14 @@ if(NOT BOOTLOADER_BUILD) | ||
# Set PARTITION_CSV_PATH to the configured partition CSV file | ||
# absolute path | ||
if(CONFIG_PARTITION_TABLE_CUSTOM) | ||
+ if(NOT CONFIG_PARTITION_TABLE_BASE_DIR) | ||
+ set(CONFIG_PARTITION_TABLE_BASE_DIR "${project_dir}") | ||
+ endif() | ||
+ | ||
idf_build_get_property(project_dir PROJECT_DIR) | ||
# Custom filename expands any path relative to the project | ||
get_filename_component(PARTITION_CSV_PATH "${CONFIG_PARTITION_TABLE_FILENAME}" | ||
- ABSOLUTE BASE_DIR "${project_dir}") | ||
+ ABSOLUTE BASE_DIR "${CONFIG_PARTITION_TABLE_BASE_DIR}") | ||
|
||
if(NOT EXISTS "${PARTITION_CSV_PATH}") | ||
message(WARNING "Partition table CSV file ${PARTITION_CSV_PATH} not found. " |
Oops, something went wrong.