{"action":"created","issue":{"url":"https://api.github.com/repos/open62541/open62541/issues/1406","repository_url":"https://api.github.com/repos/open62541/open62541","labels_url":"https://api.github.com/repos/open62541/open62541/issues/1406/labels{/name}","comments_url":"https://api.github.com/repos/open62541/open62541/issues/1406/comments","events_url":"https://api.github.com/repos/open62541/open62541/issues/1406/events","html_url":"https://github.com/open62541/open62541/issues/1406","id":277408284,"number":1406,"title":"port to ESP32","user":{"login":"Gfast2","id":2803903,"avatar_url":"https://avatars2.githubusercontent.com/u/2803903?v=4","gravatar_id":"","url":"https://api.github.com/users/Gfast2","html_url":"https://github.com/Gfast2","followers_url":"https://api.github.com/users/Gfast2/followers","following_url":"https://api.github.com/users/Gfast2/following{/other_user}","gists_url":"https://api.github.com/users/Gfast2/gists{/gist_id}","starred_url":"https://api.github.com/users/Gfast2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gfast2/subscriptions","organizations_url":"https://api.github.com/users/Gfast2/orgs","repos_url":"https://api.github.com/users/Gfast2/repos","events_url":"https://api.github.com/users/Gfast2/events{/privacy}","received_events_url":"https://api.github.com/users/Gfast2/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2017-11-28T14:40:03Z","updated_at":"2017-12-07T16:38:49Z","closed_at":null,"author_association":"NONE","body":"Description\r\n===========\r\nI've hange around for porting this library for days. (for **_months_** actually). I've been nearly there. 💇‍♂️ \r\nBut there is still some thing really just start to beyond what I can understand.\r\n\r\nSo I've made up a simple demo repo to reproduce my working status:\r\n1. [Demo repo](https://github.com/Gfast2/open62541_port)\r\n2. I've fix some small details like `clock_gettime()` -> `gettimeofday`, `gethostname()` -> `tcpip_adapter_get_hostname()` to fit in this enviroment.\r\n3. I've successfully let [ESP-IDF](https://github.com/espressif/esp-idf) drive `cmake` to compile this library.\r\n4. I've put the compiled `open62541.h` and `open62541.c` into where they should be. (under /main/)\r\n5. I've really do my best without a [JTAG Debugger](http://esp-idf.readthedocs.io/en/latest/api-guides/jtag-debugging/index.html) on this platform with the help of `printf()` (in this platform is `ESP_LOGI(TAG, \"things\")`) to understand why the Server crash its own thread and eventually crash the RTOS.\r\n6. I do invested time on asking more experienced seniors. ([issue921](https://github.com/espressif/esp-idf/issues/921))\r\n7. I've written topics about [my issue](https://esp32.com/viewtopic.php?f=2&t=3771) in esp32.com, in order to get more chance to let this up & running.\r\n8. I feel my brain is burning 🔥 (I know this is the fire burning a _SUPER JUNIOR_ me to a much better one )\r\n\r\nI have two concreate question:\r\n1. If neither `gethostname()` nor `tcpip_adapter_get_hostname`(ESP32 specifically) works here, can I pass my IP address some how into `discoveryUrl` instead? (in `ServerNetworkLayerTCP_start`)?\r\n2. I'm stucked on the size of layers (`layer->mappingsSize`). In my observation, there is only one place increases is size: `++layer->mappingsSize`. But this happens in function `ServerNetworkLayerTCP_add()` which is called in function `ServerNetworkLayerTCP_getJobs()`. But in `ServerNetworkLayerTCP_getJobs()`, one line \r\n```\r\nUA_Job *js = malloc(sizeof(UA_Job) * (size_t)((layer->mappingsSize * 2)));\r\n```\r\nit is start to get the size of `mappings`. which will let `malloc()` address `0` space from memory, I believe this is what actally let the programm crash. What I was totally wrong?\r\n\r\nThis is the log I got:\r\n```\r\nI (3804) event: sta ip: 192.168.178.30, mask: 255.255.255.0, gw: 192.168.178.1\r\nV (3804) event: exit default callback\r\nI (3814) APP_MAIN: SYSTEM_EVENT_STA_GOT_IP\r\nI (3814) APP_MAIN: Got IP: 192.168.178.30\r\n\r\nI (3824) APP_MAIN: Fire up OPC UA Server.\r\nI (3824) OPC UA: UA_ServerNetworkLayerTCP: sizeof(ServerNetworkLayerTCP): 40\r\nI (3864) OPC UA: newsock is created.\r\nI (3864) OPC UA: passed bind()\r\n[01/01/1970 00:00:03.750] info/network   TCP network layer listening on opc.tcp://192.168.178.30:4840\r\nI (3874) OPC UA: passed listen()\r\nI (3874) OPC UA: server->config.networkLayersSize: 1\r\nI (3884) OPC UA: jobs: 0\r\nI (3884) OPC UA: ServerNetworkLayerTCP_getJobs() get called\r\nI (3884) OPC UA: sizeof(UA_Job):16\r\nI (3894) OPC UA: (size_t)(layer->mappingsSize):0\r\nW (3894) OPC UA: UA_Job *js size: 0\r\nE (3904) OPC UA: UA_Job *js malloc() failed.\r\nI (3904) OPC UA: jobsSize statement get executed.\r\nI (3914) OPC UA: jobs: 0\r\nI (3914) OPC UA: jobsSize: -2147287040\r\nI (3924) OPC UA: UA_JOBTYPE_BINARYMESSAGE_NETWORKLAYER: 2\r\nI (3924) OPC UA: k:0\r\nGuru Meditation Error: Core  1 panic'ed (LoadProhibited)\r\n. Exception was unhandled.\r\nRegister dump:\r\nPC      : 0x40116b5d  PS      : 0x00060130  A0      : 0x80116c55  A1      : 0x3ffd9450  \r\n0x40116b5d: UA_Server_run_iterate at /home/gfast2/workspace/open62541_port/main/./open62541.c:18737\r\n\r\nA2      : 0x3ffbb324  A3      : 0x00000000  A4      : 0x3f40af44  A5      : 0x00000000  \r\nA6      : 0x80030000  A7      : 0x00000000  A8      : 0x00000000  A9      : 0x3ffd9430  \r\nA10     : 0x00000f5e  A11     : 0x3ffb716c  A12     : 0x3f40e3bc  A13     : 0x0000001f  \r\nA14     : 0x00000001  A15     : 0x00000005  SAR     : 0x00000004  EXCCAUSE: 0x0000001c  \r\nEXCVADDR: 0x00000000  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xfffffffe  \r\n\r\nBacktrace: 0x40116b5d:0x3ffd9450 0x40116c52:0x3ffd9490 0x4010b7a5:0x3ffd94b0\r\n0x40116b5d: UA_Server_run_iterate at /home/gfast2/workspace/open62541_port/main/./open62541.c:18737\r\n\r\n0x40116c52: UA_Server_run at /home/gfast2/workspace/open62541_port/main/./open62541.c:18737\r\n\r\n0x4010b7a5: opcua_task at /home/gfast2/workspace/open62541_port/main/./app_main.c:52\r\n\r\n\r\nEntering gdb stub now.\r\n```\r\n\r\nBackground Information / Reproduction Steps\r\n===========================================\r\nopen62541 git: 6058674f43bab241d4deefa1b55df8eae75dbf8a\r\nesp-idf git: 7e8c2a9c00a6fb05cd5da306b62c4474a999b1a2\r\nOS: Ubuntu Mate 16.10 (64bit in Virtual box)\r\n\r\nChecklist\r\n=========\r\nPlease provide the following information:\r\n\r\n - [x] open62541 Version (release number or git tag):\r\n - [ ] Other OPC UA SDKs used (client or server): \r\n - [x] Operating system:\r\n - [ ] Logs (with `UA_LOGLEVEL` set as low as necessary) attached\r\n - [ ] Wireshark network dump attached\r\n - [x] Self-contained code example attached\r\n - [ ] Critical issue\r\n"},"comment":{"url":"https://api.github.com/repos/open62541/open62541/issues/comments/350023483","html_url":"https://github.com/open62541/open62541/issues/1406#issuecomment-350023483","issue_url":"https://api.github.com/repos/open62541/open62541/issues/1406","id":350023483,"user":{"login":"Gfast2","id":2803903,"avatar_url":"https://avatars2.githubusercontent.com/u/2803903?v=4","gravatar_id":"","url":"https://api.github.com/users/Gfast2","html_url":"https://github.com/Gfast2","followers_url":"https://api.github.com/users/Gfast2/followers","following_url":"https://api.github.com/users/Gfast2/following{/other_user}","gists_url":"https://api.github.com/users/Gfast2/gists{/gist_id}","starred_url":"https://api.github.com/users/Gfast2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gfast2/subscriptions","organizations_url":"https://api.github.com/users/Gfast2/orgs","repos_url":"https://api.github.com/users/Gfast2/repos","events_url":"https://api.github.com/users/Gfast2/events{/privacy}","received_events_url":"https://api.github.com/users/Gfast2/received_events","type":"User","site_admin":false},"created_at":"2017-12-07T16:38:49Z","updated_at":"2017-12-07T16:38:49Z","author_association":"NONE","body":"Today I got little time to going on porting open62541 to ESP-IDF platform. \r\nAfter mangling all uncompatible stuff in ***`ua_network_tcp.c`***, I get successfully cross-compiled the library (again, but this time is _0.3dev_) but in the last step I got the following error log:\r\n\r\n```\r\n[100%] Built target open62541\r\nLD build/open62541_port.elf\r\n/home/gfast2/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/gfast2/workspace/open62541_port03/build/open62541_port.elf: section .tbss.op_timestampsToReturn2 lma 0x40150b98 adjusted to 0x40150b9c\r\n/home/gfast2/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/gfast2/workspace/open62541_port03/build/open62541_port.elf: section .tbss.op_sub lma 0x40150b98 adjusted to 0x40150ba0\r\n/home/gfast2/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/gfast2/workspace/open62541_port03/build/open62541_port.elf: section .tbss.op_publishingEnabled lma 0x40150b98 adjusted to 0x40150ba4\r\n/home/gfast2/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/gfast2/workspace/open62541_port03/build/open62541_port.elf: section .tbss.op_timestampsToReturn lma 0x40150b98 adjusted to 0x40150ba5\r\n/home/gfast2/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/gfast2/workspace/open62541_port03/build/open62541_port.elf: section .tbss.op_releaseContinuationPoint lma 0x40150b98 adjusted to 0x40150ba9\r\n/home/gfast2/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/gfast2/workspace/open62541_port03/build/open62541_port.elf: section .tbss.g_exchangeBufferCallbackHandle lma 0x40150b98 adjusted to 0x40150baa\r\n/home/gfast2/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/gfast2/workspace/open62541_port03/build/open62541_port.elf: section .tbss.g_exchangeBufferCallback lma 0x40150b98 adjusted to 0x40150bae\r\n/home/gfast2/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/gfast2/workspace/open62541_port03/build/open62541_port.elf: section .tbss.g_end lma 0x40150b98 adjusted to 0x40150bb2\r\n/home/gfast2/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/gfast2/workspace/open62541_port03/build/open62541_port.elf: section .tbss.g_pos lma 0x40150b98 adjusted to 0x40150bb6\r\n/home/gfast2/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/gfast2/workspace/open62541_port03/build/open62541_port.elf: section .tbss.g_customTypesArray lma 0x40150b98 adjusted to 0x40150bba\r\n/home/gfast2/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/gfast2/workspace/open62541_port03/build/open62541_port.elf: section .tbss.g_customTypesArraySize lma 0x40150b98 adjusted to 0x40150bbe\r\n/home/gfast2/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: /home/gfast2/workspace/open62541_port03/build/open62541_port.elf: section .tdata.UA_rng lma 0x40150b98 adjusted to 0x40150bc2\r\n/home/gfast2/workspace/open62541_port03/build/main/libmain.a(open62541.o):(.literal.UA_Discovery_cleanupTimedOut+0xc): undefined reference to `access'\r\n/home/gfast2/workspace/open62541_port03/build/main/libmain.a(open62541.o): In function `UA_Discovery_cleanupTimedOut':\r\n/home/gfast2/workspace/open62541_port03/main/./open62541.c:35233: undefined reference to `access'\r\n/home/gfast2/workspace/open62541_port03/build/main/libmain.a(open62541.o): In function `process_RegisterServer':\r\n/home/gfast2/workspace/open62541_port03/main/./open62541.c:35233: undefined reference to `access'\r\ncollect2: error: ld returned 1 exit status\r\n/home/gfast2/esp/esp-idf/make/project.mk:373: recipe for target '/home/gfast2/workspace/open62541_port03/build/open62541_port.elf' failed\r\nmake: *** [/home/gfast2/workspace/open62541_port03/build/open62541_port.elf] Error 1\r\n\r\n```\r\nMy current git Head of open62541is at : f99ef61d49190f5bb48bc0ebc5014cb2916a78f3\r\nESP-IDF is at: 7e8c2a9c00a6fb05cd5da306b62c4474a999b1a2\r\nEverything till now is double checked (with _`git submodule update --init --recursive`_)\r\n\r\nIf someone happen to be interested into this topic, and wanna push it forward. I'd very be pleasure to work together. 👯‍♂️ \r\n"}}
{"actor":{"display_login":"Gfast2"}}