Skip to content

Commit

Permalink
Update dependencies for IDF v5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
atanisoft committed Sep 6, 2023
1 parent 1d34d16 commit f273c4f
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 107 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ jobs:
CONFIG_OLCB_ENABLE_PWM=y
write-mode: overwrite
- name: Build
uses: espressif/esp-idf-ci-action@branch-release-v4.4
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: v5.1.1
path: firmware
- name: Prepare Binaries
run: |
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ firmware/dependencies.lock
firmware/managed_components
firmware/sdkconfig
firmware/sdkconfig.old
firmware/web/*.gz
pcb*/*.*-bak
pcb*/*-backups
pcb*/Outputs/*.g*
Expand Down
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

84 changes: 30 additions & 54 deletions firmware/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,85 +1,61 @@
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.20)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)

set(SUPPORTED_TARGETS esp32)
project(Esp32OlcbIO)

###############################################################################
# Switch from GNU++11 to GNU++14
#
# NOTE: C++14 would be preferred but IDF has dependencies on GNU extensions.
###############################################################################

string(REPLACE "-std=gnu++11" "-std=gnu++14" CXX_OPTIONS "${CXX_COMPILE_OPTIONS}")
idf_build_set_property(CXX_COMPILE_OPTIONS "${CXX_OPTIONS}" REPLACE)

###############################################################################
# Enable usage of std::stoi/stol/etc
###############################################################################

idf_build_set_property(COMPILE_DEFINITIONS "-D_GLIBCXX_USE_C99" APPEND)

###############################################################################
# Search for GZIP application
# Compress the web content with gzip
###############################################################################

FIND_PROGRAM(GZIP
NAMES gzip
PATHS /bin
/usr/bin
/usr/local/bin
)

if (NOT GZIP)
message(FATAL_ERROR "Unable to find 'gzip' program")
endif()

###############################################################################
# Generate a compressed version of web content on-demand
###############################################################################
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/web/index.html.gz
COMMAND ${GZIP} -fk ${CMAKE_CURRENT_SOURCE_DIR}/web/index.html
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/web/index.html
VERBATIM)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/web/index.html.gz PROPERTIES GENERATED TRUE)
file(ARCHIVE_CREATE OUTPUT "${BUILD_DIR}/index.html.gz"
PATHS ${CMAKE_CURRENT_SOURCE_DIR}/web/index.html
FORMAT raw
COMPRESSION GZip
VERBOSE)
set_property(TARGET ${CMAKE_PROJECT_NAME}.elf APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/web/index.html.gz")
"${BUILD_DIR}/index.html.gz")

add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/web/cash.min.js.gz
COMMAND ${GZIP} -fk ${CMAKE_CURRENT_SOURCE_DIR}/web/cash.min.js
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/web/cash.min.js
VERBATIM)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/web/cash.min.js.gz PROPERTIES GENERATED TRUE)
file(ARCHIVE_CREATE OUTPUT "${BUILD_DIR}/cash.min.js.gz"
PATHS "${CMAKE_CURRENT_SOURCE_DIR}/web/cash.min.js"
FORMAT raw
COMPRESSION GZip
VERBOSE)
set_property(TARGET ${CMAKE_PROJECT_NAME}.elf APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/web/cash.min.js.gz")
"${BUILD_DIR}/cash.min.js.gz")

add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/web/spectre.min.css.gz
COMMAND ${GZIP} -fk ${CMAKE_CURRENT_SOURCE_DIR}/web/spectre.min.css
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/web/spectre.min.css
VERBATIM)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/web/spectre.min.css.gz PROPERTIES GENERATED TRUE)
file(ARCHIVE_CREATE OUTPUT "${BUILD_DIR}/spectre.min.css.gz"
PATHS "${CMAKE_CURRENT_SOURCE_DIR}/web/spectre.min.css"
FORMAT raw
COMPRESSION GZip
VERBOSE)
set_property(TARGET ${CMAKE_PROJECT_NAME}.elf APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/web/spectre.min.css.gz")
"${BUILD_DIR}/spectre.min.css.gz")

add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/web/cdi.js.gz
COMMAND ${GZIP} -fk ${CMAKE_CURRENT_SOURCE_DIR}/web/cdi.js
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/web/cdi.js
VERBATIM)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/web/cdi.js.gz PROPERTIES GENERATED TRUE)
file(ARCHIVE_CREATE OUTPUT "${BUILD_DIR}/cdi.js.gz"
PATHS "${CMAKE_CURRENT_SOURCE_DIR}/web/cdi.js"
FORMAT raw
COMPRESSION GZip
VERBOSE)
set_property(TARGET ${CMAKE_PROJECT_NAME}.elf APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/web/cdi.js.gz")
"${BUILD_DIR}/cdi.js.gz")

###############################################################################
# Add web content to the binary
###############################################################################

target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "${CMAKE_CURRENT_SOURCE_DIR}/web/index.html.gz" BINARY)
target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "${CMAKE_CURRENT_SOURCE_DIR}/web/cash.min.js.gz" BINARY)
target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "${CMAKE_CURRENT_SOURCE_DIR}/web/spectre.min.css.gz" BINARY)
target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "${CMAKE_CURRENT_SOURCE_DIR}/web/cdi.js.gz" BINARY)
target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "${BUILD_DIR}/index.html.gz" BINARY)
target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "${BUILD_DIR}/cash.min.js.gz" BINARY)
target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "${BUILD_DIR}/spectre.min.css.gz" BINARY)
target_add_binary_data(${CMAKE_PROJECT_NAME}.elf "${BUILD_DIR}/cdi.js.gz" BINARY)

###############################################################################
# Configuration validations
Expand Down
40 changes: 20 additions & 20 deletions firmware/main/CDIClient.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private:
{
case CDIClientRequest::CMD_READ:
LOG(VERBOSE
, "[CDI:%d] Requesting %zu bytes from %s at offset %zu"
, "[CDI:%" PRIu32 "] Requesting %zu bytes from %s at offset %zu"
, request()->req_id, request()->size
, uint64_to_string_hex(request()->target_node.id).c_str()
, request()->offs);
Expand All @@ -146,7 +146,7 @@ private:
, request()->offs, request()->size);
case CDIClientRequest::CMD_WRITE:
LOG(VERBOSE
, "[CDI:%d] Writing %zu bytes to %s at offset %zu"
, "[CDI:%" PRIu32 "] Writing %zu bytes to %s at offset %zu"
, request()->req_id, request()->size
, uint64_to_string_hex(request()->target_node.id).c_str()
, request()->offs);
Expand All @@ -156,7 +156,7 @@ private:
, openlcb::MemoryConfigDefs::SPACE_CONFIG
, request()->offs, request()->value);
case CDIClientRequest::CMD_UPDATE_COMPLETE:
LOG(VERBOSE, "[CDI:%d] Sending update-complete to %s"
LOG(VERBOSE, "[CDI:%" PRIu32 "] Sending update-complete to %s"
, request()->req_id
, uint64_to_string_hex(request()->target_node.id).c_str());
return invoke_subflow_and_wait(client_, STATE(update_complete)
Expand All @@ -169,28 +169,28 @@ private:
StateFlowBase::Action read_complete()
{
auto b = get_buffer_deleter(full_allocation_result(client_));
LOG(VERBOSE, "[CDI:%d] read bytes request returned with code: %d"
LOG(VERBOSE, "[CDI:%" PRIu32 "] read bytes request returned with code: %d"
, request()->req_id, b->data()->resultCode);
string response;
if (b->data()->resultCode)
{
LOG(VERBOSE, "[CDI:%d] non-zero result code, sending error response."
LOG(VERBOSE, "[CDI:%" PRIu32 "] non-zero result code, sending error response."
, request()->req_id);
response =
StringPrintf(
R"!^!({"res":"error","error":"request failed: %d","id":%d}\m)!^!"
R"!^!({"res":"error","error":"request failed: %d","id":%)!^!" PRIu32 "}"
, b->data()->resultCode, request()->req_id);
}
else
{
LOG(VERBOSE, "[CDI:%d] Received %zu bytes from offset %zu"
LOG(VERBOSE, "[CDI:%" PRIu32 "] Received %zu bytes from offset %zu"
, request()->req_id, request()->size, request()->offs);
if (request()->type == "str")
{
remove_nulls_and_FF(b->data()->payload);
response =
StringPrintf(
R"!^!({"res":"field","tgt":"%s","val":"%s","type":"%s","id":%d})!^!"
R"!^!({"res":"field","tgt":"%s","val":"%s","type":"%s","id":%)!^!" PRIu32 "}"
, request()->target.c_str(), base64_encode(b->data()->payload).c_str()
, request()->type.c_str(), request()->req_id);
}
Expand All @@ -211,7 +211,7 @@ private:
}
response =
StringPrintf(
R"!^!({"res":"field","tgt":"%s","val":"%d","type":"%s","id":%d})!^!"
R"!^!({"res":"field","tgt":"%s","val":"%)!^!" PRIu32 R"!^!(","type":"%s","id":%)!^!" PRIu32 "}"
, request()->target.c_str(), data, request()->type.c_str()
, request()->req_id);
}
Expand All @@ -221,7 +221,7 @@ private:
memcpy(&event_id, b->data()->payload.data(), sizeof(uint64_t));
response =
StringPrintf(
R"!^!({"res":"field","tgt":"%s","val":"%s","type":"%s","id":%d})!^!"
R"!^!({"res":"field","tgt":"%s","val":"%s","type":"%s","id":%)!^!" PRIu32 "}"
, request()->target.c_str()
, uint64_to_string_hex(be64toh(event_id)).c_str()
, request()->type.c_str(), request()->req_id);
Expand All @@ -235,24 +235,24 @@ private:
StateFlowBase::Action write_complete()
{
auto b = get_buffer_deleter(full_allocation_result(client_));
LOG(VERBOSE, "[CDI:%d] write bytes request returned with code: %d"
LOG(VERBOSE, "[CDI:%" PRIu32 "] write bytes request returned with code: %d"
, request()->req_id, b->data()->resultCode);
string response;
if (b->data()->resultCode)
{
LOG(VERBOSE, "[CDI:%d] non-zero result code, sending error response."
LOG(VERBOSE, "[CDI:%" PRIu32 "] non-zero result code, sending error response."
, request()->req_id);
response =
StringPrintf(
R"!^!({"res":"error","error":"request failed: %d","id":%d})!^!"
R"!^!({"res":"error","error":"request failed: %d","id":%)!^!" PRIu32 "}"
, b->data()->resultCode, request()->req_id);
}
else
{
LOG(VERBOSE, "[CDI:%d] Write request processed successfully."
LOG(VERBOSE, "[CDI:%" PRIu32 "] Write request processed successfully."
, request()->req_id);
response =
StringPrintf(R"!^!({"res":"saved","tgt":"%s","id":%d})!^!"
StringPrintf(R"!^!({"res":"saved","tgt":"%s","id":%)!^!" PRIu32 "}"
, request()->target.c_str(), request()->req_id);
}
LOG(VERBOSE, "[CDI-WRITE] %s", response.c_str());
Expand All @@ -263,24 +263,24 @@ private:
StateFlowBase::Action update_complete()
{
auto b = get_buffer_deleter(full_allocation_result(client_));
LOG(VERBOSE, "[CDI:%d] update-complete request returned with code: %d"
LOG(VERBOSE, "[CDI:%" PRIu32 "] update-complete request returned with code: %d"
, request()->req_id, b->data()->resultCode);
string response;
if (b->data()->resultCode)
{
LOG(VERBOSE, "[CDI:%d] non-zero result code, sending error response."
LOG(VERBOSE, "[CDI:%" PRIu32 "] non-zero result code, sending error response."
, request()->req_id);
response =
StringPrintf(
R"!^!({"res":"error","error":"request failed: %d","id":%d}\m)!^!"
R"!^!({"res":"error","error":"request failed: %d","id":%)!^!" PRIu32 "}"
, b->data()->resultCode, request()->req_id);
}
else
{
LOG(VERBOSE, "[CDI:%d] update-complete request processed successfully."
LOG(VERBOSE, "[CDI:%" PRIu32 "] update-complete request processed successfully."
, request()->req_id);
response =
StringPrintf(R"!^!({"res":"update-complete","id":%d})!^!"
StringPrintf(R"!^!({"res":"update-complete","id":%)!^!" PRIu32 "}"
, request()->req_id);
}
LOG(VERBOSE, "[CDI-UPDATE-COMPLETE] %s", response.c_str());
Expand Down
6 changes: 3 additions & 3 deletions firmware/main/PCA9685PWM.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public:
{
.clk_speed = I2C_BUS_SPEED
},
.clk_flags = I2C_SCLK_DEFAULT
.clk_flags = I2C_SCLK_SRC_FLAG_FOR_NOMAL
};

// ensure the PWM frequency is within normal range.
Expand Down Expand Up @@ -398,8 +398,8 @@ private:
(REGISTERS)(REGISTERS::LED0_ON_L + (channel << 2));
ESP_LOGV(TAG, "[%02x:%d] Setting PWM to %d:%d", addr_, channel,
reg_value.on.value, reg_value.off.value);
htole16(reg_value.on.value);
htole16(reg_value.off.value);
reg_value.on.value = htole16(reg_value.on.value);
reg_value.off.value = htole16(reg_value.off.value);
return register_write_multiple((REGISTERS)output_register, &reg_value,
sizeof(OUTPUT_STATE_REGISTER));
}
Expand Down
4 changes: 2 additions & 2 deletions firmware/main/esp32io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ void app_main()
{
// capture the reason for the CPU reset
uint8_t reset_reason = Esp32SocInfo::print_soc_info();
const esp_app_desc_t *app_data = esp_ota_get_app_description();
const esp_app_desc_t *app_data = esp_app_get_description();
LOG(INFO, "%s uses the OpenMRN library\n"
"Copyright (c) 2019-2022, OpenMRN\n"
"Copyright (c) 2019-2023, OpenMRN\n"
"All rights reserved.", app_data->project_name);

// silence all but error messages by default
Expand Down
6 changes: 4 additions & 2 deletions firmware/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
dependencies:
idf: ">=4.4.0,<5.0.0"
idf: ">=5.0"
OpenMRNIDF:
version: 5.1.0
git: https://github.com/atanisoft/OpenMRNIDF.git
HttpServer:
git: https://github.com/atanisoft/HttpServer.git
version: 5.1.0
git: https://github.com/atanisoft/HttpServer.git
6 changes: 3 additions & 3 deletions firmware/main/web_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ WEBSOCKET_STREAM_HANDLER_IMPL(websocket_proc, socket, event, data, len)
if (!cJSON_HasObjectItem(root, "val"))
{
LOG(VERBOSE,
"[WSJSON:%d] Sending CDI READ: offs:%zu size:%zu "
"[WSJSON:%" PRIu32 "] Sending CDI READ: offs:%zu size:%zu "
"type:%s tgt:%s spc:%d", WS_REQ_ID, offs, size,
param_type.c_str(), target.c_str(), space);
b->data()->reset(CDIClientRequest::READ, node_handle,
Expand Down Expand Up @@ -301,7 +301,7 @@ WEBSOCKET_STREAM_HANDLER_IMPL(websocket_proc, socket, event, data, len)
value.push_back(data & 0xFF);
}
LOG(VERBOSE,
"[WSJSON:%d] Sending CDI WRITE: offs:%zu value:%s "
"[WSJSON:%" PRIu32 "] Sending CDI WRITE: offs:%zu value:%s "
"tgt:%s spc:%d", WS_REQ_ID, offs,
raw_value->valuestring, target.c_str(), space);
b->data()->reset(CDIClientRequest::WRITE, node_handle,
Expand All @@ -316,7 +316,7 @@ WEBSOCKET_STREAM_HANDLER_IMPL(websocket_proc, socket, event, data, len)
}
else if (!strcmp(req_type->valuestring, "update-complete"))
{
LOG(VERBOSE, "[WSJSON:%d] Sending UPDATE_COMPLETE to queue",
LOG(VERBOSE, "[WSJSON:%" PRIu32 "] Sending UPDATE_COMPLETE to queue",
WS_REQ_ID);
BufferPtr<CDIClientRequest> b(cdi_client->alloc());
b->data()->reset(CDIClientRequest::UPDATE_COMPLETE,
Expand Down
23 changes: 8 additions & 15 deletions firmware/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,9 @@ CONFIG_COMPILER_STACK_CHECK_MODE_NORM=y
CONFIG_COMPILER_STACK_CHECK=y
CONFIG_COMPILER_WARN_WRITE_STRINGS=y

#
# ESP32 Specific
#
# NOTE: ESP-IDF defaults to 160Mhz mode!
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP32_XTAL_FREQ_AUTO=y
CONFIG_ESP_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP_XTAL_FREQ_AUTO=y

#
# Common ESP-related
Expand Down Expand Up @@ -93,11 +90,12 @@ CONFIG_LWIP_MAX_UDP_PCBS=8
#
# Wi-Fi configuration
#
CONFIG_ESP32_WIFI_NVS_ENABLED=n
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=16
CONFIG_ESP32_WIFI_RX_BA_WIN=16
CONFIG_ESP32_WIFI_RX_IRAM_OPT=n
CONFIG_ESP32_WIFI_IRAM_OPT=n
CONFIG_ESP_WIFI_NVS_ENABLED=n
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=16
CONFIG_ESP_WIFI_RX_BA_WIN=16
CONFIG_ESP_WIFI_RX_IRAM_OPT=n
CONFIG_ESP_WIFI_IRAM_OPT=n

#
# Watchdog configuration
#
Expand Down Expand Up @@ -136,11 +134,6 @@ CONFIG_MBEDTLS_PSK_MODES=y
# see https://github.com/espressif/esp-idf/issues/5321 for details.
CONFIG_WPA_MBEDTLS_CRYPTO=y

#
# HTTP/DNS Server
#
CONFIG_HTTP_DNS_LIGHT_OPENMRN_LIB=n

#
# LittleFS
#
Expand Down

0 comments on commit f273c4f

Please sign in to comment.