Skip to content

Commit 4a5050d

Browse files
committed
Merge branch 'fix/remove_printf' into 'staging'
Clean-up host side logging See merge request app-frameworks/esp_hosted_mcu!149
2 parents 5e4e627 + 0a57004 commit 4a5050d

File tree

10 files changed

+65
-27
lines changed

10 files changed

+65
-27
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 2.6.8
4+
5+
### Bug Fixes
6+
- Clean up ESP-Hosted prints at host
7+
38
## 2.6.7
49

510
### Features

Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,14 @@ ESP32XX_SPI_HD_CLK_FREQ_RANGE_MAX := 40
15721572

15731573
menu "Debug Settings"
15741574

1575+
config ESP_HOSTED_FW_VERSION_MISMATCH_WARNING_SUPPRESS
1576+
bool "Suppress firmware version mismatch warnings"
1577+
default n
1578+
help
1579+
Suppress warnings when host and co-processor firmware versions do not match.
1580+
By default, version mismatch warnings are shown during initialization.
1581+
Enable this option to suppress these warnings.
1582+
15751583
config ESP_HOSTED_RAW_THROUGHPUT_TRANSPORT
15761584
bool "RawTP: Transport level throughput debug test"
15771585
default n

examples/host_performs_slave_ota/main/main.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,17 @@ static int compare_self_version_with_slave_version(uint32_t slave_version)
4747
return 0;
4848
} else if (host_version > slave_version) {
4949
// host version > slave version
50-
ESP_LOGW(TAG, "=== ESP-Hosted Version Warning ===");
51-
printf("Version on Host is NEWER than version on co-processor\n");
52-
printf("RPC requests sent by host may encounter timeout errors\n");
53-
printf("or may not be supported by co-processor\n");
54-
ESP_LOGW(TAG, "=== ESP-Hosted Version Warning ===");
50+
#ifndef CONFIG_ESP_HOSTED_FW_VERSION_MISMATCH_WARNING_SUPPRESS
51+
ESP_LOGW(TAG, "Version mismatch: Host [%u.%u.%u] > Co-proc [%u.%u.%u] ==> Upgrade co-proc to avoid RPC timeouts",
52+
ESP_HOSTED_VERSION_PRINTF_ARGS(host_version), ESP_HOSTED_VERSION_PRINTF_ARGS(slave_version));
53+
#endif
5554
return -1;
5655
} else {
5756
// host version < slave version
58-
ESP_LOGW(TAG, "=== ESP-Hosted Version Warning ===");
59-
printf("Version on Host is OLDER than version on co-processor\n");
60-
printf("Host may not be compatible with co-processor\n");
61-
ESP_LOGW(TAG, "=== ESP-Hosted Version Warning ===");
57+
#ifndef CONFIG_ESP_HOSTED_FW_VERSION_MISMATCH_WARNING_SUPPRESS
58+
ESP_LOGW(TAG, "Version mismatch: Host [%u.%u.%u] < Co-proc [%u.%u.%u] ==> Upgrade host to avoid compatibility issues",
59+
ESP_HOSTED_VERSION_PRINTF_ARGS(host_version), ESP_HOSTED_VERSION_PRINTF_ARGS(slave_version));
60+
#endif
6261
return 1;
6362
}
6463
}

host/drivers/transport/transport_drv.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ transport_channel_t *transport_drv_add_channel(void *api_chan,
359359
assert(channel->memp);
360360
#endif
361361

362-
ESP_LOGI(TAG, "Add ESP-Hosted channel IF[%u]: S[%u] Tx[%p] Rx[%p]",
362+
ESP_LOGD(TAG, "Add ESP-Hosted channel IF[%u]: S[%u] Tx[%p] Rx[%p]",
363363
if_type, secure, *tx, rx);
364364

365365
return channel;
@@ -569,18 +569,17 @@ static int compare_fw_version(uint32_t slave_version)
569569
return 0;
570570
} else if (host_version > slave_version) {
571571
// host version > slave version
572-
ESP_LOGW(TAG, "=== ESP-Hosted Version Warning ===");
573-
printf("Version on Host is NEWER than version on co-processor\n");
574-
printf("RPC requests sent by host may encounter timeout errors\n");
575-
printf("or may not be supported by co-processor\n");
576-
ESP_LOGW(TAG, "=== ESP-Hosted Version Warning ===");
572+
#ifndef CONFIG_ESP_HOSTED_FW_VERSION_MISMATCH_WARNING_SUPPRESS
573+
ESP_LOGW(TAG, "Version mismatch: Host [%u.%u.%u] > Co-proc [%u.%u.%u] ==> Upgrade co-proc to avoid RPC timeouts",
574+
ESP_HOSTED_VERSION_PRINTF_ARGS(host_version), ESP_HOSTED_VERSION_PRINTF_ARGS(slave_version));
575+
#endif
577576
return -1;
578577
} else {
579578
// host version < slave version
580-
ESP_LOGW(TAG, "=== ESP-Hosted Version Warning ===");
581-
printf("Version on Host is OLDER than version on co-processor\n");
582-
printf("Host may not be compatible with co-processor\n");
583-
ESP_LOGW(TAG, "=== ESP-Hosted Version Warning ===");
579+
#ifndef CONFIG_ESP_HOSTED_FW_VERSION_MISMATCH_WARNING_SUPPRESS
580+
ESP_LOGW(TAG, "Version mismatch: Host [%u.%u.%u] < Co-proc [%u.%u.%u] ==> Upgrade host to avoid compatibility issues",
581+
ESP_HOSTED_VERSION_PRINTF_ARGS(host_version), ESP_HOSTED_VERSION_PRINTF_ARGS(slave_version));
582+
#endif
584583
return 1;
585584
}
586585
}

host/esp_hosted_host_fw_ver.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,24 @@
1515

1616
#define ESP_HOSTED_VERSION_MAJOR_1 2
1717
#define ESP_HOSTED_VERSION_MINOR_1 6
18-
#define ESP_HOSTED_VERSION_PATCH_1 7
18+
#define ESP_HOSTED_VERSION_PATCH_1 8
1919

2020
/**
2121
* Macro to convert version number into an integer
2222
*/
2323
#define ESP_HOSTED_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
2424

25+
/* Extract version components from version value */
26+
#define ESP_HOSTED_VERSION_MAJOR(ver) (((ver) >> 16) & 0xFF)
27+
#define ESP_HOSTED_VERSION_MINOR(ver) (((ver) >> 8) & 0xFF)
28+
#define ESP_HOSTED_VERSION_PATCH(ver) ((ver) & 0xFF)
29+
30+
/* Format version tuple for printing */
31+
#define ESP_HOSTED_VERSION_PRINTF_ARGS(ver) \
32+
ESP_HOSTED_VERSION_MAJOR(ver), \
33+
ESP_HOSTED_VERSION_MINOR(ver), \
34+
ESP_HOSTED_VERSION_PATCH(ver)
35+
36+
#define ESP_HOSTED_VERSION_PRINTF_FMT "%u.%u.%u"
37+
2538
#endif

host/port/esp/freertos/include/port_esp_hosted_host_os.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ enum hardware_type_e {
115115
#define MILLISEC_TO_MICROSEC(x) (1000*(x))
116116

117117
#define MEM_DUMP(s) \
118-
printf("%s free:%lu min-free:%lu lfb-def:%u lfb-8bit:%u\n\n", s, \
118+
ESP_LOGD(TAG, "%s free:%lu min-free:%lu lfb-def:%u lfb-8bit:%u", s, \
119119
(unsigned long int)esp_get_free_heap_size(), (unsigned long int)esp_get_minimum_free_heap_size(), \
120120
heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT), \
121121
heap_caps_get_largest_free_block(MALLOC_CAP_8BIT))
@@ -125,7 +125,7 @@ enum hardware_type_e {
125125
#define HOSTED_CREATE_HANDLE(tYPE, hANDLE) { \
126126
hANDLE = (tYPE *)g_h.funcs->_h_malloc(sizeof(tYPE)); \
127127
if (!hANDLE) { \
128-
printf("%s:%u Mem alloc fail while create handle\n", __func__,__LINE__); \
128+
ESP_LOGE(TAG, "%s:%u Mem alloc fail while create handle", __func__,__LINE__); \
129129
return NULL; \
130130
} \
131131
}
@@ -142,15 +142,15 @@ enum hardware_type_e {
142142
#define HOSTED_CALLOC(struct_name, buff, nbytes, gotosym) do { \
143143
buff = (struct_name *)g_h.funcs->_h_calloc(1, nbytes); \
144144
if (!buff) { \
145-
printf("%s, Failed to allocate memory \n", __func__); \
145+
ESP_LOGE(TAG, "%s, Failed to allocate memory", __func__); \
146146
goto gotosym; \
147147
} \
148148
} while(0);
149149

150150
#define HOSTED_MALLOC(struct_name, buff, nbytes, gotosym) do { \
151151
buff = (struct_name *)g_h.funcs->_h_malloc(nbytes); \
152152
if (!buff) { \
153-
printf("%s, Failed to allocate memory \n", __func__); \
153+
ESP_LOGE(TAG, "%s, Failed to allocate memory", __func__); \
154154
goto gotosym; \
155155
} \
156156
} while(0);

host/port/esp/freertos/src/port_esp_hosted_host_os.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,8 @@ void hosted_log_write(int level,
796796
{
797797
va_list list;
798798
va_start(list, format);
799-
printf(format, list);
799+
/* Use ESP-IDF logging system with proper level and tag */
800+
esp_log_writev((esp_log_level_t)level, tag, format, list);
800801
va_end(list);
801802
}
802803

idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "2.6.7"
1+
version: "2.6.8"
22
description: ESP-Hosted-MCU provide drivers to act any ESP chipset as Wi-Fi or Bluetooth co-processor.
33
url: https://github.com/espressif/esp-hosted-mcu
44
examples:

slave/main/esp_hosted_coprocessor_fw_ver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#define PROJECT_VERSION_MAJOR_1 2
1717
#define PROJECT_VERSION_MINOR_1 6
18-
#define PROJECT_VERSION_PATCH_1 7
18+
#define PROJECT_VERSION_PATCH_1 8
1919

2020
/**
2121
* Macro to convert version number into an integer

tools/check_fw_versions.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,19 @@ def write_host_footer(file_info):
118118
file_info.write(" */\n")
119119
file_info.write("#define ESP_HOSTED_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch))\n")
120120
file_info.write("\n")
121+
file_info.write("/* Extract version components from version value */\n")
122+
file_info.write("#define ESP_HOSTED_VERSION_MAJOR(ver) (((ver) >> 16) & 0xFF)\n")
123+
file_info.write("#define ESP_HOSTED_VERSION_MINOR(ver) (((ver) >> 8) & 0xFF)\n")
124+
file_info.write("#define ESP_HOSTED_VERSION_PATCH(ver) ((ver) & 0xFF)\n")
125+
file_info.write("\n")
126+
file_info.write("/* Format version tuple for printing */\n")
127+
file_info.write("#define ESP_HOSTED_VERSION_PRINTF_ARGS(ver) \\\n")
128+
file_info.write("\tESP_HOSTED_VERSION_MAJOR(ver), \\\n")
129+
file_info.write("\tESP_HOSTED_VERSION_MINOR(ver), \\\n")
130+
file_info.write("\tESP_HOSTED_VERSION_PATCH(ver)\n")
131+
file_info.write("\n")
132+
file_info.write("#define ESP_HOSTED_VERSION_PRINTF_FMT \"%u.%u.%u\"\n")
133+
file_info.write("\n")
121134

122135
def set_coprocessor_version(version: tuple) -> int:
123136
# write the coprocessor file

0 commit comments

Comments
 (0)