open62541-arduino icon indicating copy to clipboard operation
open62541-arduino copied to clipboard

Finally able to build this repo!

Open dj-fiorex opened this issue 4 years ago • 0 comments

Hello everyone! After countless attempts I managed to build this repository. I was able to start the sample server over WiFi and access it with UAExpert. I followed the instructions in the travis file, with two changes:

  1. I cloned the esp-idf repository (https://github.com/espressif/arduino-esp32) to commit with the date closest to the last update of this repo, to be precise this: https://github.com/espressif/arduino-esp32/commit/cec3fca4ad4a39feb463f9298ab3238819732d50
  2. after running the cmake command ... I replaced the line build/CMakeFiles/arduino_opcua.dir/build.make la riga ../arduino-1.8.6/hardware/espressif/esp32/tools/gen_esp32part.py -q {build.path}/partitions.csv /home/<USER>/Projects/opcua/open62541-arduino/build/arduino_opcua.partitions.bin with ../arduino-1.8.6/hardware/espressif/esp32/tools/gen_esp32part.py -q /home/<USER>/Projects/opcua/open62541-arduino/src/partitions.csv /home/<USER>/Projects/opcua/open62541-arduino/build/arduino_opcua.partitions.bin I added follow lines in travis to automatically do this: sed -i 's#../arduino-1.8.6/hardware/espressif/esp32/tools/gen_esp32part.py -q {build.path}/partitions.csv /home/fiorex/Projects/opcua/open62541-arduino/build/arduino_opcua.partitions.bin#../arduino-1.8.6/hardware/espressif/esp32/tools/gen_esp32part.py -q /home/fiorex/Projects/opcua/open62541-arduino/src/partitions.csv /home/fiorex/Projects/opcua/open62541-arduino/build/arduino_opcua.partitions.bin#g' CMakeFiles/arduino_opcua.dir/build.make

with these two fixes I was able to build and test the code.

Now I have a problem with using the ethernet, I have a FeatherWing based on the WIZ5xxx chip, I modified the sketch to use the Ethernet2 library, I tried to build but I was not successful. So I added the following lines in the CMakeLists.txt file:

set(${PROJECT_NAME}_SRCS ${${PROJECT_NAME}_SRCS} "${CMAKE_CURRENT_LIST_DIR}/lib/Ethernet2/src/Ethernet.cpp")
set(${PROJECT_NAME}_SRCS ${${PROJECT_NAME}_SRCS} "${CMAKE_CURRENT_LIST_DIR}/lib/Ethernet2/src/EthernetClient.cpp")
set(${PROJECT_NAME}_SRCS ${${PROJECT_NAME}_SRCS} "${CMAKE_CURRENT_LIST_DIR}/lib/Ethernet2/src/EthernetServer.cpp")
set(${PROJECT_NAME}_SRCS ${${PROJECT_NAME}_SRCS} "${CMAKE_CURRENT_LIST_DIR}/lib/Ethernet2/src/EthernetUdp.cpp")
set(${PROJECT_NAME}_SRCS ${${PROJECT_NAME}_SRCS} "${CMAKE_CURRENT_LIST_DIR}/lib/Ethernet2/src/socket.cpp")
set(${PROJECT_NAME}_SRCS ${${PROJECT_NAME}_SRCS} "${CMAKE_CURRENT_LIST_DIR}/lib/Ethernet2/src/utility/w5100.cpp")
set(${PROJECT_NAME}_SRCS ${${PROJECT_NAME}_SRCS} "${CMAKE_CURRENT_LIST_DIR}/lib/Ethernet2/src/Dhcp.cpp")
set(${PROJECT_NAME}_SRCS ${${PROJECT_NAME}_SRCS} "${CMAKE_CURRENT_LIST_DIR}/lib/Ethernet2/src/Dns.cpp")

include_directories(${CMAKE_CURRENT_LIST_DIR}/lib/Ethernet/src/)

set(${PROJECT_NAME}_ARDLIBS WiFi NTPClient Ethernet)

after copying the Ethernet2 library to src/lib. After this i was able to build and upload my program to the esp32... but another problem occurred!

00:59:22.575 -> Starting up...
00:59:24.539 -> Setting up lan...
00:59:25.243 ->   DHCP assigned IP 192.168.1.202
00:59:25.243 -> Setting up time...
00:59:26.318 -> 2021-02-10 00:12:57.000066 (UTC)
00:59:26.318 -> Setting up opcua...
00:59:26.318 -> Creating server...
00:59:26.503 -> run server...
00:59:26.503 -> /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:1442 (xQueueGenericReceive)- assert failed!
00:59:26.549 -> abort() was called at PC 0x40088071 on core 1
00:59:26.549 -> 
00:59:26.549 -> Backtrace: 0x4008b7a4:0x3ffb3c30 0x4008b9d5:0x3ffb3c50 0x40088071:0x3ffb3c70 0x400f44ae:0x3ffb3cb0 0x400f4692:0x3ffb3cd0 0x400e715c:0x3ffb3cf0 0x400e71c5:0x3ffb3d10 0x40121ce4:0x3ffb3d30 0x4011d1ac:0x3ffb3d80 0x401187d7:0x3ffb3ee0 0x400fb877:0x3ffb3f50 0x401216e6:0x3ffb3fb0 0x40088385:0x3ffb3fd0
00:59:26.549 -> 
00:59:26.549 -> Rebooting...

After investigating the problem and decoding the stacktrace, I think I understand that the problem is the lack of communication between the ethernet2 library and LWIP, the network stack inside the ESP32. I tried to add

#include "tcpip_adapter.h"
tcpip_adapter_init ();

with this change the ESP32 does not restart, I can get an ip address and the OPCUA server seems to start up correctly, unfortunately the server is unreachable

I hope I have contributed to someone like me who MUST use the ARDUINO framework in their project.

Please @Pro can you take a few minutes to look with me and help with the LAN implementation in order to make this repo at least executable both via WIFI and via LAN, for future curiosity or maybe for future developments in which Arduino adapts its build procedure

dj-fiorex avatar Feb 10 '21 00:02 dj-fiorex