obgm / libcoap

A CoAP (RFC 7252) implementation in C
Other
790 stars 422 forks source link

DTLS Contiki Makefile example #77

Open Gr3yh0und opened 7 years ago

Gr3yh0und commented 7 years ago

I'm trying to get the DTLS example compiled for Contiki but the process failes with:

gr3yh0und@debian:~/Downloads/libcoap/examples/contiki$ make
make -f Makefile.contiki V=1 CONTIKI=contiki TARGET=minimal-net NODE_ADDR=0x1000 server
make[1]: Entering directory '/home/gr3yh0und/Downloads/libcoap/examples/contiki'
make[1]: *** No rule to make target 'obj_minimal-net/coap_io.o', needed by 'contiki-minimal-net.a'.  Stop.
make[1]: Leaving directory '/home/gr3yh0und/Downloads/libcoap/examples/contiki'
Makefile:11: recipe for target 'server' failed
make: *** [server] Error 2

which probably happens due to the fact that coap_io.c is missing in src/platform/contiki. As src/platform/posix/coap_io.c is missing WITH_CONTIKI defs I've tried to copy the current version (dev branch) and build it which ends in:

gcc -Wl,--gc-sections,--undefined=_reset_vector__,--undefined=InterruptVectors,--undefined=_copy_data_init__,--undefined=_clear_bss_init__,--undefined=_end_of_init__ -Wl,-Map=contiki-minimal-net.map,-export-dynamic  server.co \
    contiki-minimal-net.a  -o server.minimal-net
contiki-minimal-net.a(net.o): In function `coap_new_context':
/home/gr3yh0und/Downloads/libcoap/examples/contiki/contiki/apps/libcoap/src/net.c:389: undefined reference to `coap_new_keystore'
/home/gr3yh0und/Downloads/libcoap/examples/contiki/contiki/apps/libcoap/src/net.c:390: undefined reference to `coap_dtls_new_context'
contiki-minimal-net.a(net.o): In function `coap_free_context':
/home/gr3yh0und/Downloads/libcoap/examples/contiki/contiki/apps/libcoap/src/net.c:459: undefined reference to `coap_dtls_free_context'
/home/gr3yh0und/Downloads/libcoap/examples/contiki/contiki/apps/libcoap/src/net.c:460: undefined reference to `coap_free_keystore'
contiki-minimal-net.a(net.o): In function `coap_send_impl':
/home/gr3yh0und/Downloads/libcoap/examples/contiki/contiki/apps/libcoap/src/net.c:613: undefined reference to `coap_dtls_get_session'
/home/gr3yh0und/Downloads/libcoap/examples/contiki/contiki/apps/libcoap/src/net.c:618: undefined reference to `coap_dtls_send'
contiki-minimal-net.a(net.o): In function `coap_read_endpoint':
/home/gr3yh0und/Downloads/libcoap/examples/contiki/contiki/apps/libcoap/src/net.c:909: undefined reference to `coap_dtls_handle_message'
collect2: error: ld returned 1 exit status
contiki/Makefile.include:280: recipe for target 'server.minimal-net' failed

The normal branch is compiling fine and I've also tried an older contiki version.

Background: I'm just starting to get a deeper look into that because I want to compare Contiki vs. RIOT. To make this comparison I need the same application on top. contiki/6lbr brings CoAP/tinyDTLS but is based on erbium as CoAP library. tinyDTLS and libcoap are available in Contiki and RIOT - but not combined - So I thought it could be possible to make the dtls branch work on both somehow.

obgm commented 7 years ago

Unfortunately, it is not that easy. These errors occur because coap_dtls.c, coap_event.c, and coap_keystore.c are missing in Makefile.libcoap. Moreover, in Makefile.contiki, the line CFLAGS += -DWITH_CONTIKI -DHAVE_LIBTINYDTLS would be required.

But then, tinydtls needs to be build. Usually, this would done by adding tinydtls to contiki/apps and putting APPS += tinydtls in Makefile.contiki. But with the current combination of libcoap/tinydtls, this will not work out of the box. You can expect some improvements from the ongoing work by the Contiki folks but there still will be some fine-tuning required to make that fly.