From 93bb67024fc2357d572047cf27bdf7978ac05874 Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Tue, 10 Jul 2018 00:15:43 +0800 Subject: [PATCH] [posix-app] add Makefile for building with android build system (#2864) --- .travis.yml | 6 + .travis/before_install.sh | 6 +- .travis/script.sh | 50 +++ Android.mk | 308 ++++++++++++++++++ include/openthread-config-android.h | 271 +++++++++++++++ src/posix/platform/flash.c | 3 +- src/posix/platform/misc.c | 8 +- .../platform/openthread-core-posix-config.h | 10 + src/posix/platform/radio_spinel.cpp | 8 +- 9 files changed, 664 insertions(+), 6 deletions(-) create mode 100644 Android.mk create mode 100644 include/openthread-config-android.h diff --git a/.travis.yml b/.travis.yml index 944fcbbb4..4820f1b2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,6 +53,12 @@ matrix: - env: BUILD_TARGET="posix-app-ncp" VERBOSE=1 os: linux compiler: gcc + - env: BUILD_TARGET="android-build" VERBOSE=1 + language: android + android: + components: + - tools + - platform-tools - env: BUILD_TARGET="posix-distcheck" CC=clang-5.0 CXX=clang++-5.0 VERBOSE=1 VIRTUAL_TIME=1 os: linux addons: diff --git a/.travis/before_install.sh b/.travis/before_install.sh index 3f8e3b5b5..74d423c0a 100755 --- a/.travis/before_install.sh +++ b/.travis/before_install.sh @@ -48,6 +48,10 @@ cd /tmp || die } } + [ $BUILD_TARGET != android-build ] || { + echo y | sdkmanager "ndk-bundle" + } + [ $BUILD_TARGET != pretty-check ] || { clang-format --version || die } @@ -102,7 +106,7 @@ cd /tmp || die sudo apt-get install llvm-3.4-runtime || die } - [ $BUILD_TARGET != posix -o $CC != clang ] || { + [ $BUILD_TARGET != posix -o "$CC" != clang ] || { sudo apt-get install clang || die } diff --git a/.travis/script.sh b/.travis/script.sh index 29d1a973a..0ee2e0241 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -71,6 +71,56 @@ set -x scan-build --status-bugs -analyze-headers -v make || die } +[ $BUILD_TARGET != android-build ] || { + cd .. + + # Android build system + (mkdir build && cd build && git init && git pull --depth 1 https://android.googlesource.com/platform/build 2db32730e79cafcf13e1f898a7bee7f82b0449d6) + ln -s build/core/main.mk Makefile + + # Workarounds for java checking + export ANDROID_JAVA_HOME=/usr/lib/jvm/java-8-oracle + mkdir bin + cat > bin/java < bin/javac < buildspec.mk < \ + -DOPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE=0 \ + -DOPENTHREAD_FTD=1 \ + -DOPENTHREAD_POSIX=1 \ + -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"openthread-core-posix-config.h\" \ + -DSPINEL_PLATFORM_HEADER=\"spinel_platform.h\" \ + -Wno-error=non-virtual-dtor \ + $(NULL) + +LOCAL_SRC_FILES := \ + src/core/api/border_router_api.cpp \ + src/core/api/channel_manager_api.cpp \ + src/core/api/channel_monitor_api.cpp \ + src/core/api/child_supervision_api.cpp \ + src/core/api/coap_api.cpp \ + src/core/api/commissioner_api.cpp \ + src/core/api/crypto_api.cpp \ + src/core/api/dataset_api.cpp \ + src/core/api/dataset_ftd_api.cpp \ + src/core/api/dhcp6_api.cpp \ + src/core/api/dns_api.cpp \ + src/core/api/icmp6_api.cpp \ + src/core/api/instance_api.cpp \ + src/core/api/ip6_api.cpp \ + src/core/api/jam_detection_api.cpp \ + src/core/api/joiner_api.cpp \ + src/core/api/link_api.cpp \ + src/core/api/link_raw_api.cpp \ + src/core/api/message_api.cpp \ + src/core/api/netdata_api.cpp \ + src/core/api/server_api.cpp \ + src/core/api/tasklet_api.cpp \ + src/core/api/thread_api.cpp \ + src/core/api/thread_ftd_api.cpp \ + src/core/api/tmf_proxy_api.cpp \ + src/core/api/udp_api.cpp \ + src/core/coap/coap.cpp \ + src/core/coap/coap_header.cpp \ + src/core/coap/coap_secure.cpp \ + src/core/common/crc16.cpp \ + src/core/common/instance.cpp \ + src/core/common/logging.cpp \ + src/core/common/locator.cpp \ + src/core/common/message.cpp \ + src/core/common/notifier.cpp \ + src/core/common/settings.cpp \ + src/core/common/string.cpp \ + src/core/common/tasklet.cpp \ + src/core/common/timer.cpp \ + src/core/common/tlvs.cpp \ + src/core/common/trickle_timer.cpp \ + src/core/crypto/aes_ccm.cpp \ + src/core/crypto/aes_ecb.cpp \ + src/core/crypto/hmac_sha256.cpp \ + src/core/crypto/mbedtls.cpp \ + src/core/crypto/pbkdf2_cmac.cpp \ + src/core/crypto/sha256.cpp \ + src/core/mac/mac.cpp \ + src/core/mac/mac_filter.cpp \ + src/core/mac/mac_frame.cpp \ + src/core/meshcop/announce_begin_client.cpp \ + src/core/meshcop/commissioner.cpp \ + src/core/meshcop/dataset.cpp \ + src/core/meshcop/dataset_local.cpp \ + src/core/meshcop/dataset_manager.cpp \ + src/core/meshcop/dataset_manager_ftd.cpp \ + src/core/meshcop/dtls.cpp \ + src/core/meshcop/energy_scan_client.cpp \ + src/core/meshcop/joiner.cpp \ + src/core/meshcop/joiner_router.cpp \ + src/core/meshcop/leader.cpp \ + src/core/meshcop/meshcop.cpp \ + src/core/meshcop/meshcop_tlvs.cpp \ + src/core/meshcop/panid_query_client.cpp \ + src/core/meshcop/timestamp.cpp \ + src/core/net/dhcp6_client.cpp \ + src/core/net/dhcp6_server.cpp \ + src/core/net/dns_client.cpp \ + src/core/net/icmp6.cpp \ + src/core/net/ip6.cpp \ + src/core/net/ip6_address.cpp \ + src/core/net/ip6_filter.cpp \ + src/core/net/ip6_headers.cpp \ + src/core/net/ip6_mpl.cpp \ + src/core/net/ip6_routes.cpp \ + src/core/net/netif.cpp \ + src/core/net/udp6.cpp \ + src/core/thread/address_resolver.cpp \ + src/core/thread/announce_begin_server.cpp \ + src/core/thread/announce_sender.cpp \ + src/core/thread/child_table.cpp \ + src/core/thread/data_poll_manager.cpp \ + src/core/thread/energy_scan_server.cpp \ + src/core/thread/key_manager.cpp \ + src/core/thread/link_quality.cpp \ + src/core/thread/lowpan.cpp \ + src/core/thread/mesh_forwarder.cpp \ + src/core/thread/mesh_forwarder_ftd.cpp \ + src/core/thread/mesh_forwarder_mtd.cpp \ + src/core/thread/mle.cpp \ + src/core/thread/mle_router.cpp \ + src/core/thread/network_data.cpp \ + src/core/thread/network_data_leader.cpp \ + src/core/thread/network_data_leader_ftd.cpp \ + src/core/thread/network_data_local.cpp \ + src/core/thread/network_diagnostic.cpp \ + src/core/thread/panid_query_server.cpp \ + src/core/thread/router_table.cpp \ + src/core/thread/src_match_controller.cpp \ + src/core/thread/thread_netif.cpp \ + src/core/thread/tmf_proxy.cpp \ + src/core/thread/topology.cpp \ + src/core/utils/channel_manager.cpp \ + src/core/utils/channel_monitor.cpp \ + src/core/utils/child_supervision.cpp \ + src/core/utils/heap.cpp \ + src/core/utils/jam_detector.cpp \ + src/core/utils/missing_strlcpy.c \ + src/core/utils/missing_strlcat.c \ + src/core/utils/missing_strnlen.c \ + src/core/utils/slaac_address.cpp \ + src/ncp/hdlc.cpp \ + src/ncp/hdlc.hpp \ + src/ncp/ncp_spi.cpp \ + src/ncp/ncp_spi.hpp \ + src/ncp/spinel.c \ + src/ncp/spinel.h \ + src/ncp/spinel_decoder.hpp \ + src/ncp/spinel_decoder.cpp \ + src/ncp/spinel_encoder.hpp \ + src/ncp/spinel_encoder.cpp \ + src/ncp/spinel_platform.h \ + src/posix/platform/alarm.c \ + src/posix/platform/diag.c \ + src/posix/platform/misc.c \ + src/posix/platform/logging.c \ + src/posix/platform/platform.c \ + src/posix/platform/random.c \ + src/posix/platform/uart.c \ + src/posix/platform/flash.c \ + src/posix/platform/spi-stubs.c \ + src/posix/platform/frame_queue.cpp \ + src/posix/platform/radio_spinel.cpp \ + src/posix/platform/settings.cpp \ + third_party/mbedtls/repo/library/md.c \ + third_party/mbedtls/repo/library/md_wrap.c \ + third_party/mbedtls/repo/library/memory_buffer_alloc.c \ + third_party/mbedtls/repo/library/platform.c \ + third_party/mbedtls/repo/library/sha256.c \ + third_party/mbedtls/repo/library/bignum.c \ + third_party/mbedtls/repo/library/ccm.c \ + third_party/mbedtls/repo/library/cipher.c \ + third_party/mbedtls/repo/library/cipher_wrap.c \ + third_party/mbedtls/repo/library/cmac.c \ + third_party/mbedtls/repo/library/ctr_drbg.c \ + third_party/mbedtls/repo/library/debug.c \ + third_party/mbedtls/repo/library/ecjpake.c \ + third_party/mbedtls/repo/library/ecp_curves.c \ + third_party/mbedtls/repo/library/entropy.c \ + third_party/mbedtls/repo/library/entropy_poll.c \ + third_party/mbedtls/repo/library/ssl_cookie.c \ + third_party/mbedtls/repo/library/ssl_ciphersuites.c \ + third_party/mbedtls/repo/library/ssl_cli.c \ + third_party/mbedtls/repo/library/ssl_srv.c \ + third_party/mbedtls/repo/library/ssl_ticket.c \ + third_party/mbedtls/repo/library/ssl_tls.c \ + third_party/mbedtls/repo/library/aes.c \ + third_party/mbedtls/repo/library/ecp.c \ + $(NULL) + +include $(BUILD_STATIC_LIBRARY) + +include $(CLEAR_VARS) + +LOCAL_MODULE := ot-cli +LOCAL_MODULE_TAGS := eng + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/src \ + $(LOCAL_PATH)/src/cli \ + $(LOCAL_PATH)/src/core \ + $(LOCAL_PATH)/src/posix/platform \ + $(LOCAL_PATH)/third_party/mbedtls/repo/include \ + $(NULL) + +LOCAL_CFLAGS := \ + -D_GNU_SOURCE \ + -DOPENTHREAD_CONFIG_FILE=\ \ + -DOPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE=0 \ + -DOPENTHREAD_ENABLE_NCP_SPI=0 \ + -DOPENTHREAD_ENABLE_NCP_UART=1 \ + -DOPENTHREAD_FTD=1 \ + -DOPENTHREAD_POSIX=1 \ + -DOPENTHREAD_POSIX_APP=2 \ + -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"openthread-core-posix-config.h\" \ + -DSPINEL_PLATFORM_HEADER=\"spinel_platform.h\" \ + -Wno-error=non-virtual-dtor \ + $(NULL) + +LOCAL_SRC_FILES := \ + src/cli/cli.cpp \ + src/cli/cli_coap.cpp \ + src/cli/cli_console.cpp \ + src/cli/cli_dataset.cpp \ + src/cli/cli_uart.cpp \ + src/cli/cli_udp_example.cpp \ + src/posix/main.c \ + $(NULL) + +LOCAL_STATIC_LIBRARIES = ot-core +include $(BUILD_EXECUTABLE) + +include $(CLEAR_VARS) + +LOCAL_MODULE := ot-ncp +LOCAL_MODULE_TAGS := eng + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/src \ + $(LOCAL_PATH)/src/core \ + $(LOCAL_PATH)/src/ncp \ + $(LOCAL_PATH)/src/posix/platform \ + $(LOCAL_PATH)/third_party/mbedtls/repo/include \ + $(NULL) + +LOCAL_CFLAGS := \ + -D_GNU_SOURCE \ + -DOPENTHREAD_CONFIG_FILE=\ \ + -DOPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE=0 \ + -DOPENTHREAD_ENABLE_NCP_SPI=1 \ + -DOPENTHREAD_ENABLE_NCP_UART=0 \ + -DOPENTHREAD_FTD=1 \ + -DOPENTHREAD_POSIX=1 \ + -DOPENTHREAD_POSIX_APP=1 \ + -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"openthread-core-posix-config.h\" \ + -DSPINEL_PLATFORM_HEADER=\"spinel_platform.h\" \ + -Wno-error=non-virtual-dtor \ + $(NULL) + +LOCAL_SRC_FILES := \ + src/ncp/changed_props_set.cpp \ + src/ncp/changed_props_set.hpp \ + src/ncp/ncp_base.cpp \ + src/ncp/ncp_base.hpp \ + src/ncp/ncp_base_mtd.cpp \ + src/ncp/ncp_base_ftd.cpp \ + src/ncp/ncp_base_dispatcher.cpp \ + src/ncp/ncp_buffer.cpp \ + src/ncp/ncp_buffer.hpp \ + src/ncp/ncp_uart.cpp \ + src/ncp/ncp_uart.hpp \ + src/posix/main.c \ + $(NULL) + +LOCAL_STATIC_LIBRARIES = ot-core +include $(BUILD_EXECUTABLE) diff --git a/include/openthread-config-android.h b/include/openthread-config-android.h new file mode 100644 index 000000000..ce4708e95 --- /dev/null +++ b/include/openthread-config-android.h @@ -0,0 +1,271 @@ +/* + * Copyright (c) 2018, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* Define to 1 if your C++ compiler doesn't accept -c and -o together. */ +/* #undef CXX_NO_MINUS_C_MINUS_O */ + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `memcpy' function. */ +/* #undef HAVE_MEMCPY */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if stdbool.h conforms to C99. */ +#define HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define if strlcat exists. */ +/* #undef HAVE_STRLCAT */ + +/* Define if strlcpy exists. */ +/* #undef HAVE_STRLCPY */ + +/* Define if strnlen exists. */ +#define HAVE_STRNLEN 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if the system has the type `_Bool'. */ +#define HAVE__BOOL 1 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* Define to 1 if you want to enable CoAP to an application. */ +#define OPENTHREAD_ENABLE_APPLICATION_COAP 1 + +/* Define to 1 if you want to enable Border Router */ +#define OPENTHREAD_ENABLE_BORDER_ROUTER 1 + +/* Define to 1 if you want to enable log for certification test */ +#define OPENTHREAD_ENABLE_CERT_LOG 1 + +/* Define to 1 if you want to enable channel manager feature */ +#define OPENTHREAD_ENABLE_CHANNEL_MANAGER 0 + +/* Define to 1 if you want to use channel monitor feature */ +#define OPENTHREAD_ENABLE_CHANNEL_MONITOR 0 + +/* Define to 1 if you want to use child supervision feature */ +#define OPENTHREAD_ENABLE_CHILD_SUPERVISION 1 + +/* Define to 1 to enable the commissioner role. */ +#define OPENTHREAD_ENABLE_COMMISSIONER 1 + +/* Define to 1 if you want to enable DHCPv6 Client */ +#define OPENTHREAD_ENABLE_DHCP6_CLIENT 1 + +/* Define to 1 if you want to enable DHCPv6 Server */ +#define OPENTHREAD_ENABLE_DHCP6_SERVER 1 + +/* Define to 1 if you want to use diagnostics module */ +#define OPENTHREAD_ENABLE_DIAG 0 + +/* Define to 1 if you want to enable DNS Client */ +#define OPENTHREAD_ENABLE_DNS_CLIENT 1 + +/* Define to 1 to enable dtls support. */ +#define OPENTHREAD_ENABLE_DTLS 1 + +/* Define to 1 if you want to use jam detection feature */ +#define OPENTHREAD_ENABLE_JAM_DETECTION 1 + +/* Define to 1 to enable the joiner role. */ +#define OPENTHREAD_ENABLE_JOINER 1 + +/* Define to 1 if you want to use legacy network support */ +#define OPENTHREAD_ENABLE_LEGACY 1 + +/* Define to 1 if you want to use MAC filter feature */ +#define OPENTHREAD_ENABLE_MAC_FILTER 1 + +/* Define to 1 to enable network diagnostic for MTD. */ +#define OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC 0 + +/* Define to 1 if you want to enable support for multiple OpenThread + instances. */ +#define OPENTHREAD_ENABLE_MULTIPLE_INSTANCES 0 + +/* Define to 1 to enable the NCP SPI interface. */ +#define OPENTHREAD_ENABLE_NCP_SPI 0 + +/* Define to 1 if using NCP Spinel Encrypter */ +#define OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER 0 + +/* Define to 1 to enable the NCP UART interface. */ +#define OPENTHREAD_ENABLE_NCP_UART 1 + +/* Define to 1 if using NCP vendor hook */ +#define OPENTHREAD_ENABLE_NCP_VENDOR_HOOK 0 + +/* Define to 1 if you want to enable raw link-layer API */ +#define OPENTHREAD_ENABLE_RAW_LINK_API 0 + +/* Define to 1 if you want to enable Service */ +#define OPENTHREAD_ENABLE_SERVICE 1 + +/* Define to 1 to enable the TMF proxy feature. */ +#define OPENTHREAD_ENABLE_TMF_PROXY 1 + +/* OpenThread examples */ +#define OPENTHREAD_EXAMPLES none + +/* Define to 1 if you want to use cc2538 examples */ +/* #undef OPENTHREAD_EXAMPLES_CC2538 */ + +/* Define to 1 if you want to use cc2650 examples */ +/* #undef OPENTHREAD_EXAMPLES_CC2650 */ + +/* Define to 1 if you want to use cc2652 examples */ +/* #undef OPENTHREAD_EXAMPLES_CC2652 */ + +/* Define to 1 if you want to use da15000 examples */ +/* #undef OPENTHREAD_EXAMPLES_DA15000 */ + +/* Define to 1 if you want to use efr32 examples */ +/* #undef OPENTHREAD_EXAMPLES_EFR32 */ + +/* Define to 1 if you want to use emsk examples */ +/* #undef OPENTHREAD_EXAMPLES_EMSK */ + +/* Define to 1 if you want to use gp712 examples */ +/* #undef OPENTHREAD_EXAMPLES_GP712 */ + +/* Define to 1 if you want to use kw41z examples */ +/* #undef OPENTHREAD_EXAMPLES_KW41Z */ + +/* Define to 1 if you want to use nrf52840 examples */ +/* #undef OPENTHREAD_EXAMPLES_NRF52840 */ + +/* Define to 1 if you want to use posix examples */ +/* #undef OPENTHREAD_EXAMPLES_POSIX */ + +/* Define to 1 if you want to use samr21 examples */ +/* #undef OPENTHREAD_EXAMPLES_SAMR21 */ + +/* Name of package */ +#define PACKAGE "openthread" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "openthread-devel@googlegroups.com" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "OPENTHREAD" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "OPENTHREAD gcf8d4ec" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "openthread" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "http://github.com/openthread/openthread" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "gcf8d4ec" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "gcf8d4ec" + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT8_T */ + +/* Define to the type of a signed integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int16_t */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to the type of a signed integer type of width exactly 8 bits if such + a type exists and the standard includes do not define it. */ +/* #undef int8_t */ + +/* Define to the type of an unsigned integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint16_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint8_t */ diff --git a/src/posix/platform/flash.c b/src/posix/platform/flash.c index 31837739d..4ebb61db7 100644 --- a/src/posix/platform/flash.c +++ b/src/posix/platform/flash.c @@ -58,6 +58,7 @@ otError utilsFlashInit(void) struct stat st; bool create = false; const char *offset = getenv("PORT_OFFSET"); + uint16_t index = 0; memset(&st, 0, sizeof(st)); @@ -85,7 +86,7 @@ otError utilsFlashInit(void) if (create) { - for (uint16_t index = 0; index < FLASH_PAGE_NUM; index++) + for (index = 0; index < FLASH_PAGE_NUM; index++) { error = utilsFlashErasePage(index * FLASH_PAGE_SIZE); otEXPECT(error == OT_ERROR_NONE); diff --git a/src/posix/platform/misc.c b/src/posix/platform/misc.c index 52d63d6f2..7d5561460 100644 --- a/src/posix/platform/misc.c +++ b/src/posix/platform/misc.c @@ -44,15 +44,17 @@ static otPlatMcuPowerState gPlatMcuPowerState = OT_PLAT_MCU_POWER_STATE_ON; void otPlatReset(otInstance *aInstance) { + int i = 0; + // Restart the process using execvp. + char *argv[gArgumentsCount + 1]; + #if OPENTHREAD_PLATFORM_USE_PSEUDO_RESET gPlatformPseudoResetWasRequested = true; sPlatResetReason = OT_PLAT_RESET_REASON_SOFTWARE; #else // elif OPENTHREAD_PLATFORM_USE_PSEUDO_RESET - // Restart the process using execvp. - char *argv[gArgumentsCount + 1]; - for (int i = 0; i < gArgumentsCount; ++i) + for (i = 0; i < gArgumentsCount; ++i) { argv[i] = gArguments[i]; } diff --git a/src/posix/platform/openthread-core-posix-config.h b/src/posix/platform/openthread-core-posix-config.h index cf813d228..93f0a0c46 100644 --- a/src/posix/platform/openthread-core-posix-config.h +++ b/src/posix/platform/openthread-core-posix-config.h @@ -91,4 +91,14 @@ */ #define OPENTHREAD_CONFIG_ENABLE_PLATFORM_USEC_TIMER 1 +/** + * @def OPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE + * + * Define to 1 if you want to support microsecond timer in platform. + * + */ +#ifndef OPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE +#define OPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE 1 +#endif + #endif // OPENTHREAD_CORE_POSIX_CONFIG_H_ diff --git a/src/posix/platform/radio_spinel.cpp b/src/posix/platform/radio_spinel.cpp index 6887a034d..c92baa25b 100644 --- a/src/posix/platform/radio_spinel.cpp +++ b/src/posix/platform/radio_spinel.cpp @@ -40,7 +40,9 @@ extern "C" { #include #include #include +#if OPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE #include +#endif #include #include #include @@ -246,6 +248,7 @@ static void LogIfFail(otInstance *aInstance, const char *aText, otError aError) OT_UNUSED_VARIABLE(aError); } +#if OPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE static int OpenPty(const char *aFile, const char *aConfig) { int fd = -1; @@ -308,6 +311,7 @@ static int OpenPty(const char *aFile, const char *aConfig) exit: return fd; } +#endif // OPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE static int OpenUart(const char *aRadioFile, const char *aRadioConfig) { @@ -391,10 +395,12 @@ void RadioSpinel::Init(const char *aRadioFile, const char *aRadioConfig) { mSockFd = OpenUart(aRadioFile, aRadioConfig); } +#if OPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE else if (S_ISREG(st.st_mode)) { mSockFd = OpenPty(aRadioFile, aRadioConfig); } +#endif // OPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE VerifyOrExit(mSockFd != -1, error = OT_ERROR_INVALID_ARGS); error = SendReset(); @@ -621,7 +627,7 @@ void RadioSpinel::HandleValueIs(spinel_prop_key_t aKey, const uint8_t *aBuffer, VerifyOrExit(unpacked > 0, error = OT_ERROR_PARSE); #if !OPENTHREAD_ENABLE_DIAG - otPlatRadioEnergyScanDone(aInstance, maxRssi); + otPlatRadioEnergyScanDone(mInstance, maxRssi); #endif } else if (aKey == SPINEL_PROP_STREAM_DEBUG)