Reputation: 9
#define BITINIT \
uint8_t clrClkAndData = PORTD & ~0x28
#define BIT(n) \
PORTD = clrClkAndData; \
asm __volatile__ \
( "sbrc %2," #n "\n" \
"\tsbi 18,3\n" \
"\tsbi 18,5\n" \
"\tsbic 16,2\n" \
"\tori %0,1<<" #n "\n" \
: "=d" (spiIn) : "0" (spiIn), "r" (spiOut))
I installed ubuntu and using TOSSIM. Everything compiles properly and is running. But when the file HPLAt45dbIOP.nc for micaz is executed on TOSSIM, I get errors like
/opt/tinyos-2.1.2/tos/platforms/micaz/chips/at45db/HplAt45dbIOP.nc:
Assembler messages:
/opt/tinyos-2.1.2/tos/platforms/micaz/chips/at45db/HplAt45dbIOP.nc:150: Error: no such instruction: `sbrc %cl,7'
/opt/tinyos-2.1.2/tos/platforms/micaz/chips/at45db/HplAt45dbIOP.nc:151: Error: no such instruction: `sbi 18,3'
/opt/tinyos-2.1.2/tos/platforms/micaz/chips/at45db/HplAt45dbIOP.nc:152: Error: no such instruction: `sbi 18,5'
/opt/tinyos-2.1.2/tos/platforms/micaz/chips/at45db/HplAt45dbIOP.nc:153: Error: no such instruction: `sbic 16,2'
/opt/tinyos-2.1.2/tos/platforms/micaz/chips/at45db/HplAt45dbIOP.nc:154: Error: no such instruction: `ori %dl,1<<7'
I have an Intel machine. Why does TOSSIM unable to run assembly language instructions?
Upvotes: 0
Views: 170
Reputation: 1471
First of all, sbrc
, sbi
, and so on are AVR Assembler instructions, so an Intel machine cannot execute them.
Nevertheless, TOSSIM does not and cannot run the same platform-dependent components as real nodes. Such components use microcontroller's registers for controlling IO pins, handle hardware interrupts, communicate with external peripherals over buses such as SPI, etc. Apart from wireless sensor networks: imagine you have an application that takes photo from a camera plugged to a PC and then prints it. How would you simulate execution of such application without physical possesion of a camera and a printer?
What TOSSIM actually does, is that it works by replacing components with simulation implementations (see documentation). Compared to the PC application I mentioned before, TOSSIM works by substituting certain hardware components, such as a printer and a camera, by software modules simulating their behavior, so-called mocks. The application then communicates with such software modules instead of real hardware, what allows for testing higher layers of the application logic without having physical hardware.
This approach, however, requires implementing software mocks, what sometimes is not necessarily easy. The TinyOS micaz platform, which, as far as I know, is the only one supporting TOSSIM, comes with some mock modules. You can find them in directories named sim. For instance, tos/platforms/micaz/chips/cc2420/sim/ contains mocks for the CC2420 radio chip and tos/chips/atm128/timer/sim/ includes mocks for hardware timers available on the ATM128 microcontroller.
In TinyOS, when compiling with a command make micaz sim
, mock components are automatically used instead of real implementations by preceding all include paths with include paths ending with /sim
(the TinyOS build system chooses always a first matching component).
Unfortunately, it seems there is no mock for the flash memory driver, so it is not possible to use flash in simulations. You need to have a MICAz mote to test your application. TOSSIM is mainly used for simulations concerning radio, because such experiments cannot always be easily performed in a real environment and their results may be indeterministic, what hinders reproducing issues and debugging applications.
Upvotes: 1