[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/storage/Config
Makefile, NONE, 1.1.2.1 README.txt, NONE,
1.1.2.1 RandRWAppC.nc, NONE, 1.1.2.1 RandRWC.nc, NONE,
1.1.2.1 volumes-at45db.xml, NONE, 1.1.2.1 volumes-stm25p.xml,
NONE, 1.1.2.1
David Gay
idgay at users.sourceforge.net
Thu May 25 15:21:48 PDT 2006
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/storage/Config - New
directory
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/at45db
At45dbBlockConfig.nc, NONE, 1.1.2.1 At45dbP.nc, 1.1.2.4,
1.1.2.5 BlockStorageP.nc, 1.1.2.8, 1.1.2.9 ConfigStorageC.nc,
1.1.2.1, 1.1.2.2 ConfigStorageP.nc, 1.1.2.1,
1.1.2.2 HplAt45dbByteC.nc, 1.1.2.6, 1.1.2.7 At45dbBlockLog.nc,
1.1.2.1, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/storage/Config
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv27729
Added Files:
Tag: tinyos-2_0_devel-BRANCH
Makefile README.txt RandRWAppC.nc RandRWC.nc
volumes-at45db.xml volumes-stm25p.xml
Log Message:
config storage test app
--- NEW FILE: Makefile ---
COMPONENT=RandRWAppC
include $(MAKERULES)
--- NEW FILE: README.txt ---
README for Log
Author/Contact: tinyos-help at millennium.berkeley.edu
Description:
Application to test the ConfigStorageC abstraction. There must be a
volumes-<chip>.xml file in this directory describing the test volume
for your flash chip.
The mote id controls a random seed used in the test (k), and the actual
test performed
k * 2: do a bunch of writes, reads and commits
k * 2 + 1: check if the result of a previous run with id = k * 2 is correct
A successful test will turn on the green led. A failed test will turn on
the red led. The yellow led blinks to indicate test progress
Tools:
Known bugs/limitations:
None.
$Id: README.txt,v 1.1.2.1 2006/05/25 22:21:46 idgay Exp $
--- NEW FILE: RandRWAppC.nc ---
/* $Id: RandRWAppC.nc,v 1.1.2.1 2006/05/25 22:21:46 idgay Exp $
* Copyright (c) 2005 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* Block storage test application. Does a pattern of random reads and
* writes, based on mote id. See README.txt for more details.
*
* @author David Gay
*/
#include "StorageVolumes.h"
configuration RandRWAppC { }
implementation {
components RandRWC, new ConfigStorageC(VOLUME_CONFIGTEST),
MainC, LedsC, PlatformC, SerialActiveMessageC;
MainC.Boot <- RandRWC;
MainC.SoftwareInit -> SerialActiveMessageC;
RandRWC.SerialControl -> SerialActiveMessageC;
RandRWC.AMSend -> SerialActiveMessageC.AMSend[1];
RandRWC.ConfigStorage -> ConfigStorageC.ConfigStorage;
RandRWC.ConfigMount -> ConfigStorageC.SplitControl;
RandRWC.Leds -> LedsC;
}
--- NEW FILE: RandRWC.nc ---
/* $Id: RandRWC.nc,v 1.1.2.1 2006/05/25 22:21:46 idgay Exp $
* Copyright (c) 2005 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* Log storage test application. Does a pattern of random reads and
* writes, based on mote id. See README.txt for more details.
*
* @author David Gay
*/
/*
address & 3:
1: erase, write
2: read
3: write some more
*/
module RandRWC {
uses {
interface Boot;
interface Leds;
interface ConfigStorage;
interface AMSend;
interface SplitControl as SerialControl;
interface SplitControl as ConfigMount;
}
}
implementation {
enum {
SIZE = 2048,
NWRITES = 100,
};
uint16_t shiftReg;
uint16_t initSeed;
uint16_t mask;
uint8_t data[512], rdata[512];
int count, testCount, writeCount;
struct {
uint32_t addr;
void *data;
uint16_t len;
} ops[NWRITES];
message_t reportmsg;
void done();
/* Return the next 16 bit random number */
uint16_t rand() {
bool endbit;
uint16_t tmpShiftReg;
tmpShiftReg = shiftReg;
endbit = ((tmpShiftReg & 0x8000) != 0);
tmpShiftReg <<= 1;
if (endbit)
tmpShiftReg ^= 0x100b;
tmpShiftReg++;
shiftReg = tmpShiftReg;
tmpShiftReg = tmpShiftReg ^ mask;
return tmpShiftReg;
}
void resetSeed() {
shiftReg = 119 * 119 * ((TOS_NODE_ID >> 1) + 1 + writeCount);
initSeed = shiftReg;
mask = 137 * 29 * ((TOS_NODE_ID >> 1) + 1 + writeCount);
}
void report(error_t e) {
uint8_t *msg = call AMSend.getPayload(&reportmsg);
msg[0] = e;
if (call AMSend.send(AM_BROADCAST_ADDR, &reportmsg, 1) != SUCCESS)
call Leds.led0On();
}
event void AMSend.sendDone(message_t* msg, error_t error) {
if (error != SUCCESS)
call Leds.led0On();
}
void fail(error_t e) {
call Leds.led0On();
report(e);
}
void success() {
call Leds.led1On();
report(0x80);
}
bool scheck(error_t r) __attribute__((noinline)) {
if (r != SUCCESS)
fail(r);
return r == SUCCESS;
}
bool bcheck(bool b) {
if (!b)
fail(FAIL);
return b;
}
void setupOps() {
int i;
uint16_t offset;
count = 0;
resetSeed();
for (i = 0; i < NWRITES; i++)
{
ops[i].addr = rand() & (SIZE - 1);
ops[i].len = rand() >> 7;
if (ops[i].addr + ops[i].len > SIZE)
ops[i].addr = SIZE - ops[i].len;
offset = rand() >> 8;
if (offset + ops[i].len > sizeof data)
offset = sizeof data - ops[i].len;
ops[i].data = data + offset;
}
}
int overlap(int a, int b) {
return ops[a].addr >= ops[b].addr && ops[a].addr < ops[b].addr + ops[b].len;
}
int overwritten(int c) {
int i;
/* True if write c is overwritten by a later write */
for (i = c + 1; i < NWRITES; i++)
if (overlap(i, c) || overlap(c, i))
return TRUE;
return FALSE;
}
void nextRead() {
int c = count++;
if (c == NWRITES)
done();
else
scheck(call ConfigStorage.read(ops[c].addr, rdata, ops[c].len));
}
event void ConfigStorage.readDone(storage_addr_t x, void* buf, storage_len_t rlen, error_t result) __attribute__((noinline)) {
int c = count - 1;
if (scheck(result) &&
bcheck(x == ops[c].addr && rlen == ops[c].len && buf == rdata) &&
bcheck(overwritten(c) || memcmp(ops[c].data, rdata, rlen) == 0))
nextRead();
}
void nextWrite() {
int c = count++;
if (c == NWRITES)
done();
else
scheck(call ConfigStorage.write(ops[c].addr, ops[c].data, ops[c].len));
}
event void ConfigStorage.writeDone(storage_addr_t x, void *buf, storage_len_t y, error_t result) {
int c = count - 1;
if (scheck(result) &&
bcheck(x == ops[c].addr && y == ops[c].len && buf == ops[c].data))
nextWrite();
}
event void ConfigStorage.commitDone(error_t result) {
if (scheck(result))
done();
}
event void Boot.booted() {
int i;
resetSeed();
for (i = 0; i < sizeof data; i++)
data[i++] = rand() >> 8;
call SerialControl.start();
}
event void SerialControl.startDone(error_t e) {
if (e != SUCCESS)
{
call Leds.led0On();
return;
}
call ConfigMount.start();
}
event void ConfigMount.startDone(error_t e) {
if (e != SUCCESS)
fail(e);
else
done();
}
enum { A_COMMIT, A_READ, A_WRITE };
void doAction(int act) {
switch (act)
{
case A_COMMIT:
scheck(call ConfigStorage.commit());
break;
case A_WRITE:
writeCount++;
setupOps();
nextWrite();
break;
case A_READ:
setupOps();
nextRead();
break;
}
}
const uint8_t actions[] = {
A_WRITE,
A_READ,
A_COMMIT,
A_READ,
A_WRITE,
A_COMMIT,
A_READ,
A_WRITE
};
void done() {
call Leds.led2Toggle();
if (TOS_NODE_ID & 1)
{
if (testCount)
success();
else
{
uint8_t i, nwrites = 0;
/* Figure out what writeCount was at last commit */
for (i = 0; i < sizeof actions; i++)
switch (actions[i])
{
case A_WRITE:
nwrites++;
break;
case A_COMMIT:
writeCount = nwrites;
break;
}
/* And check we have the right data */
doAction(A_READ);
}
}
else if (testCount < sizeof actions)
doAction(actions[testCount]);
else
success();
testCount++;
}
event void SerialControl.stopDone(error_t e) { }
event void ConfigMount.stopDone(error_t e) { }
}
--- NEW FILE: volumes-at45db.xml ---
<volume_table>
<volume name="LOGTEST" size="262144"/>
<volume name="CONFIGTEST" size="4608"/>
</volume_table>
--- NEW FILE: volumes-stm25p.xml ---
<volume_table>
<volume name="LOGTEST" size="262144"/>
<volume name="CONFIGTEST" size="131072"/>
</volume_table>
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/storage/Config - New
directory
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/at45db
At45dbBlockConfig.nc, NONE, 1.1.2.1 At45dbP.nc, 1.1.2.4,
1.1.2.5 BlockStorageP.nc, 1.1.2.8, 1.1.2.9 ConfigStorageC.nc,
1.1.2.1, 1.1.2.2 ConfigStorageP.nc, 1.1.2.1,
1.1.2.2 HplAt45dbByteC.nc, 1.1.2.6, 1.1.2.7 At45dbBlockLog.nc,
1.1.2.1, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list