The FreeRTOS port fo OpenWSN have been finalized recently. We contributed to the integration of the FreeRTOS kernel to the OpenWSN protocol stack. The objective of such integration was to maintain intact the OpenWSN APIs and hide behind them the fact that an RTOS is running. A detailed description of what has been done is found in the OpenWSN website
The approach used 3 FreeRTOS task to hide the protocol stack operation, the implementation aimed to keep things simple, the 3 tasks have been defined as:
- Rx Task: handles callbacks triggered by packets comming from the MAC layer and pushes them up. The usual case is when a packet is received at the Low MAC and this is pushed up the stack until it reaches the target layer (e.g ICMPv6). This task has the highest priority.
- Send Done and timers Task: Once an ACK from a sent packet is received, this confirms the succes on the packet transmission and this information is pushed up the stack for those tasks waiting that notification. Note that this is similar than the previous case but however we prefer to separate in another tasks with lowest priority than that of receiving a packet. This task also handles OpenWSN timer callbacks such RPL DIO timer or 6top maintenance tasks.
- App Task: This task is used to move packets down the stack. Basically applications or upper layers use it to send down the packet to the High MAC until it is inserted into the MAC layer queue. It has the lowest priority.
The scheduler operation has been implemented as follows:
- Each task looks into the callback list for those callbacks that fall in its priority range (see task_prio_t enum). If a callback for that particular priority is found then the freertos task executes it and subsequently blocks in its sempahore until is triggered again by the scheduler. This trigger happens when a new callback for a certain priority is pushed into the list.
The new kernel has been fully tested using OpenMotes and the Scons toolchain adapted to support a new kernel option which enables the selection of FreeRTOS or the simple OpenOS. Now we can compile OpenWSN using the FreeRTOS kernel using
scons board=OpenMote-CC2538 toolchain=armgcc kernel=freertos oos_openwsn