Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openthread porting #40

Open
wants to merge 3 commits into
base: hamilton-combined-v11.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "pkg/openthread/source"]
path = pkg/openthread/source
url = https://github.com/Hyungsin/openthread.git
branch = openthread-v1.0
6 changes: 5 additions & 1 deletion Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,12 @@ ifneq (,$(filter random,$(USEMODULE)))
endif
endif

ifneq (,$(filter openthread,$(USEPKG)))
USEMODULE += openthread_contrib
USEMODULE += mbedcrypto
endif

ifneq (,$(filter openthread_contrib,$(USEMODULE)))
USEMODULE += openthread_contrib_netdev
FEATURES_REQUIRED += cpp
endif

Expand Down
12 changes: 12 additions & 0 deletions core/include/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,18 @@ extern "C" {
puts("Cannot debug, stack too small"); \
} \
} while (0)
#define DEBUG_VPRINT(format, arg) \
do { \
if ((sched_active_thread == NULL) || (sched_active_thread->stack_size > THREAD_EXTRA_STACKSIZE_PRINTF)) { \
vprintf(format, arg); \
} \
else { \
puts("Cannot debug, stack too small"); \
} \
} while (0)
#else
#define DEBUG_PRINT(...) printf(__VA_ARGS__)
#define DEBUG_VPRINT(format, arg) vprintf(format, arg)
#endif

/**
Expand Down Expand Up @@ -93,8 +103,10 @@ extern "C" {
* @note Another name for ::DEBUG_PRINT
*/
#define DEBUG(...) DEBUG_PRINT(__VA_ARGS__)
#define DEBUG_V(format, arg) DEBUG_VPRINT(format, arg)
#else
#define DEBUG(...)
#define DEBUG_V(format, arg)
#endif
/** @} */

Expand Down
16 changes: 16 additions & 0 deletions drivers/at86rf2xx/at86rf2xx_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ static void _irq_handler(void *arg)
netdev_t *dev = (netdev_t *) arg;

if (dev->event_callback) {
#if MODULE_OPENTHREAD
if (((at86rf2xx_t *) dev)->netdev.flags & AT86RF2XX_OPT_TELL_TX_END) {
dev->event_callback(dev, NETDEV_EVENT_ISR2);
} else {
dev->event_callback(dev, NETDEV_EVENT_ISR);
}
#else
dev->event_callback(dev, NETDEV_EVENT_ISR);
#endif
}
}

Expand Down Expand Up @@ -595,6 +603,14 @@ static void _isr(netdev_t *netdev)
dev->idle_state = AT86RF2XX_STATE_RX_AACK_ON;
}
#endif
#endif
#if MODULE_OPENTHREAD
/* Wake up for a while when receiving an ACK with pending bit */
if (trac_status == AT86RF2XX_TRX_STATE__TRAC_SUCCESS_DATA_PENDING) {
dev->idle_state = AT86RF2XX_STATE_RX_AACK_ON;
} else {
dev->idle_state = AT86RF2XX_STATE_SLEEP;
}
#endif
at86rf2xx_set_state(dev, dev->idle_state);
DEBUG("[at86rf2xx] return to state 0x%x\n", dev->idle_state);
Expand Down
1 change: 1 addition & 0 deletions drivers/include/net/netdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ enum {
*/
typedef enum {
NETDEV_EVENT_ISR, /**< driver needs it's ISR handled */
NETDEV_EVENT_ISR2, /**< driver needs it's another ISR handled */
NETDEV_EVENT_RX_STARTED, /**< started to receive a packet */
NETDEV_EVENT_RX_COMPLETE, /**< finished receiving a packet */
NETDEV_EVENT_RX_DATAREQ, /**< receiving a dataReq packet */
Expand Down
44 changes: 31 additions & 13 deletions pkg/openthread/Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,50 @@
PKG_NAME=openthread
PKG_URL=https://github.com/openthread/openthread.git
PKG_VERSION=fbfd76a990b81f007957e1bd774e51bce742e53e
PKG_BUILDDIR ?= $(BINDIRBASE)/pkg/$(BOARD)/$(PKG_NAME)

$(info Compile OpenThread for FTD device)
OPENTHREAD_ARGS+= --enable-cli-app=ftd --enable-application-coap
PKG_BUILDDIR ?= $(RIOTBASE)/pkg/openthread/source

ifneq (,$(filter openthread-cli-ftd,$(USEMODULE)))
$(info Compile OpenThread for FTD device)
OPENTHREAD_ARGS += --enable-cli-app=ftd
endif
ifneq (,$(filter openthread-cli-mtd,$(USEMODULE)))
$(info Compile OpenThread for MTD device)
OPENTHREAD_ARGS += --enable-cli-app=mtd --enable-joiner
endif
ifneq (,$(filter openthread-ncp-ftd,$(USEMODULE)))
$(info Compile OpenThread with NCP)
OPENTHREAD_ARGS += --enable-ncp-app=ftd --with-ncp-bus=uart --enable-commissioner --enable-border-router
endif
OPENTHREAD_ARGS += --enable-application-coap
CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"platform_config.h\"'
$(info $$OPENTHREAD_ARGS is [${OPENTHREAD_ARGS}])

.PHONY: all

OPENTHREAD_COMMON_FLAGS=-fdata-sections -ffunction-sections -Os
all: git-download
all:
cd $(PKG_BUILDDIR) && PREFIX="/" ./bootstrap
cd $(PKG_BUILDDIR) && CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)"\
OBJC="" OBJCXX="" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" \
STRIP="$(STRIP)" \
CPPFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) " \
CPPFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) -D$(CONFIG_FILE)" \
CFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) " \
CXXFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) -fno-exceptions -fno-rtti " \
LDFLAGS="$(OPENTHREAD_COMMON_FLAGS) $(CFLAGS_CPU) -nostartfiles -specs=nano.specs \
-specs=nosys.specs -Wl,--gc-sections -Wl,-Map=map.map " \
./configure --disable-docs --host=$(TARGET_ARCH) --target=$(TARGET_ARCH) \
--prefix=/ --enable-default-logging ${OPENTHREAD_ARGS}
cd $(PKG_BUILDDIR) && DESTDIR=$(PKG_BUILDDIR)/output PREFIX=/ make -j4 --no-print-directory install

cp $(PKG_BUILDDIR)/output/lib/libmbedcrypto.a ${BINDIR}/libmbedcrypto.a
cp $(PKG_BUILDDIR)/output/lib/libopenthread-ftd.a ${BINDIR}/libopenthread.a
cp $(PKG_BUILDDIR)/output/lib/libopenthread-cli-ftd.a ${BINDIR}/libopenthread-cli.a
cp $(PKG_BUILDDIR)/output/lib/libmbedcrypto.a ${BINDIR}/mbedcrypto.a
ifneq (,$(filter openthread-cli-ftd,$(USEMODULE)))
cp $(PKG_BUILDDIR)/output/lib/libopenthread-ftd.a ${BINDIR}/openthread-ftd.a
cp $(PKG_BUILDDIR)/output/lib/libopenthread-cli-ftd.a ${BINDIR}/openthread-cli-ftd.a
endif
ifneq (,$(filter openthread-cli-mtd,$(USEMODULE)))
cp $(PKG_BUILDDIR)/output/lib/libopenthread-mtd.a ${BINDIR}/openthread-mtd.a
cp $(PKG_BUILDDIR)/output/lib/libopenthread-cli-mtd.a ${BINDIR}/openthread-cli-mtd.a
endif
ifneq (,$(filter openthread-ncp-ftd,$(USEMODULE)))
cp $(PKG_BUILDDIR)/output/lib/libopenthread-ftd.a ${BINDIR}/openthread-ftd.a
cp $(PKG_BUILDDIR)/output/lib/libopenthread-ncp-ftd.a ${BINDIR}/openthread-ncp-ftd.a
endif
sed -ie 's/BASE/_BASE/g' $(PKG_BUILDDIR)/output/include/openthread/types.h
include $(RIOTBASE)/pkg/pkg.mk

8 changes: 5 additions & 3 deletions pkg/openthread/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
OPENTHREAD_DIR = $(RIOTBASE)/pkg/openthread
OPENTHREAD_SOURCEDIR = $(RIOTBASE)/pkg/openthread/source

INCLUDES += -I$(OPENTHREAD_DIR)/include \
-I$(OPENTHREAD_DIR)/include/openthread \
-I$(BINDIRBASE)/pkg/$(BOARD)/openthread/output/include \
-I$(BINDIRBASE)/pkg/$(BOARD)/openthread/include/openthread \
-I$(OPENTHREAD_SOURCEDIR)/output/include \
-I$(OPENTHREAD_SOURCEDIR)/include \
-I$(OPENTHREAD_SOURCEDIR)/include/openthread \
-I$(OPENTHREAD_SOURCEDIR)/include/openthread/platform \

ifneq (,$(filter openthread_contrib,$(USEMODULE)))
DIRS += $(OPENTHREAD_DIR)/contrib
DIRS += $(OPENTHREAD_DIR)/contrib/netdev
endif
3 changes: 0 additions & 3 deletions pkg/openthread/contrib/netdev/Makefile

This file was deleted.

186 changes: 0 additions & 186 deletions pkg/openthread/contrib/netdev/openthread_netdev.c

This file was deleted.

Loading