Discussion:
[Contiki-developers] Emulating TelosB grid with TinyOS
August Betzler
2012-10-09 09:22:30 UTC
Permalink
Hi,

I'm working with TelosB motes and saw in this mailing list that they can
be simulated in Cooja by compiling the TinyOS code and loading it into the
simulator. However, I'm having some issues with it.
Since the nodes are programmed with TinyOS, the following question may be
"out of scope" for this mailing list. Still, i hope that maybe someone had
similar issues and may help me out:

I implemented 60 nodes that all use the same code and have different node
IDs. They form a sensor network, where each node needs to be able to find
routes to other nodes and to exchange data with them. This program uses
millisecond timers, as provided by TinyOS. Some of these timers are set to
about 1500 ms, but when I run the Cooja simulation, they expire after a
few ms. I really don't understand what is going on.

The program is relatively complex, so it's no simple "ping-pong" code that
I could post here. I just can say that the timers are part of the routing
mechanism (discovery timeout) and I use many more (transport layer RTOs,
etc.) that also behave strangely. Other aspects of the code seem to work
fine so far, only the timers are causing problems. For the simulations I'm
using the newest version of instant Contiki downloaded from sourceforge.

To make the timers work, do I have to adjust a certain parameter in Cooja?
Or do i need to use a different type of timers in TinyOS to make the
simulation possible?

As I said, I know this is not a Contiki issue, but maybe someone has an idea.

With best regards,

August
Moritz Struebe
2012-10-09 09:45:12 UTC
Permalink
Post by August Betzler
I implemented 60 nodes that all use the same code and have different node
IDs. They form a sensor network, where each node needs to be able to find
routes to other nodes and to exchange data with them. This program uses
millisecond timers, as provided by TinyOS. Some of these timers are set to
about 1500 ms, but when I run the Cooja simulation, they expire after a
few ms. I really don't understand what is going on.
Do they work on real hardware? Tossim only simulates the network layer
(as do NS2 and Omnet), thus the runtime of the code is pretty much
ignored. When choosing TelosB/Sky in Cooja the whole hardware is
emulated, executing the actual binary code and the network is simulated.
Post by August Betzler
To make the timers work, do I have to adjust a certain parameter in Cooja?
Or do i need to use a different type of timers in TinyOS to make the
simulation possible?
As MSPSim is pretty well developed it's likely to be a problem with
TinyOS or some bug in your code that is only triggered on real hardware.
Besides it's own debugging options, it's possible to connect msp430-gdb
to Cooja [1], thus debugging the hardware. There was even some project
allowing to debug TinyOS code using Cooja. If you can not reproduce the
behaviour on real hardware, this is probably something worth looking
into by the MSPsim-devs.


Cheers
Morty

[1] http://i4git.cs.fau.de/contiki_projects.git/tree/gdbstub
--
Dipl.-Ing. Moritz 'Morty' Struebe (Wissenschaftlicher Mitarbeiter)
Lehrstuhl für Informatik 4 (Verteilte Systeme und Betriebssysteme)
Friedrich-Alexander-Universität Erlangen-Nürnberg
Martensstr. 1
91058 Erlangen

Tel : +49 9131 85-25419
Fax : +49 9131 85-28732
eMail : ***@informatik.uni-erlangen.de
WWW : http://www4.informatik.uni-erlangen.de/~morty
August Betzler
2012-10-09 10:17:01 UTC
Permalink
Thank you for the quick response!
Post by Moritz Struebe
Do they work on real hardware? Tossim only simulates the network layer
(as do NS2 and Omnet), thus the runtime of the code is pretty much
ignored. When choosing TelosB/Sky in Cooja the whole hardware is
emulated, executing the actual binary code and the network is simulated.
Actually, this program has been running over half a year in a real grid
and those problems never appeared. The idea was to confirm/compare the
results i got in the real network with some simulator (or better: an
emulator like Cooja). I considered Tossim as an option, but as far as I
know, it does not support TelosB motes.
Post by Moritz Struebe
As MSPSim is pretty well developed it's likely to be a problem with
TinyOS or some bug in your code that is only triggered on real hardware.
Besides it's own debugging options, it's possible to connect msp430-gdb
to Cooja [1], thus debugging the hardware. There was even some project
allowing to debug TinyOS code using Cooja. If you can not reproduce the
behaviour on real hardware, this is probably something worth looking
into by the MSPsim-devs.
Since this bug does not appear on the real hardware, i assume it may be a
problem with TinyOS. I will try to find out, if and how I can use a
debugger to check where things go wrong.
Moritz Struebe
2012-10-09 12:12:42 UTC
Permalink
Post by August Betzler
Actually, this program has been running over half a year in a real grid
and those problems never appeared. The idea was to confirm/compare the
results i got in the real network with some simulator (or better: an
emulator like Cooja).
Then it's not unlikely to be a bug in MSPSim[1]. So that ML is probably
the right place to ask for support[2].

Morty

[1] http://sourceforge.net/projects/mspsim/
[2]
http://sourceforge.net/mailarchive/forum.php?forum_name=mspsim-developers
--
Dipl.-Ing. Moritz 'Morty' Struebe (Wissenschaftlicher Mitarbeiter)
Lehrstuhl für Informatik 4 (Verteilte Systeme und Betriebssysteme)
Friedrich-Alexander-Universität Erlangen-Nürnberg
Martensstr. 1
91058 Erlangen

Tel : +49 9131 85-25419
Fax : +49 9131 85-28732
eMail : ***@informatik.uni-erlangen.de
WWW : http://www4.informatik.uni-erlangen.de/~morty
Joakim Eriksson
2012-10-10 08:45:11 UTC
Permalink
Hello,

Would it be possible for you to create a fairly small example
application that cause the same problem to occur? If so it would
be great if you could send me a firmware that has this timer-problem.
We might be able to figure out what happens - it might be the case
that TinyOS use some parts of the timer systems that are not used
in Contiki and therefore not very tested (or possibly not even
implemented in the emulator).

Best Regards,
-- Joakim Eriksson, SICS
Post by August Betzler
Thank you for the quick response!
Post by Moritz Struebe
Do they work on real hardware? Tossim only simulates the network layer
(as do NS2 and Omnet), thus the runtime of the code is pretty much
ignored. When choosing TelosB/Sky in Cooja the whole hardware is
emulated, executing the actual binary code and the network is simulated.
Actually, this program has been running over half a year in a real grid
and those problems never appeared. The idea was to confirm/compare the
results i got in the real network with some simulator (or better: an
emulator like Cooja). I considered Tossim as an option, but as far as I
know, it does not support TelosB motes.
Post by Moritz Struebe
As MSPSim is pretty well developed it's likely to be a problem with
TinyOS or some bug in your code that is only triggered on real hardware.
Besides it's own debugging options, it's possible to connect msp430-gdb
to Cooja [1], thus debugging the hardware. There was even some project
allowing to debug TinyOS code using Cooja. If you can not reproduce the
behaviour on real hardware, this is probably something worth looking
into by the MSPsim-devs.
Since this bug does not appear on the real hardware, i assume it may be a
problem with TinyOS. I will try to find out, if and how I can use a
debugger to check where things go wrong.
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Contiki-developers mailing list
https://lists.sourceforge.net/lists/listinfo/contiki-developers
August Betzler
2012-10-10 16:16:47 UTC
Permalink
Hello,

thank you for offering me help with this.

I decided to compile the Blink application from the apps folder in TinyOS
(some basic example, where LEDs blink at different rates), to check if
timers work right there.

Emulating the nodes with just the LEDs blinking seems to work fine. Then,
I added the printf module and a local Timer module (HilTimerMilliC). With
these two modules I pretended to print the local time at the moment a LED
is toggled.

## code ##
event void Timer0.fired()
{
printf("%lu\n", call MyTime.get()); // <-- print local time
printfflush(); // flush printf-buffer
call Leds.led0Toggle();
}
## /code ##

Here I ran into a problem; the simulation crashed with the following error:

[java] FATAL [Thread-7] (Simulation.java:292) - Simulation stopped due to
error: null
[java] se.sics.cooja.ContikiError
[java] at se.sics.cooja.mspmote.MspMote.execute(MspMote.java:310)
[java] at se.sics.cooja.mspmote.MspMote.execute(MspMote.java:277)
[java] at
se.sics.cooja.motes.AbstractWakeupMote$1.execute(AbstractWakeupMote.java:48)
[java] at se.sics.cooja.Simulation.run(Simulation.java:280)
[java] at java.lang.Thread.run(Thread.java:722)
[java] Caused by: se.sics.mspsim.core.EmulationException: Writing to
read-only P3IN
[java] at se.sics.mspsim.core.IOPort.write_port(IOPort.java:262)
[java] at se.sics.mspsim.core.IOPort.write(IOPort.java:349)
[java] at se.sics.mspsim.core.IOSegment.write(IOSegment.java:51)
[java] at se.sics.mspsim.core.MSP430Core$1.write(MSP430Core.java:161)
[java] at
se.sics.mspsim.core.MSP430Core.emulateOP(MSP430Core.java:2011)
[java] at se.sics.mspsim.core.MSP430.stepMicros(MSP430.java:253)
[java] at se.sics.cooja.mspmote.MspMote.execute(MspMote.java:304)
[java] ... 4 more

I'm using the current version of instant Contiki (2.6.).
I compiled the binary with "make telosb" on a machine with xubuntu and got
no warnings or errors. The printf module seems to cause some problems.
However, in my "complex" application printf does not cause the simulation
to crash. But maybe printf is buggy and that is why i get wrong readings
during the Cooja emulation.
I attach the compile folder of the Blink application to this mail.

Let me check, if without printf my program works fine.

With best regards,

August
Post by Joakim Eriksson
Hello,
Would it be possible for you to create a fairly small example
application that cause the same problem to occur? If so it would
be great if you could send me a firmware that has this timer-problem.
We might be able to figure out what happens - it might be the case
that TinyOS use some parts of the timer systems that are not used
in Contiki and therefore not very tested (or possibly not even
implemented in the emulator).
Best Regards,
-- Joakim Eriksson, SICS
Post by August Betzler
Thank you for the quick response!
Post by Moritz Struebe
Do they work on real hardware? Tossim only simulates the network layer
(as do NS2 and Omnet), thus the runtime of the code is pretty much
ignored. When choosing TelosB/Sky in Cooja the whole hardware is
emulated, executing the actual binary code and the network is simulated.
Actually, this program has been running over half a year in a real grid
and those problems never appeared. The idea was to confirm/compare the
results i got in the real network with some simulator (or better: an
emulator like Cooja). I considered Tossim as an option, but as far as I
know, it does not support TelosB motes.
Post by Moritz Struebe
As MSPSim is pretty well developed it's likely to be a problem with
TinyOS or some bug in your code that is only triggered on real hardware.
Besides it's own debugging options, it's possible to connect msp430-gdb
to Cooja [1], thus debugging the hardware. There was even some project
allowing to debug TinyOS code using Cooja. If you can not reproduce the
behaviour on real hardware, this is probably something worth looking
into by the MSPsim-devs.
Since this bug does not appear on the real hardware, i assume it may be a
problem with TinyOS. I will try to find out, if and how I can use a
debugger to check where things go wrong.
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Contiki-developers mailing list
https://lists.sourceforge.net/lists/listinfo/contiki-developers
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Contiki-developers mailing list
https://lists.sourceforge.net/lists/listinfo/contiki-developers
Niclas Finne
2012-10-12 00:20:57 UTC
Permalink
Hi,

This firmware does not seem to work even on hardware. The node blinks
the leds for a short time and then the node seems to die (I tested it on
a Tmote Sky).

I also tested the firmware in MSPSim and it looks like the call to
SerialActiveMessageP__0__Packet__getPayload returns the address NULL.
The application then seems to start writing zeros to the memory from
this address (0) and up until it crashes.

Best regards,
-- Niclas Finne
Post by Joakim Eriksson
Hello,
thank you for offering me help with this.
I decided to compile the Blink application from the apps folder in TinyOS
(some basic example, where LEDs blink at different rates), to check if
timers work right there.
Emulating the nodes with just the LEDs blinking seems to work fine. Then,
I added the printf module and a local Timer module (HilTimerMilliC). With
these two modules I pretended to print the local time at the moment a LED
is toggled.
## code ##
event void Timer0.fired()
{
printf("%lu\n", call MyTime.get()); // <-- print local time
printfflush(); // flush printf-buffer
call Leds.led0Toggle();
}
## /code ##
[java] FATAL [Thread-7] (Simulation.java:292) - Simulation stopped due to
error: null
[java] se.sics.cooja.ContikiError
[java] at se.sics.cooja.mspmote.MspMote.execute(MspMote.java:310)
[java] at se.sics.cooja.mspmote.MspMote.execute(MspMote.java:277)
[java] at
se.sics.cooja.motes.AbstractWakeupMote$1.execute(AbstractWakeupMote.java:48)
[java] at se.sics.cooja.Simulation.run(Simulation.java:280)
[java] at java.lang.Thread.run(Thread.java:722)
[java] Caused by: se.sics.mspsim.core.EmulationException: Writing to
read-only P3IN
[java] at se.sics.mspsim.core.IOPort.write_port(IOPort.java:262)
[java] at se.sics.mspsim.core.IOPort.write(IOPort.java:349)
[java] at se.sics.mspsim.core.IOSegment.write(IOSegment.java:51)
[java] at se.sics.mspsim.core.MSP430Core$1.write(MSP430Core.java:161)
[java] at
se.sics.mspsim.core.MSP430Core.emulateOP(MSP430Core.java:2011)
[java] at se.sics.mspsim.core.MSP430.stepMicros(MSP430.java:253)
[java] at se.sics.cooja.mspmote.MspMote.execute(MspMote.java:304)
[java] ... 4 more
I'm using the current version of instant Contiki (2.6.).
I compiled the binary with "make telosb" on a machine with xubuntu and got
no warnings or errors. The printf module seems to cause some problems.
However, in my "complex" application printf does not cause the simulation
to crash. But maybe printf is buggy and that is why i get wrong readings
during the Cooja emulation.
I attach the compile folder of the Blink application to this mail.
Let me check, if without printf my program works fine.
With best regards,
August
Post by Joakim Eriksson
Hello,
Would it be possible for you to create a fairly small example
application that cause the same problem to occur? If so it would
be great if you could send me a firmware that has this timer-problem.
We might be able to figure out what happens - it might be the case
that TinyOS use some parts of the timer systems that are not used
in Contiki and therefore not very tested (or possibly not even
implemented in the emulator).
Best Regards,
-- Joakim Eriksson, SICS
Post by August Betzler
Thank you for the quick response!
Post by Moritz Struebe
Do they work on real hardware? Tossim only simulates the network layer
(as do NS2 and Omnet), thus the runtime of the code is pretty much
ignored. When choosing TelosB/Sky in Cooja the whole hardware is
emulated, executing the actual binary code and the network is simulated.
Actually, this program has been running over half a year in a real grid
and those problems never appeared. The idea was to confirm/compare the
results i got in the real network with some simulator (or better: an
emulator like Cooja). I considered Tossim as an option, but as far as I
know, it does not support TelosB motes.
Post by Moritz Struebe
As MSPSim is pretty well developed it's likely to be a problem with
TinyOS or some bug in your code that is only triggered on real hardware.
Besides it's own debugging options, it's possible to connect msp430-gdb
to Cooja [1], thus debugging the hardware. There was even some project
allowing to debug TinyOS code using Cooja. If you can not reproduce the
behaviour on real hardware, this is probably something worth looking
into by the MSPsim-devs.
Since this bug does not appear on the real hardware, i assume it may be a
problem with TinyOS. I will try to find out, if and how I can use a
debugger to check where things go wrong.
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Contiki-developers mailing list
https://lists.sourceforge.net/lists/listinfo/contiki-developers
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Contiki-developers mailing list
https://lists.sourceforge.net/lists/listinfo/contiki-developers
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Contiki-developers mailing list
https://lists.sourceforge.net/lists/listinfo/contiki-developers
August Betzler
2012-10-12 07:26:37 UTC
Permalink
Hello,

you are absolutely right. I just tested it on my own TelosB mote and it
crashes after the LEDs toggled a few times. The printf buffer seems to get
filled, until it is flushed, resulting in a crash. I compiled the firmware
on another machine and it works as expected, printing and not crashing. If
I eliminate all printf() from the code, the firmware is corectly emulated
by Cooja.

So sorry for posting a faulty firmware, it seems there is a problem with
my TinyOS installation. The weird thing about this is the fact that I am
able to compile and run without problems my "complex" code that is
implemented in the real test bed (using printf!).

I'll try to compile the "complex" firmware on another machine too, perhaps
then it will work with Cooja.

Thanks for replying and checking the firmware,

August
Post by Niclas Finne
Hi,
This firmware does not seem to work even on hardware. The node blinks
the leds for a short time and then the node seems to die (I tested it on
a Tmote Sky).
I also tested the firmware in MSPSim and it looks like the call to
SerialActiveMessageP__0__Packet__getPayload returns the address NULL.
The application then seems to start writing zeros to the memory from
this address (0) and up until it crashes.
Best regards,
-- Niclas Finne
Post by Joakim Eriksson
Hello,
thank you for offering me help with this.
I decided to compile the Blink application from the apps folder in TinyOS
(some basic example, where LEDs blink at different rates), to check if
timers work right there.
Emulating the nodes with just the LEDs blinking seems to work fine. Then,
I added the printf module and a local Timer module (HilTimerMilliC). With
these two modules I pretended to print the local time at the moment a LED
is toggled.
## code ##
event void Timer0.fired()
{
printf("%lu\n", call MyTime.get()); // <-- print local time
printfflush(); // flush printf-buffer
call Leds.led0Toggle();
}
## /code ##
[java] FATAL [Thread-7] (Simulation.java:292) - Simulation stopped due to
error: null
[java] se.sics.cooja.ContikiError
[java] at se.sics.cooja.mspmote.MspMote.execute(MspMote.java:310)
[java] at se.sics.cooja.mspmote.MspMote.execute(MspMote.java:277)
[java] at
se.sics.cooja.motes.AbstractWakeupMote$1.execute(AbstractWakeupMote.java:48)
[java] at se.sics.cooja.Simulation.run(Simulation.java:280)
[java] at java.lang.Thread.run(Thread.java:722)
[java] Caused by: se.sics.mspsim.core.EmulationException: Writing to
read-only P3IN
[java] at se.sics.mspsim.core.IOPort.write_port(IOPort.java:262)
[java] at se.sics.mspsim.core.IOPort.write(IOPort.java:349)
[java] at se.sics.mspsim.core.IOSegment.write(IOSegment.java:51)
[java] at
se.sics.mspsim.core.MSP430Core$1.write(MSP430Core.java:161)
[java] at
se.sics.mspsim.core.MSP430Core.emulateOP(MSP430Core.java:2011)
[java] at se.sics.mspsim.core.MSP430.stepMicros(MSP430.java:253)
[java] at se.sics.cooja.mspmote.MspMote.execute(MspMote.java:304)
[java] ... 4 more
I'm using the current version of instant Contiki (2.6.).
I compiled the binary with "make telosb" on a machine with xubuntu and got
no warnings or errors. The printf module seems to cause some problems.
However, in my "complex" application printf does not cause the simulation
to crash. But maybe printf is buggy and that is why i get wrong readings
during the Cooja emulation.
I attach the compile folder of the Blink application to this mail.
Let me check, if without printf my program works fine.
With best regards,
August
Post by Joakim Eriksson
Hello,
Would it be possible for you to create a fairly small example
application that cause the same problem to occur? If so it would
be great if you could send me a firmware that has this timer-problem.
We might be able to figure out what happens - it might be the case
that TinyOS use some parts of the timer systems that are not used
in Contiki and therefore not very tested (or possibly not even
implemented in the emulator).
Best Regards,
-- Joakim Eriksson, SICS
Post by August Betzler
Thank you for the quick response!
Post by Moritz Struebe
Do they work on real hardware? Tossim only simulates the network layer
(as do NS2 and Omnet), thus the runtime of the code is pretty much
ignored. When choosing TelosB/Sky in Cooja the whole hardware is
emulated, executing the actual binary code and the network is simulated.
Actually, this program has been running over half a year in a real grid
and those problems never appeared. The idea was to confirm/compare the
results i got in the real network with some simulator (or better: an
emulator like Cooja). I considered Tossim as an option, but as far as I
know, it does not support TelosB motes.
Post by Moritz Struebe
As MSPSim is pretty well developed it's likely to be a problem with
TinyOS or some bug in your code that is only triggered on real hardware.
Besides it's own debugging options, it's possible to connect msp430-gdb
to Cooja [1], thus debugging the hardware. There was even some project
allowing to debug TinyOS code using Cooja. If you can not reproduce the
behaviour on real hardware, this is probably something worth looking
into by the MSPsim-devs.
Since this bug does not appear on the real hardware, i assume it may
be
a
problem with TinyOS. I will try to find out, if and how I can use a
debugger to check where things go wrong.
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Contiki-developers mailing list
https://lists.sourceforge.net/lists/listinfo/contiki-developers
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Contiki-developers mailing list
https://lists.sourceforge.net/lists/listinfo/contiki-developers
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Contiki-developers mailing list
https://lists.sourceforge.net/lists/listinfo/contiki-developers
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Contiki-developers mailing list
https://lists.sourceforge.net/lists/listinfo/contiki-developers
Loading...