OVMS3-idf/examples/system/ota/otatool
2018-12-06 09:34:33 +01:00
..
main examples: add otatool and parttool examples 2018-11-28 17:28:20 +08:00
CMakeLists.txt examples: add otatool and parttool examples 2018-11-28 17:28:20 +08:00
example_test.py examples: Fix Python coding style 2018-12-06 09:34:33 +01:00
Makefile examples: add otatool and parttool examples 2018-11-28 17:28:20 +08:00
otatool_example.py examples: add otatool and parttool examples 2018-11-28 17:28:20 +08:00
README.md examples: add otatool and parttool examples 2018-11-28 17:28:20 +08:00
sdkconfig.defaults examples: add otatool and parttool examples 2018-11-28 17:28:20 +08:00

OTA Tool Example

This example demonstrates common operations the OTA tool otatool.py allows the user to perform:

  • reading, writing and erasing OTA partitions,
  • switching boot partitions, and
  • switching to factory partition.

Users taking a look at this example should focus on the contents of the python script otatool_example.py. The script contains programmatic invocations of the tool otatool.py in Python for the operations mentioned above; and can serve as a guide for users wanting to do the same in their applications.

The built application in this example outputs the currently running partition, whose output is used to verify if the tool switched OTA partitions succesfully. The built application binary is written to all OTA partitions at the start of the example to be able to determine the running partition for all switches performed.

How to use example

Build and Flash

Before running the example script otatool_example.py, it is necessary to build and flash the firmware using the usual means:

# If using Make
make build flash

# If using CMake
idf.py build flash

Running otatool_example.py

The example can be executed by running the script otatool_example.py. Either run it directly using

./otatool_example.py

or run it using

python otatool_example.py

The script searches for valid target devices connected to the host and performs the operations on the first one it finds. This could present problems if there are multiple viable target devices attached to the host. To perform the operations on a specific device, specify the port it is attached to during script invocation:

# The target device is attached to /dev/ttyUSB2, for example
python otatool_example.py --port /dev/ttyUSB2

Example output

Running the script produces the following output:

Writing factory firmware to ota_0
Writing factory firmware to ota_1
Checking written firmware to ota_0 and ota_1 match factory firmware
Switching to ota partition name factory
Switching to ota partition name factory
Switching to ota partition slot 0
Switching to ota partition name ota_1
Switching to ota partition slot 1
Switching to ota partition name ota_0
Switching to ota partition slot 0
Switching to ota partition name factory
Switching to ota partition slot 1

OTA tool operations executed successfully!