Skip to content

Commit ecc617e

Browse files
committed
Add support for IDF v5.0
Resolves #979
1 parent 8b5e233 commit ecc617e

36 files changed

+531
-338
lines changed

builder/frameworks/espidf.py

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,15 @@ def generate_project_ld_script(sdk_config, ignore_targets=None):
576576
)
577577

578578

579+
# A temporary workaround to avoid modifying CMake mainly for the "heap" library.
580+
# The "tlsf.c" source file in this library has an include flag relative
581+
# to CMAKE_CURRENT_SOURCE_DIR which breaks PlatformIO builds that have a
582+
# different working directory
583+
def _fix_component_relative_include(config, build_flags, source_index):
584+
source_file_path = config["sources"][source_index]["path"]
585+
build_flags = build_flags.replace("..", os.path.dirname(source_file_path) + "/..")
586+
return build_flags
587+
579588
def prepare_build_envs(config, default_env, debug_allowed=True):
580589
build_envs = []
581590
target_compile_groups = config.get("compileGroups")
@@ -597,6 +606,10 @@ def prepare_build_envs(config, default_env, debug_allowed=True):
597606
for cc in compile_commands:
598607
build_flags = cc.get("fragment")
599608
if not build_flags.startswith("-D"):
609+
if build_flags.startswith("-include") and ".." in build_flags:
610+
source_index = cg.get("sourceIndexes")[0]
611+
build_flags = _fix_component_relative_include(
612+
config, build_flags, source_index)
600613
build_env.AppendUnique(**build_env.ParseFlags(build_flags))
601614
build_env.AppendUnique(CPPDEFINES=defines, CPPPATH=includes)
602615
if sys_includes:
@@ -639,9 +652,17 @@ def compile_source_files(
639652
else:
640653
obj_path = os.path.join(obj_path, os.path.basename(src_path))
641654

655+
preserve_source_file_extension = board.get(
656+
"build.esp-idf.preserve_source_file_extension", False
657+
)
658+
642659
objects.append(
643660
build_envs[compile_group_idx].StaticObject(
644-
target=os.path.splitext(obj_path)[0] + ".o",
661+
target=(
662+
obj_path
663+
if preserve_source_file_extension
664+
else os.path.splitext(obj_path)[0]
665+
) + ".o",
645666
source=os.path.realpath(src_path),
646667
)
647668
)
@@ -1029,7 +1050,14 @@ def _get_installed_pip_packages():
10291050
result = {}
10301051
packages = {}
10311052
pip_output = subprocess.check_output(
1032-
[env.subst("$PYTHONEXE"), "-m", "pip", "list", "--format=json"]
1053+
[
1054+
env.subst("$PYTHONEXE"),
1055+
"-m",
1056+
"pip",
1057+
"list",
1058+
"--format=json",
1059+
"--disable-pip-version-check",
1060+
]
10331061
)
10341062
try:
10351063
packages = json.loads(pip_output)
@@ -1045,9 +1073,13 @@ def _get_installed_pip_packages():
10451073
# https://github.com/platformio/platform-espressif32/issues/635
10461074
"cryptography": ">=2.1.4,<35.0.0",
10471075
"future": ">=0.15.2",
1048-
"pyparsing": ">=2.0.3,<2.4.0",
1076+
"pyparsing": ">=3"
1077+
if platform.get_package_version("framework-espidf")
1078+
.split(".")[1]
1079+
.startswith("5")
1080+
else ">=2.0.3,<2.4.0",
10491081
"kconfiglib": "==13.7.1",
1050-
"idf-component-manager": "~=1.0"
1082+
"idf-component-manager": "~=1.0",
10511083
}
10521084

10531085
installed_packages = _get_installed_pip_packages()
@@ -1471,4 +1503,6 @@ def _skip_prj_source_files(node):
14711503
)
14721504

14731505
# Propagate application offset to debug configurations
1474-
env["INTEGRATION_EXTRA_DATA"].update({"application_offset": env.subst("$ESP32_APP_OFFSET")})
1506+
env["INTEGRATION_EXTRA_DATA"].update(
1507+
{"application_offset": env.subst("$ESP32_APP_OFFSET")}
1508+
)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
idf_component_register(SRCS "esp_eddystone_api.c"
22
"esp_eddystone_demo.c"
3-
INCLUDE_DIRS "")
3+
INCLUDE_DIRS "")
4+
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")

examples/espidf-ble-eddystone/src/esp_eddystone_api.c

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/*
2-
This example code is in the Public Domain (or CC0 licensed, at your option.)
3-
4-
Unless required by applicable law or agreed to in writing, this
5-
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
6-
CONDITIONS OF ANY KIND, either express or implied.
7-
*/
2+
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Unlicense OR CC0-1.0
5+
*/
86

97

108
/****************************************************************************
@@ -62,21 +60,21 @@ Byte offset Field Description
6260
0 Frame Type Value = 0x00
6361
1 Ranging Data Calibrated Tx power at 0 m
6462
2 NID[0] 10-byte Namespace
65-
3 NID[1]
66-
4 NID[2]
67-
5 NID[3]
68-
6 NID[4]
69-
7 NID[5]
70-
8 NID[6]
71-
9 NID[7]
72-
10 NID[8]
73-
11 NID[9]
63+
3 NID[1]
64+
4 NID[2]
65+
5 NID[3]
66+
6 NID[4]
67+
7 NID[5]
68+
8 NID[6]
69+
9 NID[7]
70+
10 NID[8]
71+
11 NID[9]
7472
12 BID[0] 6-byte Instance
75-
13 BID[1]
76-
14 BID[2]
77-
15 BID[3]
78-
16 BID[4]
79-
17 BID[5]
73+
13 BID[1]
74+
14 BID[2]
75+
15 BID[3]
76+
16 BID[4]
77+
17 BID[5]
8078
18 RFU Reserved for future use, must be0x00
8179
19 RFU Reserved for future use, must be0x00
8280
*********************************************/
@@ -135,7 +133,7 @@ static esp_err_t esp_eddystone_url_received(const uint8_t* buf, uint8_t len, esp
135133
//ERROR:too long url
136134
return -1;
137135
}
138-
res->inform.url.tx_power = buf[pos++];
136+
res->inform.url.tx_power = buf[pos++];
139137
url_res = esp_eddystone_resolve_url_scheme(buf+pos, buf+len-1);
140138
memcpy(&res->inform.url.url, url_res, strlen(url_res));
141139
res->inform.url.url[strlen(url_res)] = '\0';
@@ -148,17 +146,17 @@ Byte offset Field Description
148146
0 Frame Type Value = 0x20
149147
1 Version TLM version, value = 0x00
150148
2 VBATT[0] Battery voltage, 1 mV/bit
151-
3 VBATT[1]
149+
3 VBATT[1]
152150
4 TEMP[0] Beacon temperature
153-
5 TEMP[1]
151+
5 TEMP[1]
154152
6 ADV_CNT[0] Advertising PDU count
155-
7 ADV_CNT[1]
156-
8 ADV_CNT[2]
157-
9 ADV_CNT[3]
153+
7 ADV_CNT[1]
154+
8 ADV_CNT[2]
155+
9 ADV_CNT[3]
158156
10 SEC_CNT[0] Time since power-on or reboot
159-
11 SEC_CNT[1]
160-
12 SEC_CNT[2]
161-
13 SEC_CNT[3]
157+
11 SEC_CNT[1]
158+
12 SEC_CNT[2]
159+
13 SEC_CNT[3]
162160
************************************************/
163161
/* decode and store received TLM */
164162
static esp_err_t esp_eddystone_tlm_received(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res)
@@ -211,14 +209,14 @@ esp_err_t esp_eddystone_decode(const uint8_t* buf, uint8_t len, esp_eddystone_re
211209
return -1;
212210
}
213211
uint8_t pos=0;
214-
while(res->common.srv_data_type != EDDYSTONE_SERVICE_UUID)
212+
while(res->common.srv_data_type != EDDYSTONE_SERVICE_UUID)
215213
{
216214
pos++;
217-
if(pos >= len ) {
215+
if(pos >= len ) {
218216
return -1;
219217
}
220218
uint8_t ad_type = buf[pos++];
221-
switch(ad_type)
219+
switch(ad_type)
222220
{
223221
case ESP_BLE_AD_TYPE_FLAG: {
224222
res->common.flags = buf[pos++];
@@ -227,7 +225,7 @@ esp_err_t esp_eddystone_decode(const uint8_t* buf, uint8_t len, esp_eddystone_re
227225
case ESP_BLE_AD_TYPE_16SRV_CMPL: {
228226
uint16_t uuid = little_endian_read_16(buf, pos);
229227
if(uuid != EDDYSTONE_SERVICE_UUID) {
230-
return -1;
228+
return -1;
231229
}
232230
res->common.srv_uuid = uuid;
233231
pos += 2;
@@ -237,7 +235,7 @@ esp_err_t esp_eddystone_decode(const uint8_t* buf, uint8_t len, esp_eddystone_re
237235
uint16_t type = little_endian_read_16(buf, pos);
238236
pos += 2;
239237
uint8_t frame_type = buf[pos++];
240-
if(type != EDDYSTONE_SERVICE_UUID || !(frame_type == EDDYSTONE_FRAME_TYPE_UID || frame_type == EDDYSTONE_FRAME_TYPE_URL ||
238+
if(type != EDDYSTONE_SERVICE_UUID || !(frame_type == EDDYSTONE_FRAME_TYPE_UID || frame_type == EDDYSTONE_FRAME_TYPE_URL ||
241239
frame_type == EDDYSTONE_FRAME_TYPE_TLM)) {
242240
return -1;
243241
}
@@ -251,4 +249,3 @@ esp_err_t esp_eddystone_decode(const uint8_t* buf, uint8_t len, esp_eddystone_re
251249
}
252250
return esp_eddystone_get_inform(buf+pos, len-pos, res);
253251
}
254-

examples/espidf-ble-eddystone/src/esp_eddystone_api.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/*
2-
This example code is in the Public Domain (or CC0 licensed, at your option.)
3-
4-
Unless required by applicable law or agreed to in writing, this
5-
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
6-
CONDITIONS OF ANY KIND, either express or implied.
7-
*/
2+
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Unlicense OR CC0-1.0
5+
*/
86

97

108
#ifndef __ESP_EDDYSTONE_API_H__
@@ -57,8 +55,8 @@ static inline uint32_t big_endian_read_32(const uint8_t *buffer, uint8_t pos)
5755
}
5856

5957
/*
60-
* The esp eddystone API.
61-
* This function is called to decode eddystone information from adv_data.
58+
* The esp eddystone API.
59+
* This function is called to decode eddystone information from adv_data.
6260
* The res points to the result struct.
6361
*
6462
*/
@@ -67,4 +65,3 @@ esp_err_t esp_eddystone_decode(const uint8_t* buf, uint8_t len, esp_eddystone_re
6765
//bool esp_eddystone_is_eddystone_packet(.....);
6866

6967
#endif /* __ESP_EDDYSTONE_API_H__ */
70-

examples/espidf-ble-eddystone/src/esp_eddystone_demo.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/*
2-
This example code is in the Public Domain (or CC0 licensed, at your option.)
3-
4-
Unless required by applicable law or agreed to in writing, this
5-
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
6-
CONDITIONS OF ANY KIND, either express or implied.
7-
*/
2+
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Unlicense OR CC0-1.0
5+
*/
86

97

108
/****************************************************************************
@@ -110,7 +108,7 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* par
110108
// error:The received data is not an eddystone frame packet or a correct eddystone frame packet.
111109
// just return
112110
return;
113-
} else {
111+
} else {
114112
// The received adv data is a correct eddystone frame packet.
115113
// Here, we get the eddystone infomation in eddystone_res, we can use the data in res to do other things.
116114
// For example, just print them:
@@ -143,7 +141,7 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* par
143141
void esp_eddystone_appRegister(void)
144142
{
145143
esp_err_t status;
146-
144+
147145
ESP_LOGI(DEMO_TAG,"Register callback");
148146

149147
/*<! register the scan callback function to the gap module */
@@ -160,14 +158,14 @@ void esp_eddystone_init(void)
160158
esp_eddystone_appRegister();
161159
}
162160

163-
void app_main()
161+
void app_main(void)
164162
{
165163
ESP_ERROR_CHECK(nvs_flash_init());
166164
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
167165
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
168166
esp_bt_controller_init(&bt_cfg);
169167
esp_bt_controller_enable(ESP_BT_MODE_BLE);
170-
168+
171169
esp_eddystone_init();
172170

173171
/*<! set scan parameters */

examples/espidf-ble-eddystone/src/esp_eddystone_protocol.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/*
2-
This example code is in the Public Domain (or CC0 licensed, at your option.)
3-
4-
Unless required by applicable law or agreed to in writing, this
5-
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
6-
CONDITIONS OF ANY KIND, either express or implied.
7-
*/
2+
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Unlicense OR CC0-1.0
5+
*/
86

97
#ifndef __ESP_EDDYSTONE_PROTOCOL_H__
108
#define __ESP_EDDYSTONE_PROTOCOL_H__
@@ -32,7 +30,7 @@
3230
#define EDDYSTONE_TLM_ADV_COUNT_LEN 4
3331
#define EDDYSTONE_TLM_TIME_LEN 4
3432
#define EDDYSTONE_TLM_DATA_LEN (EDDYSTONE_TLM_VERSION_LEN + EDDYSTONE_TLM_BATTERY_VOLTAGE_LEN + \
35-
EDDYSTONE_TLM_TEMPERATURE_LEN + EDDYSTONE_TLM_ADV_COUNT_LEN + EDDYSTONE_TLM_TIME_LEN)
33+
EDDYSTONE_TLM_TEMPERATURE_LEN + EDDYSTONE_TLM_ADV_COUNT_LEN + EDDYSTONE_TLM_TIME_LEN)
3634
//URL
3735
#define EDDYSTONE_URL_SCHEME_LEN 1
3836
#define EDDYSTONE_URL_ENCODED_MAX_LEN 17
@@ -49,8 +47,8 @@ typedef struct {
4947
} __attribute__((packed))esp_eddystone_uid_t;
5048

5149
/* Eddystone URL frame */
52-
typedef struct {
53-
int8_t tx_power; /*<! calibrated Tx power at 0m */
50+
typedef struct {
51+
int8_t tx_power; /*<! calibrated Tx power at 0m */
5452
uint8_t url_scheme; /*<! encoded scheme prefix */
5553
uint8_t encoded_url[0]; /*<! length 1-17 */
5654
} __attribute__((packed))esp_eddystone_url_t;
@@ -98,9 +96,9 @@ typedef struct {
9896
esp_eddystone_frame_t frame;
9997
} __attribute__((packed)) esp_eddystone_packet_t;
10098

101-
/*
102-
* URLs are written only with the graphic printable characters of the US-ASCII coded character set.
103-
* The octets 00-20 and 7F-FF hexadecimal are not used.
99+
/*
100+
* URLs are written only with the graphic printable characters of the US-ASCII coded character set.
101+
* The octets 00-20 and 7F-FF hexadecimal are not used.
104102
* See “Excluded US-ASCII Characters” in RFC 2936.
105103
*
106104
*/
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
idf_component_register(SRCS "coap_server_example_main.c"
2-
INCLUDE_DIRS ".")
2+
INCLUDE_DIRS "."
3+
EMBED_TXTFILES certs/coap_ca.pem certs/coap_server.crt certs/coap_server.key)

0 commit comments

Comments
 (0)