Custom Firmware Server Example¶
WiPhone's firmware can be updated through a remote Server. An updated firmware file is first uploaded to a remote server by developers. Whenever the phone boots up, it checks and see if a newer firmware version is available to download. Information about this update is available within an ini file located at the server.
Within the ini file, version number of available firmware to download and a url from where it could be downloaded is available. Upon startup, the WiPhone will load this ini file, check the version in ini file against the local version. If the server version is newer and auto update is set to true, the firmware binary will be downloaded and installed.
The firmware binary and ini file are downloaded using https and the
certificate chain for the certificate used for the site hosting the
firmware is needed in the spiffs data partition. The name of the custom
pem file is:
user.pem. An example pem file is located in the data
directory and it contains the Lets Encrypt certificate which is used for
the official WiPhone firmware repository.
The WiPhone has an app called:
Firmware Settings located in the
Settings menu. Within this app, there is a text field where user can
enter a URL. This URL is the location of the ini file which contains the
server firmware version number along with the link to that firmware
binary. User can change this URL to a custom URL for server, the
WiPhone will load this ini file on boot and check for new firmware
Firmware update code¶
The code to handle the firmware update can be found in the
ota.h files which points to default official WiPhone firmware repository.
It is possible to alter the default URL which appears inside the "Firmware
Settings" app. This URL can be found in the
ota.h file. The lines which
can be changed are below:-
#define DEFAULT_INI_HOST "wiphone.io"
#define DEFAULT_INI_LOC "/static/releases/firmware/WiPhone-phone.ini"
DEFAULT_INI_HOST is the hostname for the firmware repository and
DEFAULT_INI_LOC is the location of the ini file on the host. In above
example, the phone will load the ini file to the following location:
https://wiphone.io/static/releases/firmware/WiPhone-phone.ini So by
User is allowed to Change these values to set a dfferent default firmware
downlad server of their own.
When a release fails to install on the WiPhone it is marked as failed within the SPIFFS data partition of the phone. This prevents the phone from trying to load the same failed version again and again and just looping forever trying to install the same version. It is possible to force the phone to install a failed firmware version from the Firmware app using the reset button. This button will reset all firmware settings on the phone and place them back to the default state as set in the source code.
Steps to setup custom server¶
- Install a web server, nginx for example, and add your domain to the virtual hosts.
- Setup SSL on the domain being used for the firmware server.
- Upload the firmware binary along with an ini file in the correct format.
- Setup the WiPhone update so that it will load the above ini file.
- Reboot the WiPhone and it should load the firmware from your server
This video will teach you how to Host your own Firmware Server on WiPhone.