Skip to content

Commit

Permalink
Merge pull request #8 from igrr/bugfix/minor_fixes
Browse files Browse the repository at this point in the history
Fix build with Ethernet enabled, simplify CMakeLists.txt, add Github workflow file
  • Loading branch information
Pro authored Apr 29, 2021
2 parents 7ae8e5a + 30f5fb1 commit ef88155
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 15 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'build'

on: [push, pull_request]

jobs:
build:
strategy:
matrix:
# Build with the following release/vX.Y branches of ESP-IDF:
idf_ver: ["v4.1", "v4.2", "v4.3"]
# Build for the following chip targets:
idf_target: ["esp32"]
runs-on: ubuntu-20.04
container: espressif/idf:release-${{ matrix.idf_ver }}
steps:
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Build for ESP32
env:
IDF_TARGET: ${{ matrix.idf_target }}
shell: bash
run: |
. ${IDF_PATH}/export.sh
cat sdkconfig.defaults > sdkconfig
echo "CONFIG_ETHERNET_HELPER_CUSTOM_HOSTNAME=y" >> sdkconfig
echo "CONFIG_ETHERNET_HELPER_CUSTOM_HOSTNAME_STR=\"esp32-host.local\"" >> sdkconfig
idf.py build
1 change: 1 addition & 0 deletions components/ethernet_helper/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ static void on_eth_event(void *esp_netif, esp_event_base_t event_base,
static esp_eth_handle_t s_eth_handle = NULL;
static esp_eth_mac_t *s_mac = NULL;
static esp_eth_phy_t *s_phy = NULL;
static void *s_eth_glue = NULL;

static void start(void)
{
Expand Down
18 changes: 6 additions & 12 deletions components/open62541/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@

# This directory needs to exist, otherwise idf_component_register fails
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/open62541")

# Create a dummy file so that idf_component_register succeeds
if(NOT EXISTS "${CMAKE_BINARY_DIR}/open62541/open62541.c")
FILE(WRITE ${CMAKE_BINARY_DIR}/open62541/open62541.c
"#error open62541 not yet generated"
)
endif()

set(USE_ENCRYPTION OFF)

set(ADDITIONAL_REQUIRES "")
Expand All @@ -17,12 +7,15 @@ if (USE_ENCRYPTION)
endif()

idf_component_register(
SRCS ${CMAKE_BINARY_DIR}/open62541/open62541.c custom_getaddrinfo.c
SRCS custom_getaddrinfo.c
REQUIRES lwip vfs freertos ${ADDITIONAL_REQUIRES}
INCLUDE_DIRS ${CMAKE_BINARY_DIR}/open62541
PRIV_INCLUDE_DIRS ${IDF_PATH}/components/freertos/include/freertos
)

set_property(SOURCE ${CMAKE_BINARY_DIR}/open62541/open62541.c PROPERTY GENERATED 1)
target_sources(${COMPONENT_LIB} PRIVATE ${CMAKE_BINARY_DIR}/open62541/open62541.c)
target_include_directories(${COMPONENT_LIB} PUBLIC ${CMAKE_BINARY_DIR}/open62541)

set(open62541_OPTIONS
"-DUA_ARCHITECTURE=freertosLWIP"
"-DUA_ENABLE_AMALGAMATION=ON"
Expand All @@ -35,6 +28,7 @@ set(open62541_OPTIONS
"-DUA_LOGLEVEL=300"
"-DUA_ENABLE_NODESET_COMPILER_DESCRIPTIONS=OFF"
"-DUA_FILE_NS0_BLACKLIST=${CMAKE_CURRENT_SOURCE_DIR}/../../nodes_blacklist.txt"
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
)


Expand Down
4 changes: 2 additions & 2 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ void app_main(void)
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &disconnect_handler, NULL));
#endif // CONFIG_ETHERNET_HELPER_WIFI
#ifdef CONFIG_ETHERNET_HELPER_ETHERNET
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &connect_handler, &server));
ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_DISCONNECTED, &disconnect_handler, &server));
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &connect_handler, NULL));
ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_DISCONNECTED, &disconnect_handler, NULL));
#endif // CONFIG_ETHERNET_HELPER_ETHERNET

ESP_LOGI(TAG, "Waiting for wifi connection. OnConnect will start OPC UA...");
Expand Down
3 changes: 2 additions & 1 deletion sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_example.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions_example.csv"
CONFIG_PARTITION_TABLE_OFFSET=0x9000
CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y

0 comments on commit ef88155

Please sign in to comment.