Skip to content

Commit

Permalink
Merge branch 'feature/add_new_esp32c2_eco4_module' into 'master'
Browse files Browse the repository at this point in the history
feat: Added a new esp32c2-eco4-4mb module support

See merge request application/esp-at!1692
  • Loading branch information
xcguang committed Dec 18, 2024
2 parents 8f63974 + 1081afe commit 9638835
Show file tree
Hide file tree
Showing 15 changed files with 585 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build_template_esp32c2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ on:
secrets:
ESP32C2_4MB_TOKEN:
required: false
ESP32C2_ECO4_4MB_TOKEN:
required: false
ESP32C2_2MB_TOKEN:
required: false

Expand All @@ -39,6 +41,8 @@ jobs:
echo -e "#define CONFIG_ESP_AT_OTA_SSL_TOKEN_ESP32C2_2MB \"${{ secrets.ESP32C2_2MB_TOKEN }}\"" >> at_ota_token.h
echo -e "#define CONFIG_ESP_AT_OTA_TOKEN_ESP32C2_4MB \"${{ secrets.ESP32C2_4MB_TOKEN }}\"" >> at_ota_token.h
echo -e "#define CONFIG_ESP_AT_OTA_SSL_TOKEN_ESP32C2_4MB \"${{ secrets.ESP32C2_4MB_TOKEN }}\"" >> at_ota_token.h
echo -e "#define CONFIG_ESP_AT_OTA_TOKEN_ESP32C2_ECO4_4MB \"${{ secrets.ESP32C2_ECO4_4MB_TOKEN }}\"" >> at_ota_token.h
echo -e "#define CONFIG_ESP_AT_OTA_SSL_TOKEN_ESP32C2_ECO4_4MB \"${{ secrets.ESP32C2_ECO4_4MB_TOKEN }}\"" >> at_ota_token.h
cd -
- name: Install environment variables
run: |
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ jobs:
artifacts_name: esp32c2-4MB-at
secrets: inherit

build-esp32c2-eco4-4mb-at:
uses: ./.github/workflows/build_template_esp32c2.yml
with:
module_name: ESP32C2-ECO4-4MB
artifacts_name: esp32c2-eco4-4MB-at
secrets: inherit

build-esp32c2-2mb-at:
uses: ./.github/workflows/build_template_esp32c2.yml
with:
Expand Down
7 changes: 7 additions & 0 deletions .gitlab/ci/build_esp32c2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ esp32c2_4mb_at:
variables:
MODULE_NAME: "ESP32C2-4MB"

esp32c2_eco4_4mb_at:
extends:
- .build_template_esp32c2
- .rules:build:build_project
variables:
MODULE_NAME: "ESP32C2-ECO4-4MB"

esp32c2_ble_2mb_at:
extends:
- .build_template_esp32c2
Expand Down
2 changes: 2 additions & 0 deletions .gitlab/ci/build_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
- echo -e "#define CONFIG_ESP_AT_OTA_SSL_TOKEN_ESP32C2_2MB \"$ESP32C2_2MB_TOKEN\"" >> at_ota_token.h
- echo -e "#define CONFIG_ESP_AT_OTA_TOKEN_ESP32C2_4MB \"$ESP32C2_4MB_TOKEN\"" >> at_ota_token.h
- echo -e "#define CONFIG_ESP_AT_OTA_SSL_TOKEN_ESP32C2_4MB \"$ESP32C2_4MB_TOKEN\"" >> at_ota_token.h
- echo -e "#define CONFIG_ESP_AT_OTA_TOKEN_ESP32C2_ECO4_4MB \"$ESP32C2_ECO4_4MB_TOKEN\"" >> at_ota_token.h
- echo -e "#define CONFIG_ESP_AT_OTA_SSL_TOKEN_ESP32C2_ECO4_4MB \"$ESP32C2_ECO4_4MB_TOKEN\"" >> at_ota_token.h
- cd -

.setup_tokens_esp32c3: &setup_tokens_esp32c3
Expand Down
2 changes: 2 additions & 0 deletions components/at/private_include/at_ota_token.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#define CONFIG_ESP_AT_OTA_SSL_TOKEN_ESP32C2_2MB CONFIG_ESP_AT_OTA_SSL_TOKEN_DEFAULT
#define CONFIG_ESP_AT_OTA_TOKEN_ESP32C2_4MB CONFIG_ESP_AT_OTA_TOKEN_DEFAULT
#define CONFIG_ESP_AT_OTA_SSL_TOKEN_ESP32C2_4MB CONFIG_ESP_AT_OTA_SSL_TOKEN_DEFAULT
#define CONFIG_ESP_AT_OTA_TOKEN_ESP32C2_ECO4_4MB CONFIG_ESP_AT_OTA_TOKEN_DEFAULT
#define CONFIG_ESP_AT_OTA_SSL_TOKEN_ESP32C2_ECO4_4MB CONFIG_ESP_AT_OTA_SSL_TOKEN_DEFAULT
#elif defined(CONFIG_IDF_TARGET_ESP32C5)
#define CONFIG_ESP_AT_OTA_TOKEN_ESP32C5_4MB CONFIG_ESP_AT_OTA_TOKEN_DEFAULT
#define CONFIG_ESP_AT_OTA_SSL_TOKEN_ESP32C5_4MB CONFIG_ESP_AT_OTA_SSL_TOKEN_DEFAULT
Expand Down
1 change: 1 addition & 0 deletions components/at/src/at_default_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static const esp_at_module_info_t esp_at_module_info[] = {
#if defined(CONFIG_IDF_TARGET_ESP32C2)
{"ESP32C2-2MB", CONFIG_ESP_AT_OTA_TOKEN_ESP32C2_2MB, CONFIG_ESP_AT_OTA_SSL_TOKEN_ESP32C2_2MB},
{"ESP32C2-4MB", CONFIG_ESP_AT_OTA_TOKEN_ESP32C2_4MB, CONFIG_ESP_AT_OTA_SSL_TOKEN_ESP32C2_4MB},
{"ESP32C2-ECO4-4MB", CONFIG_ESP_AT_OTA_TOKEN_ESP32C2_ECO4_4MB, CONFIG_ESP_AT_OTA_SSL_TOKEN_ESP32C2_ECO4_4MB},
{"ESP32C2-BLE-2MB", NULL, NULL},
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ PLATFORM_ESP32C3,ESP32C3_RAINMAKER,"support rainmaker cloud, TX:7 RX:6",4,78,1,1
PLATFORM_ESP32C2,ESP32C2-2MB,"single Wi-Fi, 2MB, TX:7 RX:6",4,78,1,1,13,CN,115200,7,6,19,20
PLATFORM_ESP32C2,ESP32C2-4MB,"Wi-Fi + BluFi, 4MB, TX:7 RX:6",4,78,1,1,13,CN,115200,7,6,5,4
PLATFORM_ESP32C2,ESP32C2-BLE-2MB,"single BLE, 2MB, TX:7 RX:6",4,78,1,1,13,CN,115200,7,6,5,4
PLATFORM_ESP32C2,ESP32C2-ECO4-4MB,"Wi-Fi + BluFi, ECO4 only, 4MB, TX:7 RX:6",4,78,1,1,13,CN,115200,7,6,5,4
PLATFORM_ESP32C5,ESP32C5-4MB,"TX:14 RX:13",4,78,1,1,13,CN,115200,14,13,9,8
PLATFORM_ESP32C6,ESP32C6-4MB,"TX:7 RX:6",4,78,1,1,13,CN,115200,7,6,5,4
PLATFORM_ESP32S2,MINI,"TX:17 RX:21",4,78,1,1,13,CN,115200,17,21,20,19
3 changes: 3 additions & 0 deletions module_config/module_esp32c2-eco4-4mb/IDF_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
branch:release/v5.1
commit:64849cb7039a93b7b3a4ad8e8da328fa9c09c5e7
repository:https://github.com/espressif/esp-idf.git
3 changes: 3 additions & 0 deletions module_config/module_esp32c2-eco4-4mb/at_customize.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Name, Type, SubType, Offset, Size
mfg_nvs, data, nvs, 0x1f000, 124K
fatfs, data, fat, 0x47000, 100K
7 changes: 7 additions & 0 deletions module_config/module_esp32c2-eco4-4mb/partitions_at.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 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, 0x1d0000
ota_1, app, ota_1, 0x230000, 0x1d0000
147 changes: 147 additions & 0 deletions module_config/module_esp32c2-eco4-4mb/patch/blufi-adv.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
From 880c46ed4830a561df3dc6ba72dfee9c39b0559a Mon Sep 17 00:00:00 2001
From: xiewenxiang <[email protected]>
Date: Thu, 13 Jul 2023 19:24:50 +0800
Subject: [PATCH] feat(blufi): Support ext adv

---
.../profile/esp/blufi/nimble_host/esp_blufi.c | 98 ++++++++++++++++++-
1 file changed, 97 insertions(+), 1 deletion(-)

diff --git a/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c b/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c
index 5a22773c7a..220a29de81 100644
--- a/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c
+++ b/components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c
@@ -32,11 +32,22 @@

#if (BLUFI_INCLUDED == TRUE)

+#if !CONFIG_BT_NIMBLE_EXT_ADV
static uint8_t own_addr_type;
+#endif

struct gatt_value gatt_values[SERVER_MAX_VALUES];
const static char *TAG = "BLUFI_EXAMPLE";

+#if CONFIG_BT_NIMBLE_EXT_ADV
+static uint8_t ext_adv_pattern_1[] = {
+ 0x02, 0x01, 0x06,
+ 0x03, 0x03, 0xFF, 0xFF,
+ 0x0d, 0X09, 'B', 'L', 'U', 'F','I', '_' ,'D','E','V','I','C','E',
+ 0x02, 0x0A, 0x09
+};
+#endif
+
enum {
GATT_VALUE_TYPE_CHR,
GATT_VALUE_TYPE_DSC,
@@ -333,6 +344,79 @@ esp_blufi_gap_event(struct ble_gap_event *event, void *arg)

void esp_blufi_adv_start(void)
{
+#if CONFIG_BT_NIMBLE_EXT_ADV //Extended Adv
+ struct ble_gap_ext_adv_params params;
+ struct os_mbuf *data;
+ uint8_t instance = 0;
+ int rc;
+ const char *name;
+ uint8_t adv_data[31] = {0};
+
+ /* use defaults for non-set params */
+ memset (&params, 0, sizeof(params));
+
+ /* enable connectable advertising */
+ params.connectable = 1;
+ params.scannable = 1;
+ params.legacy_pdu = 1;
+
+ /* advertise using public addr */
+ params.own_addr_type = BLE_OWN_ADDR_PUBLIC;
+
+ params.primary_phy = BLE_HCI_LE_PHY_1M;
+ params.secondary_phy = BLE_HCI_LE_PHY_1M;
+ params.sid = 1;
+
+ params.itvl_min = BLE_GAP_ADV_FAST_INTERVAL1_MIN;
+ params.itvl_max = BLE_GAP_ADV_FAST_INTERVAL1_MIN;
+
+ /* configure instance 0 */
+ rc = ble_gap_ext_adv_configure(instance, &params, NULL,
+ esp_blufi_gap_event, NULL);
+ if (rc != 0) {
+ ESP_LOGE(TAG, "Configuration failed with reason : %d \n" , rc);
+ return;
+ }
+
+ name = ble_svc_gap_device_name();
+ adv_data[0] = 0x02;
+ adv_data[1] = 0x01;
+ adv_data[2] = 0x06;
+ adv_data[3] = 1 + strlen(name);
+ adv_data[4] = 0x09;
+ memcpy(adv_data + 5, name, strlen(name));
+
+ /* get mbuf for scan rsp data */
+ data = os_msys_get_pkthdr(strlen(name) + 5, 0);
+
+ if (data == NULL) {
+ ESP_LOGE(TAG, "Failed to get mbuf \n");
+ return;
+ }
+
+ /* fill mbuf with scan rsp data */
+ rc = os_mbuf_append(data, adv_data, strlen(name) + 5);
+
+ if (rc != 0) {
+ ESP_LOGE(TAG, "Failed to fill scan rsp data with reason: %d \n", rc);
+ return;
+ }
+
+ rc = ble_gap_ext_adv_set_data(instance, data);
+
+ if (rc != 0) {
+ ESP_LOGE(TAG, "Failed to set adv data with reason: %d \n", rc);
+ return;
+ }
+
+ /* start advertising */
+ rc = ble_gap_ext_adv_start(instance, 0, 0);
+
+ if (rc != 0) {
+ ESP_LOGE(TAG, "Failed to start ext adv with reason: %d \n", rc);
+ return;
+ }
+#else // Legacy ADV
int rc;

rc = ble_hs_util_ensure_addr(0);
@@ -404,6 +488,7 @@ void esp_blufi_adv_start(void)
ESP_LOGE(TAG, "error enabling advertisement; rc=%d\n", rc);
return;
}
+#endif
}

uint8_t esp_blufi_init(void)
@@ -447,7 +532,18 @@ void esp_blufi_disconnect(void)
ble_gap_terminate(blufi_env.conn_id, BLE_ERR_REM_USER_CONN_TERM);
}

-void esp_blufi_adv_stop(void) {}
+void esp_blufi_adv_stop(void)
+{
+#if CONFIG_BT_NIMBLE_EXT_ADV
+ int i;
+
+ for (i = 0; i < BLE_ADV_INSTANCES; i++) {
+ ble_gap_ext_adv_stop(i);
+ }
+#else
+ ble_gap_adv_stop();
+#endif
+}

void esp_blufi_send_encap(void *arg)
{
--
2.25.1

9 changes: 9 additions & 0 deletions module_config/module_esp32c2-eco4-4mb/patch/patch_list.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
; Add your patches to the section below

[blufi-adv.patch]
path = esp-idf
note = "Add the support for BluFi advertising if uses nimble"

[support_ext_partition.patch]
path = esp-idf
note = "[IDF-9560] Support to use partition table outside of the project directory"
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. "
Loading

0 comments on commit 9638835

Please sign in to comment.