Skip to content

Commit 7451ec2

Browse files
authored
Merge pull request #363 from david-cermak/feat/modem_test_ota
feat(modem): Add OTA test to exercise modem layers
2 parents 7d0eb5c + d88cd61 commit 7451ec2

File tree

22 files changed

+1262
-11
lines changed

22 files changed

+1262
-11
lines changed

.github/workflows/modem__build-host-tests.yml

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,19 @@ on:
88
types: [opened, synchronize, reopened, labeled]
99

1010
jobs:
11-
build_esp_modem:
11+
build_esp_modem_examples:
1212
if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push'
13-
name: Build
13+
name: Build examples
1414
strategy:
1515
matrix:
16-
idf_ver: ["latest", "release-v4.2", "release-v4.3", "release-v4.4", "release-v5.0"]
16+
idf_ver: ["latest", "release-v4.3", "release-v4.4", "release-v5.0"]
1717
example: ["pppos_client", "modem_console", "modem_tcp_client", "ap_to_pppos", "simple_cmux_client"]
1818
exclude:
19-
- idf_ver: "release-v4.2"
20-
example: simple_cmux_client
21-
- idf_ver: "release-v4.2"
22-
example: modem_tcp_client
2319
- idf_ver: "release-v4.3"
2420
example: modem_tcp_client
2521
- idf_ver: "release-v4.4"
2622
example: modem_tcp_client
2723
include:
28-
- idf_ver: "release-v4.2"
29-
skip_config: usb
3024
- idf_ver: "release-v4.3"
3125
skip_config: usb
3226
- idf_ver: "release-v5.0"
@@ -50,7 +44,33 @@ jobs:
5044
. ${IDF_PATH}/export.sh
5145
python -m pip install idf-build-apps
5246
cd $GITHUB_WORKSPACE/protocols
53-
python ./ci/build_apps.py components/esp_modem/examples/${{ matrix.example }} -m components/esp_modem/examples/.build-test-rules.yml
47+
python ./ci/build_apps.py components/esp_modem/examples/${{ matrix.example }} -m components/esp_modem/.build-test-rules.yml
48+
49+
build_esp_modem_tests:
50+
if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push'
51+
name: Build tests
52+
strategy:
53+
matrix:
54+
idf_ver: ["release-v5.0", "release-v5.1", "latest"]
55+
test: ["target", "target_ota"]
56+
57+
runs-on: ubuntu-20.04
58+
container: espressif/idf:${{ matrix.idf_ver }}
59+
steps:
60+
- name: Checkout esp-protocols
61+
uses: actions/checkout@v3
62+
with:
63+
path: protocols
64+
- name: Build ${{ matrix.test }} with IDF-${{ matrix.idf_ver }}
65+
env:
66+
EXPECTED_WARNING: ${{ matrix.warning }}
67+
shell: bash
68+
run: |
69+
. ${IDF_PATH}/export.sh
70+
python -m pip install idf-build-apps
71+
cd $GITHUB_WORKSPACE/protocols
72+
python ./ci/build_apps.py components/esp_modem/test/${{ matrix.test }} -m components/esp_modem/.build-test-rules.yml
73+
5474
5575
host_test_esp_modem:
5676
if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push'

components/esp_modem/examples/modem_tcp_client/components/extra_tcp_transports/include/mbedtls_wrap.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Tls {
2929
int read(unsigned char *buf, size_t len);
3030
[[nodiscard]] bool set_own_cert(const_buf crt, const_buf key);
3131
[[nodiscard]] bool set_ca_cert(const_buf crt);
32+
bool set_hostname(const char *name);
3233
virtual int send(const unsigned char *buf, size_t len) = 0;
3334
virtual int recv(unsigned char *buf, size_t len) = 0;
3435
size_t get_available_bytes();

components/esp_modem/examples/modem_tcp_client/components/extra_tcp_transports/mbedtls_wrap.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ bool Tls::set_ca_cert(const_buf crt)
116116
return true;
117117
}
118118

119+
bool Tls::set_hostname(const char *name)
120+
{
121+
int ret = mbedtls_ssl_set_hostname(&ssl_, name);
122+
if (ret < 0) {
123+
print_error("mbedtls_ssl_set_hostname", ret);
124+
return false;
125+
}
126+
return true;
127+
}
128+
119129
Tls::Tls()
120130
{
121131
mbedtls_x509_crt_init(&public_cert_);

components/esp_modem/include/vfs_resource/vfs_create.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232
struct esp_modem_vfs_uart_creator {
3333
const char *dev_name; /*!< VFS device name, e.g. /dev/uart/n */
34-
const struct esp_modem_uart_term_config uart; /*!< UART driver init struct */
34+
struct esp_modem_uart_term_config uart; /*!< UART driver init struct */
3535
};
3636

3737
/**
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The following lines of boilerplate have to be in your project's CMakeLists
2+
# in this exact order for cmake to work correctly
3+
cmake_minimum_required(VERSION 3.8)
4+
5+
set(EXTRA_COMPONENT_DIRS "../.." "../../examples/modem_tcp_client/components")
6+
7+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
8+
project(ota_test)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Target test running OTA update
2+
3+
## Overview
4+
5+
The aim of this test is to exercise the most commonly failing scenario, running OTA over PPPoS with https.
6+
7+
This project opens a data session, runs basic mqtt operations and initiates OTA update.
8+
It supports the following test configurations:
9+
* Using a real modem device (default config)
10+
* Using VFS device (only to exercise VFS DTE)
11+
* Using network-only DCE (connecting directly to PPP server) -- needs some configuration
12+
13+
### Configuring the PPP server
14+
15+
You need to run these applications on your host machine:
16+
* PPP server
17+
```bash
18+
sudo pppd /dev/ttyUSB1 115200 192.168.11.1:192.168.11.2 ms-dns 8.8.8.8 modem local noauth debug nocrtscts nodetach +ipv6
19+
```
20+
* MQTT broker: Running mosquitto in the default config is enough, configuring the broker's URL to the local PPP address: `config.broker.address.uri = "mqtt://192.168.11.1";`
21+
* HTTP server: Need to support HTTP/1.1 (to support ranges). You can use the script `http_server.py` and configure the OTA endpoint as `"https://192.168.11.1:1234/esp32.bin"`
22+
23+
## Potential issues
24+
25+
When running this test it is expected to experience some buffer overflows or connection interruption.
26+
The modem library should recover from these failure modes and continue and complete OTA update.
27+
These issues are expected, since UART ISR is deliberately not placed into IRAM in the test configuration to exhibit some minor communication glitches.
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
idf_component_register(SRCS manual_ota.cpp transport_batch_tls.cpp
2+
INCLUDE_DIRS "."
3+
PRIV_REQUIRES extra_tcp_transports esp_http_client app_update)

0 commit comments

Comments
 (0)