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

TCPlp #23

Open
wants to merge 3 commits into
base: hamilton-combined-v8.0
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
24 changes: 24 additions & 0 deletions Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,26 @@ ifneq (,$(filter gnrc_netapi_mbox,$(USEMODULE)))
USEMODULE += core_mbox
endif

ifneq (,$(filter gnrc_sock_tcp_freebsd,$(USEMODULE)))
USEMODULE += gnrc_tcp_freebsd
USEMODULE += gnrc_sock_tcp_freebsd_zalloc
USEMODULE += sock_tcp_freebsd
endif

ifneq (,$(filter gnrc_tcp_freebsd,$(USEMODULE)))
USEMODULE += gnrc_tcp_freebsd_internal
USEMODULE += gnrc_tcp_freebsd_blip
USEMODULE += task_sched
endif

ifneq (,$(filter gnrc_tcp_freebsd_internal,$(USEMODULE)))
USEMODULE += gnrc_tcp_freebsd_internal_cc
endif

ifneq (,$(filter task_sched,$(USEMODULE)))
USEMODULE += xtimer
endif

ifneq (,$(filter netdev_tap,$(USEMODULE)))
USEMODULE += netif
USEMODULE += netdev_eth
Expand Down Expand Up @@ -503,6 +523,10 @@ ifneq (,$(filter %_conn_tcp,$(USEMODULE)))
USEMODULE += conn_tcp
endif

ifneq (,$(filter %_conn_tcp_freebsd,$(USEMODULE)))
USEMODULE += conn_tcp_freebsd
endif

ifneq (,$(filter %_conn_udp,$(USEMODULE)))
USEMODULE += conn_udp
endif
Expand Down
47 changes: 47 additions & 0 deletions boards/hamilton/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,53 @@ extern "C" {

#define PM_BLOCKER_INITIAL { .val_u32=0x00000000 }

/**
* @name Network configuration
* @{
*/
#ifndef DUTYCYCLE_EN
#define DUTYCYCLE_EN (1)
#endif

#ifndef DUTYCYCLE_WAKEUP_INTERVAL
#define DUTYCYCLE_WAKEUP_INTERVAL 20000UL /* Don't change it w/o particular reasons */
#endif

#ifndef DUTYCYCLE_SLEEP_INTERVAL
#define DUTYCYCLE_SLEEP_INTERVAL 2000000UL
#endif

#ifndef DUTYCYCLE_SLEEP_INTERVAL_MIN
#define DUTYCYCLE_SLEEP_INTERVAL_MIN 20000UL
#endif

#ifndef DUTYCYCLE_SLEEP_INTERVAL_MAX
#define DUTYCYCLE_SLEEP_INTERVAL_MAX 5000000UL /* 1) When it is ZERO, a leaf node does not send beacons
(i.e., extremely low duty-cycle,
but downlink transmission is disabled)
2) Router and leaf node should have same sleep interval.
Router does not sleep
but uses the value for downlink transmissions */
#endif

#define ROUTER (0) /* Plugged-in router */
#define LEAF_NODE (1-ROUTER) /* Duty-cycling node */

#define HARDWARE_CSMA_EN (0)

#define HARDWARE_CSMA_MAX_TRIES (5)
#define HARDWARE_CSMA_MIN_BACKOFF_EXP (3) /* Hardware default. */
#define HARDWARE_CSMA_MAX_BACKOFF_EXP (5) /* Hardware default. */
#define HARDWARE_MAX_FRAME_RETRIES (0) /* No delay between these. */

#define SOFTWARE_MAX_FRAME_RETRIES (3)
#define SOFTWARE_FRAME_RETRY_DELAY_MICROS (0)
#define SOFTWARE_CSMA_MAX_TRIES (5)
#define SOFTWARE_CSMA_BACKOFF_MICROS (320)
#define SOFTWARE_CSMA_MIN_BACKOFF_EXP (3) /* Hardware default. */
#define SOFTWARE_CSMA_MAX_BACKOFF_EXP (5) /* Hardware default. */
/** @} */

/**
* @name Timer peripheral configuration
* @{
Expand Down
57 changes: 39 additions & 18 deletions boards/samr21-xpro/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,45 @@
export CPU = samd21
export CPU_MODEL = samr21g18a

# set default port depending on operating system
PORT_LINUX ?= /dev/ttyACM0
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
# debugger config
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
export DEBUGSERVER = JLinkGDBServer -device atsamr21e18a -if swd
export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh

# setup serial terminal
include $(RIOTMAKE)/tools/serial.inc.mk
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export FFLAGS = $(BINDIR) $(HEXFILE)

# Add board selector (USB serial) to OpenOCD options if specified.
# Use /dist/tools/usb-serial/list-ttys.sh to find out serial number.
# Usage: SERIAL="ATML..." BOARD="samr21-xpro" make flash
ifneq (,$(SERIAL))
export OPENOCD_EXTRA_INIT += "-c cmsis_dap_serial $(SERIAL)"
SERIAL_TTY = $(firstword $(shell $(RIOTBASE)/dist/tools/usb-serial/find-tty.sh $(SERIAL)))
ifeq (,$(SERIAL_TTY))
$(error Did not find a device with serial $(SERIAL))
endif
PORT_LINUX := $(SERIAL_TTY)
endif
CFLAGS += -O0 -g3

# this board uses openocd
include $(RIOTMAKE)/tools/openocd.inc.mk
export OFLAGS = -O binary --gap-fill 0xff
export HEXFILE = $(ELFFILE:.elf=.bin)
export DEBUGGER_FLAGS = $(BINDIR) $(ELFFILE)
export RESET_FLAGS = $(BINDIR)

export TERMPROG = JLinkRTTClient
export OBJDUMPFLAGS += --disassemble --source --disassembler-options=force-thumb

# setup the boards dependencies
include $(RIOTBOARD)/$(BOARD)/Makefile.dep

# # set default port depending on operating system
# PORT_LINUX ?= /dev/ttyACM0
# PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
#
# # setup serial terminal
# include $(RIOTBOARD)/Makefile.include.serial
#
# # Add board selector (USB serial) to OpenOCD options if specified.
# # Use /dist/tools/usb-serial/list-ttys.sh to find out serial number.
# # Usage: SERIAL="ATML..." BOARD="samr21-xpro" make flash
# ifneq (,$(SERIAL))
# export OPENOCD_EXTRA_INIT += "-c cmsis_dap_serial $(SERIAL)"
# SERIAL_TTY = $(firstword $(shell $(RIOTBASE)/dist/tools/usb-serial/find-tty.sh $(SERIAL)))
# ifeq (,$(SERIAL_TTY))
# $(error Did not find a device with serial $(SERIAL))
# endif
# PORT_LINUX := $(SERIAL_TTY)
# endif
#
# # this board uses openocd
# include $(RIOTBOARD)/Makefile.include.openocd
9 changes: 9 additions & 0 deletions boards/samr21-xpro/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
#include "board.h"
#include "periph/gpio.h"

const uint64_t* const fb_sentinel = ((const uint64_t* const)0x3fc00);
const uint64_t* const fb_flashed_time = ((const uint64_t* const)0x3fc08);
const uint8_t* const fb_eui64 = ((const uint8_t* const)0x3fc10);
const uint16_t* const fb_device_id = ((const uint16_t* const)0x3fc18);
const uint64_t* const fb_designator = ((const uint64_t* const)0x3fc1c);
const uint8_t* const fb_aes128_key = ((const uint8_t* const)0x3fc30);
const uint8_t* const fb_25519_pub = ((const uint8_t* const)0x3fc40);
const uint8_t* const fb_25519_priv = ((const uint8_t* const)0x3fc60);

void board_init(void)
{
/* initialize the on-board LED */
Expand Down
18 changes: 18 additions & 0 deletions boards/samr21-xpro/dist/debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

# Start in-circuit debugging on this board: this script starts up the GDB
# client and connects to a GDB server.
#
# Start the GDB server first using the 'make debugserver' target

# @author Hauke Petersen <[email protected]>
# @author Michael Andersen <[email protected]>

BINDIR=$1
ELFFILE=$2

# write GDB config file
echo "target extended-remote 127.0.0.1:2331" > $BINDIR/gdb.cfg

# run GDB
arm-none-eabi-gdb -tui -command=$BINDIR/gdb.cfg $ELFFILE
25 changes: 25 additions & 0 deletions boards/samr21-xpro/dist/flash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

# This flash script dynamically generates a file with a set of commands which
# have to be handed to the flashing script of SEGGER (JLinkExe >4.84).
# After that, JLinkExe will be executed with that set of commands to flash the
# latest .bin file to the board.

# @author Hauke Petersen <[email protected]>
# @author Michael Andersen <[email protected]>

BINDIR=$1
HEXFILE=$2
FLASHADDR=0

# setup JLink command file
echo "power on" > $BINDIR/burn.seg
echo "speed 1000" >> $BINDIR/burn.seg
echo "loadbin $HEXFILE $FLASHADDR" >> $BINDIR/burn.seg
echo "r" >> $BINDIR/burn.seg
echo "g" >> $BINDIR/burn.seg
echo "exit" >> $BINDIR/burn.seg

# flash new binary to the board
JLinkExe -if swd -device atsamr21g18a < $BINDIR/burn.seg
echo ""
18 changes: 18 additions & 0 deletions boards/samr21-xpro/dist/reset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

# This script resets a CC2538SF53 target using JLink called
# with a pre-defined reset sequence.

# @author Hauke Petersen <[email protected]>
# @author Michael Andersen <[email protected]>

BINDIR=$1

# create JLink command file for resetting the board
echo "r" > $BINDIR/reset.seg
echo "g" >> $BINDIR/reset.seg
echo "exit" >> $BINDIR/reset.seg

# reset the board
JLinkExe -device atsamr21g18a < $BINDIR/reset.seg
echo ""
11 changes: 11 additions & 0 deletions boards/samr21-xpro/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@
extern "C" {
#endif

extern const uint64_t* const fb_sentinel;
extern const uint64_t* const fb_flashed_time;
extern const uint8_t* const fb_eui64;
extern const uint16_t* const fb_device_id;
extern const uint64_t* const fb_designator;
extern const uint8_t* const fb_aes128_key;
extern const uint8_t* const fb_25519_pub;
extern const uint8_t* const fb_25519_priv;
#define FB_SENTINEL_VALUE 0x27c83f60f6b6e7c8
#define HAS_FACTORY_BLOCK (*fb_sentinel == FB_SENTINEL_VALUE)

/**
* @name xtimer configuration
* @{
Expand Down
80 changes: 80 additions & 0 deletions core/condition.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (C) 2016 Sam Kumar <[email protected]>
* 2016 University of California, Berkeley
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup core_sync
* @{
*
* @file
* @brief Kernel condition variable implementation
*
* @author Sam Kumar <[email protected]>
*
* @}
*/

#include "condition.h"
#include "irq.h"
#include "mutex.h"
#include "thread.h"

#define ENABLE_DEBUG (0)
#include "debug.h"

void cond_wait(condition_t* cond, mutex_t* mutex)
{
unsigned irqstate = irq_disable();
thread_t* me = (thread_t*) sched_active_thread;
mutex_unlock(mutex);
sched_set_status(me, STATUS_CONDITION_BLOCKED);
thread_add_to_list(&cond->queue, me);
irq_restore(irqstate);
thread_yield_higher();

/*
* Once we reach this point, the condition variable was signalled,
* and we are free to continue.
*/
mutex_lock(mutex);
}

void _cond_signal(condition_t* cond, bool broadcast)
{
unsigned irqstate = irq_disable();
list_node_t* next;

uint16_t min_prio = THREAD_PRIORITY_MIN + 1;
while ((next = list_remove_head(&cond->queue)) != NULL) {
thread_t* process = container_of((clist_node_t*) next, thread_t, rq_entry);
sched_set_status(process, STATUS_PENDING);
uint16_t process_priority = process->priority;
if (process_priority < min_prio) {
min_prio = process_priority;
}

if (!broadcast) {
break;
}
}

irq_restore(irqstate);
if (min_prio <= THREAD_PRIORITY_MIN) {
sched_switch(min_prio);
}
}

void cond_signal(condition_t* cond)
{
_cond_signal(cond, false);
}

void cond_broadcast(condition_t* cond)
{
_cond_signal(cond, true);
}
Loading