Dual Tibbo BASIC/C Apps
Two Tibbo devices, the WM2000 and the WS1102, can store up to two compiled Tibbo BASIC/C application binaries — "APP0" and "APP1" (only one can run at any given time).
Of the module's total program storage of 4,096KB, the Monitor/Loader (M/L) takes up 960KB, and the sole instance of TiOS occupies 1,448KB, leaving 1,688KB available for apps. Note that this storage is 4KB-aligned, meaning that if APP0 is "empty" or smaller than 4KB, it will still use up 4KB. Likewise, if APP0 is larger than a multiple of 4KB, it will use the space up to the next 4KB block.
All earlier Tibbo BASIC/C-programmable hardware stores a single app that can take up all of the flash space not occupied by the M/L and TiOS. The WM2000 and WS1102 — which have at least four times the flash storage of any predecessor — allows you to store the second app — APP1 — in the space left over from the M/L, TiOS, and APP0.
A Device Configuration Block (DCB) stored in the flash memory allows you to define which of the two apps runs when the device is powered up or reboots (there is also an override through the MD line that forces execution of APP0). We have provided a convenient web app called BLE Terminal to interface with a new BLE Console, allowing you to access the DCB.
Tibbo BASIC/C applications can work with the DCB through a provided API (new properties and methods of several objects). Specifically, your APP0 and APP1 can read and write DCB data, as well as switch between each other through sys.reboottoapp.
Tibbo envisions APP0 playing the role of a "secondary Monitor/Loader" and APP1 implementing the main functionality of WM2000-based products. For example, this "secondary M/L" could provide avenues for configuring the product's settings, updating its code from the cloud, or performing other management functions.
To this end, we have developed a "companion" application that ships with the WM2000 as APP0. This companion app allows users to view and alter the DCB through the L.U.I.S. smartphone app (available for iOS and Android, as well as a web app). As Tibbo sees the companion app serving as the starting point and inspiration for your own such project, its source code is published here, and you are free to modify it in any way you please.
Alternatively, APP0 and APP1 can be populated with separate, fully functional user apps.
App Selection and Behavior
The sys.defaultapp property specifies which app TiOS will load when the device is powered on or rebooted. This property can be modified via the DCB or by defining its value in your Tibbo BASIC/C application.
By default, the WM2000 and WS1102 load APP1 when the device is powered on or rebooted. If the device is loaded with only one app as APP1 — or with the companion app as APP0, but never used — everything works almost exactly the same way it did on earlier Tibbo hardware. If you plan to use only one app loaded as APP0, sys.defaultapp must be set to PL_APP_NUM_0 for the device to boot your application.
After using the MD line override to force-launch APP0, the next time the device boots, it will launch whichever app is specified as the default — unless you use the MD override again, of course.
Uploading Apps and Updates
Device Explorer will always upload to the active app, while remote upgrades take place via external flash. Device Explorer will show which app is active with a 0 or 1 before the current project's name.
Whenever APP0 is updated, APP1 is deleted and must be re-uploaded. This arrangement eliminates the necessity of maintaining empty space between the two apps. However, there will inevitably be space (up to nearly 4KB) because all files on the WM2000 and WS1102 must be 4KB-aligned.
APP0 should always be distributed attached to TiOS to avoid mismatches, while APP1 should be checked to ensure that it's using the same TiOS version.
For your convenience, we have updated the BinMerger web app to support multiple-app systems such as the WM2000. The updated web app allows you to merge TiOS, APP0, and APP1 into a single binary file that you can use for firmware updates, vastly simplifying the upgrade process. The older BinMerger utility for Windows, however, does not support multi-app systems.
The Tibbo Composite Uncompressed (.TCU) File Generator has also been updated to support multiple apps.
The WM2000 is the first Tibbo device in which the firmware can be updated using a .BIN file via Wi-Fi in the M/L update mode's network phase.