Skip to content

Commit c8116cf

Browse files
authored
Merge branch 'master' into feat/nand_flash_bdl_support
2 parents 110bdac + 0f45b78 commit c8116cf

20 files changed

+637
-25
lines changed

.idf_build_apps.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ manifest_file = [
88
"ccomp_timer/.build-test-rules.yml",
99
"coremark/.build-test-rules.yml",
1010
"esp_daylight/.build-test-rules.yml",
11+
"esp_delta_ota/.build-test-rules.yml",
1112
"esp_cli_commands/.build-test-rules.yml",
1213
"esp_encrypted_img/.build-test-rules.yml",
1314
"esp_flash_dispatcher/.build-test-rules.yml",

esp_cli_commands/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "0.1.2"
1+
version: "0.1.3"
22
description: "esp_cli_commands - Command handling component"
33
url: https://github.com/espressif/idf-extra-components/tree/master/esp_cli_commands
44
dependencies:

esp_cli_commands/src/esp_cli_commands.c

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ void go_through_commands(esp_cli_command_sets_t *cmd_sets, void *cmd_walker_ctx,
129129
}
130130

131131
esp_cli_command_set_t *dynamic_set = cmd_sets ? &cmd_sets->dynamic_set : NULL;
132-
/* it is possible that the set is empty, in which case set dynamic_set to NULL
133-
* to prevent the for loop to try to access a list of commands pointer set to NULL */
134-
if (dynamic_set && !dynamic_set->cmd_ptr_set) {
135-
dynamic_set = NULL;
136-
}
132+
/* Note: unlike FOR_EACH_STATIC_COMMAND which uses the comma operator,
133+
* FOR_EACH_DYNAMIC_COMMAND uses && short-circuit evaluation, so it is safe
134+
* to pass a set with cmd_ptr_set == NULL and cmd_set_size == 0.
135+
* We must NOT null out the set here, because FOR_EACH_DYNAMIC_COMMAND(NULL, ...)
136+
* means "walk ALL dynamic commands", bypassing the set filter. */
137137
esp_cli_dynamic_commands_lock();
138138
FOR_EACH_DYNAMIC_COMMAND(dynamic_set, cmd) {
139139
continue_walk = cmd_walker(cmd_walker_ctx, cmd);
@@ -325,6 +325,13 @@ esp_cli_command_t *esp_cli_commands_find_command(esp_cli_command_set_handle_t cm
325325
find_cmd_ctx_t ctx = { .cmd = NULL, .name = name };
326326
go_through_commands(cmd_set, &ctx, compare_command_name);
327327

328+
/* The "help" command is a built-in registered by esp_cli_commands itself.
329+
* It must always be found regardless of the command set passed by the user.
330+
* If not found in the filtered set, search all commands. */
331+
if (!ctx.cmd && cmd_set != NULL && strcmp(name, "help") == 0) {
332+
go_through_commands(NULL, &ctx, compare_command_name);
333+
}
334+
328335
/* if command was found during the walk, cmd field will be populated with
329336
* the command matching the name given in parameter, otherwise it will still
330337
* be NULL (value set as default value above) */
@@ -541,6 +548,12 @@ void esp_cli_commands_get_completion(esp_cli_command_set_handle_t cmd_set, const
541548
.completion_cb = completion_cb
542549
};
543550
go_through_commands(cmd_set, &ctx, call_completion_cb);
551+
552+
/* The "help" command is a built-in that must always be completable
553+
* regardless of the command set */
554+
if (cmd_set != NULL && len <= 4 && strncmp(buf, "help", len) == 0) {
555+
completion_cb(cb_ctx, "help");
556+
}
544557
}
545558

546559
const char *esp_cli_commands_get_hint(esp_cli_command_set_handle_t cmd_set, const char *buf, int *color, bool *bold)
@@ -740,6 +753,22 @@ static int help_command(void *context, esp_cli_commands_exec_arg_t *cmd_args, in
740753
};
741754
go_through_commands(cmd_sets, &ctx, call_command_funcs);
742755

756+
/* The "help" command is a built-in that must always appear in listings
757+
* regardless of the command set */
758+
if (cmd_sets != NULL) {
759+
esp_cli_command_t *help_cmd = esp_cli_commands_find_command(NULL, "help");
760+
if (help_cmd) {
761+
if (!command_name) {
762+
/* Listing all commands: also print the help entry */
763+
print_verbose_level_arr[verbose_level](cmd_args, help_cmd);
764+
} else if (strcmp(command_name, "help") == 0) {
765+
/* User asked specifically for "help help" */
766+
print_verbose_level_arr[verbose_level](cmd_args, help_cmd);
767+
ctx.command_found = true;
768+
}
769+
}
770+
}
771+
743772
if (command_name && !ctx.command_found) {
744773
ESP_CLI_COMMANDS_FD_PRINT(cmd_args->out_fd, cmd_args->write_func, "help: invalid command name %s\n", command_name);
745774
return 1;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
esp_delta_ota/examples:
2+
enable:
3+
- if: IDF_TARGET == "esp32"
4+
reason: Delta OTA example currently only tested on ESP32
5+
6+
esp_delta_ota/test_apps:
7+
enable:
8+
- if: IDF_TARGET == "esp32"
9+
reason: Delta OTA test app currently only tested on ESP32
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# The following lines of boilerplate have to be in your project's CMakeLists
22
# in this exact order for cmake to work correctly
3-
cmake_minimum_required(VERSION 3.5)
3+
cmake_minimum_required(VERSION 3.16)
44

55
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
6-
set(COMPONENTS main)
76
project(https_delta_ota)
Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1-
idf_component_register(SRCS "main.c"
2-
INCLUDE_DIRS "."
3-
EMBED_TXTFILES ca_cert.pem
4-
PRIV_REQUIRES esp_http_client esp_partition nvs_flash app_update esp_timer esp_wifi console)
1+
set(SRCS "main.c")
2+
set(INCLUDE_DIRS ".")
3+
set(EMBED_TXTFILES "tests/certs/servercert.pem")
4+
set(PRIV_REQS "esp_http_client esp_partition nvs_flash app_update esp_timer esp_wifi console")
5+
6+
if(CONFIG_EXAMPLE_ENABLE_CI_TEST)
7+
list(APPEND SRCS
8+
"tests/test_local_server_ota.c")
9+
list(APPEND INCLUDE_DIRS "tests")
10+
list(APPEND EMBED_TXTFILES "tests/certs/prvtkey.pem")
11+
endif()
12+
13+
idf_component_register(SRCS ${SRCS}
14+
INCLUDE_DIRS ${INCLUDE_DIRS}
15+
EMBED_TXTFILES ${EMBED_TXTFILES}
16+
PRIV_REQUIRES ${PRIV_REQS})
17+
18+
19+
if(CONFIG_EXAMPLE_ENABLE_CI_TEST)
20+
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::esp_https_server)
21+
endif()

esp_delta_ota/examples/https_delta_ota/main/Kconfig.projbuild

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,14 @@ menu "Example Configuration"
2424
help
2525
Maximum time for reception
2626

27+
config EXAMPLE_FIRMWARE_UPG_URL_FROM_STDIN
28+
bool
29+
default y if EXAMPLE_FIRMWARE_UPG_URL = "FROM_STDIN"
30+
31+
config EXAMPLE_ENABLE_CI_TEST
32+
bool "Enable the CI test code"
33+
default n
34+
help
35+
This enables the CI test code i.e. https local server code.
36+
2737
endmenu

esp_delta_ota/examples/https_delta_ota/main/main.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@
3636
#define BUFFSIZE 1024
3737
#define PATCH_HEADER_SIZE 64
3838
#define DIGEST_SIZE 32
39+
#define OTA_URL_SIZE 256
3940
static uint32_t esp_delta_ota_magic = 0xfccdde10;
4041

4142
static const char *TAG = "https_delta_ota_example";
4243

4344
static char ota_write_data[BUFFSIZE + 1] = { 0 };
44-
extern const uint8_t server_cert_pem_start[] asm("_binary_ca_cert_pem_start");
45-
extern const uint8_t server_cert_pem_end[] asm("_binary_ca_cert_pem_end");
45+
extern const uint8_t server_cert_pem_start[] asm("_binary_servercert_pem_start");
46+
extern const uint8_t server_cert_pem_end[] asm("_binary_servercert_pem_end");
47+
48+
#ifdef CONFIG_EXAMPLE_ENABLE_CI_TEST
49+
#include "test_local_server_ota.h"
50+
#endif
4651

4752
const esp_partition_t *current_partition, *destination_partition;
4853
static esp_ota_handle_t ota_handle;
@@ -156,6 +161,24 @@ static void ota_example_task(void *pvParameter)
156161
config.skip_cert_common_name_check = true;
157162
#endif
158163

164+
#ifdef CONFIG_EXAMPLE_ENABLE_CI_TEST
165+
ESP_LOGI(TAG, "Reading OTA URL from stdin");
166+
delta_ota_test_firmware_data_from_stdin(&config.url);
167+
#elif defined(CONFIG_EXAMPLE_FIRMWARE_UPG_URL_FROM_STDIN)
168+
if (strcmp(config.url, "FROM_STDIN") == 0) {
169+
ESP_LOGI(TAG, "Reading OTA URL from stdin");
170+
char url_buf[OTA_URL_SIZE];
171+
example_configure_stdin_stdout();
172+
fgets(url_buf, OTA_URL_SIZE, stdin);
173+
int len = strlen(url_buf);
174+
url_buf[len - 1] = '\0';
175+
config.url = url_buf;
176+
} else {
177+
ESP_LOGE(TAG, "Configuration mismatch: wrong firmware upgrade image url");
178+
abort();
179+
}
180+
#endif
181+
159182
esp_http_client_handle_t client = esp_http_client_init(&config);
160183
if (client == NULL) {
161184
ESP_LOGE(TAG, "Failed to initialise HTTP connection");
@@ -273,5 +296,12 @@ void app_main(void)
273296
* examples/protocols/README.md for more information about this function.
274297
*/
275298
ESP_ERROR_CHECK(example_connect());
299+
300+
#ifdef CONFIG_EXAMPLE_ENABLE_CI_TEST
301+
/* Start the local HTTPS server for CI test */
302+
ESP_ERROR_CHECK(delta_ota_test_start_webserver());
303+
ESP_LOGI(TAG, "Local HTTPS server started for CI test");
304+
#endif
305+
276306
xTaskCreate(&ota_example_task, "ota_example_task", 8192, NULL, 5, NULL);
277307
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-----BEGIN PRIVATE KEY-----
2+
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDhxF/y7bygndxP
3+
wiWLSwS9LY3uBMaJgup0ufNKVhx+FhGQOu44SghuJAaH3KkPUnt6SOM8jC97/yQu
4+
c32WukI7eBZoA12kargSnzdv5m5rZZpd+NznSSpoDArOAONKVlzr25A1+aZbix2m
5+
KRbQS5w9o1N2BriQuSzd8gL0Y0zEk3VkOWXEL+0yFUT144HnErnD+xnJtHe11yPO
6+
2fEzYaGiilh0ddL26PXTugXMZN/8fRVHP50P2OG0SvFpC7vghlLp4VFM1/r3UJn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L2N6WVT481tnxjW4ujgzrFcE4YuxZ
23+
hgwYu9TOCmeqopGwBvGYWLbj+C4mfSahOAs0FfXDoYazuIIGBpuv03UhbpB1Si4O
24+
rJDfRnuCnVWyOTkl54gKJ2OusinhjztBjcrV1XkCgYEA3qNi4uBsPdyz9BZGb/3G
25+
rOMSw0CaT4pEMTLZqURmDP/0hxvTk1polP7O/FYwxVuJnBb6mzDa0xpLFPTpIAnJ
26+
YXB8xpXU69QVh+EBbemdJWOd+zp5UCfXvb2shAeG3Tn/Dz4cBBMEUutbzP+or0nG
27+
vSXnRLaxQhooWm+IuX9SuBQ=
28+
-----END PRIVATE KEY-----
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIDWDCCAkACCQCbF4+gVh/MLjANBgkqhkiG9w0BAQsFADBuMQswCQYDVQQGEwJJ
3+
TjELMAkGA1UECAwCTUgxDDAKBgNVBAcMA1BVTjEMMAoGA1UECgwDRVNQMQwwCgYD
4+
VQQLDANFU1AxDDAKBgNVBAMMA0VTUDEaMBgGCSqGSIb3DQEJARYLZXNwQGVzcC5j
5+
b20wHhcNMjEwNzEyMTIzNjI3WhcNNDEwNzA3MTIzNjI3WjBuMQswCQYDVQQGEwJJ
6+
TjELMAkGA1UECAwCTUgxDDAKBgNVBAcMA1BVTjEMMAoGA1UECgwDRVNQMQwwCgYD
7+
VQQLDANFU1AxDDAKBgNVBAMMA0VTUDEaMBgGCSqGSIb3DQEJARYLZXNwQGVzcC5j
8+
b20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDhxF/y7bygndxPwiWL
9+
SwS9LY3uBMaJgup0ufNKVhx+FhGQOu44SghuJAaH3KkPUnt6SOM8jC97/yQuc32W
10+
ukI7eBZoA12kargSnzdv5m5rZZpd+NznSSpoDArOAONKVlzr25A1+aZbix2mKRbQ
11+
S5w9o1N2BriQuSzd8gL0Y0zEk3VkOWXEL+0yFUT144HnErnD+xnJtHe11yPO2fEz
12+
YaGiilh0ddL26PXTugXMZN/8fRVHP50P2OG0SvFpC7vghlLp4VFM1/r3UJnvL6Oz
13+
3ALc6dhxZEKQucqlpj8l1UegszQToopemtIj0qXTHw2+uUnkUyWIPjPC+wdOAoap
14+
rFTRAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAItw24y565k3C/zENZlxyzto44ud
15+
IYPQXN8Fa2pBlLe1zlSIyuaA/rWQ+i1daS8nPotkCbWZyf5N8DYaTE4B0OfvoUPk
16+
B5uGDmbuk6akvlB5BGiYLfQjWHRsK9/4xjtIqN1H58yf3QNROuKsPAeywWS3Fn32
17+
3//OpbWaClQePx6udRYMqAitKR+QxL7/BKZQsX+UyShuq8hjphvXvk0BW8ONzuw9
18+
RcoORxM0FzySYjeQvm4LhzC/P3ZBhEq0xs55aL2a76SJhq5hJy7T/Xz6NFByvlrN
19+
lFJJey33KFrAf5vnV9qcyWFIo7PYy2VsaaEjFeefr7q3sTFSMlJeadexW2Y=
20+
-----END CERTIFICATE-----

0 commit comments

Comments
 (0)