Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test fork base #172

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/lint_build_unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ jobs:
- name: Build ESP-IDF golioth_basics project
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: v5.0
esp_idf_version: v5.1.1
target: esp32
path: 'examples/esp_idf/golioth_basics'
- name: Build ESP-IDF cpp project
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: v5.0
esp_idf_version: v5.1.1
target: esp32
path: 'examples/esp_idf/cpp'
- name: Create empty certs/keys required by certificate_auth project
Expand All @@ -95,13 +95,13 @@ jobs:
- name: Build ESP-IDF certificate_auth project
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: v5.0
esp_idf_version: v5.1.1
target: esp32
path: 'examples/esp_idf/certificate_auth'
- name: Build ESP-IDF magtag_demo project
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: v5.0
esp_idf_version: v5.1.1
target: esp32
path: 'examples/esp_idf/magtag_demo'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_esp32s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Build test project
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: v5.0
esp_idf_version: v5.1.1
target: esp32s3
path: 'examples/esp_idf/test'
- name: Create build tarball for serial flashing
Expand All @@ -49,7 +49,7 @@ jobs:
- name: Rebuild test project with version 1.2.99
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: v5.0
esp_idf_version: v5.1.1
target: esp32s3
path: 'examples/esp_idf/test'
- name: Copy test.bin to test_new.bin
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ The `verify.py` script will return 0 on success (all tests pass), and non-zero o

| Board | Platform | Module | Last Tested Commit |
| --- | --- | --- | --- |
| ESP32-S3-DevKitC-1 | ESP-IDF (v5.0) | ESP32-S3-WROOM-1 | Every commit, CI/CD |
| ESP32-DevKitC-32E | ESP-IDF (v5.0) | ESP32-WROOM-32E | v0.7.0 (Jun 15, 2023) |
| ESP32-C3-DevKitM-1 | ESP-IDF (v5.0) | ESP32-C3-MINI-1 | v0.7.0 (Jun 15, 2023) |
| ESP32-S3-DevKitC-1 | ESP-IDF (v5.1.1) | ESP32-S3-WROOM-1 | Every commit, CI/CD |
| ESP32-DevKitC-32E | ESP-IDF (v5.1.1) | ESP32-WROOM-32E | v0.7.0 (Jun 15, 2023) |
| ESP32-C3-DevKitM-1 | ESP-IDF (v5.1.1) | ESP32-C3-MINI-1 | v0.7.0 (Jun 15, 2023) |
| CY8CPROTO-062-4343W | ModusToolbox (3.0.0) | PSoC® 6 CYW4343W | v0.7.0 (Jun 15, 2023) |
6 changes: 3 additions & 3 deletions examples/esp_idf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

This repo contains a set of examples intended to build
and run in the latest release of esp-idf
(currently [5.0](https://github.com/espressif/esp-idf/releases/tag/v5.0)).
(currently [5.1.1](https://github.com/espressif/esp-idf/releases/tag/v5.1.1)).

### Install esp-idf

Install version 5.0 of esp-idf using the
Install version 5.1.1 of esp-idf using the
[installation directions from Espressif](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html#installation).
This is the version of esp-idf this SDK is tested against.

Expand All @@ -16,7 +16,7 @@ For Linux users, you can install esp-idf with these commands:
sudo apt-get install git wget flex bison gperf python3 python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
mkdir -p ~/esp
cd ~/esp
git clone --recursive https://github.com/espressif/esp-idf.git -b v5.0
git clone --recursive https://github.com/espressif/esp-idf.git -b v5.1.1
cd esp-idf
./install.sh all
```
Expand Down
3 changes: 1 addition & 2 deletions examples/esp_idf/certificate_auth/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n

# TODO - re-enable once resolved: https://github.com/espressif/esp-idf/issues/10322
#CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y

# Default sdkconfig parameters to use the OTA
# partition table layout, with a 4MB flash size
Expand Down
3 changes: 1 addition & 2 deletions examples/esp_idf/cpp/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n

# TODO - re-enable once resolved: https://github.com/espressif/esp-idf/issues/10322
#CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y

# GLTH_LOGX statements will automatically upload to Golioth Logs service
CONFIG_GOLIOTH_AUTO_LOG_TO_CLOUD=1
Expand Down
5 changes: 1 addition & 4 deletions examples/esp_idf/golioth_basics/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n

# TODO - re-enable once resolved: https://github.com/espressif/esp-idf/issues/10322
# Until then, optimize for performance, otherwise IRAM will overflow (BLE stack uses a lot of IRAM).
#CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y

# OTA Partition Table
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
Expand Down
3 changes: 1 addition & 2 deletions examples/esp_idf/magtag_demo/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n

# TODO - re-enable once resolved: https://github.com/espressif/esp-idf/issues/10322
#CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y

# Refer to Adafruit schematic:
# https://cdn-learn.adafruit.com/assets/assets/000/096/946/original/adafruit_products_MagTag_sch.png?1605026160
Expand Down
4 changes: 2 additions & 2 deletions examples/esp_idf/test/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n

# TODO - re-enable once resolved: https://github.com/espressif/esp-idf/issues/10322
#CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y

CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
Expand All @@ -24,5 +23,6 @@ CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n
CONFIG_GOLIOTH_ALLOCATION_TRACKING=1
CONFIG_ESP_COREDUMP_DECODE=y

CONFIG_GOLIOTH_COAP_HOST_URI="coaps://coap.golioth.dev"
2 changes: 1 addition & 1 deletion external/libcoap
Submodule libcoap updated 212 files
13 changes: 8 additions & 5 deletions port/esp_idf/components/coap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,33 @@ set(sdk_port ${sdk_root}/port)
set(libcoap_dir ${sdk_root}/external/libcoap)

set(libcoap_srcs
"${libcoap_dir}/src/block.c"
"${libcoap_dir}/src/coap_address.c"
"${libcoap_dir}/src/coap_asn1.c"
"${libcoap_dir}/src/coap_async.c"
"${libcoap_dir}/src/coap_block.c"
"${libcoap_dir}/src/coap_cache.c"
"${libcoap_dir}/src/coap_debug.c"
"${libcoap_dir}/src/coap_dtls.c"
"${libcoap_dir}/src/coap_encode.c"
"${libcoap_dir}/src/coap_event.c"
"${libcoap_dir}/src/coap_hashkey.c"
"${libcoap_dir}/src/coap_io.c"
"${libcoap_dir}/src/coap_layers.c"
"${libcoap_dir}/src/coap_mbedtls.c"
"${libcoap_dir}/src/coap_mem.c"
"${libcoap_dir}/src/coap_notls.c"
"${libcoap_dir}/src/coap_net.c"
"${libcoap_dir}/src/coap_netif.c"
"${libcoap_dir}/src/coap_option.c"
"${libcoap_dir}/src/coap_pdu.c"
"${libcoap_dir}/src/coap_prng.c"
"${libcoap_dir}/src/coap_resource.c"
"${libcoap_dir}/src/coap_session.c"
"${libcoap_dir}/src/coap_str.c"
"${libcoap_dir}/src/coap_subscribe.c"
"${libcoap_dir}/src/coap_tcp.c"
"${libcoap_dir}/src/coap_time.c"
"${libcoap_dir}/src/coap_uri.c"
"${libcoap_dir}/src/net.c"
"${libcoap_dir}/src/pdu.c"
"${libcoap_dir}/src/resource.c"
"${libcoap_dir}/src/coap_ws.c"
)

idf_component_register(
Expand Down
7 changes: 4 additions & 3 deletions port/esp_idf/libcoap/include/coap3/coap.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ extern "C" {
#include "coap3/libcoap.h"

#include "coap3/coap_forward_decls.h"
#include "coap3/block.h"
#include "coap3/coap_address.h"
#include "coap3/coap_async.h"
#include "coap3/coap_block.h"
#include "coap3/coap_cache.h"
#include "coap3/coap_debug.h"
#include "coap3/coap_dtls.h"
Expand All @@ -36,13 +36,14 @@ extern "C" {
#include "coap3/coap_mem.h"
#include "coap3/coap_net.h"
#include "coap3/coap_option.h"
#include "coap3/coap_pdu.h"
#include "coap3/coap_prng.h"
#include "coap3/coap_str.h"
#include "coap3/coap_resource.h"
#include "coap3/coap_subscribe.h"
#include "coap3/coap_time.h"
#include "coap3/coap_uri.h"
#include "coap3/pdu.h"
#include "coap3/resource.h"
#include "coap3/coap_ws.h"

#ifdef __cplusplus
}
Expand Down
6 changes: 6 additions & 0 deletions port/esp_idf/libcoap/include/coap_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,10 @@

#define HAVE_GETRANDOM

#define COAP_WITH_LIBMBEDTLS

#define COAP_CLIENT_SUPPORT 1
#define COAP_IPV4_SUPPORT 1
#define COAP_WS_SUPPORT 0

#endif /* _CONFIG_H_ */
18 changes: 11 additions & 7 deletions port/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,34 @@ zephyr_library_sources(
../../external/heatshrink/src/heatshrink_decoder.c

# libcoap
../../external/libcoap/src/block.c
../../external/libcoap/src/coap_address.c
../../external/libcoap/src/coap_asn1.c
../../external/libcoap/src/coap_async.c
../../external/libcoap/src/coap_block.c
../../external/libcoap/src/coap_cache.c
../../external/libcoap/src/coap_debug.c
../../external/libcoap/src/coap_dtls.c
../../external/libcoap/src/coap_encode.c
../../external/libcoap/src/coap_event.c
../../external/libcoap/src/coap_hashkey.c
../../external/libcoap/src/coap_layers.c
../../external/libcoap/src/coap_mem.c
../../external/libcoap/src/coap_net.c
../../external/libcoap/src/coap_netif.c
../../external/libcoap/src/coap_option.c
../../external/libcoap/src/coap_pdu.c
../../external/libcoap/src/coap_prng.c
../../external/libcoap/src/coap_resource.c
../../external/libcoap/src/coap_session.c
../../external/libcoap/src/coap_str.c
../../external/libcoap/src/coap_subscribe.c
../../external/libcoap/src/coap_tcp.c
../../external/libcoap/src/coap_uri.c
../../external/libcoap/src/net.c
../../external/libcoap/src/pdu.c
../../external/libcoap/src/resource.c
libcoap/io.c
../../external/libcoap/src/coap_ws.c
libcoap/coap_io_zephyr.c
libcoap/coap_time.c
libcoap/coap_zephyrtls.c
libcoap/log.c
libcoap/time.c
libcoap/tls.c

# miniz
../../external/miniz/miniz_tinfl.c
Expand Down
39 changes: 25 additions & 14 deletions port/zephyr/libcoap/io.c → port/zephyr/libcoap/coap_io_zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ unsigned int coap_io_prepare_io(

*num_sockets = 0;

#ifndef WITHOUT_ASYNC
#if COAP_ASYNC_SUPPORT
/* Check to see if we need to send off any Async requests */
timeout = coap_check_async(ctx, now);
#endif /* WITHOUT_ASYNC */
#endif /* COAP_ASYNC_SUPPORT */

/* Check to see if we need to send off any retransmit request */
nextpdu = coap_peek_next(ctx);
Expand Down Expand Up @@ -186,7 +186,7 @@ void coap_packet_get_memmapped(coap_packet_t* packet, unsigned char** address, s

ssize_t coap_socket_send(
coap_socket_t* sock,
coap_session_t* session,
const coap_session_t* session,
const uint8_t* data,
size_t data_len) {
LOG_DBG("coap_socket_send()");
Expand Down Expand Up @@ -215,6 +215,16 @@ int coap_socket_connect_udp(
goto close_socket;
}

// If Connection IDs are enabled, set socket option to send CIDs, but not require that the
// server sends one in return.
#ifdef CONFIG_MBEDTLS_SSL_DTLS_CONNECTION_ID
int ENABLED = 1;
ret = zsock_setsockopt(sock->fd, SOL_TLS, TLS_DTLS_CID, &ENABLED, sizeof(ENABLED));
if (ret < 0) {
goto close_socket;
}
#endif /* CONFIG_MBEDTLS_SSL_DTLS_CONNECTION_ID */

if (session->proto == COAP_PROTO_UDP) {
ret = zsock_connect(sock->fd, &connect_addr.addr.sa, connect_addr.size);
if (ret < 0) {
Expand Down Expand Up @@ -261,33 +271,33 @@ void coap_socket_close(coap_socket_t* sock) {
sock->fd = -1;
}

ssize_t coap_network_read(coap_socket_t* sock, coap_packet_t* packet) {
ssize_t coap_socket_recv(coap_socket_t* sock, coap_packet_t* packet) {
ssize_t ret;

if ((sock->flags & COAP_SOCKET_CAN_READ) == 0) {
LOG_DBG("coap_network_read: COAP_SOCKET_CAN_READ not set");
LOG_DBG("coap_socket_recv: COAP_SOCKET_CAN_READ not set");
return -1;
}

/* clear has-data flag */
sock->flags &= ~COAP_SOCKET_CAN_READ;

if (!(sock->flags & COAP_SOCKET_CONNECTED)) {
LOG_DBG("coap_network_read: !COAP_SOCKET_CONNECTED");
LOG_DBG("coap_socket_recv: !COAP_SOCKET_CONNECTED");
return -1;
}

ret = zsock_recv(sock->fd, packet->payload, COAP_RXBUFFER_SIZE, 0);
if (ret < 0) {
if (errno == ECONNREFUSED || errno == EHOSTUNREACH) {
/* client-side ICMP destination unreachable, ignore it */
LOG_WRN("%s: coap_network_read: ICMP: %s",
LOG_WRN("%s: coap_socket_recv: ICMP: %s",
sock->session ? coap_session_str(sock->session) : "",
strerror(errno));
return -2;
}

LOG_WRN("%s: coap_network_read: %s",
LOG_WRN("%s: coap_socket_recv: %s",
sock->session ? coap_session_str(sock->session) : "",
strerror(errno));

Expand All @@ -306,10 +316,11 @@ ssize_t coap_network_read(coap_socket_t* sock, coap_packet_t* packet) {
return -1;
}

ssize_t coap_network_send(
coap_socket_t* sock,
const coap_session_t* session,
const uint8_t* data,
size_t datalen) {
return -1;
const char *
coap_socket_format_errno(int error) {
return strerror(error);
}
const char *
coap_socket_strerror(void) {
return coap_socket_format_errno(errno);
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int coap_dtls_zephyr_connect(coap_session_t* session) {
}

int coap_dtls_send(coap_session_t* session, const uint8_t* data, size_t data_len) {
return coap_session_send(session, data, data_len);
return (int)session->sock.lfunc[COAP_LAYER_TLS].l_write(session, data, data_len);
}

void coap_dtls_startup(void) {}
Expand Down
7 changes: 4 additions & 3 deletions port/zephyr/libcoap/include/coap3/coap.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ extern "C" {
#include "coap3/libcoap.h"

#include "coap3/coap_forward_decls.h"
#include "coap3/block.h"
#include "coap3/coap_address.h"
#include "coap3/coap_async.h"
#include "coap3/coap_block.h"
#include "coap3/coap_cache.h"
#include "coap3/coap_debug.h"
#include "coap3/coap_dtls.h"
Expand All @@ -20,13 +20,14 @@ extern "C" {
#include "coap3/coap_mem.h"
#include "coap3/coap_net.h"
#include "coap3/coap_option.h"
#include "coap3/coap_pdu.h"
#include "coap3/coap_prng.h"
#include "coap3/coap_str.h"
#include "coap3/coap_resource.h"
#include "coap3/coap_subscribe.h"
#include "coap3/coap_time.h"
#include "coap3/coap_uri.h"
#include "coap3/pdu.h"
#include "coap3/resource.h"
#include "coap3/coap_ws.h"

#ifdef __cplusplus
}
Expand Down
Loading
Loading