Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Oliver Schmidt 2014-06-12 22:57:46 +02:00
commit d955b179eb
26 changed files with 146 additions and 84 deletions

1
.gitignore vendored
View file

@ -36,6 +36,7 @@ symbols.*
Makefile.target
doc/html
patches-*
tools/tunslip
tools/tunslip6
build
tools/coffee-manager/build/

View file

@ -17,9 +17,8 @@ before_script:
| tar xjf - -C /tmp/ && sudo cp -f -r /tmp/arm-2008q3/* /usr/ && rm -rf /tmp/arm-2008q3 && arm-none-eabi-gcc --version || true"
## Install RL78 GCC chain (following the instructions in platform/eval-adf7xxxmb4z/README.md)
- "sudo apt-get install git make gcc libc-dev multiarch-support libncurses5:i386 zlib1g:i386"
- "wget https://dl.dropboxusercontent.com/u/60522916/gnurl78-v13.02-elf_1-2_i386.deb"
- "sudo dpkg -i gnurl78*.deb"
- "sudo apt-get install libncurses5:i386 zlib1g:i386 || true"
- "wget http://adamdunkels.github.io/contiki-fork/gnurl78-v13.02-elf_1-2_i386.deb && sudo dpkg -i gnurl78*.deb || true"
## Install SDCC from a purpose-built bundle
- "[ ${BUILD_ARCH:-0} = 8051 ] && curl -s \

View file

@ -183,7 +183,7 @@ clean:
-rm -rf $(OBJECTDIR)
distclean: clean
-rm -rf $(CONTIKI_PROJECT).$(TARGET)
-rm -f ${addsuffix .$(TARGET),$(CONTIKI_PROJECT)}
-include $(CONTIKI)/platform/$(TARGET)/Makefile.customrules-$(TARGET)

View file

@ -651,7 +651,7 @@ reserve(const char *name, coffee_page_t pages,
}
memset(&hdr, 0, sizeof(hdr));
memcpy(hdr.name, name, sizeof(hdr.name) - 1);
strncpy(hdr.name, name, sizeof(hdr.name) - 1);
hdr.max_pages = pages;
hdr.flags = HDR_FLAG_ALLOCATED | flags;
write_header(&hdr, page);

View file

@ -34,54 +34,58 @@
#include "sys/clock.h"
#include "sys/energest.h"
static unsigned char leds, invert;
static unsigned char leds;
/*---------------------------------------------------------------------------*/
static void
show_leds(unsigned char changed)
show_leds(unsigned char new_leds)
{
unsigned char changed;
changed = leds ^ new_leds;
leds = new_leds;
if(changed & LEDS_GREEN) {
/* Green did change */
if((invert ^ leds) & LEDS_GREEN) {
if(leds & LEDS_GREEN) {
ENERGEST_ON(ENERGEST_TYPE_LED_GREEN);
} else {
ENERGEST_OFF(ENERGEST_TYPE_LED_GREEN);
}
}
if(changed & LEDS_YELLOW) {
if((invert ^ leds) & LEDS_YELLOW) {
if(leds & LEDS_YELLOW) {
ENERGEST_ON(ENERGEST_TYPE_LED_YELLOW);
} else {
ENERGEST_OFF(ENERGEST_TYPE_LED_YELLOW);
}
}
if(changed & LEDS_RED) {
if((invert ^ leds) & LEDS_RED) {
if(leds & LEDS_RED) {
ENERGEST_ON(ENERGEST_TYPE_LED_RED);
} else {
ENERGEST_OFF(ENERGEST_TYPE_LED_RED);
}
}
leds_arch_set(leds ^ invert);
leds_arch_set(leds);
}
/*---------------------------------------------------------------------------*/
void
leds_init(void)
{
leds_arch_init();
leds = invert = 0;
leds = 0;
}
/*---------------------------------------------------------------------------*/
void
leds_blink(void)
{
/* Blink all leds. */
unsigned char inv;
inv = ~(leds ^ invert);
leds_invert(inv);
/* Blink all leds that were initially off. */
unsigned char blink;
blink = ~leds;
leds_toggle(blink);
clock_delay(400);
leds_invert(inv);
leds_toggle(blink);
}
/*---------------------------------------------------------------------------*/
unsigned char
@ -90,33 +94,26 @@ leds_get(void) {
}
/*---------------------------------------------------------------------------*/
void
leds_set(unsigned char ledv)
{
show_leds(ledv);
}
/*---------------------------------------------------------------------------*/
void
leds_on(unsigned char ledv)
{
unsigned char changed;
changed = (~leds) & ledv;
leds |= ledv;
show_leds(changed);
show_leds(leds | ledv);
}
/*---------------------------------------------------------------------------*/
void
leds_off(unsigned char ledv)
{
unsigned char changed;
changed = leds & ledv;
leds &= ~ledv;
show_leds(changed);
show_leds(leds & ~ledv);
}
/*---------------------------------------------------------------------------*/
void
leds_toggle(unsigned char ledv)
{
leds_invert(ledv);
}
/*---------------------------------------------------------------------------*/
/* invert the invert register using the leds parameter */
void
leds_invert(unsigned char ledv) {
invert = invert ^ ledv;
show_leds(ledv);
show_leds(leds ^ ledv);
}
/*---------------------------------------------------------------------------*/

View file

@ -77,13 +77,13 @@ void leds_blink(void);
#endif /* LEDS_CONF_ALL */
/**
* Returns the current status of all leds (respects invert)
* Returns the current status of all leds
*/
unsigned char leds_get(void);
void leds_set(unsigned char leds);
void leds_on(unsigned char leds);
void leds_off(unsigned char leds);
void leds_toggle(unsigned char leds);
void leds_invert(unsigned char leds);
/**
* Leds implementation

View file

@ -28,9 +28,10 @@
*
*/
#ifndef ASSERT_H
#define ASSERT_H
#ifndef ASSERT_H_
#define ASSERT_H_
#undef assert
#ifdef NDEBUG
#define assert(e) ((void)0)
#else
@ -44,4 +45,4 @@ void _xassert(const char *, int);
#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1]
#endif
#endif /* ASSERT_H */
#endif /* ASSERT_H_ */

View file

@ -1434,19 +1434,12 @@ output(const uip_lladdr_t *localdest)
* needs to be fragmented or not. */
#define USE_FRAMER_HDRLEN 1
#if USE_FRAMER_HDRLEN
packetbuf_clear();
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &dest);
framer_hdrlen = NETSTACK_FRAMER.create();
framer_hdrlen = NETSTACK_FRAMER.length();
if(framer_hdrlen < 0) {
/* Framing failed, we assume the maximum header length */
framer_hdrlen = 21;
}
packetbuf_clear();
/* We must set the max transmissions attribute again after clearing
the buffer. */
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS,
SICSLOWPAN_MAX_MAC_TRANSMISSIONS);
#else /* USE_FRAMER_HDRLEN */
framer_hdrlen = 21;
#endif /* USE_FRAMER_HDRLEN */

View file

@ -87,7 +87,7 @@ is_broadcast_addr(uint8_t mode, uint8_t *addr)
}
/*---------------------------------------------------------------------------*/
static int
create(void)
create_frame(int type, int do_create)
{
frame802154_t params;
int len;
@ -115,20 +115,24 @@ create(void)
params.fcf.frame_version = FRAME802154_IEEE802154_2003;
/* Increment and set the data sequence number. */
if(packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO)) {
if(!do_create) {
/* Only length calculation - no sequence number is needed and
should not be consumed. */
} else if(packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO)) {
params.seq = packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO);
} else {
params.seq = mac_dsn++;
packetbuf_set_attr(PACKETBUF_ATTR_MAC_SEQNO, params.seq);
}
/* params.seq = packetbuf_attr(PACKETBUF_ATTR_PACKET_ID); */
/* Complete the addressing fields. */
/**
\todo For phase 1 the addresses are all long. We'll need a mechanism
in the rime attributes to tell the mac to use long or short for phase 2.
*/
if(sizeof(linkaddr_t) == 2) {
if(LINKADDR_SIZE == 2) {
/* Use short address mode if linkaddr size is short. */
params.fcf.src_addr_mode = FRAME802154_SHORTADDRMODE;
} else {
@ -150,7 +154,7 @@ create(void)
linkaddr_copy((linkaddr_t *)&params.dest_addr,
packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
/* Use short address mode if linkaddr size is small */
if(sizeof(linkaddr_t) == 2) {
if(LINKADDR_SIZE == 2) {
params.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
} else {
params.fcf.dest_addr_mode = FRAME802154_LONGADDRMODE;
@ -169,7 +173,11 @@ create(void)
params.payload = packetbuf_dataptr();
params.payload_len = packetbuf_datalen();
len = frame802154_hdrlen(&params);
if(packetbuf_hdralloc(len)) {
if(!do_create) {
/* Only calculate header length */
return len;
} else if(packetbuf_hdralloc(len)) {
frame802154_create(&params, packetbuf_hdrptr(), len);
PRINTF("15.4-OUT: %2X", params.fcf.frame_type);
@ -184,6 +192,18 @@ create(void)
}
/*---------------------------------------------------------------------------*/
static int
hdr_length(void)
{
return create_frame(FRAME802154_DATAFRAME, 0);
}
/*---------------------------------------------------------------------------*/
static int
create(void)
{
return create_frame(FRAME802154_DATAFRAME, 1);
}
/*---------------------------------------------------------------------------*/
static int
parse(void)
{
frame802154_t frame;
@ -218,5 +238,5 @@ parse(void)
}
/*---------------------------------------------------------------------------*/
const struct framer framer_802154 = {
create, parse
hdr_length, create, parse
};

View file

@ -55,6 +55,12 @@ struct nullmac_hdr {
linkaddr_t sender;
};
/*---------------------------------------------------------------------------*/
static int
hdr_length(void)
{
return sizeof(struct nullmac_hdr);
}
/*---------------------------------------------------------------------------*/
static int
create(void)
@ -91,5 +97,5 @@ parse(void)
}
/*---------------------------------------------------------------------------*/
const struct framer framer_nullmac = {
create, parse
hdr_length, create, parse
};

View file

@ -45,6 +45,7 @@
struct framer {
int (* length)(void);
int (* create)(void);
int (* parse)(void);

View file

@ -434,7 +434,7 @@ void packetbuf_attr_copyfrom(struct packetbuf_attr *attrs,
#define PACKETBUF_ATTR_BIT 1
#define PACKETBUF_ATTR_BYTE 8
#define PACKETBUF_ADDRSIZE (sizeof(linkaddr_t) * PACKETBUF_ATTR_BYTE)
#define PACKETBUF_ADDRSIZE (LINKADDR_SIZE * PACKETBUF_ATTR_BYTE)
struct packetbuf_attrlist {
uint8_t type;

View file

@ -162,7 +162,7 @@
* Initial metric attributed to a link when the ETX is unknown
*/
#ifndef RPL_CONF_INIT_LINK_METRIC
#define RPL_INIT_LINK_METRIC 5
#define RPL_INIT_LINK_METRIC 2
#else
#define RPL_INIT_LINK_METRIC RPL_CONF_INIT_LINK_METRIC
#endif

View file

@ -58,8 +58,4 @@ leds_off(unsigned char leds)
void
leds_toggle(unsigned char leds)
{
/*
* Synonym: void leds_invert(unsigned char leds);
*/
asm(".global leds_invert\nleds_invert:\n");
}

View file

@ -49,10 +49,36 @@ ieee_addr_cpy_to(uint8_t *dst, uint8_t len)
memcpy(dst, &ieee_addr_hc[8 - len], len);
} else {
/* Reading from Info Page, we need to invert byte order */
/*
* By default, we assume that the IEEE address is stored on flash using
* little-endian byte order.
*
* However, some SoCs ship with a different byte order, whereby the first
* four bytes are flipped with the four last ones.
*
* Using this address as an example: 00 12 4B 00 01 02 03 04
* We expect it stored as: 04 03 02 01 00 4B 12 00
* But it is also possible to encounter: 00 4B 12 00 04 03 02 01
*
* Thus: read locations [3, 2, 1] and if we encounter the TI OUI, flip the
* order of the two 4-byte sequences. Each of the 4-byte sequences is still
* little-endian.
*/
int i;
for(i = 0; i < len; i++) {
dst[i] = ((uint8_t *)IEEE_ADDR_LOCATION)[len - 1 - i];
uint8_t oui_ti[3] = IEEE_ADDR_OUI_TI;
if(((uint8_t *)IEEE_ADDR_LOCATION)[3] == oui_ti[0]
&& ((uint8_t *)IEEE_ADDR_LOCATION)[2] == oui_ti[1]
&& ((uint8_t *)IEEE_ADDR_LOCATION)[1] == oui_ti[2]) {
for(i = 0; i < len / 2; i++) {
dst[i] = ((uint8_t *)IEEE_ADDR_LOCATION)[len / 2 - 1 - i];
}
for(i = 0; i < len / 2; i++) {
dst[i + len / 2] = ((uint8_t *)IEEE_ADDR_LOCATION)[len - 1 - i];
}
} else {
for(i = 0; i < len; i++) {
dst[i] = ((uint8_t *)IEEE_ADDR_LOCATION)[len - 1 - i];
}
}
}

View file

@ -49,11 +49,27 @@
#include <stdint.h>
/*---------------------------------------------------------------------------*/
/**
* \name IEEE address locations
* \name TI OUI
* @{
*/
#define IEEE_ADDR_LOCATION_PRIMARY 0x00280028 /**< IEEE address location */
#define IEEE_ADDR_LOCATION_SECONDARY 0x0027FFCC /**< IEEE address location */
#define IEEE_ADDR_OUI_TI { 0x00, 0x12, 0x4B } /**< TI OUI */
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \name IEEE address locations
*
* The address of the secondary location can be configured by the platform
* or example
*
* @{
*/
#define IEEE_ADDR_LOCATION_PRIMARY 0x00280028 /**< Primary IEEE address location */
#ifdef IEEE_ADDR_CONF_LOCATION_SECONDARY
#define IEEE_ADDR_LOCATION_SECONDARY IEEE_ADDR_CONF_LOCATION_SECONDARY
#else
#define IEEE_ADDR_LOCATION_SECONDARY 0x0027FFCC /**< Secondary IEEE address location */
#endif
/** @} */
/*---------------------------------------------------------------------------*/
/**

View file

@ -59,7 +59,7 @@ void
cc2420_arch_sfd_init(void)
{
/* Need to select the special function! */
P4SEL = BV(CC2420_SFD_PIN);
CC2420_SFD_PORT(SEL) = BV(CC2420_SFD_PIN);
/* start timer B - 32768 ticks per second */
TBCTL = TBSSEL_1 | TBCLR;

View file

@ -58,7 +58,7 @@ void
cc2520_arch_sfd_init(void)
{
/* Need to select the special function! */
P4SEL = BV(CC2520_SFD_PIN);
CC2520_SFD_PORT(SEL) = BV(CC2520_SFD_PIN);
/* start timer B - 32768 ticks per second */
TBCTL = TBSSEL_1 | TBCLR;

View file

@ -74,10 +74,5 @@ leds_off(unsigned char leds)
void
leds_toggle(unsigned char leds)
{
/*
* Synonym: void leds_invert(unsigned char leds);
*/
asm(".global leds_invert\nleds_invert:\n");
LEDS_PxOUT ^= l2p[leds & LEDS_ALL];
}

View file

@ -58,6 +58,6 @@ RESOURCE(res_toggle,
static void
res_post_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
leds_invert(LEDS_RED);
leds_toggle(LEDS_RED);
}
#endif /* PLATFORM_HAS_LEDS */

View file

@ -76,6 +76,13 @@ is_broadcast_addr(uint8_t mode, uint8_t *addr)
}
/*---------------------------------------------------------------------------*/
static int
hdr_length(void)
{
/* never adds any header */
return 0;
}
/*---------------------------------------------------------------------------*/
static int
create(void)
{
/* nothing extra... */
@ -116,5 +123,5 @@ parse(void)
}
/*---------------------------------------------------------------------------*/
const struct framer no_framer = {
create, parse
hdr_length, create, parse
};

View file

@ -85,7 +85,7 @@ typedef unsigned long clock_time_t;
typedef unsigned long rtimer_clock_t;
#define RTIMER_CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
#define RTIMER_CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
#define LEDS_CONF_RED_PIN boardDescription->io->leds[1].gpioPin
#define LEDS_CONF_GREEN_PIN boardDescription->io->leds[0].gpioPin

View file

@ -35,6 +35,7 @@
#include <string.h>
#include <unistd.h>
#include <sys/select.h>
#include <errno.h>
#ifdef __CYGWIN__
#include "net/wpcap-drv.h"
@ -190,6 +191,7 @@ main(int argc, char **argv)
process_init();
process_start(&etimer_process, NULL);
ctimer_init();
rtimer_init();
#if WITH_GUI
process_start(&ctk_process, NULL);
@ -197,12 +199,12 @@ main(int argc, char **argv)
set_rime_addr();
queuebuf_init();
netstack_init();
printf("MAC %s RDC %s NETWORK %s\n", NETSTACK_MAC.name, NETSTACK_RDC.name, NETSTACK_NETWORK.name);
#if WITH_UIP6
queuebuf_init();
memcpy(&uip_lladdr.addr, serial_id, sizeof(uip_lladdr.addr));
process_start(&tcpip_process, NULL);
@ -259,7 +261,9 @@ main(int argc, char **argv)
retval = select(maxfd + 1, &fdr, &fdw, NULL, &tv);
if(retval < 0) {
perror("select");
if(errno != EINTR) {
perror("select");
}
} else if(retval > 0) {
/* timeout => retval == 0 */
for(i = 0; i <= maxfd; i++) {

View file

@ -338,7 +338,7 @@ main(int argc, char **argv)
NETSTACK_MAC.name, NETSTACK_RDC.name,
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:
NETSTACK_RDC.channel_check_interval()),
CC2420_CONF_CCA_THRESH);
CC2420_CONF_CHANNEL);
#endif /* WITH_UIP6 */
#if !WITH_UIP && !WITH_UIP6

View file

@ -64,7 +64,7 @@ tcpip_output(const uip_lladdr_t *a)
/* printf("pppp o %u tx %u rx %u\n", UIP_IP_BUF->proto,
packetbuf_attr(PACKETBUF_ATTR_TRANSMIT_TIME),
packetbuf_attr(PACKETBUF_ATTR_LISTEN_TIME));*/
leds_invert(LEDS_GREEN);
leds_toggle(LEDS_GREEN);
}
return 0;
}
@ -94,7 +94,7 @@ tcpip_input(void)
packetbuf_attr(PACKETBUF_ATTR_TRANSMIT_TIME),
packetbuf_attr(PACKETBUF_ATTR_LISTEN_TIME));*/
slip_write(uip_buf, uip_len);
leds_invert(LEDS_RED);
leds_toggle(LEDS_RED);
uip_len = 0;
}
}
@ -112,7 +112,7 @@ slip_tcpip_input(void)
static void
slip_activity(void)
{
leds_invert(LEDS_BLUE);
leds_toggle(LEDS_BLUE);
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(uip6_bridge, ev, data)

View file

@ -968,7 +968,7 @@ void mac_802154raw(const struct radio_driver *radio)
#endif
slip_write(uip_buf, len);
leds_invert(LEDS_RED);
leds_toggle(LEDS_RED);
//rndis_send(raw_buf, sendlen, 1);
//rndis_stat.rxok++;