Updating Firmware

The WA2000 Wi-Fi/BLE add-on module stores its firmware in its flash memory. The firmware comprises two independent parts:

  • The main firmware that implements all the features and functionality required by the wln. and bl. (Bluetooth) objects; and
  • The Monitor/Loader (firmware) that assists in upgrading the main firmware of the WA2000.

The wln. object provides a mechanism to update both the main firmware and the Monitor/Loader from within your Tibbo BASIC/C app. The following methods exist exclusively for this purpose:

  • Wln.setupgraderegion — selects the upgrade target (firmware or Monitor/Loader) and resets an internal flash pointer.
  • Wln.writeflashpage — sends 128 bytes of the firmware file into the WA2000. Rather than overwriting the target flash area directly, the WA2000 first stores the firmware file in a spare area of its flash. With each invocation of this method, the flash pointer increments.
  • Wln.upgradeInitiates copying of the uploaded file (stored in the spare area of the flash) into the target (firmware or Monitor/Loader) area. Returns control back to the app immediately.
  • Wln.waitforupgradecompletion — blocks until the update process (initiated by wln.upgrade) completes.

There are also two read-only properties that allow you to query the current versions of the main firmware and the Monitor/Loader:

Finally, the following two methods also play a role in the firmware update process:

The primary purpose of these methods have already been explained: wln.getmoduletype detects the Wi-Fi module type, and wln.boot boots up the module. During the update process, these two methods play another role: they launch the WA2000 into the execution of either the Monitor/Loader, or the main firmware. To be able to update its main firmware, the WA2000 must be executing its Monitor/Loader. This is achieved by calling wln.getmoduletype after resetting the module. To be able to update its Monitor/Loader, the WA2000 must be executing its main firmware. This is achieved by calling wln.boot after resetting the module.

To improve the reliability of the upgrade process, the WA2000 requires your app to calculate and send the checksum of the firmware file.

Rather than dive into a deep and boring discussion of the intricacies of the update process, we have provided a working code example. You can find it at XXXXXXXXXX This mini-app updates the main firmware and the Monitor/Loader of the WA2000 from the files embedded in the app itself (to understand how this works, see the romfile. object). Except for the firmware version verification and debug printing, everything in this code is essential and should not be deleted.

Updating either portion of the firmware make take up to a minute, so be patient.